/* ============================================================
   Motion
   ------------------------------------------------------------
   CONTRATO INEGOCIÁVEL
   1. Todo estado inicial de animação vive sob `html.js`. Sem JS,
      ou se o GSAP falhar em carregar, o conteúdo fica VISÍVEL.
      Isso protege a indexação e o LCP.
   2. `prefers-reduced-motion: reduce` desliga tudo, sem exceção.
   3. Só animamos `transform`, `opacity`, `clip-path` e `filter`.
      Nada que dispare layout (top/left/width/height/margin).
   ============================================================ */

/* ------------------------------------------------ Estados iniciais */
/* Aplicados APENAS com JS ativo. A ausência da classe é o fallback. */

.js [data-reveal] {
  opacity: 0;
  will-change: transform, opacity;
}
.js [data-reveal="up"],
.js [data-reveal=""],
.js [data-reveal]:not([data-reveal="clip"]):not([data-reveal="lines"]):not([data-reveal="chars"]):not([data-reveal="fade"]):not([data-reveal="scale"]) {
  transform: translate3d(0, 2.5rem, 0);
}
.js [data-reveal="fade"] { transform: none; }
.js [data-reveal="scale"] { transform: scale(1.06); }

/* Revelação por linha/caractere: a máscara é o elemento externo. */
.js [data-reveal="lines"],
.js [data-reveal="chars"] { opacity: 1; }

/* A máscara corta em overflow, e com entrelinha apertada isso decepa hastes e
   acentos. O padding devolve o espaço e a margem negativa o retira do fluxo. */
.line-mask {
  display: block;
  overflow: hidden;
  padding-block: .12em;
  margin-block: -.12em;
}
.js .line-mask > .line-in {
  display: block;
  transform: translate3d(0, 105%, 0);
  will-change: transform;
}
.js .char-mask { display: inline-block; overflow: hidden; vertical-align: top; }
.js .char-mask > .char-in { display: inline-block; transform: translate3d(0, 105%, 0); }

/* Imagem revelada por cortina. O wrapper corta, a imagem contra-move. */
.js [data-reveal="clip"] {
  opacity: 1;
  clip-path: inset(0 0 100% 0);
  will-change: clip-path;
}
.js [data-reveal="clip"] > img,
.js [data-reveal="clip"] > picture > img { transform: scale(1.18); will-change: transform; }

/* Elementos já revelados: libera o will-change para não segurar memória. */
[data-reveal].is-in { will-change: auto; }

/* REDE DE SEGURANÇA. O estado inicial de [data-reveal] é opacity:0 e quem o
   desfaz é o GSAP. Se o CDN cair, se houver erro de script, ou se o cão de
   guarda do motion.js disparar, a página inteira ficaria invisível.
   `.motion-off` no <html> devolve tudo, e `.is-in` garante o estado final. */
html.motion-off [data-reveal],
[data-reveal].is-in {
  opacity: 1 !important;
  transform: none !important;
  clip-path: none !important;
}
html.motion-off .line-mask > .line-in,
html.motion-off .char-mask > .char-in,
[data-reveal].is-in .line-mask > .line-in,
[data-reveal].is-in .char-mask > .char-in {
  transform: none !important;
}
html.motion-off [data-reveal="clip"] > img,
html.motion-off [data-reveal="clip"] > picture > img { transform: none !important; }

/* ------------------------------------------------ Hero */
/* O LCP é o título do hero. Ele NÃO espera o GSAP: a animação é CSS
   pura e dispara no próprio parse, com fallback visível garantido. */

/* IMPORTANTE — por que o estado inicial NÃO está na regra do elemento:
   se escrevêssemos `opacity: 0` aqui, o elemento dependeria da animação
   para aparecer. Qualquer coisa que impeça a animação de rodar (aba em
   segundo plano, motor de animação pausado, rasterização travada) deixaria
   o texto invisível para sempre — e invisível para quem indexa.
   Com `both`, o estado inicial vem do próprio @keyframes durante o delay,
   e o repouso do elemento continua sendo VISÍVEL. Falha segura. */

.js .hero__fade {
  animation: fadeUp .9s var(--e-out) both;
  animation-delay: calc(var(--i, 0) * 90ms + .25s);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translate3d(0, 1.5rem, 0); }
  to   { opacity: 1; transform: none; }
}

