/* Natural document flow is the baseline. JavaScript stages a scene only when
   its tallest step and its controls fit within the available viewport. */
.story {
  --story-inset: var(--story-top, var(--bar, 0rem));
  --scene-ease: cubic-bezier(.19,.8,.2,1);
  position: relative;
}
.story-pin {
  display: grid;
  grid-template-columns: var(--story-columns, minmax(0, .8fr) minmax(0, 1.2fr));
  column-gap: var(--story-gap, clamp(2rem, 6vw, 6rem));
  align-content: center;
  align-items: center;
  padding-block: var(--story-pad-y, clamp(2rem, 5vh, 4rem));
  box-sizing: border-box;
}
.story-meta, .story-panels, .story-panel { min-inline-size: 0; }
.story:not(.is-staged) .story-meta { align-self: start; }
.story:not(.is-staged) .story-panel + .story-panel { margin-block-start: clamp(3rem, 8vh, 6rem); }
.story.is-staged { min-block-size: calc(var(--scene-frame) + var(--scene-run)); }
.story.is-staged .story-pin {
  position: sticky;
  top: var(--story-inset);
  min-block-size: var(--scene-frame);
}
.story.is-staged .story-panels {
  --lane-top: 0px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  isolation: isolate;
  clip-path: inset(-.35rem -.5rem);
}
.story.is-staged .story-panel {
  grid-area: 1 / 1;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}
.story.is-staged .story-panel.is-active { visibility: visible; opacity: 1; pointer-events: auto; z-index: 2; }
.story-controls:empty { display: none; }
.story-announcement {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.story-controls:not(:empty) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .7rem;
  width: fit-content;
  max-width: 100%;
  color: var(--muted, #abb0c1);
  margin-block-start: clamp(1.25rem, 3vh, 2rem);
}
.story-controls button {
  background: transparent;
  color: inherit;
  box-sizing: border-box;
  border: 0;
  appearance: none;
  cursor: pointer;
  padding: 0;
}
.story-controls button:focus-visible {
  outline: 2px solid var(--mint, #73edcb);
  outline-offset: 2px;
}
.story-controls .story-turn {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: 1px solid var(--line, #39394c);
  display: grid;
  place-items: center;
  color: var(--paper, white);
}
.story-turn::before {
  content: '';
  width: .42rem;
  height: .42rem;
  border-right: 1.5px solid;
  border-top: 1.5px solid;
  transform: translateX(-.09rem) rotate(45deg);
}
.story-turn[data-shift="-1"]::before { transform: translateX(.09rem) rotate(-135deg); }
.story-controls .story-turn[aria-disabled="true"] { color: var(--muted, #abb0c1); opacity: .42; cursor: default; }
.story-controls .story-turn:not([aria-disabled="true"]):hover { border-color: currentColor; color: var(--mint, #73edcb); }
.story-counter {
  display: inline-flex;
  gap: .3em;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
  font-size: .79rem;
  line-height: 1;
}
.story-current { color: var(--paper, white); font-weight: 600; }
.story-segments { display: inline-flex; align-items: center; max-width: 100%; }
.story-controls .story-segment {
  height: 2.75rem;
  width: clamp(1.5rem, 2.3vw, 2.2rem);
  padding-inline: .15rem;
  position: relative;
}
.story-segment::after {
  content: '';
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: var(--line, #3b4050);
  transition: background-color .24s, transform .24s;
}
.story-segment.is-past::after { background: var(--muted, #a8acba); }
.story-segment:hover::after, .story-segment[aria-current="step"]::after {
  transform: scaleY(1.55);
  background: var(--mint, #73edcb);
}
@media (max-width: 47.5rem) {
  .story-pin {
    grid-template-columns: minmax(0,1fr);
    row-gap: var(--story-gap-mobile, clamp(1.25rem, 3.75vh, 2.4rem));
    padding-block: var(--story-pad-y-mobile, clamp(1.2rem, 3.5vh, 2.5rem));
  }
  .story-controls:not(:empty) { margin-block-start: 1rem; }
  .story:not(.is-staged) .story-panel + .story-panel { margin-block-start: clamp(2.75rem, 8vh, 4.5rem); }
}
@media screen and (prefers-reduced-motion: no-preference) {
  .story.is-staged .story-panels.scrubbing-copy,
  .story.is-staged .chapter-handoff .story-panels {
    mask-image: linear-gradient(to bottom, transparent var(--lane-top),
      black calc(var(--lane-top) + var(--feather, 0px)),
      black calc(100% - var(--feather, 0px)), transparent 100%);
  }
  /* Semantics and pointer targets follow one current step. The two visible
     copies share the artwork's scroll position, including when paused. */
  .story.is-staged .story-panel.is-blending { visibility: visible; opacity: 1; }
  .story-panel.is-blending > .graphic-copy {
    opacity: var(--copy-alpha);
    transform: translate3d(0, var(--copy-y), 0);
  }
}
@media print {
  .story.is-staged, .story.is-staged .story-pin { min-block-size: 0; }
  .story .story-controls { display: none; }
  .story.is-staged .story-pin, .story.is-staged .story-panels { display: block; position: static; }
  .story.is-staged .story-panel {
    visibility: visible; opacity: 1; transform: none; animation: none !important;
    margin-block: 1rem; break-inside: avoid;
  }
}

/* The artwork occupies the anchor reserved in each article, independently
   of the text's entrance/exit animation. It never intercepts a gesture. */
.glyph-field { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
.glyphs-unavailable .glyph-anchor { display: none; }
.story:not(.is-staged) .story-pin { position: relative; }
/* The chapter keeps its native scroll height. Both pins share the viewport
   during a handoff, independent of asynchronous wheel/touch scrolling. */
.story.is-staged > .story-pin.chapter-handoff {
  position: fixed;
  inset-inline: 0;
  pointer-events: none;
}
.story.is-staged > .chapter-handoff.handoff-present { pointer-events: auto; }
@media screen and (prefers-reduced-motion: no-preference) {
  .chapter-handoff .story-meta {
    transform: translate3d(0, var(--heading-y), 0);
    opacity: var(--heading-alpha);
  }
  .chapter-handoff .story-panel > .graphic-copy {
    transform: translate3d(0, var(--handoff-y), 0);
    opacity: var(--handoff-alpha);
  }
}
@media (max-width: 47.5rem) {
  .story.is-staged .story-panels {
    /* The artwork is on a separate canvas. Clip just the copy's track
       below its reserved slot as the next thought rises into view. */
    --lane-top: calc(var(--stage-art-size) + var(--stage-row-gap) - .35rem);
    clip-path: inset(var(--lane-top) -.5rem -.35rem);
  }
  .glyphs-unavailable .story.is-staged .story-panels { --lane-top: 0px; clip-path: inset(-.35rem -.5rem); }
}
@media print {
  .story.is-staged .story-panels { clip-path: none; }
  .glyph-field { display: none; }
  .story.is-staged > .story-pin.chapter-handoff {
    position: static; opacity: 1; transform: none; pointer-events: auto;
  }
}
