/* ==========================================================================
   n8 Cloud Host — motion.css (v2)
   Estados animados da camada "cinema" do Clarix. Tudo aqui depende de classes
   que só existem com JS: html.pl (preloader), html.motion (motion.js ativo).
   Sem elas — sem JS, JS com erro, movimento reduzido — a página é estática e
   100% legível (os estilos-base estão em landing.css).
   ========================================================================== */

/* Lenis controla a rolagem: o smooth nativo do CSS brigaria com ele */
html.lenis, html.lenis body { scroll-behavior: auto !important; }

/* ------------------------------------------------------------- preloader */
.preloader { display: none; }
.js.pl .preloader, .preloader.is-done {
  display: block;
  position: fixed; inset: 0; z-index: 300;
  background: var(--bg);
  color: var(--text);
  pointer-events: none;
  overflow: hidden;
}
/* rede de segurança: mesmo que motion.js nunca rode, o preloader some sozinho */
.js.pl .preloader { animation: pl-failsafe .4s ease 1.2s forwards; }
@keyframes pl-failsafe { to { opacity: 0; visibility: hidden; } }
.preloader.is-done {
  animation: none;
  opacity: 0; visibility: hidden;
  transition: opacity .5s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .5s;
}

.pl-odo {
  position: absolute; top: clamp(1.6rem, 4.4vh, 2.5rem); left: max(var(--gutter), 3.125rem);
  display: flex; align-items: flex-start;
  font-family: var(--font-body); font-weight: 200;
  font-size: clamp(2.6rem, 4.4vw, 4rem); line-height: 1; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  color: var(--n8-light);
}
.pl-gap { display: inline-block; width: .32em; }
.pl-window { display: inline-block; position: relative; width: 1.7em; height: 1em; overflow: hidden; text-align: center; }
.pl-reel { position: absolute; left: 0; top: 0; width: 100%; will-change: transform; }
.pl-reel > span { display: block; height: 1em; line-height: 1em; }
.pl-brand {
  position: absolute; left: max(var(--gutter), 3.125rem); bottom: clamp(1.6rem, 4.4vh, 2.5rem);
  font-size: var(--fs-label); font-weight: 400; letter-spacing: .2em; text-transform: uppercase;
  color: var(--text-faint);
}
/* o "blob" holográfico do Clarix, em CSS: cresce com o contador e se estilhaça no 100 */
.pl-orb {
  position: absolute; left: 50%; top: 50%;
  width: min(46vmin, 400px); aspect-ratio: 1;
  translate: -50% -50%;
  scale: calc(.55 + var(--plp, 0) * .45);
  transition: scale .35s var(--ease-out);
}
.pl-orb span {
  position: absolute; inset: 0;
  border-radius: 46% 54% 52% 48% / 50% 44% 56% 50%;
  background:
    radial-gradient(circle at 34% 32%, rgba(0, 209, 232, .95), rgba(0, 209, 232, 0) 46%),
    radial-gradient(circle at 70% 64%, rgba(157, 104, 210, .9), rgba(157, 104, 210, 0) 50%),
    radial-gradient(circle at 50% 50%, rgba(0, 84, 200, .9) 0%, rgba(113, 69, 204, .8) 46%, rgba(113, 69, 204, 0) 70%);
  filter: blur(14px) saturate(120%);
  animation: orb-wobble 2.6s ease-in-out infinite alternate, orb-spin 7s linear infinite;
}
@keyframes orb-wobble {
  to { border-radius: 54% 46% 44% 56% / 44% 56% 46% 54%; }
}
@keyframes orb-spin { to { rotate: 360deg; } }
.preloader.is-shatter .pl-orb { scale: 2.8; opacity: 0; transition: scale .55s cubic-bezier(.55, 0, .85, .25), opacity .55s ease-in; }
.preloader.is-shatter .pl-orb span { filter: blur(60px) saturate(140%); transition: filter .55s ease-in; }
.preloader.is-shatter .pl-odo, .preloader.is-shatter .pl-brand { opacity: 0; translate: 0 -10px; transition: opacity .5s ease, translate .6s var(--ease-out); }

