/* ═══════════════════════════════════════════════════════════
   ROIA · hero 3D: celular em WebGL que abre em camadas com a rolagem
   Cena em assets/hero3d.js (fonte em src/hero3d). Sem WebGL, a seção
   ganha .no-webgl e mostra assets/hero3d-poster.webp.
   ═══════════════════════════════════════════════════════════ */

.hero.hero3d {
  --h3d-bg: var(--night);
  padding: 0;
  overflow: visible; /* .hero usa overflow hidden, que mata o sticky */
  background: var(--h3d-bg);
}

.hero3d-pin {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  min-height: 640px;
  overflow: hidden;
  display: flex; align-items: center;
}

.hero3d-inner { position: relative; z-index: 2; width: 100%; padding-top: var(--header-h); pointer-events: none; }
.hero3d-inner .hero-copy { max-width: min(540px, 44%); pointer-events: auto; gap: clamp(16px, 2.6vh, 26px); }
.hero3d-inner .display { font-size: clamp(48px, min(7.2vw, 11.5vh), 104px); }
@media (max-height: 760px) and (min-width: 901px) {
  .hero3d-inner .lead { font-size: 17px; }
  .hero3d-inner .hero-audience { padding-top: 12px; }
}

/* ─── Headline: cada palavra é uma etapa e se preenche com a rolagem ───
   Atrair enche na abertura; Vender e Escalar enchem junto com as camadas
   do 3D (hero3d.js escreve --fill/--edge e as classes is-active/is-done).
   Sem JS ou com movimento reduzido, as três aparecem cheias. */
@property --fill { syntax: '<percentage>'; inherits: true; initial-value: 100%; }
@property --edge { syntax: '<percentage>'; inherits: true; initial-value: 0%; }

.hero3d-inner .hero-title { max-width: none; display: block; }
.hero-title .ht-line { position: relative; display: block; width: fit-content; --ink: var(--mist); --ghost: rgba(245, 244, 240, 0.12); }
.hero-title .ht-accent { --ink: var(--teal-3); --ghost: rgba(63, 169, 200, 0.2); }
.hero-title .ht-word { display: inline-block; color: var(--ink); padding-right: 0.04em; }

.js .hero-title .ht-line:nth-child(n+2) { --fill: 0%; }
.js .hero-title .ht-word {
  color: transparent;
  background-image: linear-gradient(90deg,
    var(--ink) 0, var(--ink) calc(var(--fill) - var(--edge)),
    #D4F6FF calc(var(--fill) - var(--edge)), #D4F6FF var(--fill),
    var(--ghost) var(--fill));
  -webkit-background-clip: text; background-clip: text;
}
.js .hero-title .ht-line { animation: ht-rise 0.9s var(--ease-out) both; }
.js .hero-title .ht-line:nth-child(1) { animation: ht-rise 0.9s var(--ease-out) both, ht-fill 1.15s 0.45s cubic-bezier(0.65, 0, 0.35, 1) both; }
.js .hero-title .ht-line:nth-child(2) { animation-delay: 0.08s; }
.js .hero-title .ht-line:nth-child(3) { animation-delay: 0.16s; }
.js .hero3d.no-webgl .hero-title .ht-line { --fill: 100%; }
@keyframes ht-rise { from { opacity: 0; transform: translateY(0.24em); } }
@keyframes ht-fill { 0% { --fill: 0%; --edge: 4%; } 96% { --edge: 4%; } 100% { --fill: 100%; --edge: 0%; } }

/* etiqueta de cada etapa, alinhadas numa coluna e ligadas à palavra
   por um fio, como as legendas do 3D (--tagx/--gapw vêm do hero3d.js) */
