/**
 * Site-wide responsive layer — Neurollamas / K2 Branding
 * Loaded on all user-facing pages. Complements page-specific styles.
 */

/* ── Foundations ── */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
  max-width: 100vw;
  min-width: 0;
}

img,
video,
svg,
canvas,
iframe,
embed,
object {
  max-width: 100%;
  height: auto;
}

table {
  max-width: 100%;
}

pre,
code,
.seo-output-content,
.strategy-text,
.section p,
.ui-result-recommendations {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* iOS: fixed backgrounds cause jank */
@media (max-width: 768px) {
  body,
  [style*="background-attachment: fixed"],
  .bg-fixed {
    background-attachment: scroll !important;
  }
}

/* ── Touch-friendly controls ── */
button,
.button,
.generate-btn,
.home-button,
.more-info-btn,
.read-more,
.download-btn,
.seo-generate-btn,
.k2chat-send-btn,
.k2chat-btn,
input[type="submit"],
input[type="button"],
.btn,
a.button {
  min-height: 44px;
  touch-action: manipulation;
}

input,
select,
textarea,
.form-control {
  font-size: 16px; /* prevents iOS zoom on focus */
  max-width: 100%;
}

/* ── Layout containers ── */
.container,
.result-container,
.products-section .container,
.survey-container,
.survey-box,
.survey-card,
.content-wrapper,
.checkout-container,
.cart-container,
.profile-container,
.article-container {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

/* ── Grids ── */
.products-grid,
.stats-grid,
.team-grid,
.logo-grid,
.features,
.samples-slider,
.article-grid {
  min-width: 0;
}

/* ── Chat & modals ── */
#chat-modal,
.k2chat-modal-overlay,
#payment-modal,
.k2chat-payment-overlay,
.loading-overlay,
.teaser-overlay {
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#chat-modal {
  display: none;
  flex-direction: column;
  overflow: hidden;
}

#chat-modal[style*="flex"] {
  display: flex !important;
}

.chat-wrapper,
.k2chat-modal-card {
  min-height: 0;
  min-width: 0;
}

.k2chat-input-wrap,
#chat-input-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
}

.k2chat-input,
#chat-question-input {
  flex: 1 1 180px;
  min-width: 0;
}

.k2chat-send-btn,
#chat-send-btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.k2chat-messages,
#chat-messages {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ── Strategy / result pages ── */
.strategy-card,
.section,
.logo-card,
.product-card,
.stat-card,
.feature-card {
  min-width: 0;
}

.button-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: center;
}

.button-container .home-button,
.button-container .more-info-btn {
  width: auto;
  max-width: 100%;
}

/* ── Survey forms ── */
.survey-form,
form.survey-form,
.question-block,
.form-group {
  max-width: 100%;
}

.radio-group,
.choice-group,
.form-check {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Tables (cart, admin-like) ── */
.table-responsive,
.cart-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Video / image playground (socila) ── */
.ui-result-preview img {
  width: 100% !important;
  height: auto !important;
  max-height: 70vh;
  object-fit: contain;
}

/* Video playground — generated video fills the preview box */
#playground .sample-preview {
  align-items: stretch;
}

#playground .video-container {
  width: 100%;
  height: 100%;
  min-height: 100%;
}

#playground .video-container video,
#playground .sample-preview > video {
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  object-fit: cover !important;
  display: block;
  transform: none !important;
}

/* Image playground — match video preview box sizing */
#image-playground .sample-preview {
  align-items: stretch;
}

#image-playground .sample-preview > img,
#image-playground .generated-image-wrapper,
#image-playground .generated-image-wrapper img {
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  object-fit: cover !important;
  display: block;
  transform: none !important;
}

.playground,
.image-playground,
.seo-tools-section,
#playground {
  min-width: 0;
}

.prompt-input,
.seo-prompt-input {
  width: 100%;
  box-sizing: border-box;
}

/* ── Progress bars ── */
.loading-progress,
.progress-bar-container {
  width: min(100%, 320px);
  max-width: 100%;
}

/* ── Navbar / header helpers ── */
.nav-menu,
.navbar-nav {
  flex-wrap: wrap;
}

/* ── Promo / floating UI ── */
.neon-bubble,
#neurollamas-promo-banner {
  max-width: calc(100vw - 24px);
}

/* ═══════════════════════════════════════
   BREAKPOINTS
   ═══════════════════════════════════════ */

/* Large tablet / small laptop */
@media (max-width: 1200px) {
  .container,
  .result-container {
    padding-left: clamp(12px, 3vw, 28px);
    padding-right: clamp(12px, 3vw, 28px);
  }

  .section-title {
    font-size: clamp(1.75rem, 5vw, 2.75rem) !important;
  }
}

