/* Irvana motion. Decorative only: progressive enhancement, no JS fallback.
   Every rule sits inside prefers-reduced-motion: no-preference, so the static
   (final) state is the default for anyone who asks for less motion.
   Guides: motion, scroll-entry-exit-effects, dynamic-sibling-animations,
   cross-document-transitions (modern-web-guidance). */

@media (prefers-reduced-motion: no-preference) {

  /* 1. Page-to-page cross-fade, header held in place */
  @view-transition { navigation: auto; }
  .site-header { view-transition-name: site-header; }
  ::view-transition-group(root) { animation-duration: 0.35s; }

  /* 2. Colour bar builds segment by segment on load */
  @keyframes bar-in {
    from { scale: 0 1; }
  }
  .colour-bar span {
    --stagger: 0.09s;
    transform-origin: left;
    animation: bar-in 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
    animation-delay: calc(0.15s + var(--i, 0) * var(--stagger));
  }
  @supports (animation-delay: calc(sibling-index() * 0.1s)) {
    .colour-bar span { animation-delay: calc(0.15s + sibling-index() * var(--stagger)); }
  }
  @supports not (animation-delay: calc(sibling-index() * 0.1s)) {
    .colour-bar span:nth-child(1) { --i: 1; }
    .colour-bar span:nth-child(2) { --i: 2; }
    .colour-bar span:nth-child(3) { --i: 3; }
    .colour-bar span:nth-child(4) { --i: 4; }
    .colour-bar span:nth-child(5) { --i: 5; }
  }

  @supports ((animation-timeline: view()) and (animation-range: entry)) {

    /* 3. "Your company exists twice": the market's line starts out of step
       with the business line and settles into alignment as it scrolls in.
       Slide only, no fade, so the line always meets text contrast (Steve, 23 Nov 2026). */
    @keyframes close-gap {
      from { translate: 2.5em 0; }
    }
    .twice-market {
      animation: close-gap linear both;
      animation-timeline: view();
      animation-range: entry 40% cover 50%;
    }

    /* 4. Coloured rules on navy grids draw left to right, one after another */
    @keyframes rule-draw {
      from { scale: 0 1; }
    }
    .card-grid { view-timeline: --grid; }
    .card-grid > *::before {
      animation: rule-draw linear both;
      animation-timeline: --grid;
      animation-range: entry 30% cover 40%;
    }
    .card-grid > :nth-child(3n + 2)::before { animation-range: entry 55% cover 45%; }
    .card-grid > :nth-child(3n + 3)::before { animation-range: entry 80% cover 50%; }

    /* 5. Diagonal line on navy bands draws upward as the band arrives */
    @keyframes line-draw {
      from { clip-path: inset(100% 0 0 0); }
      to { clip-path: inset(0 0 0 0); }
    }
    .band-navy { view-timeline: --band; }
    .band-navy::after {
      animation: line-draw linear both;
      animation-timeline: --band;
      animation-range: entry 10% cover 55%;
    }
  }
}
