/* Motion: one signature moment (the stamp lands) and three recurring patterns.
   Every pre-reveal state is scoped to html.js, set by a pre-paint script, so nothing is
   hidden without JavaScript. Each hidden state also carries a safety animation that
   shows the element after 2.5s even if motion.js never runs. */

@keyframes safety { to { opacity: 1; } }

/* ---------- Signature: H1 lines rise, the double rule draws, the stamp lands ---------- */
/* The rise is a wide-screen moment. On phones the headline is the LCP element and paints at once. */
@media (min-width: 960px) {
  html.js .hero [data-split]:not(.is-ready) { opacity: 0; animation: safety 1ms 2.5s forwards; }
}

/* The mask keeps room below the baseline for italic descenders, which otherwise clip on desktop */
.split-line { display: block; padding-bottom: 0.14em; margin-bottom: -0.14em; clip-path: inset(-0.3em 0 0 0); }
.split-line__inner { display: block; }
html.js .hero .is-ready .split-line__inner { animation: rise var(--dur-base) var(--ease-ink) both; animation-delay: calc(var(--stagger-line) * var(--i, 0)); }
@keyframes rise { from { transform: translateY(130%); } to { transform: none; } }

/* The clerk's double rule under the highlighted phrase draws left to right once the lines are up */
/* After a re-split on resize the lines are already up: no replay */
html.js .hero .is-settled .split-line__inner { animation: none; }

/* The stamp */
html.js [data-stamp]:not(.is-ready) { opacity: 0; animation: safety 1ms 2.5s forwards; }
html.js [data-stamp].is-ready { animation: stamp var(--dur-base) var(--ease-stamp) both; animation-delay: var(--stamp-delay, 700ms); }
@keyframes stamp {
  from { opacity: 0; transform: rotate(var(--tilt-stamp)) scale(1.18); }
  to { opacity: 1; transform: rotate(var(--tilt-stamp)) scale(1); }
}

/* ---------- Pattern 1: masked reveals on result figures (IntersectionObserver, once) ---------- */
html.js [data-reveal]:not(.is-in) { opacity: 0; transform: translateY(0.3em); animation: safety 1ms 2.5s forwards; }
html.js [data-reveal] { transition: opacity var(--dur-base) var(--ease-ink), transform var(--dur-base) var(--ease-ink); }
html.js [data-reveal].is-in { opacity: 1; transform: none; }

/* ---------- Pattern 2: hairline rules draw on scroll (CSS scroll-driven, static elsewhere) ---------- */
@supports (animation-timeline: view()) {
  html.js [data-rule] { position: relative; border-top-color: transparent; }
  html.js [data-rule]::before {
    content: '';
    position: absolute;
    top: -1px; left: 0; right: 0;
    height: 1px;
    background: var(--ink);
    transform-origin: left;
    animation: rule-draw linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 60%;
  }
  html.js .docket[data-rule] { border-top-color: transparent; }
  @keyframes rule-draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }
}

/* ---------- Pattern 3: magnetic primary CTA (JS, hover + fine pointer only) ---------- */
@media (hover: hover) and (pointer: fine) {
  html.js [data-magnetic] { transition: transform var(--dur-fast) var(--ease-ink), background-color var(--dur-fast) var(--ease-ink); will-change: transform; }
}

/* ---------- Reduced motion: no translation, scale or draw. Fades only. The page looks identical at rest. ---------- */
@media (prefers-reduced-motion: reduce) {
  html.js .hero .is-ready .split-line__inner { animation: fade var(--dur-fast) linear both; }
  html.js [data-stamp].is-ready { animation: fade var(--dur-fast) linear both; }
  html.js [data-reveal]:not(.is-in) { transform: none; }
  html.js [data-rule]::before { animation: none; transform: none; }
  html.js [data-magnetic] { transition: none; transform: none !important; }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
}
