/* Story section shell. Without data-mode (no JS, engine failed) the beats stack, one per screen, over their stills.
   The engine sets data-mode (live | still | poster), data-beat and data-ready; then the stage pins.
   Phone composition (subject on top, copy below) runs on phones and portrait tablets: the same query as story-mount.js. */
.story { position: relative; background: var(--ink); }
.story__stage { position: relative; }
.story__poster, .story__canvas, .story__bpm { display: none; }
.story__beat { position: relative; min-height: 100svh; display: flex; flex-direction: column; justify-content: flex-end;
  padding: calc(var(--hdr) + 24px) var(--gutter) 120px; overflow: hidden; }
.story__beat[data-beat="4"] { display: none; }
.story__still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .55; }
.story__copy { position: relative; max-width: 40rem; }
.story__beat:not(.story__beat--b0) .story__copy { margin: 0 auto; text-align: center; }
.story__beat[data-beat="3"] .story__copy { text-align: left; }

.story__sub { margin-top: 20px; max-width: 34rem; color: var(--ice); }
.story__actions { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 12px; }
.story__line { font: 400 clamp(2rem, 1.3rem + 2.9vw, 3.75rem)/1.08 var(--serif); letter-spacing: -.01em; text-wrap: balance; font-optical-sizing: auto; }
.story__para { font: 400 clamp(1.375rem, 1.05rem + 1.25vw, 2.125rem)/1.3 var(--serif); max-width: 30ch; font-optical-sizing: auto; text-wrap: pretty; }
.story__para--b2 { margin-top: 20px; color: var(--ice); }
.story__hint { margin-top: 20px; font-size: 17px; color: var(--mist); }
.story__tools { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.story__status { margin-top: 12px; min-height: 1.4em; font-size: 15px; color: var(--ice); }
.story__rub { display: none; }
.story__rub[aria-pressed="true"], .story.is-rubbing .story__rub { border-color: var(--pulse); color: var(--pulse); }
@media (pointer: coarse) { .story__rub { display: inline-flex; } .story__hint { display: none; } }
.story:not([data-mode]) .story__tools, .story:not([data-mode]) .story__hint, .story:not([data-mode]) .story__status { display: none; }
@media (max-width: 759px) { .story__actions .btn--primary { display: none; } .story__actions .btn--ghost { border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; } }

/* Hero entrance: an animation, never a hidden start state that waits on a script. */
html.js .rise { animation: rise var(--t-reveal) var(--ease-expo) both; }
.rise:nth-child(2) { animation-delay: var(--stagger); }
.story__sub.rise { animation-delay: calc(var(--stagger) * 2); }
.story__actions.rise { animation-delay: calc(var(--stagger) * 3); }
.h1 .rise { display: inline-block; }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }

/* Pinned stage (engine running, in any mode). Stills are whole-stage frames, so the poster covers the stage. */
.story[data-mode] .story__stage { position: sticky; top: 0; height: 100lvh; overflow: hidden; }
.story[data-mode] .story__still { display: none; }
.story[data-mode] .story__poster { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.story[data-mode] .story__canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 600ms var(--ease-out); }
.story[data-mode][data-ready] .story__canvas { opacity: 1; }
.story[data-mode="live"][data-ready] .story__poster { visibility: hidden; transition: visibility 0s 600ms; }
.story[data-mode="poster"] .story__canvas { display: none; }
.story[data-mode] .story__wave { z-index: 2; pointer-events: none; }
.story[data-mode] .story__bpm { display: block; position: absolute; z-index: 3; right: var(--gutter); bottom: calc(4svh - 26px + (100lvh - 100svh));
  font-size: 15px; color: var(--mist); transition: opacity 350ms ease; }
.story[data-mode]:not([data-beat="0"]) .story__bpm { opacity: 0; }

.story[data-mode] .story__beat { position: absolute; inset: 0; min-height: 0; z-index: 4; display: block; padding: 0; pointer-events: none;
  opacity: 0; visibility: hidden; transition: opacity 350ms var(--ease-out), transform 350ms var(--ease-out), visibility 0s 350ms; transform: translateY(16px); }
