/* Homepage scroll story: a pinned stage with full-bleed beats that wipe in as you scroll.
   Loaded only on index.html. With reduced motion on, it falls back to a plain stacked layout. */

.story { position: relative; background: var(--bg); height: 500vh; }

.story-stage {
  position: sticky; top: 0; height: 100vh; overflow: hidden;
}

.story-progress {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  height: 3px; background: var(--line); overflow: hidden;
}
.story-progress span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

/* Each beat sits on top of the last. JS sets --wipe (0 to 1) as it enters. */
.story-beat {
  position: absolute; inset: 0;
  display: flex; align-items: flex-end;
  overflow: hidden; isolation: isolate;
}
.js .story-beat { visibility: hidden; }

.story-beat-bg {
  position: absolute; inset: 0; z-index: -2;
  background: linear-gradient(135deg, var(--bg-3), var(--bg-2));
  /* Diagonal wipe: the photo is revealed along a slanted edge. */
  clip-path: polygon(
    0 0,
    calc(var(--wipe, 1) * 140%) 0,
    calc(var(--wipe, 1) * 140% - 30%) 100%,
    0 100%
  );
}
.story-beat-bg { --nav: 76px; }
/* A blurred, darkened copy of the photo fills the screen... */
.story-beat-bg::before {
  content: ""; position: absolute; inset: -48px;
  background: var(--img, none) center / cover no-repeat;
  filter: blur(30px) brightness(.42) saturate(1.1);
}
/* ...and the photo itself is always shown whole, never cropped. */
.story-beat-bg img {
  position: absolute; display: block; object-fit: contain;
  left: 0; top: var(--nav); width: 100%; height: 38vh;
}
@media (min-width: 900px) {
  .story-beat-bg img {
    left: auto; right: 2vw; top: calc(var(--nav) + 2.5vh);
    width: 54%; height: calc(100vh - var(--nav) - 5vh);
  }
}
.story-beat-bg img[hidden] { display: none; }

/* Darkens the photo so the text stays readable. */
.story-beat::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(0deg, rgba(28,31,36,.95) 0%, rgba(28,31,36,.85) 42%, rgba(28,31,36,0) 62%);
  opacity: var(--copy, 1);
}

.story-beat-copy {
  width: min(var(--maxw), 100% - var(--gutter) * 2);
  margin-inline: auto;
  padding: 92px 0 clamp(20px, 6vh, 64px);
  max-height: 100vh; box-sizing: border-box;
  opacity: var(--copy, 1);
  transform: translateY(calc((1 - var(--copy, 1)) * 28px));
}

.story-caption {
  display: inline-block;
  font: 700 .8rem/1 var(--display); letter-spacing: .18em; text-transform: uppercase;
  color: var(--accent-2); margin-bottom: clamp(8px, 2vh, 18px);
}

/* Stacked uppercase headline. Each word lights up as the beat arrives. */
.story-beat-copy h2 {
  font-size: clamp(1.7rem, min(7.2vw, 9.5vh), 5.8rem);
  font-weight: 700; line-height: .95; text-transform: uppercase;
  margin-bottom: .4em;
}
.story-word {
  color: rgba(242, 242, 243, .18);
  transition: color .35s var(--ease);
}
.story-word.is-lit { color: var(--ink); }

.story-pull {
  font: 500 clamp(1.1rem, 2.2vw, 1.5rem)/1.35 var(--display);
  color: var(--ink); max-width: 34ch;
  border-left: 3px solid var(--accent);
  padding-left: 18px; margin: 0 0 clamp(12px, 3vh, 28px);
}

/* Interactive pieces */
.story-toggle { display: inline-flex; gap: 8px; padding: 6px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,.04); margin-bottom: 16px; }
.story-toggle button,
.story-choice button {
  font: 700 .95rem/1 var(--display); color: var(--muted); background: transparent;
  border: 0; border-radius: 999px; padding: 12px 18px; cursor: pointer;
  transition: background .3s var(--ease), color .3s var(--ease);
}
.story-toggle button[aria-pressed="true"],
.story-choice button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.story-reply { min-height: 3.4em; font-size: 1.05rem; color: var(--ink); max-width: 56ch; }

.story-choice { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.story-choice button { border: 1px solid var(--line); }

.story-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 18px; max-width: 760px; }
.story-tool {
  text-align: left; cursor: pointer; border-radius: var(--radius);
  border: 1px solid var(--line); background: rgba(28,31,36,.6); backdrop-filter: blur(8px);
  padding: 16px; color: var(--ink); font: 700 1rem/1.2 var(--display);
}
.story-tool small { display: block; margin-top: 8px; font: 400 .9rem/1.45 var(--body); color: var(--muted); }
.story-tool[aria-expanded="false"] small { display: none; }
.story-tool:hover { border-color: var(--accent); }