/* Tablet */
@media (max-width: 992px) {
  body {
    padding-left: clamp(8px, 2vw, 16px) !important;
    padding-right: clamp(8px, 2vw, 16px) !important;
  }

  .container,
  .result-container {
    padding: clamp(16px, 4vw, 28px) !important;
    border-radius: clamp(14px, 3vw, 24px) !important;
  }

  .header h1,
  h1 {
    font-size: clamp(1.45rem, 5.5vw, 2rem) !important;
    line-height: 1.25 !important;
  }

  .logo-section h2,
  .strategy-section h2,
  .section-title {
    font-size: clamp(1.2rem, 4.5vw, 1.6rem) !important;
  }

  .products-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)) !important;
    gap: 1.25rem !important;
  }

  .stats-grid,
  .team-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .logo-grid {
    flex-direction: column;
    align-items: center;
  }

  .logo-card {
    width: 100%;
    max-width: 360px;
    min-width: 0 !important;
  }

  .k2chat-sidebar {
    display: none;
  }

  .k2chat-modal-card {
    flex-direction: column;
    height: 92vh;
    max-height: none;
    border-radius: 16px;
  }

  .chat-wrapper::before {
    background-size: 200px !important;
    opacity: 0.12 !important;
  }
}

/* Mobile landscape / large phone */
@media (max-width: 768px) {
  body {
    padding: 12px !important;
  }

  .products-section {
    padding: 2.5rem 0.75rem !important;
  }

  .products-grid,
  .stats-grid,
  .team-grid,
  .features {
    grid-template-columns: 1fr !important;
  }

  .product-card,
  .stat-card {
    padding: 1.25rem !important;
  }

  .generate-btn,
  .button,
  .home-button,
  .more-info-btn {
    width: 100%;
    max-width: 100%;
    text-align: center;
    justify-content: center;
  }

  .logo-generator {
    padding: 28px 16px !important;
  }

  .strategy-card {
    padding: 18px !important;
  }

  .teaser-logo img {
    width: min(240px, 70vw) !important;
  }

  .teaser-tagline {
    font-size: 1.15rem !important;
  }

  .teaser-description {
    font-size: 0.95rem !important;
  }

  .survey-box,
  .survey-card {
    margin: 0 !important;
    padding: 16px !important;
  }

  .chat-header {
    padding: 10px 14px !important;
  }

  .chat-brand-name {
    font-size: 15px !important;
  }

  .k2chat-container {
    padding: 16px !important;
    background-size: cover !important;
    background-position: center !important;
  }

  .k2chat-status {
    flex-wrap: wrap;
    gap: 8px;
    font-size: 13px;
  }

  .k2chat-payment-card {
    width: calc(100vw - 24px) !important;
    max-width: 100% !important;
    margin: 12px;
    max-height: 90vh;
    overflow-y: auto;
  }

  .loading-text h5 {
    font-size: 1rem !important;
    padding: 0 12px;
  }

  .loading-logo img {
    width: min(120px, 35vw) !important;
  }

  .neon-bubble {
    width: 56px !important;
    height: 56px !important;
    bottom: 16px !important;
    right: 16px !important;
  }

  #neurollamas-promo-banner {
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    font-size: 0.85rem !important;
  }

  .samples-slider {
    flex-direction: column;
    align-items: center;
  }

  .sample-card {
    width: 100% !important;
    max-width: 420px;
  }

  .seo-tools-form,
  .seo-tools-output {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .footer,
  footer {
    padding: 1.5rem 1rem !important;
  }
}

/* Small phone */
@media (max-width: 576px) {
  .header h1,
  h1 {
    font-size: 1.35rem !important;
  }

  .container,
  .result-container {
    padding: 14px !important;
    border-radius: 16px !important;
  }

  .generate-btn {
    padding: 14px 20px !important;
    font-size: 15px !important;
  }

  .logo-image {
    height: auto !important;
    min-height: 120px;
    max-height: 200px;
  }

  .read-more {
    display: block;
    text-align: center;
    width: 100%;
  }

  .chat-close {
    width: 40px !important;
    height: 40px !important;
  }

  .k2chat-msg {
    max-width: 92% !important;
    font-size: 13px !important;
  }

  .stat-number {
    font-size: 2rem !important;
  }

  .navbar-brand {
    font-size: 1rem !important;
  }

  main.container {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}

/* Very small devices */
@media (max-width: 380px) {
  body {
    padding: 8px !important;
  }

  .button-container {
    flex-direction: column;
    width: 100%;
  }

  .button-container > * {
    width: 100%;
  }

  .product-title {
    font-size: 1.15rem !important;
  }
}

/* Landscape phones — reduce vertical chrome */
@media (max-height: 500px) and (orientation: landscape) {
  .loading-overlay,
  .teaser-overlay {
    overflow-y: auto;
    justify-content: flex-start;
    padding-top: 16px;
  }

  #chat-modal .chat-wrapper,
  .k2chat-modal-card {
    height: 100%;
    max-height: 100vh;
  }
}

/* ── Landing / AI Studio (shared mobile polish) ── */
@media (max-width: 768px) {
  .socila-studio-section,
  .socila-strategy-section,
  .landing-spotlight,
  .brand-suite-section {
    overflow-x: hidden;
    max-width: 100%;
  }

  .form-container,
  .survey-box,
  .survey-card {
    width: 100%;
    max-width: min(100%, 520px);
    margin-left: auto;
    margin-right: auto;
  }

  .brand-suite-strategist-intro,
  .brand-suite-catalog {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }

  .site-nav .nav-link-accent,
  .site-nav .nav-link.nav-link-suite,
  .site-nav .nav-link.nav-link-sound,
  .site-nav .nav-sound-wrap {
    white-space: normal;
    text-align: center;
    line-height: 1.25;
  }

  .nav-sound-wrap {
    width: 100%;
    max-width: 280px;
    margin: 0.35rem auto;
  }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
