/* Scroll story on the home page.
   Without JS (or with reduced motion) the story renders as a plain stacked
   section with a still frame. js/home.js adds `.motion` to <html> to
   switch on the pinned, scroll-scrubbed layout. */

:root {
  --story-window: #efe7da;
  --header-h: 0px;
}

/* ---------- Loader ----------
   A single rope-like line grows while the first frames load, then widens
   into the hero capsule. Only shown while <html> has `.is-loading`. */

.loader {
  display: none;
}

.is-loading {
  overflow: hidden;
  scrollbar-gutter: stable;
}

.is-loading .loader {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 100;
}

.loader-cover {
  position: absolute;
  inset: 0;
  background: var(--bg);
}

.loader-line {
  position: absolute;
  left: 50%;
  top: 20%;
  width: 2px;
  height: 60%;
  background: var(--al-brown);
  /* Clamped by the browser to half the shorter side, so it ends as the capsule's radius */
  border-radius: 999px;
  transform: scaleY(0);
}

/* ---------- Static fallback ---------- */

.story-stage {
  display: grid;
  gap: 1.5rem;
  padding: clamp(2.5rem, 6vw, 5rem) 0;
  width: min(100% - 2rem, var(--max-width));
  margin-inline: auto;
}

.story-canvas,
.story-marquee,
.story-cue,
.story-progress {
  display: none;
}

.story-still {
  width: min(100%, 720px);
  margin-inline: auto;
}

.story-intro {
  order: -1;
}

.story-intro h1 {
  font-size: clamp(2.8rem, 8vw, 7rem);
  line-height: 0.95;
  letter-spacing: -0.035em;
  font-weight: 600;
  margin: 0 0 1rem;
}

.story-sub {
  max-width: 34ch;
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.15rem);
}

.story-fill {
  font-size: clamp(1.4rem, 2.6vw, 2.3rem);
  line-height: 1.2;
  letter-spacing: -0.015em;
  max-width: 24ch;
  margin: 0;
}

/* ---------- Scroll-driven layout ---------- */

.motion .story {
  height: 800vh;
  position: relative;
}

.motion .story-stage {
  position: sticky;
  top: var(--header-h);
  height: calc(100svh - var(--header-h));
  width: 100%;
  padding: 0;
  display: block;
  overflow: hidden;
}

.motion .story-window {
  position: absolute;
  inset: 0;
  background: var(--story-window);
  overflow: hidden;
  will-change: clip-path;
}

.motion .story-canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.motion .story-still {
  display: none;
}

.motion .story-marquee {
  display: block;
  position: absolute;
  top: 50%;
  left: 0;
  margin: 0;
  transform: translateY(-50%);
  white-space: nowrap;
  font-size: clamp(5rem, 17vw, 16rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--al-brown);
  opacity: 0;
  pointer-events: none;
}

.motion .story-intro,
.motion .story-beat {
  position: absolute;
  z-index: 2;
}

.motion .story-intro {
  left: max(1rem, calc((100% - var(--max-width)) / 2));
  top: 50%;
  transform: translateY(-50%);
  width: min(46%, 640px);
}

.motion .story-beat {
  left: max(1rem, calc((100% - var(--max-width)) / 2));
  top: 50%;
  transform: translateY(-50%);
  width: min(34%, 460px);
}

.motion .story-beat--beyond {
  left: auto;
  right: max(1rem, calc((100% - var(--max-width)) / 2));
}

.story-fill .word {
  opacity: 0.18;
}

.story-fill b,
.story-fill .word--strong {
  font-weight: 600;
}

.story-count {
  margin-left: 0.6em;
  font-weight: 400;
  opacity: 0.6;
}

.motion .story-beat--benefit,
.motion .story-beat--benefit h2 {
  color: var(--al-beige);
}

.motion .story-cue,
.motion .story-progress {
  display: block;
  position: absolute;
  bottom: 1.25rem;
  z-index: 3;
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.motion .story-cue {
  left: 50%;
  transform: translateX(-50%);
}

.motion .story-progress {
  right: max(1rem, calc((100% - var(--max-width)) / 2));
  font-variant-numeric: tabular-nums;
}

@media (max-width: 760px) {
  .motion .story-intro {
    top: 1.5rem;
    transform: none;
    width: calc(100% - 2rem);
  }

  .motion .story-beat,
  .motion .story-beat--beyond {
    left: 1rem;
    right: 1rem;
    top: auto;
    width: auto;
    bottom: 3.5rem;
    transform: none;
  }
}

/* ---------- Fade-up for sections below the story ---------- */

.motion .reveal {
  opacity: 0;
  transform: translateY(40px);
}
