/* ==========================================================================
   SignLater Design 2.0 — Global Motion System
   Motion as storytelling: every animation must explain a fact.
   If it explains nothing, it must not exist.

   Semantic direction law:
   - Known/input (controls, sliders, assumptions) arrives from the LEFT
     or rises gently — grounded, already-understood.
   - Reveal/output (Second Number, results, charts) arrives from the RIGHT
     or settles in with emphasis — the answer arriving.
   - Facts stage: quoted -> true -> gap, never all at once.

   Performance law: transform and opacity ONLY. No layout-triggering
   properties in animations. No scroll handlers — IntersectionObserver.
   ========================================================================== */

/* ---------- Keyframes ---------- */
@keyframes sl-rise {
  from { opacity: 0; translate: 0 40px; }
  to   { opacity: 1; translate: 0 0; }
}
@keyframes sl-left {   /* known / input arrives */
  from { opacity: 0; translate: -56px 20px; }
  to   { opacity: 1; translate: 0 0; }
}
@keyframes sl-right {  /* reveal / output arrives */
  from { opacity: 0; translate: 56px 20px; }
  to   { opacity: 1; translate: 0 0; }
}
@keyframes sl-pop {    /* the Second Number settles */
  from { opacity: 0; scale: .55; translate: 0 12px; }
  to   { opacity: 1; scale: 1; translate: 0 0; }
}
@keyframes sl-float {  /* ambient float — opt-in only */
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -10px; }
}

/* ---------- Entrance choreography ----------
   Apply .en + one modifier. Stagger via --d custom property. */
.en { opacity: 0; }
.en-rise  { animation: sl-rise  .7s var(--ease) var(--d, 0s) both; }
.en-left  { animation: sl-left  .9s var(--ease) var(--d, 0s) both; }
.en-right { animation: sl-right .9s var(--ease-settle) var(--d, 0s) both; }
.en-pop   { animation: sl-pop   .8s var(--ease-settle) var(--d, 0s) both; }

/* ---------- Scroll reveals ----------
   .rv = rise (default) | .rv-l = from left (input) | .rv-r = from right (reveal)
   JS adds .in via IntersectionObserver. Stagger siblings with --d. */
.rv, .rv-l, .rv-r {
  opacity: 0;
  transition: opacity var(--t-slow) var(--ease), translate var(--t-slow) var(--ease);
  transition-delay: var(--d, 0s);
}
.rv   { translate: 0 30px; }
.rv-l { translate: -44px 18px; }
.rv-r { translate: 44px 18px; }
.rv.in, .rv-l.in, .rv-r.in { opacity: 1; translate: 0 0; }

/* ---------- Ambient float (opt-in) ---------- */
.float {
  animation: sl-float 7s ease-in-out infinite;
}

/* ---------- Restrained parallax (opt-in, JS-driven) ----------
   Elements with [data-parallax="0.08"] translate at 8% of scroll delta.
   Disabled on mobile and reduced-motion by motion.js. */
[data-parallax] { will-change: translate; }

/* ---------- Chart construction ----------
   Bars/fills grow via scaleX from the baseline. SVG strokes draw via
   stroke-dashoffset driven by JS (charts.js). */
.bar-fill {
  transform-origin: left center;
  scale: 0 1;
  transition: scale 1s var(--ease);
  transition-delay: var(--d, 0s);
}
.in .bar-fill, .bar-fill.in { scale: 1 1; }

/* ---------- Reduced motion: COMPLETE static fallback ----------
   All content visible immediately. No count-up dependency — motion.js
   resolves final values. No parallax, no float, no entrance movement. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }

  .en, .rv, .rv-l, .rv-r {
    opacity: 1 !important;
    translate: 0 0 !important;
    scale: 1 1 !important;
  }

  .float { animation: none !important; }
  [data-parallax] { will-change: auto; translate: 0 0 !important; }
  .bar-fill { scale: 1 1 !important; }
}

/* No-JS fallback: reveal everything (motion.js adds .js to <html>) */
html:not(.js) .en,
html:not(.js) .rv,
html:not(.js) .rv-l,
html:not(.js) .rv-r {
  opacity: 1;
  translate: 0 0;
}
html:not(.js) .bar-fill { scale: 1 1; }
