/* ============================================================
   fx.css — motion layer (pairs with fx.js and js/hero.js)
   Lenis, scroll progress, reveal + split-word headings, the automatic
   intro (name reveal → flies into the nav), the pause-animations
   switch (html.motion-paused) and the reduced-motion overrides
   (the only place !important is used, besides motion-paused).
   Hidden "before" states are scoped to html.js so the page is fully
   visible if JavaScript never runs.
   ============================================================ */

/* ---------- Lenis smooth-scroll required styles ---------- */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }
.lenis.lenis-smooth iframe { pointer-events: none; }

/* ---------- scroll progress (2px gradient bar) ---------- */
.scroll-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: var(--z-progress);
  background: var(--grad); transform: scaleX(0); transform-origin: 0 50%; pointer-events: none;
  transition: opacity .2s;
}
/* it sits above every overlay — hide it while a dialog / the lightbox / the intro is up */
body.modal-open .scroll-progress, html.intro .scroll-progress { opacity: 0; }

/* ---------- reveal: fade + rise, keyed by [data-reveal] → .is-in ----------
   An animation (not a transition) so it never fights a component's own
   hover transitions. backwards fill = hidden during its delay only. */
html.js [data-reveal]:not(.is-in) { opacity: 0; }
[data-reveal].is-in { animation: revealUp .9s var(--ease) var(--d, 0ms) backwards; }
@keyframes revealUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

/* ---------- split headings: each word rises out of a mask ---------- */
[data-split] .w {
  display: inline-block; overflow: hidden; vertical-align: top;
  padding: .12em .1em .2em; margin: -.12em -.1em -.2em;
}
[data-split] .wi { display: inline-block; transition: transform 1s var(--ease) calc(var(--wi, 0) * 40ms); }
html.js [data-split]:not(.is-in) .wi { transform: translateY(135%); }

/* ---------- intro: name reveal → flies into the nav (first visit per session) ----------
   No click, no dialog. html.intro (decided by the <head> script) shows it.
   1. The letters of "Sinned Blanza" rise out of the line's mask (compositor-only
      transform + opacity, from the first paint); a gradient rule sweeps in under the
      name and the tagline fades up.
   2. js/hero.js FLIPs the name (WAAPI, transform + opacity only) into the
      visible nav brand while the panel lifts away; the real brand stays
      hidden until the flying name lands on it, then the two crossfade.
   .is-out = leaving (stays up after html.intro is dropped), .is-landed =
   the name has reached the nav. Reduced motion / Pause animations: no intro. */
.preloader { display: none; position: fixed; inset: 0; z-index: var(--z-preloader); pointer-events: none; }
html.intro .preloader, .preloader.is-out { display: block; }
/* the page is scroll-locked meanwhile (styles.css): keep the scrollbar's gutter, so the
   nav doesn't shift sideways under the landing name when the scrollbar comes back */
html.intro { scrollbar-gutter: stable; }
.intro-panel { position: absolute; inset: 0; background: var(--bg); pointer-events: auto; }
/* a hairline that rides the panel's edge as it lifts */
.intro-panel::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 2px;
  background: var(--grad); box-shadow: 0 0 18px 1px var(--glow);
  opacity: 0; transition: opacity .25s;   /* its glow would tint the bottom edge while the panel rests */
}
.preloader.is-out .intro-panel::after { opacity: 1; }
.intro-stage { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; }
.intro-lockup {
  position: relative; margin-top: -4vh;
  font-size: min(clamp(2.6rem, 8.5vw, 6.8rem), 11.5vw);
}
.intro-name {
  position: relative; overflow: hidden; white-space: nowrap;
  padding: .1em .08em .16em;
  font: 800 1em/1 var(--sans); letter-spacing: -.04em; color: var(--text);
  transform-origin: 0 0;
}
/* transform + opacity only, so the compositor runs it: the page's boot (parsing, module
   eval — 200–400ms long tasks on load) can't freeze the reveal. An animated blur() would
   move pixels, which Chrome keeps on the main thread — it stalled the letters mid-rise
   for ~0.4s and then popped them in. The "focus" comes from the scale + fade instead. */
.intro-ch {
  display: inline-block; transform-origin: 50% 100%;
  animation: introCh .62s var(--ease) calc(50ms + var(--i, 0) * 28ms) both;
}
@keyframes introCh {
  from { transform: translateY(118%) scaleY(1.18); opacity: 0; }
  55% { opacity: 1; }
  to { transform: none; opacity: 1; }
}
/* one gradient across the word: each letter shows its slice (offsets measured inline in index.html) */
.intro-word--grad .intro-ch {
  background-image: var(--grad-text);
  background-size: var(--gw, 100%) 100%;
  background-position: calc(var(--gx, 0em) * -1) 0;
  background-repeat: no-repeat;
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.intro-sub {
  position: absolute; top: 100%; left: .08em; right: .08em;
  display: grid; justify-items: center; gap: 16px; padding-top: 6px;
}
.intro-rule {
  display: block; width: 100%; height: 2px; border-radius: 2px; background: var(--grad);
  transform: scaleX(0); transform-origin: 0 50%;
  animation: introRule .6s var(--ease-io) .5s forwards;
}
.intro-tag {
  font: 500 clamp(14px, 1.3vw, 17px)/1.4 var(--sans); letter-spacing: -.005em; color: var(--muted);
  white-space: nowrap; opacity: 0;
  animation: introTag .5s var(--ease) .62s forwards;   /* settled by ≈ 1.1s, well before the exit */
}
@keyframes introRule { to { transform: scaleX(1); } }
@keyframes introTag { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* the real nav brand waits for the flying name */
html.intro .brand > *,
.preloader.is-out:not(.is-landed) ~ :is(.nav, .mbar) .brand > * { opacity: 0; }

/* ---------- pause animations (WCAG 2.2.2) — the footer / palette switch ----------
   Only named loops are paused (never entrance animations — a paused
   reveal would keep content invisible). rAF loops stop in JS. */
html.motion-paused :is(.blob, .hchip, .live-dot, .caret, .mouse i, .lt, .hero-hey .wave,
  .ring-text, .ind-track, .method-runner, .st-vinyl, .st-eq i) {
  animation-play-state: paused !important;
}

/* ---------- reduced motion: everything static and visible ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    animation-delay: 0s !important; transition-duration: .01ms !important; transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
  html.js [data-reveal] { opacity: 1 !important; animation: none !important; }
  [data-split] .wi { transform: none !important; }
  .caret { display: none !important; }
  html.js .hero .code-typed { width: auto !important; animation: none !important; }
  html.js .hero .hero-word span, html.js .hero .hero-portrait-inner, html.js .hero .hero-copy > *,
  html.js .hero .role-card, html.js .hero .hero-status, html.js .hero .hero-bar, html.js .hero .hchip {
    opacity: 1 !important; transform: none !important; scale: none !important;
  }
  .hchip, .blob, .method-runner, .ind-track, .ring-text, .live-dot, .mouse i, .lt, .hero-hey .wave { animation: none !important; }
  .ind-row { flex-wrap: wrap; }
  .ind-track { flex: 1 1 100%; flex-wrap: wrap; }
  .ind-track[aria-hidden="true"] { display: none; }
  .band-track { transform: none !important; }
}
