/* ============================================================================
   Spark motion kit - motion.css
   Pairs with motion.js. Copy both into a fork as assets/css/motion.css and
   assets/js/motion.js (load the JS with defer). Every effect is opt-in through
   a data attribute, so a page with no attributes pays nothing.

   The four safety rules this file keeps:
   1. No JS, no hiding. Hidden start states only apply under html.js-motion,
      which motion.js sets. A failed or blocked script leaves every word visible.
   2. Reduced motion wins. Start states are dropped entirely, not shortened.
   3. Only transform, opacity, clip-path and filter animate. Nothing that
      changes layout, so nothing shifts (no CLS).
   4. Above-the-fold entrance motion (.m-enter) never animates opacity, so an
      accessibility scan can never measure a half-faded color.
   ============================================================================ */

:root {
  --m-dur: 700ms;
  --m-dur-fast: 300ms;
  --m-ease: cubic-bezier(.2, .7, .2, 1);
  --m-ease-back: cubic-bezier(.34, 1.4, .64, 1);
  --m-dist: 28px;
  --m-stagger: 80ms;
}

/* ---------------------------------------------------------------- reveals */
[data-reveal] {
  transition:
    opacity var(--m-dur) var(--m-ease),
    transform var(--m-dur) var(--m-ease),
    clip-path var(--m-dur) var(--m-ease),
    filter var(--m-dur) var(--m-ease);
  transition-delay: calc(var(--i, 0) * var(--m-stagger));
}
html.js-motion [data-reveal]:not(.is-in) { opacity: 0; }
html.js-motion [data-reveal="up"]:not(.is-in)    { transform: translateY(var(--m-dist)); }
html.js-motion [data-reveal="down"]:not(.is-in)  { transform: translateY(calc(var(--m-dist) * -1)); }
html.js-motion [data-reveal="left"]:not(.is-in)  { transform: translateX(var(--m-dist)); }
html.js-motion [data-reveal="right"]:not(.is-in) { transform: translateX(calc(var(--m-dist) * -1)); }
html.js-motion [data-reveal="zoom"]:not(.is-in)  { transform: scale(.94); }
html.js-motion [data-reveal="blur"]:not(.is-in)  { filter: blur(10px); transform: translateY(12px); }
html.js-motion [data-reveal="tilt"]:not(.is-in)  { transform: perspective(900px) rotateX(14deg) translateY(var(--m-dist)); transform-origin: 50% 100%; }

/* mask: a wipe, not a fade. Opacity stays 1 so colors are always true. */
html.js-motion [data-reveal="mask"]:not(.is-in),
html.js-motion [data-reveal="mask-up"]:not(.is-in) { opacity: 1; }
html.js-motion [data-reveal="mask"]:not(.is-in)    { clip-path: inset(0 100% 0 0); }
html.js-motion [data-reveal="mask-up"]:not(.is-in) { clip-path: inset(100% 0 0 0); }
[data-reveal="mask"], [data-reveal="mask-up"] { clip-path: inset(0 0 0 0); }
[data-reveal="mask"].is-done, [data-reveal="mask-up"].is-done { clip-path: none; }

