/* ══════════════════════════════════════════════════════════════════
   BIONIC LENSES — campanha interativa (hero + 3 cenas + transições)
   Linguagem: cena fotográfica full-bleed · produto dominante ·
   tipografia editorial sobreposta · câmara lenta conduzida pelo scroll.
   Sem cenários feitos de CSS: o ambiente é sempre fotografia.
   Cada .cx-scene recebe --p (0→1) do scroll; a "câmara" é o transform
   da própria fotografia.
   ══════════════════════════════════════════════════════════════════ */
#campaign {
  --ink: #0A0908;
  --paper: #F7F5F1;
  --dim: rgba(247,245,241,.62);
  --par: 1;                     /* intensidade de movimento (menor em mobile) */
  --scene-vh: 100svh;
  position: relative;
  background: var(--ink);
  color: var(--paper);
}

/* ── Cena: altura longa, palco fixo (a câmara move-se, a página não salta) ── */
.cx-scene { position: relative; height: 520vh; }   /* ~5 ecrãs por cena: ritmo lento */
.cx-hero { height: 200vh; }
.cx-stage {
  position: sticky; top: 0;
  height: 100vh; height: var(--scene-vh);
  overflow: hidden;
  background: var(--ink);
}

/* ── Camada de câmara: a fotografia ── */
.cx-frame {
  position: absolute; inset: 0;
  z-index: 0;
}
.cx-frame img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: var(--focus, 50% 50%);
  display: block;
}

/* Camada de vídeo (clips reais aprovados) sobre a fotografia-poster.
   --cx-zoom compensa letterbox cozido nos masters (night/sun); não é efeito. */
.cx-frame video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: var(--focus, 50% 50%);
  transform: scale(var(--cx-zoom, 1));
  opacity: 0;
  transition: opacity .6s ease;
}
.cx-scene.cx-video-on .cx-frame video { opacity: 1; }

/* Push-in contínuo + saída "através da lente" no fim da cena.
   scale: 1.06 → 1.16 durante a cena; dispara para 2.6 nos últimos 12%. */
.cx-scene .cx-frame {
  transform: scale(calc(
    1.06 + var(--p, 0) * 0.10 * var(--par)
    + max(0, calc(var(--p, 0) - 0.88)) * 12 * var(--par)
  ));
}
/* Com vídeo ativo o movimento vem do próprio clip: sem push-in artificial,
   mas a saída "através da lente" mantém-se (continuidade entre cenas). */
.cx-scene.cx-video-on .cx-frame {
  transform: scale(calc(1 + max(0, calc(var(--p, 0) - 0.88)) * 12 * var(--par)));
}
/* A fotografia está sempre presente; quem faz a transição é o véu — assim
   uma âncora directa (#cx-night) nunca cai num ecrã preto. */

