/* CODR landing — Hero motion (L7). Requires hero.css + hero-mock.css and js/hero-motion.js.
   Rules (design-decisions §1.8): purposeful, ease-out, transform/opacity only (single exception: the readiness ring
   animates a registered number property, paint-only, tiny element), nothing loops.
   Classes set on <html> by the inline script in index.html:
     js            script is running
     motion        animate: the OS/browser does NOT ask for reduced motion, OR the page was opened with ?motion=on
     motion-forced opened with ?motion=on (owner preview): animate even if the OS asks for reduced motion
     has-prop      @property is supported (ring fill)
     hero-ready    i18n text + fonts are in (set by js/hero-motion.js) → release the hero
   Reduced motion (OS setting, e.g. Windows "Animation effects" off) WITHOUT ?motion=on: nothing animates,
   the hero simply appears at its final state. */

:root {
  --hero-step: 120ms;        /* delay between two consecutive elements (quick, fluid cascade; whole entrance ≈1.9s) */
  --hero-dur: 480ms;         /* duration of each element's entrance */
  --hero-bar-dur: 480ms;     /* orange bar under the H1 */
  --hero-fill-dur: 700ms;    /* readiness bars */
  --hero-donut-dur: 800ms;   /* readiness ring */
}

/* ---- Gate: hold the hero (opacity, not visibility) until strings + fonts are ready ---- */
html.js:not(.hero-ready) .hero__inner {
  opacity: 0;
  animation: hero-failsafe 1ms 3s forwards;      /* if hero-motion.js never runs, show the hero anyway after 3s */
}
@keyframes hero-failsafe {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---- Entrance: one cascade, top to bottom, alternating between the two columns ---- */
.hero__eyebrow  { --i: 0; }
.hero__title    { --i: 1; }
.win--modules   { --i: 2; }
.hero__subtitle { --i: 3; }
.win--task      { --i: 4; }
.win--ready     { --i: 5; }
.hero__features { --i: 6; }
.hero__cta      { --i: 7; }
.win--review    { --i: 8; }

html.motion.hero-ready .hero :is(.hero__eyebrow, .hero__title, .hero__subtitle, .hero__features, .hero__cta, .win) {
  animation-name: hero-rise;
  animation-duration: var(--hero-dur);
  animation-timing-function: var(--ease-out);
  animation-delay: calc(var(--i) * var(--hero-step));
  animation-fill-mode: both;
  animation-iteration-count: 1;
}
@keyframes hero-rise {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: none; }
}

/* Orange bar under the H1 draws in once the title is mostly in (the title starts at step 1) */
html.motion.hero-ready .hero__title::after {
  transform-origin: left center;
  animation-name: hero-bar;
  animation-duration: var(--hero-bar-dur);
  animation-timing-function: var(--ease-out);
  animation-delay: calc(1 * var(--hero-step) + 260ms);
  animation-fill-mode: both;
  animation-iteration-count: 1;
}
@keyframes hero-bar {
  from { transform: scaleX(0); }
  to   { transform: none; }
}

/* ---- The one functional micro-interaction: delivery readiness fills up (tasks done ≠ ready) ---- */
@property --pct {
  syntax: '<number>';
  inherits: false;
  initial-value: 0;
}
.ready__bars li:nth-child(1) { --k: 0; }
.ready__bars li:nth-child(2) { --k: 1; }
.ready__bars li:nth-child(3) { --k: 2; }

/* The readiness window enters at step 5; the fill starts 300ms later, once it is on screen */
html.motion.hero-ready .ready__bars .bar i {
  transform-origin: left center;
  animation-name: hero-fill;
  animation-duration: var(--hero-fill-dur);
  animation-timing-function: var(--ease-out);
  animation-delay: calc(5 * var(--hero-step) + 300ms + var(--k) * 100ms);
  animation-fill-mode: both;
  animation-iteration-count: 1;
}
@keyframes hero-fill {
  from { transform: scaleX(0); }
  to   { transform: none; }
}
html.has-prop.motion.hero-ready .donut {
  animation-name: hero-donut;
  animation-duration: var(--hero-donut-dur);
  animation-timing-function: var(--ease-out);
  animation-delay: calc(5 * var(--hero-step) + 300ms);
  animation-fill-mode: both;
  animation-iteration-count: 1;
}
@keyframes hero-donut {
  from { --pct: 0; }                 /* the end value is the inline --pct on .donut (72) */
}

/* ---- Owner preview (?motion=on): run the motion even when the OS asks for reduced motion ----
   css/base.css zeroes every animation duration under prefers-reduced-motion with !important; these rules
   win over it (same !important, higher specificity) but only inside the hero and only when forced. */
html.motion-forced.hero-ready .hero :is(.hero__eyebrow, .hero__title, .hero__subtitle, .hero__features, .hero__cta, .win) {
  animation-duration: var(--hero-dur) !important;
}
html.motion-forced.hero-ready .hero__title::after { animation-duration: var(--hero-bar-dur) !important; }
html.motion-forced.hero-ready .ready__bars .bar i { animation-duration: var(--hero-fill-dur) !important; }
html.motion-forced.has-prop.hero-ready .donut { animation-duration: var(--hero-donut-dur) !important; }
