/* Vanilla-JS scroll-scrub engine — companion stylesheet.
   Mirrors Higgsfield's scroll-scrub.css layout contract: a sticky
   full-viewport media stage behind scrolling chapter copy. */

.scroll-scrub {
  position: relative;
  display: grid;
  background: var(--ss-bg, #0a0a0a);
  color: var(--ss-ink, #f5f5f5);
}

/* The stage and the story occupy the SAME grid cell so the sticky video
   sits pinned behind the story's bands as they scroll past on top of it —
   not stacked sequentially in normal document flow. */
.scroll-scrub__stage,
.scroll-scrub__story {
  grid-column: 1;
  grid-row: 1;
}

.scroll-scrub__stage {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  overflow: hidden;
  z-index: 1;
}

.scroll-scrub__media {
  position: absolute;
  inset: 0;
}

.scroll-scrub__layer {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  transition: none;
}

.scroll-scrub__picture,
.scroll-scrub__poster,
.scroll-scrub__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--ss-object-position, 50% 50%);
}

.scroll-scrub__video {
  opacity: 0;
}
.scroll-scrub__layer[data-video-painted] .scroll-scrub__video {
  opacity: 1;
}
.scroll-scrub__layer[data-video-painted] .scroll-scrub__poster {
  opacity: 0;
}

/* Subtle cinematic drift on the media itself — a slow, continuous scale
   tied to overall scroll progress (--ss-progress, set every frame by the
   engine), not per-segment, so it reads as one long push-in rather than a
   per-chapter reset. transform-only so it stays compositor-cheap. */
.scroll-scrub__media {
  transform: scale(calc(1 + var(--ss-progress, 0) * 0.06));
  transform-origin: center;
  will-change: transform;
}
@media (prefers-reduced-motion: reduce) {
  .scroll-scrub__media {
    transform: none;
  }
}

/* Scroll progress bar — pure CSS, driven by the same --ss-progress var. */
.scroll-scrub__progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 4;
  background: rgba(255, 255, 255, 0.12);
}
.scroll-scrub__progress span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--ss-accent, #e5533d);
  transform: scaleX(var(--ss-progress, 0));
  transform-origin: left center;
  will-change: transform;
}

.scroll-scrub__story {
  position: relative;
  z-index: 3;
}

.scroll-scrub__chapter {
  box-sizing: border-box;
}

.scroll-scrub__chapter-pin {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  align-items: center;
  padding: 2rem 1.5rem;
  box-sizing: border-box;
}

.scroll-scrub__chapter[data-align="right"] .scroll-scrub__chapter-pin {
  justify-content: flex-end;
  text-align: right;
}
.scroll-scrub__chapter[data-align="left"],
.scroll-scrub__chapter:not([data-align]) {
  justify-content: flex-start;
}

.scroll-scrub__chapter-pin {
  max-width: 34rem;
}

.scroll-scrub__copy {
  background: rgba(10, 10, 10, 0.55);
  backdrop-filter: blur(6px);
  padding: 1.75rem 2rem;
  border-radius: 0.75rem;
}

/* Staggered entrance, replayed each time a chapter becomes active (the
   engine toggles [data-active] on the current chapter's .scroll-scrub__copy —
   see scroll-scrub.js). transform+opacity only, so it's compositor-cheap and
   safe to restart via a reflow trick without layout thrash. */
.scroll-scrub__copy > * {
  opacity: 0;
  transform: translateY(14px);
}
.scroll-scrub__copy[data-active] > * {
  animation: scrollScrubReveal 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.scroll-scrub__copy[data-active] > *:nth-child(1) { animation-delay: 0s; }
.scroll-scrub__copy[data-active] > *:nth-child(2) { animation-delay: 0.08s; }
.scroll-scrub__copy[data-active] > *:nth-child(3) { animation-delay: 0.16s; }
.scroll-scrub__copy[data-active] > *:nth-child(4) { animation-delay: 0.24s; }
.scroll-scrub__copy[data-active] > *:nth-child(5) { animation-delay: 0.32s; }
@keyframes scrollScrubReveal {
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .scroll-scrub__copy > * {
    opacity: 1;
    transform: none;
    animation: none;
  }
}

.scroll-scrub__kicker {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ss-accent, #e5533d);
  margin: 0 0 0.5rem;
  font-weight: 700;
}

.scroll-scrub__title {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  line-height: 1.1;
  margin: 0 0 0.75rem;
}

.scroll-scrub__body {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ss-muted, #c8c8c8);
  margin: 0;
}

.scroll-scrub__tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 0;
  padding: 0;
}
.scroll-scrub__tags li {
  font-size: 0.75rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
}

.scroll-scrub__actions {
  margin-top: 1.25rem;
}

.scroll-scrub__connector-band {
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .scroll-scrub__stage {
    position: relative;
    height: 70dvh;
  }
}
