/* ─────────────────────────────────────────────────────────────────────────
   Section: Built for Your Community — scroll-linked reveal.

   BEHAVIOUR, per the design's animation guide (Figma node 1663:1729, ref
   https://www.schoolofstyle.com/#all-courses): the section "reveals itself
   line-by-line or item-by-item based exactly on where the user has
   scrolled". The operative phrase is "based exactly on where the user has
   scrolled" — this is scroll-LINKED, not a one-shot transition fired when
   the section comes into view. Scroll down and items reveal; scroll back up
   and they un-reveal, tracking the scrollbar exactly.

   That rules out the usual IntersectionObserver + add-a-class approach,
   which plays on a clock once a threshold is crossed and then stays put.
   animation-timeline: view() is the scroll-linked equivalent, and it is the
   same mechanism the one-platform deck uses, so the two sections agree.

   THE STAGGER IS FREE. Every revealing item carries the same rule. view()
   measures each element's OWN progress through the viewport, and the items
   sit at different heights, so they reveal in document order as the section
   passes: heading lines, subhead, then each card item in turn. No per-item
   delays and no nth-child offsets to keep in sync when the copy changes.

   Items are marked with a class in the partial rather than selected by tag
   here, so the choreography stays visible in the markup and editing the
   copy cannot silently change it.

   Never put the transform variant on an element that is positioned with a
   transform — the "vs" is centred with -translate-x-1/2 -translate-y-1/2,
   and these keyframes would overwrite that and knock it out of place. It
   uses the --fade variant, which animates opacity only.

   SUPPORT: scroll-driven animations are Chrome/Edge and Safari 26+. Firefox
   has no animation-timeline yet, so @supports keeps this away from it
   entirely and the section renders fully visible and static. That is the
   only acceptable fallback for a reveal: content must never be left hidden
   in a browser that cannot run the animation that would show it.
   ───────────────────────────────────────────────────────────────────────── */

/* The line starts fully below the clip edge and slides up into it. No
   opacity: the mask does the revealing, which is what makes it read as the
   line APPEARING rather than some text fading about. */
@keyframes section-built-for-reveal {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

/* The clip container. Nothing animates here — it just hides whatever sits
   below its bottom edge.

   The padding/negative-margin pair is load-bearing: a box sized to the text
   clips its own descenders (g, y, p) and the tails of the Rock Salt accent.
   Padding opens the box enough to clear them, and the equal negative margin
   takes that space back out of the layout so nothing shifts. */
.section-built-for__reveal {
  display: block;
  overflow: hidden;
  padding-bottom: 0.18em;
  margin-bottom: -0.18em;

  /* Publishes a NAMED timeline tracking this box's progress through the
     page. The inner element must use this rather than a plain view(),
     because `overflow: hidden` above makes this box a scroll container —
     and view() resolves against the nearest ancestor scroll container. The
     inner span would therefore measure itself against this clip box, which
     never scrolls, leaving the timeline inert and the animation frozen at
     its start frame. Naming the timeline here anchors it to the page
     scroller instead. */
  view-timeline-name: --section-built-for-line;
  view-timeline-axis: block;
}

.section-built-for__reveal-inner {
  display: block;
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    /* The INNER element animates; the outer stays put doing the clipping.
       Keeping them separate is also what lets the "vs" work — its outer box
       holds the -translate-x-1/2 -translate-y-1/2 that centres it, while
       the inner slides, so the reveal cannot knock it out of position. */
    .section-built-for__reveal-inner {
      animation: section-built-for-reveal linear both;
      animation-timeline: --section-built-for-line;

      /* cover, NOT entry. The entry range spans only the element's own
         height — for a single line of text that is ~30px of scroll, so the
         reveal finished almost instantly and read as a pop rather than a
         line animating in. cover spans the element's whole passage through
         the viewport (viewport height + element height), so this is a few
         hundred px of scroll and the movement is legible. */
      animation-range: cover 5% cover 38%;
    }
  }
}