.js .hero__rule {
  transform-origin: left;
  animation: ruleIn .8s var(--e-out) both;
  animation-delay: .45s;
}
@keyframes ruleIn {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* Ken Burns: a foto do hero respira devagar enquanto está ativa.
   Só transform — não força layout nem repaint da árvore. */
.js .hero__slide img {
  animation: kenburns 18s linear both;
  animation-play-state: paused;
}
.js .hero__slide[data-on] img { animation-play-state: running; }
@keyframes kenburns {
  from { transform: scale(1.06); }
  to   { transform: scale(1.16); }
}

/* A barra do slide corrente preenche no tempo do intervalo. */
.js .hero__dot[aria-current="true"]::after {
  animation: dotFill var(--hero-dur, 6.5s) linear both;
}
@keyframes dotFill {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* ------------------------------------------------ Pré-carregador */

.loader {
  position: fixed;
  inset: 0;
  z-index: var(--z-loader);
  display: grid;
  place-items: center;
  background: var(--grafite-900);
  transition: clip-path var(--d-curtain) var(--e-in-out);
}
.loader.is-done { clip-path: inset(0 0 100% 0); pointer-events: none; }
.loader__n {
  font-size: clamp(3rem, 12vw, 8rem);
  font-weight: 900;
  letter-spacing: -.05em;
  color: var(--cal);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.loader__bar {
  position: absolute;
  left: 0; bottom: 0;
  height: 3px;
  width: 100%;
  background: var(--verde);
  transform: scaleX(0);
  transform-origin: left;
}
/* Sem JS não existe pré-carregador. */
html:not(.js) .loader { display: none; }

/* ------------------------------------------------ Cortina de transição */

.curtain {
  position: fixed;
  inset: 0;
  z-index: var(--z-curtain);
  background: var(--grafite-900);
  clip-path: inset(0 0 100% 0);
  pointer-events: none;
  display: grid;
  place-items: center;
}
.curtain.is-in { clip-path: inset(0 0 0 0); transition: clip-path var(--d-curtain) var(--e-in-out); }
.curtain.is-out { clip-path: inset(100% 0 0 0); transition: clip-path var(--d-curtain) var(--e-in-out); }
.curtain img { width: 56px; opacity: .9; }

/* ------------------------------------------------ Cursor */

.cursor {
  position: fixed;
  top: 0; left: 0;
  z-index: var(--z-curtain);
  width: 12px; height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--verde);
  pointer-events: none;
  mix-blend-mode: difference;
  transform: translate3d(-100px, -100px, 0);
  transition: width .3s var(--e-out), height .3s var(--e-out), margin .3s var(--e-out), opacity .3s;
}
.cursor.is-lg { width: 56px; height: 56px; margin: -28px 0 0 -28px; }
/* Só em ponteiro fino: em toque, cursor não existe. */
@media (hover: none), (pointer: coarse) { .cursor { display: none; } }

/* ------------------------------------------------ Micro-interação */

[data-magnetic] { will-change: transform; }

.hover-lift { transition: transform var(--d-base) var(--e-out); }
.hover-lift:hover { transform: translateY(-6px); }


/* ------------------------------------------------ Barra de progresso */

.progress {
  position: fixed;
  inset: 0 0 auto;
  height: 2px;
  z-index: calc(var(--z-header) + 1);
  background: var(--verde);
  transform: scaleX(0);
  transform-origin: left;
}

/* ============================================================
   Preferência por menos movimento — desliga tudo.
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  .js [data-reveal],
  .js [data-reveal="scale"],
  .js [data-reveal="fade"] { opacity: 1 !important; transform: none !important; }

  .js [data-reveal="clip"] { clip-path: none !important; }
  .js [data-reveal="clip"] > img,
  .js [data-reveal="clip"] > picture > img { transform: none !important; }

  .js .line-mask > .line-in,
  .js .char-mask > .char-in { transform: none !important; }
  .js .hero__fade,
  .js .hero__rule { animation: none !important; opacity: 1 !important; transform: none !important; }

  /* O hero para de trocar de foto e de respirar: fica na primeira, parada. */
  .js .hero__slide img { animation: none !important; transform: none !important; }
  .js .hero__dot[aria-current="true"]::after { animation: none !important; transform: scaleX(1) !important; }
  .hero__slide { transition: none !important; }

  .marquee__track { animation: none !important; }
  .badge--obra::before { animation: none !important; }

  .loader { display: none !important; }
  .curtain { display: none !important; }
  .cursor { display: none !important; }
  