/* curtain: an image slides out from under a brand-color panel */
[data-reveal="curtain"] { position: relative; overflow: hidden; }
html.js-motion [data-reveal="curtain"]:not(.is-in) { opacity: 1; }
[data-reveal="curtain"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--m-curtain, var(--brand-primary, #1f3a5f));
  transform: scaleX(0);
  transform-origin: right;
  transition: transform calc(var(--m-dur) * 1.2) var(--m-ease);
  pointer-events: none;
}
html.js-motion [data-reveal="curtain"]:not(.is-in)::after { transform: scaleX(1); }
[data-reveal="curtain"] > img { transition: transform calc(var(--m-dur) * 1.6) var(--m-ease); }
html.js-motion [data-reveal="curtain"]:not(.is-in) > img { transform: scale(1.15); }

/* split words: motion.js wraps each word; the line itself never fades */
[data-split] .m-word { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .08em; margin-bottom: -.08em; }
[data-split] .m-word__in { display: inline-block; transition: transform var(--m-dur) var(--m-ease); transition-delay: calc(var(--i, 0) * 45ms); }
html.js-motion [data-split]:not(.is-in) { opacity: 1; transform: none; }
html.js-motion [data-split]:not(.is-in) .m-word__in { transform: translateY(105%); }

/* set by motion.js on anything already in view at load: show it, no tween */
.is-instant, .is-instant::after, .is-instant > img, .is-instant .m-word__in { transition: none !important; }

/* ---------------------------------------------------------- count-up stats */
[data-count] { font-variant-numeric: tabular-nums; }

/* -------------------------------------------- above-the-fold entrance (.m-enter)
   Runs once on load with no JS. .m-enter and .m-enter-zoom move with transform
   only, so the h1 and hero photo are painted from the first frame (no LCP delay).
   .m-enter-wipe starts clipped: use it on decorative rules and shapes, never on
   the h1 or the main photo. Stagger with style="--i:1", "--i:2"... */
@keyframes m-enter-rise { from { transform: translateY(40px); } to { transform: none; } }
@keyframes m-enter-wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes m-enter-zoom { from { transform: scale(1.12); } to { transform: none; } }
.m-enter       { animation: m-enter-rise .9s var(--m-ease) both; animation-delay: calc(var(--i, 0) * 120ms); }
.m-enter-wipe  { animation: m-enter-wipe 1.1s var(--m-ease) both; animation-delay: calc(var(--i, 0) * 120ms); }
.m-enter-zoom  { animation: m-enter-zoom 2.4s var(--m-ease) both; }

/* ------------------------------------------------------------ scroll progress
   CSS scroll-driven where supported; motion.js sets --p elsewhere. */
[data-progress] { transform-origin: 0 50%; transform: scaleX(var(--p, 0)); }
@supports (animation-timeline: scroll()) {
  @keyframes m-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
  [data-progress] { animation: m-progress linear both; animation-timeline: scroll(root); }
}

/* ------------------------------------------------- parallax (desktop, CSS only)
   data-parallax on an element inside a clipped box. Browsers without
   scroll-driven animations simply show it still, which is fine. */
@supports (animation-timeline: view()) {
  @media (min-width: 900px) and (prefers-reduced-motion: no-preference) {
    @keyframes m-parallax { from { transform: translateY(calc(var(--m-px, 60px) * -1)) scale(var(--m-ps, 1.12)); } to { transform: translateY(var(--m-px, 60px)) scale(var(--m-ps, 1.12)); } }
    [data-parallax] { animation: m-parallax linear both; animation-timeline: view(); }
  }
}

/* --------------------------------------------------- hover physics (fine pointers)
   motion.js feeds --rx/--ry (tilt) and --mx/--my (magnet). */
[data-tilt] { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform var(--m-dur-fast) var(--m-ease); will-change: transform; }
[data-magnet] { transform: translate(var(--mx, 0px), var(--my, 0px)); transition: transform var(--m-dur-fast) var(--m-ease-back); }

/* --------------------------------------------------------- nav scroll states
   motion.js toggles .is-scrolled and .is-hidden on any [data-nav] element.
   Each nav example styles what those states look like. */
[data-nav~="hide"] { transition: transform var(--m-dur-fast) var(--m-ease); }
[data-nav~="hide"].is-hidden { transform: translateY(-110%); }

/* ------------------------------------------- cross-page transitions (View Transitions)
   Same-origin page loads cross-fade; the header stays put. Opt in per fork by
   keeping this block. Browsers without support just navigate normally. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  .site-header { view-transition-name: site-header; }
  ::view-transition-old(root) { animation: m-vt-out .25s var(--m-ease) both; }
  ::view-transition-new(root) { animation: m-vt-in .45s var(--m-ease) both; }
  @keyframes m-vt-out { to { opacity: 0; transform: translateY(-8px); } }
  @keyframes m-vt-in { from { opacity: 0; transform: translateY(14px); } }
}

/* ------------------------------------------------------------- reduced motion
   Drop the start states outright so nothing waits on a transition. */
@media (prefers-reduced-motion: reduce) {
  html.js-motion [data-reveal]:not(.is-in),
  html.js-motion [data-split]:not(.is-in) .m-word__in { opacity: 1; transform: none; clip-path: none; filter: none; }
  html.js-motion [data-reveal="curtain"]:not(.is-in)::after { transform: scaleX(0); }
  .m-enter, .m-enter-wipe, .m-enter-zoom { animation: none; }
  [data-tilt], [data-magnet] { transform: none; }
  [data-nav~="hide"].is-hidden { transform: none; }
}
