/* motion.css: motion tokens, scroll reveals, load choreography, hero words, micro-interactions, reduced-motion kill switch.
   Read when you add motion to a page. Produces hidden-to-visible states that alive.js triggers.
   Needs <html class="js-alive"> set by an inline script before this stylesheet. Without it every rule here is inert
   and the page is fully visible. Animates transform, opacity, translate and scale only. */

:root {
  /* Durations: hover 150, small state 200, enter or reveal 300, slow or dramatic 700. One personality per project. */
  --dur-hover: 150ms;
  --dur-state: 200ms;
  --dur-enter: 300ms;
  --dur-slow: 700ms;
  /* Easing: standard for all UI, float for ambient. Override --ease-signature once per project. */
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-float: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-signature: var(--ease-standard);
  --stagger: 80ms;          /* step between siblings; alive.js caps a group at 500ms in total */
  --reveal-y: 28px;         /* travel distance; keep under a third of the viewport */
  --failsafe-delay: 3s;     /* must equal FAILSAFE_MS in alive.js */
}

/* Scroll reveals: <div data-alive="reveal | reveal-left | reveal-scale">. Hidden only once JS is confirmed. */
.js-alive [data-alive] { opacity: 0; transform: translateY(var(--reveal-y)); }
.js-alive [data-alive="reveal-left"] { transform: translateX(-36px); }
.js-alive [data-alive="reveal-scale"] { transform: scale(0.94) translateY(12px); }
.js-alive [data-alive]:not(.is-done) {
  transition: opacity var(--dur-enter) var(--ease-signature), transform var(--dur-enter) var(--ease-signature);
  transition-delay: calc(var(--alive-i, 0) * var(--alive-step, var(--stagger)));
}
.js-alive [data-alive].is-in { opacity: 1; transform: none; }

/* Page-load choreography: data-load="1".."5". Structure 0-200ms, hero words 200-600ms, support 600-1200ms. */
.js-alive [data-load] {
  opacity: 0; transform: translateY(18px);
  transition: opacity var(--dur-enter) var(--ease-signature), transform var(--dur-enter) var(--ease-signature);
}
.js-alive [data-load="1"] { transition-delay: 0ms; }
.js-alive [data-load="2"] { transition-delay: 150ms; }
.js-alive [data-load="3"] { transition-delay: 600ms; }
.js-alive [data-load="4"] { transition-delay: 750ms; }
.js-alive [data-load="5"] { transition-delay: 900ms; }
.js-alive.is-loaded [data-load] { opacity: 1; transform: none; }

/* Hero words: <h1 data-alive-words>. Each word slides up on its own; the block never fades as one. */
.alive-word { text-decoration: inherit; }
.js-alive .alive-word {
  display: inline-block; opacity: 0; transform: translateY(0.6em);
  transition: opacity var(--dur-enter) var(--ease-signature), transform var(--dur-slow) var(--ease-signature);
  transition-delay: calc(200ms + var(--alive-i, 0) * var(--alive-step, var(--stagger)));
}
.js-alive.is-loaded .alive-word { opacity: 1; transform: none; }

/* Failsafe: if alive.js never starts (404, blocked, crash), content shows after 3s. It stops applying the moment
   alive.js starts, so it can never override a scroll reveal. Never remove it. */
@keyframes alive-failsafe { to { opacity: 1; transform: none; } }
.js-alive:not(.alive-ready) [data-alive],
.js-alive:not(.is-loaded) [data-load],
.js-alive:not(.is-loaded) .alive-word {
  animation: alive-failsafe var(--dur-enter) var(--ease-standard) var(--failsafe-delay) forwards;
}

/* Counters: stop the digits jittering sideways while they count. */
[data-alive-count] { font-variant-numeric: tabular-nums; }

/* Micro-interactions. Individual transform properties, so they combine with a reveal on the same element. */
.alive-press, .alive-lift {
  transition-property: translate, scale, box-shadow;
  transition-duration: var(--dur-hover);
  transition-timing-function: var(--ease-standard);
}
.alive-press:active { scale: 0.97; }
@media (hover: hover) { .alive-lift:hover { translate: 0 -3px; } }

/* Ambient: use on ONE element, low amplitude. */
@keyframes alive-drift { 0%, 100% { translate: 0 0; } 50% { translate: 0 -14px; } }
.alive-ambient { animation: alive-drift 9s var(--ease-float) infinite; }

/* Reduced motion: the real kill switch. It covers the kit and any other animation or transition on the page. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important; transition-delay: 0s !important; scroll-behavior: auto !important;
  }
  .js-alive [data-alive], .js-alive [data-load], .js-alive .alive-word { opacity: 1 !important; transform: none !important; }
  .alive-ambient { animation: none !important; }
  .alive-lift:hover { translate: none; }
  .alive-press:active { scale: none; }
}