.hero-title .ht-line::before, .hero-title .ht-line::after { content: ''; position: absolute; pointer-events: none; }
.hero-title .ht-line::before {
  left: calc(100% + 10px); top: 23px; width: 5px; height: 5px; border-radius: 50%;
  background: var(--on-night-border-strong); transition: background-color 0.35s var(--ease);
}
.hero-title .ht-line::after {
  left: calc(100% + 19px); top: 25px; height: 1px;
  width: calc(var(--gapw, 0px) + 19px);
  background: linear-gradient(90deg, var(--on-night-border-strong), var(--on-night-border));
  transform-origin: left center; transition: background 0.35s var(--ease);
}
.hero-title .ht-line.is-active::before { background: var(--teal-3); }
.hero-title .ht-line.is-active::after { background: linear-gradient(90deg, var(--teal-3), rgba(63, 169, 200, 0.3)); }
.hero-title .ht-line.is-done::before { background: rgba(63, 169, 200, 0.6); }
.js .hero-title .ht-line::after { animation: ht-wire 0.5s var(--ease-out) both; }
.js .hero-title .ht-line:nth-child(1)::after { animation-delay: 1.05s; }
.js .hero-title .ht-line:nth-child(2)::after { animation-delay: 1.25s; }
.js .hero-title .ht-line:nth-child(3)::after { animation-delay: 1.45s; }
@keyframes ht-wire { from { transform: scaleX(0); } }
.ht-tag {
  position: absolute; left: calc(var(--tagx, 100%) + 44px); top: 12px;
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  font-family: var(--mono); font-size: 11px; font-weight: 500; line-height: 1; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--on-night-faint);
  padding: 7px 11px 7px 9px; border: 1px solid var(--on-night-border); border-radius: 999px;
  transition: color 0.35s var(--ease), border-color 0.35s var(--ease), background-color 0.35s var(--ease);
}
.ht-tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.7; flex-shrink: 0; }
.ht-tag b { font-weight: 500; color: var(--teal-3); }
.js .ht-tag { animation: ht-type 0.7s steps(14, end) both; }
.js .ht-line:nth-child(1) .ht-tag { animation-delay: 1.2s; }
.js .ht-line:nth-child(2) .ht-tag { animation-delay: 1.4s; }
.js .ht-line:nth-child(3) .ht-tag { animation-delay: 1.6s; }
@keyframes ht-type { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.ht-line.is-active .ht-tag { color: var(--on-night); border-color: var(--teal-line); background: var(--teal-soft); }
.ht-line.is-active .ht-tag::before { background: var(--teal-3); opacity: 1; animation: ht-dot 1.6s var(--ease) infinite; }
.ht-line.is-done .ht-tag { color: var(--on-night-muted); }
@keyframes ht-dot { 0%, 100% { box-shadow: 0 0 0 0 rgba(63, 169, 200, 0.45); } 60% { box-shadow: 0 0 0 6px rgba(63, 169, 200, 0); } }

/* ─── Visual ─── */
.hero3d-visual { position: absolute; inset: 0; z-index: 1; }
.hero3d-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  opacity: 0; transition: opacity 0.9s var(--ease);
}
.hero3d.is-live .hero3d-canvas { opacity: 1; }
.hero3d-fallback {
  display: none; position: absolute; right: 0; top: var(--header-h);
  width: 56%; height: calc(100% - var(--header-h) - 40px);
  object-fit: contain; object-position: center;
}
.hero3d.no-webgl .hero3d-fallback { display: block; }

/* ─── Fundo ───
   .hero3d-bg: campo de luz em WebGL (backdrop.js). Enquanto não carrega,
   ou sem WebGL, fica este degradê. .hero3d-dots: malha de pontos que
   aparece em volta do celular e acende onde o mouse passa. */