/* Véu de transição: escurece (Blue→Night) ou estoura de luz (Night→Sun) */
.cx-veil {
  position: absolute; inset: 0; z-index: 1;
  pointer-events: none;
  opacity: 0;
}
.cx-veil.dark { background: var(--ink); opacity: clamp(0, calc((var(--p, 0) - 0.9) * 10), 1); }
.cx-veil.light { background: #FFFDF8; opacity: clamp(0, calc((var(--p, 0) - 0.9) * 10), 1); }
/* véu de entrada (dissolve o clarão da cena anterior) */
.cx-veil.in-dark { background: var(--ink); opacity: clamp(0, calc(1 - var(--p, 0) * 9), 1); }
.cx-veil.in-light { background: #FFFDF8; opacity: clamp(0, calc(1 - var(--p, 0) * 9), 1); }

/* Legibilidade do texto sobre fotografia — gradiente ancorado ao lado do texto,
   não um "efeito": é o mesmo recurso de qualquer campanha impressa. */
.cx-shade {
  position: absolute; inset: 0; z-index: 2;
  pointer-events: none;
}
.cx-shade.left  { background: linear-gradient(100deg, rgba(10,9,8,.86) 0%, rgba(10,9,8,.5) 34%, transparent 62%); }
.cx-shade.right { background: linear-gradient(260deg, rgba(10,9,8,.86) 0%, rgba(10,9,8,.5) 34%, transparent 62%); }
.cx-shade.bottom { background: linear-gradient(transparent 45%, rgba(10,9,8,.75)); }

/* ── Tipografia editorial ── */
.cx-type {
  position: relative; z-index: 3;
  height: 100%;
  display: grid; align-content: center;
  padding-inline: clamp(24px, 6vw, 104px);
  padding-block: 12vh;
  max-width: min(1500px, 100%);
  margin-inline: auto;
}
.cx-type.right { justify-items: end; text-align: right; }

.cx-label {
  font-size: clamp(10px, .85vw, 12px);
  font-weight: 700; letter-spacing: .34em; text-transform: uppercase;
  color: var(--dim);
  margin-bottom: clamp(14px, 2vw, 26px);
}
.cx-title {
  font-size: clamp(46px, 9.2vw, 172px);
  font-weight: 800;
  line-height: .88;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  margin: 0;
}
/* palavra em contorno — o contraste cheio/vazado da referência */
.cx-title em {
  font-style: normal;
  color: transparent;
  -webkit-text-stroke: clamp(1px, .13vw, 2.4px) var(--paper);
  paint-order: stroke fill;
}
.cx-line {
  font-size: clamp(15px, 1.5vw, 22px);
  line-height: 1.45;
  color: var(--dim);
  max-width: 30ch;
  margin-top: clamp(18px, 2.4vw, 34px);
}
.cx-type.right .cx-line { margin-left: auto; }

/* Coreografia do texto: entra cedo, sai antes da transição */
.cx-type > * {
  opacity: clamp(0, calc(var(--p, 0) * 6 - 0.5), 1);
  transform: translateY(calc((1 - clamp(0, calc(var(--p, 0) * 6 - 0.5), 1)) * 30px * var(--par)));
  transition: none;
}
.cx-type > *:nth-child(2) { opacity: clamp(0, calc(var(--p, 0) * 6 - 0.75), 1); }
.cx-type > *:nth-child(3) { opacity: clamp(0, calc(var(--p, 0) * 6 - 1.0), 1); }
.cx-type > *:nth-child(4) { opacity: clamp(0, calc(var(--p, 0) * 6 - 1.25), 1); }
/* desvanece antes de atravessar a lente */
.cx-scene .cx-type { opacity: clamp(0, calc(1 - (var(--p, 0) - 0.78) * 6), 1); }

/* ── CTA: contorno fino, sem preenchimento (linguagem editorial) ── */
.cx-cta {
  justify-self: start;
  display: inline-flex; align-items: center; gap: 14px;
  margin-top: clamp(24px, 3vw, 44px);
  padding: 15px 26px;
  border: 1px solid rgba(247,245,241,.5);
  color: var(--paper);
  font-size: clamp(11px, .95vw, 13px);
  font-weight: 700; letter-spacing: .22em; text-transform: uppercase;
  text-decoration: none;
  transition: background .3s, border-color .3s, color .3s;
}
.cx-type.right .cx-cta { justify-self: end; }
.cx-cta::after { content: ''; width: 22px; height: 1px; background: currentColor; transition: width .3s; }
.cx-cta:hover { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.cx-cta:hover::after { width: 34px; }
.cx-cta:focus-visible { outline: 2px solid var(--paper); outline-offset: 3px; }

/* ── Hero ── */
.cx-hero .cx-type { align-content: center; justify-items: start; }
.cx-hero .cx-title {
  font-size: clamp(44px, 7.8vw, 148px);
  line-height: .92;
  letter-spacing: -0.03em;
  max-width: 9.5em;         /* o produto continua protagonista à direita */
}
.cx-hero .cx-frame { transform: scale(calc(1.04 + var(--p, 0) * 0.16 * var(--par))); opacity: 1; }
/* hero com vídeo em loop: o movimento é o do clip, sem zoom artificial */
.cx-hero.cx-video-on .cx-frame { transform: none; }
.cx-hero .cx-type { opacity: clamp(0, calc(1 - var(--p, 0) * 1.9), 1); }
/* o hero não espera pelo scroll: o texto entra ao carregar (1-3s, §8 anterior) */
.cx-hero .cx-type > * {
  opacity: 0;
  transform: translateY(22px);
  animation: cx-in .9s cubic-bezier(.2,.7,.25,1) forwards;
  animation-delay: var(--d, 0s);
}
.cx-hero .cx-type > *:nth-child(1) { --d: .15s }
.cx-hero .cx-type > *:nth-child(2) { --d: .28s }
.cx-hero .cx-type > *:nth-child(3) { --d: .52s }
.cx-hero .cx-type > *:nth-child(4) { --d: .66s }
@keyframes cx-in { to { opacity: 1; transform: none; } }

.cx-scroll {
  position: absolute; left: 50%; bottom: clamp(22px, 4vh, 46px);
  transform: translateX(-50%);
  z-index: 4;
  display: grid; justify-items: center; gap: 10px;
  font-size: 10px; font-weight: 700; letter-spacing: .3em; text-transform: uppercase;
  color: var(--dim); text-decoration: none;
  opacity: clamp(0, calc(1 - var(--p, 0) * 3), 1);
}
.cx-scroll svg { animation: cx-bob 2.4s ease-in-out infinite; }
@keyframes cx-bob { 0%,100% { transform: translateY(-3px); opacity:.55 } 50% { transform: translateY(3px); opacity:1 } }

/* ── CTA persistente (compra em 5 segundos, §16) ── */
.cx-buy {
  position: fixed; right: 20px; bottom: 20px; z-index: 75;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 22px;
  background: #F7F5F1; color: #0A0908;
  border-radius: 2px;
  font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase;
  text-decoration: none;
  box-shadow: 0 12px 34px rgba(0,0,0,.4);
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .35s, transform .35s;
}
body.cx-buy-on .cx-buy { opacity: 1; transform: none; pointer-events: auto; }
.cx-buy:hover { background: #fff; }

/* ── Header: estado de tema explícito (FASE 3) ─────────────────────
   data-header-theme="dark" durante a campanha, "light" na loja.
   Valores literais (nunca vars de #campaign — o header vive fora dele). */
html[data-header-theme="dark"] .header {
  --header-bg: rgba(8, 8, 8, 0.96);
  --header-text: #ffffff;
  --header-muted: rgba(255, 255, 255, 0.72);
  --header-border: rgba(255, 255, 255, 0.18);
  background: var(--header-bg);
  backdrop-filter: none;
  border-bottom: 1px solid var(--header-border);
}
html[data-header-theme="dark"] .header .logo { color: var(--header-text); }
html[data-header-theme="dark"] .header .logo span { color: var(--header-muted); }
html[data-header-theme="dark"] .header .nav a { color: var(--header-muted); }
html[data-header-theme="dark"] .header .nav a:hover,
html[data-header-theme="dark"] .header .nav a:focus-visible { color: var(--header-text); }
html[data-header-theme="dark"] .header .cart-btn {
  color: var(--header-text);
  border: 1px solid var(--header-border);
  background: transparent;
}
html[data-header-theme="dark"] .header .cart-btn:hover { border-color: var(--header-text); }
html[data-header-theme="dark"] .header .cart-badge { background: #ffffff; color: #0a0908; }
.header, .header .logo, .header .logo span, .header .nav a, .header .cart-btn {
  transition: background .3s ease, color .3s ease, border-color .3s ease;
}

/* ══════════════ MOBILE ══════════════ */
@media (max-width: 767px) {
  #campaign { --par: .55; }
  /* Enquadramento por cena em retrato: os óculos ficam sempre em cena.
     (night/sun já usam exports 4:3 recortados por cena — focus neutro) */
  #cx-hero .cx-frame img, #cx-hero .cx-frame video { --focus: 60% 55%; }
  .cx-scene { height: 380vh; }
  .cx-hero { height: 170vh; }
  .cx-type { padding-inline: 22px; padding-block: 14vh; }
  .cx-type.right { justify-items: start; text-align: left; }
  .cx-type.right .cx-line { margin-left: 0; }
  .cx-type.right .cx-cta { justify-self: start; }
  .cx-title { font-size: clamp(40px, 13vw, 76px); }
  .cx-hero .cx-title { font-size: clamp(40px, 12.5vw, 76px); }
  .cx-line { max-width: 26ch; }
  /* o texto assenta em baixo, deixando a fotografia respirar em cima */
  .cx-type { align-content: end; }
  .cx-shade.left, .cx-shade.right { background: linear-gradient(transparent 28%, rgba(10,9,8,.55) 52%, rgba(10,9,8,.92) 88%); }
  .cx-buy { left: 14px; right: 14px; bottom: 14px; justify-content: center; }
  body.cx-buy-on .whatsapp-fab { bottom: 78px; }
  .cx-scroll { bottom: 78px; }
}

/* ══════════════ REDUCED MOTION ══════════════ */
@media (prefers-reduced-motion: reduce) {
  .cx-scene, .cx-hero { height: auto; }
  .cx-stage { position: relative; height: 88vh; }
  .cx-frame, .cx-scene .cx-frame, .cx-hero .cx-frame { transform: none !important; opacity: 1 !important; }
  /* FASE 24: sem vídeo — ficam os posters (o JS também não cria os elementos) */
  .cx-frame video { display: none !important; }
  .cx-veil { display: none; }
  .cx-type, .cx-type > *, .cx-scene .cx-type, .cx-hero .cx-type > * {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }
  .cx-scroll { display: none; }
  .cx-scroll svg, .cx-buy { animation: none; transition: none; }
}
