/* ================================================================
   MOBILE — O Fantástico Laboratório
   Mobile-first fixes: safe area, navigation, layouts, touch UX
================================================================ */

/* ── Safe area: iOS notch + home indicator ──────────────────── */
.site-header {
  padding-top: max(18px, env(safe-area-inset-top));
  padding-right: max(clamp(18px, 5vw, 72px), env(safe-area-inset-right));
  padding-left:  max(clamp(18px, 5vw, 72px), env(safe-area-inset-left));
}

.site-footer {
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  padding-right:  max(clamp(18px, 6vw, 88px), env(safe-area-inset-right));
  padding-left:   max(clamp(18px, 6vw, 88px), env(safe-area-inset-left));
}

.contact-section .button-primary {
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

/* ── Hamburger button ───────────────────────────────────────── */
.mobile-menu-btn {
  display: none; /* shown via media query below */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 1px solid rgba(57, 255, 20, 0.36);
  border-radius: 6px;
  background: rgba(3, 4, 8, 0.62);
  cursor: pointer;
  padding: 0;
  z-index: 102;
  transition: border-color 160ms ease, background 160ms ease;
}

.mobile-menu-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--green);
  border-radius: 2px;
  transition: transform 280ms ease, opacity 160ms ease;
  box-shadow: 0 0 6px rgba(57, 255, 20, 0.6);
}