.hero3d-pin {
  background:
    radial-gradient(60% 70% at 72% 48%, rgba(11, 134, 168, 0.16), transparent 70%),
    linear-gradient(180deg, #08111C 0%, var(--night) 70%);
}
.hero3d-bg {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 0;
  opacity: 0; transition: opacity 1.2s var(--ease);
}
.hero3d.is-live.has-field .hero3d-bg { opacity: 1; }
.hero3d-dots {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(circle, rgba(150, 215, 235, 0.42) 1.2px, transparent 1.9px);
  background-size: 26px 26px; background-position: 13px 13px;
  -webkit-mask-image: radial-gradient(640px 520px at var(--fx, 72%) var(--fy, 50%), #000 0%, rgba(0, 0, 0, 0.4) 50%, rgba(0, 0, 0, 0.12) 85%);
  mask-image: radial-gradient(640px 520px at var(--fx, 72%) var(--fy, 50%), #000 0%, rgba(0, 0, 0, 0.4) 50%, rgba(0, 0, 0, 0.12) 85%);
}
.hero3d-spot {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(circle, rgba(175, 238, 252, 0.85) 1.1px, transparent 1.8px);
  background-size: 26px 26px; background-position: 13px 13px;
  -webkit-mask-image: radial-gradient(200px circle at var(--mx, -400px) var(--my, -400px), #000 0%, transparent 100%);
  mask-image: radial-gradient(200px circle at var(--mx, -400px) var(--my, -400px), #000 0%, transparent 100%);
  opacity: var(--mo, 0);
}

/* Legendas das camadas (desktop) */
.hero3d-labels { position: absolute; inset: 0; pointer-events: none; }
.hero3d-label {
  position: absolute; left: 0; top: 0;
  display: none; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--on-night); white-space: nowrap;
  opacity: 0; transition: opacity 0.45s var(--ease);
}
.hero3d.is-live .hero3d-label { display: inline-flex; }
.hero3d-label i {
  position: relative; display: block; height: 1px; width: var(--ln, 60px);
  background: linear-gradient(90deg, var(--teal-3), rgba(63, 169, 200, 0.28));
  transform: scaleX(0); transform-origin: left center;
  transition: transform 0.55s var(--ease-out);
}
.hero3d-label i::before {
  content: ''; position: absolute; left: -3px; top: -3px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--teal-3); box-shadow: 0 0 0 4px rgba(63, 169, 200, 0.18);
}
.hero3d-label b { color: var(--teal-3); font-weight: 500; }
.hero3d-label.on { opacity: 1; }
.hero3d-label.on i { transform: scaleX(1); }

/* Trilho de etapas (celular) */
.hero3d-rail {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: none; justify-content: center; gap: 6px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase;
}
.hero3d-rail li {
  display: inline-flex; gap: 6px; align-items: center;
  padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--on-night-border); color: var(--on-night-faint);
  transition: color 0.35s var(--ease), border-color 0.35s var(--ease), background-color 0.35s var(--ease);
}
.hero3d-rail li b { font-weight: 500; }
.hero3d-rail li.on { color: var(--on-night); border-color: var(--teal-line); background: var(--teal-soft); }
.hero3d-rail li.on b { color: var(--teal-3); }

.hero3d-tag {
  position: absolute; right: var(--gutter); bottom: 22px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--on-night-faint);
  padding: 4px 9px; border: 1px solid var(--on-night-border); border-radius: 999px;
}

/* Dica de rolagem (desktop) */
.hero3d-hint {
  position: absolute; left: 69%; bottom: 26px; z-index: 2; transform: translateX(-50%);
  display: none; flex-direction: column; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--on-night-faint);
  transition: opacity 0.4s var(--ease);
}
.hero3d.is-live .hero3d-hint { display: flex; }
.hero3d-hint i { width: 1px; height: 34px; background: linear-gradient(var(--teal-3), transparent); transform-origin: top; animation: h3d-hint 2.2s var(--ease) infinite; }
.hero3d.is-moved .hero3d-hint { opacity: 0; }
@keyframes h3d-hint { 0% { transform: scaleY(0); opacity: 1; } 60% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }

/* ─── Celular e tablet: texto em cima, celular embaixo ─── */
@media (max-width: 900px) {
  .hero3d-pin {
    height: auto; min-height: 0; display: block;
    padding: calc(var(--header-h) + 28px) 0 22px;
  }
  .hero3d-inner { padding-top: 0; }
  .hero3d-inner .hero-copy { max-width: none; }
  .hero3d-inner .display { font-size: clamp(44px, 12vw, 72px); }
  .ht-tag, .hero-title .ht-line::before, .hero-title .ht-line::after { display: none; }
  .hero3d-dots { background-image: radial-gradient(circle, rgba(150, 215, 235, 0.3) 0.8px, transparent 1.3px); background-size: 22px 22px; background-position: 11px 11px; }
  .js .hero-title .ht-line:nth-child(2) { animation: ht-rise 0.9s 0.08s var(--ease-out) both, ht-fill 0.9s 1.35s cubic-bezier(0.65, 0, 0.35, 1) both; }
  .js .hero-title .ht-line:nth-child(3) { animation: ht-rise 0.9s 0.16s var(--ease-out) both, ht-fill 0.9s 2.1s cubic-bezier(0.65, 0, 0.35, 1) both; }
  .hero3d-visual {
    position: relative; inset: auto;
    height: min(64svh, 112vw); margin-top: 18px;
  }
  .hero3d-fallback { top: 0; width: 100%; height: calc(100% - 40px); }
  .hero3d-canvas { height: calc(100% - 40px); }
  .hero3d.is-live .hero3d-label, .hero3d.is-live .hero3d-hint { display: none; }
  .hero3d-rail { display: flex; }
  .hero3d-tag { bottom: auto; top: 0; right: var(--gutter); }
}
@media (max-width: 440px) {
  .hero3d-rail { flex-wrap: nowrap; gap: 5px; font-size: 10px; letter-spacing: 0.06em; }
  .hero3d-rail li { padding: 6px 9px; }
  .hero3d-rail li b { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hero3d-label, .hero3d-label i, .hero3d-rail li, .hero3d-canvas { transition: none; }
  .js .hero-title .ht-line, .js .ht-tag, .js .hero-title .ht-line::after { animation: none !important; --fill: 100% !important; --edge: 0% !important; }
  .ht-line.is-active .ht-tag::before { animation: none; }
  .hero3d-hint { display: none !important; }
}
