/* ═══════════════════════════════════════════════════════════
   Our Story: motion as each part arrives
   Only our-story.html loads this file.

   The first screen animates from CSS alone, so it runs even if the
   scripts fail. Further down, a part is hidden only once site.js has
   run (.is-ready on .shell), and site.js adds .is-in as each .rise
   scrolls into view. Without the script, the page reads as before.
   With reduced motion, none of this applies.
   ═══════════════════════════════════════════════════════════ */

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

  /* ── first screen ─────────────────────────────────────── */

  .story-hero picture{ overflow:hidden; animation:storyWipeUp 1.1s var(--easing) .1s both; }
  .story-hero img{ animation:storySettle 1.7s var(--easing) .1s both; }
  .story-hero figcaption{ animation:storyFade .6s ease 1s both; }

  .story-top .eyebrow{ animation:storySlide .7s var(--easing) .2s both; }
  .story-top .display__sm{ animation:storySlideSkew .7s var(--easing) .3s both; }
  .story-top .display__lg{ animation:storySlideSkew .8s var(--easing) .42s both; }
  .story-top .lede{ animation:storyFade .7s ease .75s both; }

  /* ── on the way down ──────────────────────────────────── */

  /* Most parts rise into place. The skewed titles keep their skew. */
  .is-ready .rise:not(.is-in):not(.story-hero):not(.story-with){ opacity:0; transform:translateY(1.5rem); }
  .is-ready .section__title.rise:not(.is-in){ transform:translateY(1rem) skewX(-8deg); }

  /* Each photo opens from its outer edge, and the words follow. */
  .story-with__photo picture{
    overflow:hidden; clip-path:inset(0 0 0 0);
    transition:clip-path 1.05s var(--easing);
  }
  .is-ready .story-with:not(.is-in) .story-with__photo picture{ clip-path:inset(0 0 0 100%); }
  .is-ready :is(.story-with--flip,.story-with--sign):not(.is-in) .story-with__photo picture{ clip-path:inset(0 100% 0 0); }
  .story-with__copy,
  .story-with figcaption{ transition:opacity .8s var(--easing) .2s, transform .8s var(--easing) .2s; }
  .story-with figcaption{ transition-delay:.7s; }
  .is-ready .story-with:not(.is-in) .story-with__copy{ opacity:0; transform:translateY(1.5rem); }
  .is-ready .story-with:not(.is-in) figcaption{ opacity:0; }

  /* The punch line lands a sentence at a time, each one flashing hot first. */
  .is-ready .chapter__body--punch .stamp{ opacity:0; }
  .is-in .chapter__body--punch .stamp{ animation:storyStamp .7s var(--easing) calc(.2s + var(--i) * .17s) both; }

  /* "Be the goat." comes in heavy, after the first line. */
  .quote blockquote .heat-text{ display:inline-block; }
  .is-ready .quote:not(.is-in) blockquote .heat-text{ opacity:0; }
  .quote.is-in blockquote .heat-text{ animation:storySlam .65s cubic-bezier(.2,1.6,.4,1) .55s both; }
  .is-ready .quote:not(.is-in) figcaption{ opacity:0; }
  .quote.is-in figcaption{ animation:storyFade .6s ease 1.1s both; }

  /* House rules: each rule draws its line, then its words come in. */
  .timeline li{ position:relative; border-top-color:transparent; }
  .timeline li::before{
    content:""; position:absolute; inset:-1px 0 auto; height:1px; background:var(--line-2);
    transform-origin:left; transition:transform .7s var(--easing) calc(var(--i) * .16s);
  }
  .timeline li > *{ transition:opacity .6s ease calc(.25s + var(--i) * .16s), transform .6s var(--easing) calc(.25s + var(--i) * .16s); }
  .is-ready .timeline:not(.is-in) li::before{ transform:scaleX(0); }
  .is-ready .timeline:not(.is-in) li > *{ opacity:0; transform:translateX(-.9rem); }

  /* Gabe signs it. */
  .story-sign__name{ position:relative; display:inline-block; }
  .story-sign__name::after{
    content:""; position:absolute; left:0; right:0; bottom:-.35rem; height:2px; background:var(--heat);
    transform-origin:left; transition:transform .6s var(--easing) 1.1s;
  }
  .is-ready .story-with:not(.is-in) .story-sign__name::after{ transform:scaleX(0); }

  /* Where the browser can tie motion to scrolling: the lead fills with ink as it
     climbs the lower half of the screen, and the photos drift a little against the
     page. Other browsers show plain text and still photos. */
  @supports (animation-timeline:view()) and ((background-clip:text) or (-webkit-background-clip:text)){
    .chapter__body--lead{ view-timeline-name:--lead; }
    .chapter__body--lead .ink{
      color:transparent; -webkit-text-fill-color:transparent;
      background-image:
        linear-gradient(var(--bone), var(--bone)),
        linear-gradient(color-mix(in srgb, var(--bone) 34%, transparent), color-mix(in srgb, var(--bone) 34%, transparent));
      background-repeat:no-repeat;
      background-size:0% 100%, 100% 100%;
      -webkit-background-clip:text; background-clip:text;
      animation:storyInk linear both;
      animation-timeline:--lead;
      animation-range:entry 0% cover 34%;
    }
    .story-with__photo img{
      animation:storyDrift linear both;
      animation-timeline:view();
      animation-range:cover;
    }
  }
}

@keyframes storyWipeUp{ from{ clip-path:inset(100% 0 0 0); } to{ clip-path:inset(0 0 0 0); } }
@keyframes storySettle{ from{ transform:scale(1.12); } }
@keyframes storyFade{ from{ opacity:0; transform:translateY(.4rem); } }
@keyframes storySlide{ from{ opacity:0; transform:translateX(-1.25rem); } }
@keyframes storySlideSkew{ from{ opacity:0; transform:translateX(-2rem) skewX(-8deg); } to{ transform:skewX(-8deg); } }
@keyframes storyStamp{
  from{ opacity:0; color:var(--heat); }
  45%{ opacity:1; color:var(--heat); }
  to{ opacity:1; }
}
@keyframes storySlam{
  from{ opacity:0; transform:scale(1.7) rotate(-3deg); }
  to{ opacity:1; transform:none; }
}
@keyframes storyInk{ to{ background-size:100% 100%, 100% 100%; } }
@keyframes storyDrift{
  from{ transform:scale(1.08) translateY(-2.5%); }
  to{ transform:scale(1.08) translateY(2.5%); }
}
