/* regenerative.law — motion
 * CSS-only animation. JS only toggles `.reveal` / `.is-in` (see js/site.js);
 * every transform, delay and curve lives here.
 *
 * Principles (from the motion-design brief): motion has a job, entrances ease out,
 * siblings stagger by a small fixed step, and nothing moves for users who ask for less. */

@keyframes rise {
  from { opacity: 0; transform: translateY(var(--rise, 0.875rem)); }
  to   { opacity: 1; transform: none; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes orbit { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: no-preference) {
  /* ── Page load: header fades, hero rises in sequence ──────── */
  .site-header { animation: fade 600ms var(--ease) both; }
  .hero > :nth-child(1) { --i: 0; }
  .hero > :nth-child(2) { --i: 1; }
  .hero > :nth-child(3) { --i: 2; }
  .hero > :nth-child(4) { --i: 3; }
  .hero > :nth-child(5) { --i: 4; }
  .hero > :nth-child(6) { --i: 5; }
  .section--hero .hero > * {
    animation: rise 800ms var(--ease) both;
    animation-delay: calc(var(--i, 0) * 100ms + 150ms);
  }
  .hero h1 { --rise: 1.25rem; }
  .section--hero .contribute > h3 {
    animation: rise 800ms var(--ease) both;
    animation-delay: 650ms;
  }
  .section--hero .contribute__item {
    animation: rise 800ms var(--ease) both;
    animation-delay: calc(var(--i, 0) * 110ms + 750ms);
  }
  .contribute__item:nth-child(1) { --i: 0; }
  .contribute__item:nth-child(2) { --i: 1; }
  .contribute__item:nth-child(3) { --i: 2; }

  /* ── Scroll reveal: opt-in by script, so no-JS pages stay visible ── */
  .js .reveal { opacity: 0; transform: translateY(1rem); }
  .js .reveal.is-in {
    opacity: 1;
    transform: none;
    transition: opacity 700ms var(--ease), transform 700ms var(--ease);
    transition-delay: calc(var(--i, 0) * 90ms);
  }

  /* ── Diagrams ─────────────────────────────────────────────── */
  /* chart lines draw themselves once their block is on screen */
  .js .draw { stroke-dasharray: 1; stroke-dashoffset: 1; }
  .js .is-in .draw { animation: draw 1400ms var(--ease) 200ms forwards; }
  /* pillar arcs appear in order, then the planet-blue return arc closes the loop */
  .js .cycle__arcs path { opacity: 0; stroke-dasharray: none; stroke-dashoffset: 0; }
  .js .is-in .cycle__arcs path { animation: fade 700ms var(--ease) forwards; }
  .js .is-in .cycle__arcs path:nth-child(1) { animation-delay: 200ms; }
  .js .is-in .cycle__arcs path:nth-child(2) { animation-delay: 450ms; }
  .js .is-in .cycle__arcs path:nth-child(3) { animation-delay: 700ms; }
  .js .is-in .cycle__arcs path:nth-child(4) { animation-delay: 950ms; }
  /* a single dot circles the loop: the cycle never ends */
  .cycle__orbit { animation: orbit 28s linear infinite; }
  /* chart milestones */
  .js .chart--repair .ms { opacity: 0; }
  .js .is-in .chart--repair .ms,
  .js .chart--repair.is-in .ms { animation: fade 600ms var(--ease) forwards; }
  .js .is-in .chart--repair .ms:nth-child(1) { animation-delay: 700ms; }
  .js .is-in .chart--repair .ms:nth-child(2) { animation-delay: 1000ms; }
  .js .is-in .chart--repair .ms:nth-child(3) { animation-delay: 1300ms; }
}

/* reduced motion: show everything in its final state */
@media (prefers-reduced-motion: reduce) {
  .cycle__orbit { display: none; }
}