/* ---------------------------------------------------- entrada do hero */
/* .preload-hidden só esconde enquanto html.pl existe (o <head> remove em ≤3,2s) */
.js.pl .preload-hidden { opacity: 0; pointer-events: none; }
.js.pl .preload-hidden.from-top { translate: 0 -24px; }
.js.pl .preload-hidden.from-bottom { translate: 0 28px; }
.js.pl .preload-hidden.fade-in { scale: 1.07; }
.js .reveal-anim {
  transition:
    translate 1.6s cubic-bezier(.2, .8, .2, 1) calc(.6s + var(--rd, 0s)),
    scale 2.6s cubic-bezier(.2, .8, .2, 1) calc(.6s + var(--rd, 0s)),
    opacity 1.6s ease calc(.6s + var(--rd, 0s));
}
.js .reveal-anim.fade-in { --rd: -.45s; }

/* ------------------------------------------- itens ligados à rolagem */
/* motion.js marca com .m-item o que ele anima frame a frame (opacity + translate/scale) */
.motion .reveal.m-item { opacity: 1; transform: none; transition: none; }
.motion .btn.reveal.m-item {
  transition: transform .5s var(--ease-out), background-position .6s var(--ease-out),
              background-color .3s ease, border-color .3s ease, box-shadow .5s var(--ease-out);
}
.motion .card.reveal.m-item { transition: border-color .5s var(--ease-out), transform .6s var(--ease-out); }
.motion .sec-head .label::after { transform: scaleX(var(--lp, 1)); transform-origin: 0 50%; }
.motion .sec-head-center .label::before { transform: scaleX(calc(var(--lp, 1) * -1)); transform-origin: 100% 50%; }
.motion .trust .grad-line, .motion .footer-glass > .grad-line { transform-origin: 0 50%; }

/* ------------------------------------------------ interlúdio fixado */
.motion .interlude { height: 280vh; }
.motion .interlude-pin { position: sticky; top: 0; height: 100vh; height: 100svh; }
.motion .interlude-inner {
  height: 100%;
  grid-template-rows: auto 1fr auto;
  gap: 0;
  padding-top: clamp(96px, 13vh, 140px);
  padding-bottom: clamp(26px, 6vh, 64px);
}
.motion .interlude-main { align-self: center; }
.motion .interlude-title { perspective: 1500px; font-size: clamp(2.2rem, min(5.7vw, 10.5vh), 6.6rem); }
.motion .stat-num { font-size: clamp(2.2rem, min(4vw, 7.4vh), 4.6rem); }
.fly-visual { display: block; }
.fly-line { display: block; white-space: nowrap; transform-style: preserve-3d; transform-origin: 0 50%; will-change: transform; }
.fly-word { display: inline-block; white-space: nowrap; }
.fly-char { display: inline-block; padding: 0 .1em; margin: 0 -.1em; will-change: transform, opacity, filter; }
.motion .interlude-title .accent .fly-char { text-shadow: 0 0 50px rgba(0, 209, 232, .45); }

/* sem WebGL: o emblema estático "se monta" no lugar do logo de partículas */
html.motion:not(.n8-webgl) .interlude-emblem { top: 50%; margin-top: min(-15vw, -200px); }
@media (max-width: 959.98px) {
  html.motion:not(.n8-webgl) .interlude-emblem {
    position: absolute; left: 50%; right: auto; top: 52%;
    width: 44vw; margin: -22vw 0 0 -22vw;
  }
}

@media (max-width: 768px) {
  .motion .interlude { height: 180vh; }
  .motion .interlude-inner { padding-top: 92px; padding-bottom: 22px; }
  /* retrato: o logo de partículas fica na faixa de cima (logoY ≈ .46), o texto embaixo */
  .motion .interlude-main { align-self: end; margin-bottom: 26px; }
  .motion .stats { gap: 18px 14px; }
  .motion .stat-sub { font-size: .76rem; }
  .motion .interlude-title { font-size: clamp(2rem, 9.4vw, 3.2rem); }
  .motion .interlude-lead { font-size: 1.06rem; max-width: 30ch; }
  .motion .stat-num { font-size: clamp(2rem, 10vw, 2.8rem); }
  .motion .stat-col { gap: 8px; }
}
/* tablet em pé: mesma composição do celular (logo em cima, texto embaixo) */
@media (min-width: 768.02px) and (max-width: 1080px) and (max-aspect-ratio: 5/6) {
  .motion .interlude-main { align-self: end; margin-bottom: 26px; }
}
@media (max-width: 768px) and (max-height: 700px) {
  .motion .interlude-lead { display: none; }
}

/* ---------------------------------------------------- movimento reduzido */
@media (prefers-reduced-motion: reduce) {
  .preloader { display: none !important; }
  .js.pl .preload-hidden { opacity: 1; translate: none; scale: none; }
}