.story-end { display: grid; gap: 16px; grid-template-columns: 1fr; margin-top: 8px; max-width: 900px; }
.story-end .panel { text-align: left; background: rgba(28,31,36,.7); backdrop-filter: blur(10px); }

/* Side dots */
.story-dots { display: none; }

@media (min-width: 900px) {
  .story-end { grid-template-columns: 1fr 1fr; }
  .story-dots {
    position: absolute; right: 22px; top: 50%; z-index: 10;
    display: flex; flex-direction: column; gap: 10px;
    transform: translateY(-50%);
  }
  .story-dots button {
    width: 10px; height: 10px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
    background: rgba(255,255,255,.25);
  }
  .story-dots button[aria-current="true"] { background: var(--accent); }
}

/* Wide screens: text on the left, the whole photo on the right. */
@media (min-width: 900px) {
  .story-beat::before { background: linear-gradient(90deg, rgba(28,31,36,.7) 0%, rgba(28,31,36,.45) 38%, rgba(28,31,36,0) 50%); }
  .story-beat { align-items: center; }
  .story-beat-copy {
    width: auto; flex: 1 1 auto; min-width: 0;
    margin-left: clamp(16px, calc(20vw - 220px), 200px); margin-right: 59vw;
    padding-top: calc(76px + 2.5vh); padding-bottom: 2.5vh;
  }
  .story-beat-copy h2 { font-size: clamp(1.7rem, min(4.2vw, 9.5vh), 4.2rem); }
  .story-tools { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .story-end { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)) !important; }
}

/* Narrow screens (phones, small tablets): no pinning. Each step stacks in normal flow,
   photo on top and its full text underneath, so nothing is cut off by the screen edge
   or the phone's browser bar. */
@media (max-width: 899px) {
  .story { height: auto; }
  .story-stage { position: relative; height: auto; overflow: visible; }
  .story-progress, .story-dots { display: none; }
  .story-beat, .js .story-beat {
    position: relative; inset: auto; display: block;
    visibility: visible !important; z-index: auto !important;
  }
  .story-beat + .story-beat { border-top: 1px solid var(--line); }
  .story-beat-bg { clip-path: none; }
  .story-beat-bg img { top: 20px; height: 34vh; height: 34svh; }
  .story-beat::before {
    opacity: 1;
    background: linear-gradient(180deg, rgba(28,31,36,0) 0, rgba(28,31,36,0) calc(34vh + 20px), rgba(28,31,36,.92) calc(34vh + 60px));
  }
  .story-beat-copy {
    max-height: none; opacity: 1; transform: none;
    padding: calc(34vh + 44px) 0 48px;
    padding-top: calc(34svh + 44px);
  }
  .story-word { color: var(--ink); }
}

/* Short windows: tighten everything so a whole step fits under the nav bar. */
@media (min-width: 900px) and (max-height: 760px) {
  .story-pull { font-size: 1rem; }
  .story-reply { min-height: 0; font-size: .95rem; margin-bottom: 0; }
  .story-toggle { margin-bottom: 10px; }
  .story-toggle button, .story-choice button { padding: 9px 14px; font-size: .88rem; }
  .story-tools { margin-top: 0; gap: 8px; }
  .story-tool { padding: 11px 14px; font-size: .92rem; }
  .story-end { margin-top: 0; gap: 10px; }
  .story-end .panel { padding: 14px 18px; border-radius: 16px; }
  .story-end .panel h4 { margin-bottom: 2px; }
  .story-end .panel p { font-size: .88rem; margin-bottom: 0; }
  .story-end .btn-row { margin-top: 10px; gap: 8px; }
  .story-end .btn { --pad: 10px 16px; font-size: .88rem; }
}
@media (min-width: 900px) and (max-height: 560px) {
  .story-end .panel p { display: none; }
  .story-beat:last-child .story-pull { display: none; }
}

/* Reduced motion: no pinning, no wipes. Beats stack in normal flow. */
@media (prefers-reduced-motion: reduce) {
  .story { height: auto; }
  .story-stage { position: relative; height: auto; }
  .story-progress, .story-dots { display: none; }
  .story-beat { position: relative; min-height: 90vh; visibility: visible !important; }
  .story-beat-bg { clip-path: none; }
  .story-beat-copy { max-height: none; }
  .story-beat::before { opacity: 1; }
  .story-beat-copy { opacity: 1; transform: none; }
  .story-word { color: var(--ink); }
  .story-tool, .story-toggle button, .story-choice button { transition: none; }
}