.mobile-menu-btn[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.mobile-menu-btn[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.mobile-menu-btn[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ── Mobile menu overlay ────────────────────────────────────── */
.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  padding: max(72px, env(safe-area-inset-top) + 64px) clamp(24px, 6vw, 48px)
           max(32px, env(safe-area-inset-bottom) + 16px);
  background:
    radial-gradient(circle at 80% 10%, rgba(57, 255, 20, 0.12), transparent 40%),
    radial-gradient(circle at 20% 90%, rgba(255, 42, 191, 0.12), transparent 40%),
    rgba(3, 4, 8, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;

  /* hidden state */
  opacity: 0;
  pointer-events: none;
  transform: translateY(-12px);
  transition: opacity 260ms ease, transform 260ms ease;
}

.mobile-menu[aria-hidden="false"] {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.mobile-menu-close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 20px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  transition: border-color 160ms ease;
}
.mobile-menu-close:hover { border-color: var(--cyan); }

/* ── Mobile nav items ───────────────────────────────────────── */
.mobile-menu-nav {
  display: grid;
  gap: 2px;
  flex: 1;
}

.mobile-nav-item {
  display: grid;
  grid-template-columns: 48px 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: center;
  min-height: 64px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 14px 0;
  color: var(--text);
  text-decoration: none;
  transition: background 140ms ease, padding-left 140ms ease;
}

.mobile-nav-item:hover,
.mobile-nav-item:focus-visible {
  background: rgba(57, 255, 20, 0.05);
  padding-left: 8px;
  border-radius: 6px;
}

.mobile-nav-item span {
  grid-row: 1 / -1;
  align-self: center;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-shadow: 0 0 12px rgba(0, 244, 255, 0.5);
  text-align: center;
}

.mobile-nav-item strong {
  display: block;
  font-size: 18px;
  font-family: var(--serif);
  font-weight: 900;
  line-height: 1;
}

.mobile-nav-item em {
  display: block;
  font-style: normal;
  font-size: 11px;
  color: rgba(247, 251, 255, 0.48);
  letter-spacing: 0.06em;
  margin-top: 3px;
}

.mobile-menu-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  margin-top: 20px;
  border: 1px solid var(--green);
  border-radius: 6px;
  background: rgba(57, 255, 20, 0.1);
  color: var(--green);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-decoration: none;
  text-transform: uppercase;
  box-shadow: 0 0 28px rgba(57, 255, 20, 0.16);
  transition: background 160ms ease, box-shadow 160ms ease;
}
.mobile-menu-cta:hover {
  background: rgba(57, 255, 20, 0.18);
  box-shadow: 0 0 42px rgba(57, 255, 20, 0.26);
}

/* ── Swipe indicator on cast-interface ──────────────────────── */
.cast-swipe-hint {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 0 2px;
  color: rgba(247, 251, 255, 0.38);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

@media (max-width: 760px) {
  /* ── Show hamburger, keep header brand ──────────────────── */
  .mobile-menu-btn { display: flex; }

  /* ── VHS timecode: smaller e no topo ──────────────────── */
  .vhs-timecode {
    font-size: 10px;
    top: max(72px, env(safe-area-inset-top) + 60px);
    right: max(14px, env(safe-area-inset-right));
    gap: 5px;
  }

  /* ── Hero: mais espaço para conteúdo ──────────────────── */
  .hero-tagline::after { display: none; } /* remove cursor no mobile */
  .hero-lede { font-size: 15px; }

  /* ── Byte dossier: empilhar verticalmente ────────────── */
  .byte-dossier {
    grid-template-columns: 1fr;
    padding-top: clamp(72px, 12vw, 110px);
    gap: clamp(28px, 6vw, 48px);
  }
  .byte-dossier-media {
    grid-template-columns: 1fr; /* vídeo full width, concept card some */
  }
  .byte-concept-card { display: none; } /* hide on very small screens */
  .byte-video-frame { min-height: 280px; }
  .byte-dossier-video { min-height: 280px; }
  .byte-radar { right: 12px; bottom: 14px; width: 28px; height: 28px; }

  /* ── Cast interface: copy shows first, then frame ────── */
  .cast-interface {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .cast-copy {
    order: -1;
    border-top: 1px solid color-mix(in srgb, var(--accent), transparent 76%);
    border-left: 0;
    padding: 18px 4px 12px;
  }

  /* ── Cast: name backdrop reduced on mobile ───────────── */
  .cast-name-backdrop {
    font-size: clamp(44px, 11vw, 80px);
    opacity: 0.5;
    padding: 0 0.06em 0.04em 0;
  }

  /* ── Cast: frame height on mobile ────────────────────── */
  .cast-frame {
    min-height: min(68vh, 480px);
  }

  /* ── Cast: swipe hint ────────────────────────────────── */
  .cast-swipe-hint { display: flex; }

  /* ── Character strip: scroll snap ───────────────────── */
  .character-strip {
    grid-auto-columns: minmax(110px, 36vw);
    grid-auto-flow: column;
    grid-template-columns: none;
  }
  .character-token { height: 160px; min-width: 110px; }
  .character-token strong { font-size: 11px; margin-top: 78px; }

  /* ── Cast controls: larger touch targets ─────────────── */
  .cast-controls .icon-button {
    width: 62px;
    height: 62px;
    font-size: 44px;
  }

  /* ── Concept art gallery: 2 cols on mobile ───────────── */
  .conceptart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .conceptart-item:nth-child(1),
  .conceptart-item:nth-child(6),
  .conceptart-item:nth-child(11) {
    grid-column: span 2;
  }

  /* ── Market pulse: single column ─────────────────────── */
  .market-pulse {
    grid-template-columns: 1fr;
  }

  /* ── Reach breakdown: labels mais curtos ─────────────── */
  .reach-row { grid-template-columns: 72px 1fr 44px; gap: 8px; }
  .reach-row-label { font-size: 9px; }
  .reach-row-value { font-size: 16px; }

  /* ── ESG grid: single column on mobile ───────────────── */
  .esg-grid { grid-template-columns: 1fr; }

  /* ── Sponsor forms: 1 col on mobile ─────────────────── */
  .sponsor-forms { grid-template-columns: 1fr; }

  /* ── Fiscal flow: 2 cols já cobre (styles.css 1180px) ── */

  /* ── Posters section: single column ─────────────────── */
  .posters-section {
    grid-template-columns: 1fr !important;
  }

  /* ── Finance command: compacto ───────────────────────── */
  .finance-command { padding: 12px; }

  /* ── Contact: button full width ─────────────────────── */
  .contact-section .hero-actions { flex-direction: column; }
  .contact-section .button { width: 100%; min-width: 0; }

  /* ── Footer: empilhar vertical com logo maior ─────────── */
  .site-footer {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
  }
  .footer-partners {
    width: min(340px, 86vw);
  }

  /* ── Audio player: safe area bottom ─────────────────── */
  .audio-player {
    bottom: max(16px, env(safe-area-inset-bottom) + 8px);
  }

  /* ── Lightbox: full safe area ────────────────────────── */
  .ci-lightbox img {
    max-width: 100vw;
    max-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 80px);
  }
  .ci-lightbox-close {
    top: max(16px, env(safe-area-inset-top) + 8px);
    right: max(16px, env(safe-area-inset-right) + 4px);
  }

  /* ── Cast copy line: smaller on mobile ───────────────── */
  .cast-copy::before { width: min(200px, 60%); margin-bottom: 16px; }

  /* ── Path cards: full width on mobile ───────────────── */
  .investment-paths { grid-template-columns: 1fr; }

  /* ── Licensing note: single col ─────────────────────── */
  .licensing-note { grid-template-columns: 1fr; }

  /* ── IP compare table: scroll horizontal ────────────── */
  .ip-compare { overflow-x: auto; }
  .ip-compare-table { min-width: 560px; }
}

/* ════════════════════════════════════════════════════════════
   MOBILE: TRAILERS + INTERLÚDIOS — experiência visual limpa
   ════════════════════════════════════════════════════════════ */

@media (max-width: 760px) {

  /* ── Trailer chapters: esconder parágrafo, revelar vídeo ──── */
  /* O vídeo é a estrela — texto fica mínimo na base */
  .chapter-overlay p:not(.eyebrow) {
    display: none;
  }
  .chapter-overlay {
    padding: 14px 16px;
    border-left-width: 2px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    background:
      linear-gradient(90deg, rgba(57, 255, 20, 0.06), transparent 44%),
      linear-gradient(90deg, rgba(3, 4, 8, 0.84), rgba(3, 4, 8, 0.38));
    max-width: 92vw;
  }
  .chapter-overlay h2 {
    margin-bottom: 0;
    font-size: clamp(26px, 7.5vw, 44px);
    line-height: 0.9;
  }
  .chapter-overlay .eyebrow {
    margin-bottom: 10px;
    font-size: 9px;
    letter-spacing: 0.2em;
  }
  /* Mover o overlay para mais perto da base */
  .trailer-chapter {
    padding-bottom: clamp(28px, 6vw, 52px);
  }

  /* Indicator "tap for more" no canto superior direito */
  .chapter-overlay::after {
    content: '↓ ver mais';
    display: block;
    margin-top: 10px;
    color: rgba(247, 251, 255, 0.45);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 0.18em;
    text-transform: uppercase;
  }

  /* ── Interlúdios: recorte cinematic em portrait ──────────── */
  /* Troca height:auto (imagem inteira) por altura fixa + cover */
  .ci-interlude {
    height: clamp(280px, 60svh, 500px);
    min-height: 280px;
  }

  .ci-interlude-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 35%;  /* foca na região superior/central da cena */
  }

  /* Texto dos interlúdios: versão compacta no mobile */
  .ci-interlude-box {
    padding: 12px 14px;
    width: min(520px, 100%);
  }
  .ci-interlude-box h2 {
    font-size: clamp(18px, 5vw, 30px);
    line-height: 0.94;
  }
  .ci-interlude-box .eyebrow {
    font-size: 9px;
    letter-spacing: 0.16em;
    margin-bottom: 8px;
  }
  .ci-interlude-content {
    bottom: clamp(12px, 3vw, 22px);
    left: 12px;
    right: 12px;
    z-index: 8;
  }

  /* Fade base mais forte para legibilidade do texto compacto */
  .ci-interlude::after {
    height: 32%;
  }
}

/* ── Landscape mobile: trailers mostram vídeo sem overlay ─── */
@media (max-width: 760px) and (orientation: landscape) {
  .chapter-overlay {
    max-width: 52vw;     /* ocupa metade lateral */
    opacity: 0.88;
  }
  .ci-interlude {
    height: 88svh;
  }
  .ci-interlude-img {
    object-position: center center;
  }
}

/* ════════════════════════════════════════════════════════════
   MOBILE: GALERIA LICENCIAMENTO + TABELAS + #CUSTOMIZACAO
   ════════════════════════════════════════════════════════════ */

@media (max-width: 760px) {

  /* ── Product showcase: empilhar vertical ─────────────────── */
  .product-showcase {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  /* Hero: imagem em 16:9 completo */
  .product-hero img[data-product-main] {
    aspect-ratio: 16 / 9;
    height: auto;
    object-fit: cover;
  }

  /* Figcaption: single column */
  .product-hero figcaption {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 14px 16px;
  }

  /* Strip: horizontal scroll (flex) em vez de grid vertical */
  .product-strip {
    display: flex !important;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: inline mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
  }

  .product-thumb {
    flex: 0 0 clamp(110px, 28vw, 150px);
    height: auto;
    min-height: 54px;
    transform: none !important; /* disable hover lift on touch */
    scroll-snap-align: start;
  }

  .product-thumb img {
    aspect-ratio: 16 / 9;
    transform: none !important;
  }

  /* Product proof grid: 2 colunas */
  .product-proof-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
  }

  .product-proof-grid article {
    padding: 16px;
  }

  /* IP compare: já tem overflow-x no mobile.css, reforçar min-width */
  .ip-compare-table { min-width: 500px; }

  /* Quota ladder: force horizontal scroll no container */
  .quota-ladder {
    overflow-x: auto;
  }

  /* Route readout: compacto */
  .route-readout {
    gap: 10px;
    padding: 14px 16px;
  }

  /* ── #customizacao: chapter-ci-bg no mobile ──────────────── */
  /* A img deve se comportar como os vídeos dos outros capítulos */
  .chapter-ci-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;   /* override global img max-width: 100% */
    object-fit: cover;
    object-position: center center;
    display: block;
    transform: none;
    animation: none;   /* remove Ken Burns no mobile para performance */
  }

}

/* Em prefers-reduced-motion: esconder chapter-ci-bg quando a
   seção já tem bg via CSS (evita duplo background) */
@media (prefers-reduced-motion: reduce) {
  .chapter-ci-bg {
    display: none;
  }
}

/* ── Very small phones (< 390px) ────────────────────────────── */
@media (max-width: 390px) {
  .hero-meta { gap: 6px; }
  .hero-meta span { font-size: 9px; padding: 6px 8px; }
  .cast-name-backdrop { font-size: clamp(36px, 10vw, 60px); }
  .byte-led-strip { display: none; } /* too narrow */
  .conceptart-grid { grid-template-columns: 1fr; }
  .conceptart-item:nth-child(1),
  .conceptart-item:nth-child(6),
  .conceptart-item:nth-child(11) { grid-column: span 1; }
}

/* ── Tablet portrait (760px – 1080px) ──────────────────────── */
@media (min-width: 761px) and (max-width: 1080px) {
  .byte-dossier { gap: clamp(24px, 4vw, 60px); }
  .conceptart-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .esg-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ── Touch: make interactive elements tap-friendly ──────────── */
@media (hover: none) and (pointer: coarse) {
  /* Increase tap areas */
  .product-thumb { min-height: 54px; }
  .byte-chip { min-height: 50px; padding: 12px 18px; }
  .route-tab { min-height: 50px; }
  .cast-thumb { min-height: 80px; }
  .nav a { padding: 8px 4px; }

  /* Disable hover effects that don't work on touch */
  .thesis-grid article:hover { transform: none; }
  .sponsor-forms article:hover { transform: none; }
  .esg-card:hover { transform: none; }
  .path-card:hover { transform: none; }
  .quota-card-featured { animation-duration: 4s; }

  /* Scroll snapping on character strip */
  .character-strip {
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: inline mandatory;
  }
  .character-token { scroll-snap-align: center; }
}

/* ── Landscape mobile: fix hero height ──────────────────────── */
@media (max-width: 760px) and (orientation: landscape) {
  .hero, .byte-hero {
    min-height: 100svh;
    padding-top: max(60px, env(safe-area-inset-top) + 50px);
  }
  .trailer-chapter {
    min-height: 100svh;
    padding-top: max(70px, env(safe-area-inset-top) + 60px);
  }
  .cast-frame { min-height: min(80vw, 420px); }
}

/* ── Prevent body scroll when menu is open ──────────────────── */
body.menu-open {
  overflow: hidden;
  /* iOS momentum scroll lock */
  position: fixed;
  width: 100%;
}

/* ── Reduce motion: disable mobile-specific animations ──────── */
@media (prefers-reduced-motion: reduce) {
  .mobile-menu-btn span,
  .mobile-menu,
  .mobile-menu-close,
  .mobile-nav-item {
    transition-duration: 0.001ms !important;
    animation: none !important;
  }
}