/* The engine owns which line is on (.is-on): it staggers the hand-off and leaves a gap while the photo fades. */
.story[data-mode] .story__beat.is-on {
  opacity: 1; visibility: visible; transform: none; transition: opacity 500ms var(--ease-out) 100ms, transform 500ms var(--ease-out) 100ms, visibility 0s; }
.story[data-mode] .story__copy { position: absolute; pointer-events: auto; left: clamp(24px, 7vw, 100px); width: calc(40% - clamp(24px, 7vw, 100px)); max-width: none;
  top: 46%; transform: translateY(-50%); text-align: left; margin: 0; }
.story[data-mode] .story__tools { justify-content: flex-start; }
/* B0: two-line claim ("Advancing biological / medicine."), column capped so "biological" stays left of the portrait. */
.story[data-mode] .story__beat--b0 .story__copy { top: auto; transform: none; bottom: calc(4svh + 120px + 32px + (100lvh - 100svh)); width: min(52rem, 46%); }
.story[data-mode] .story__beat--b0 .h1 { font-size: min(clamp(2.5rem, 1.2rem + 5.6vw, 6.75rem), 11.5svh, 4.4vw); }

@media (max-width: 759px), (max-width: 1023px) and (orientation: portrait) {
  .story[data-mode] .story__bpm { display: none; }
  .story[data-mode] .story__copy { left: 24px; right: 24px; width: auto; transform: none; text-align: center; }
  .story[data-mode] .story__tools { justify-content: center; }
  .story[data-mode] .story__beat--b0 .story__copy { top: calc(36svh + 64px); bottom: auto; width: auto; max-width: 40rem; text-align: left; }
  .story[data-mode] .story__beat--b0 .h1 { font-size: min(clamp(2.5rem, 1.2rem + 5.6vw, 6.75rem), 11.5svh); }
  .story[data-mode] [data-beat="1"] .story__copy { top: calc(22svh + 35vw + 40px); }
  .story[data-mode] [data-beat="3"] .story__copy { top: 54svh; text-align: left; }
  /* B2: the heart fills 8-68svh, so the copy sits under it, bottom-anchored above the dock (it starts below 70svh).
     The long line is kept for screen readers only here: there is no room for it between the heart and the dock. */
  .story[data-mode] [data-beat="2"] .story__copy { top: auto; display: flex; flex-direction: column; align-items: center;
    bottom: calc(96px + env(safe-area-inset-bottom) + (100lvh - 100svh)); }
  .story[data-mode] [data-beat="2"] .story__line { font-size: 28px; }
  .story[data-mode] .story__para--b2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .story[data-mode] [data-beat="2"] .story__status { order: -1; min-height: 0; margin: 0 0 8px; }
  .story[data-mode] [data-beat="2"] .story__status:empty { display: none; }
}
/* Phones: B1 pushes in to the portrait at 100vw centred at 30svh (bottom edge 30svh + 50vw), so its line sits below. */
@media (max-width: 759px) {
  .story[data-mode] [data-beat="1"] .story__copy { top: calc(30svh + 50vw + 24px); }
}
/* Portrait tablets: the subject (about 56vw, centred at 22svh) and the B3 cross (to 44svh) sit above all copy. */
@media (min-width: 760px) and (max-width: 1023px) and (orientation: portrait) {
  .story[data-mode] .story__beat--b0 .story__copy { top: max(calc(36svh + 64px), calc(22svh + 28vw + 96px)); }
  .story[data-mode] [data-beat="3"] .story__copy { top: 58svh; }
}
@media (prefers-reduced-motion: reduce) {
  html.js .rise { animation: none; }
  .story[data-mode] .story__beat { transform: none; transition: opacity 200ms linear, visibility 0s 200ms; }
  .story[data-mode] .story__beat.is-on { transition: opacity 200ms linear, visibility 0s; }
}
