:root {
  --writing-route-height: 48px;
}

/* Scroll-directed chapter architecture for the writing index. */
.story-chapter {
  --chapter-progress: 0;
  --step-progress: 0;
  --chapter-accent: 241, 213, 143;
  --chapter-secondary: 111, 234, 255;
  position: relative;
  min-height: 420svh;
  border-bottom: 1px solid var(--editorial-rule);
  background: #020202;
  isolation: isolate;
  scroll-margin-top: var(--writing-route-height);
}

.story-chapter__sticky {
  position: sticky;
  top: var(--writing-route-height);
  height: calc(100svh - var(--writing-route-height));
  min-height: 580px;
  overflow: hidden;
  background:
    radial-gradient(circle at calc(64% + (var(--chapter-progress) * 10%)) 44%, rgba(var(--chapter-accent), 0.17), transparent 28rem),
    radial-gradient(circle at 84% 78%, rgba(var(--chapter-secondary), 0.07), transparent 25rem),
    linear-gradient(125deg, #030303 0%, #080704 48%, #020202 100%);
}

.story-chapter__sticky::before,
.story-chapter__sticky::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.story-chapter__sticky::before {
  inset: 8% 4% 8% 52%;
  border: 1px solid rgba(var(--chapter-accent), 0.19);
  clip-path: polygon(8% 0, 100% 10%, 90% 100%, 0 86%);
  transform: translate3d(0, calc((var(--chapter-progress) - 0.5) * -5rem), 0) rotate(calc(-7deg + (var(--chapter-progress) * 5deg)));
  opacity: 0.75;
}

.story-chapter__sticky::after {
  inset: 18% 8% 12% 68%;
  border: 1px solid rgba(var(--chapter-secondary), 0.14);
  transform: translate3d(0, calc((var(--chapter-progress) - 0.5) * 7rem), 0) rotate(calc(9deg - (var(--chapter-progress) * 6deg)));
  opacity: 0.72;
}

.story-chapter__stage {
  position: relative;
  z-index: 2;
  width: min(100%, 1760px);
  height: 100%;
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(420px, 1.28fr);
  align-items: stretch;
  gap: clamp(64px, 9vw, 154px);
  padding: clamp(42px, 7vw, 100px) clamp(22px, 5vw, 82px);
}

.story-chapter__identity {
  position: relative;
  z-index: 4;
  display: grid;
  align-content: center;
  min-width: 0;
  max-width: 38rem;
}

.story-chapter__number {
  margin: 0 0 26px;
  color: rgba(var(--chapter-accent), 0.34);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(5rem, 13vw, 12rem);
  line-height: 0.68;
  transform: translateY(calc((var(--chapter-progress) - 0.5) * -1.8rem));
}

.story-chapter__kicker {
  margin: 0 0 18px;
  color: rgba(var(--chapter-accent), 0.95);
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.19em;
  text-transform: uppercase;
}

.story-chapter__identity h2 {
  max-width: 8ch;
  margin: 0;
  color: var(--editorial-paper);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.5rem, 8vw, 8.8rem);
  font-weight: 400;
  letter-spacing: -0.055em;
  line-height: 0.78;
  text-wrap: balance;
}

.story-chapter__deck {
  max-width: 42ch;
  margin: 30px 0 0;
  color: rgba(236, 230, 218, 0.72);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.35vw, 1.25rem);
  line-height: 1.62;
}

.story-chapter__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 20px;
  margin-top: 28px;
  color: rgba(236, 230, 218, 0.44);
  font-size: 0.61rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.story-chapter__link {
  width: fit-content;
  margin-top: 34px;
  color: var(--editorial-gold-bright);
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-decoration-color: rgba(var(--chapter-secondary), 0.55);
  text-underline-offset: 7px;
  text-transform: uppercase;
}

.story-chapter__visual {
  position: relative;
  min-width: 0;
  overflow: hidden;
}

.story-scene {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: end;
  padding: clamp(32px, 5vw, 72px);
  opacity: 0;
  transform: translate3d(0, 7%, 0) scale(0.965);
  transition: opacity 420ms ease, transform 650ms cubic-bezier(.2,.75,.2,1);
  pointer-events: none;
}

.story-scene.is-active {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  pointer-events: auto;
}

.story-scene__word {
  position: absolute;
  right: -0.055em;
  bottom: -0.12em;
  margin: 0;
  color: rgba(var(--chapter-accent), 0.13);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(8rem, 24vw, 25rem);
  font-weight: 400;
  letter-spacing: -0.085em;
  line-height: 0.68;
  white-space: nowrap;
  transform: translateX(calc((0.5 - var(--step-progress)) * 4rem));
}

.story-scene__copy {
  position: relative;
  z-index: 2;
  width: min(100%, 560px);
  padding: clamp(24px, 4vw, 46px);
  border-left: 1px solid rgba(var(--chapter-accent), 0.46);
  background: linear-gradient(90deg, rgba(2,2,2,0.9), rgba(2,2,2,0.26));
  backdrop-filter: blur(8px);
}

.story-scene__copy span {
  display: block;
  margin-bottom: 13px;
  color: rgba(var(--chapter-accent), 0.92);
  font-size: 0.61rem;
  font-weight: 750;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.story-scene__copy strong {
  display: block;
  color: var(--editorial-paper);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 4vw, 4.4rem);
  font-weight: 400;
  line-height: 0.95;
  text-wrap: balance;
}

.story-scene__copy p {
  max-width: 42ch;
  margin: 18px 0 0;
  color: rgba(236, 230, 218, 0.68);
  line-height: 1.58;
}

.story-chapter__step-meter {
  position: absolute;
  right: clamp(18px, 3vw, 44px);
  top: 50%;
  z-index: 8;
  display: grid;
  gap: 11px;
  transform: translateY(-50%);
}

.story-chapter__step-meter span {
  width: 34px;
  height: 2px;
  display: block;
  background: rgba(236, 230, 218, 0.18);
  transition: width 220ms ease, background-color 220ms ease, box-shadow 220ms ease;
}

.story-chapter__step-meter span.is-active {
  width: 56px;
  background: rgba(var(--chapter-accent), 0.95);
  box-shadow: 0 0 16px rgba(var(--chapter-accent), 0.35);
}

.story-chapter__steps {
  position: relative;
  z-index: 1;
}

.story-step {
  height: 100svh;
  min-height: 640px;
  pointer-events: none;
}

.story-step:first-child {
  height: 82svh;
}

.story-step:last-child {
  height: 118svh;
}

.story-chapter--signal {
  --chapter-accent: 111, 234, 255;
  --chapter-secondary: 241, 213, 143;
}

.story-chapter--signal .story-chapter__sticky {
  background:
    radial-gradient(circle at calc(68% - (var(--chapter-progress) * 9%)) 38%, rgba(var(--chapter-accent), 0.14), transparent 27rem),
    radial-gradient(circle at 78% 74%, rgba(var(--chapter-secondary), 0.09), transparent 25rem),
    linear-gradient(132deg, #020304, #05090a 52%, #020202);
}

@media (max-width: 900px) {
  .story-chapter__stage {
    grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.2fr);
    gap: 28px;
  }

  .story-chapter__identity h2 {
    font-size: clamp(3.6rem, 10vw, 6.8rem);
  }

  .story-scene__word {
    font-size: clamp(8rem, 26vw, 16rem);
  }
}

@media (max-width: 720px) {
  :root {
    --writing-route-height: 48px;
  }

  .story-chapter {
    min-height: auto;
    padding-block: 72px;
  }

  .story-chapter__sticky {
    position: relative;
    top: auto;
    height: auto;
    min-height: 0;
    overflow: visible;
    background: transparent;
  }

  .story-chapter__sticky::before,
  .story-chapter__sticky::after,
  .story-chapter__step-meter,
  .story-chapter__steps {
    display: none;
  }

  .story-chapter__stage {
    height: auto;
    grid-template-columns: 1fr;
    gap: 44px;
    padding: 0 clamp(20px, 6vw, 34px);
  }

  .story-chapter__number {
    transform: none;
  }

  .story-chapter__visual {
    display: grid;
    gap: 16px;
    overflow: visible;
  }

  .story-scene {
    position: relative;
    inset: auto;
    min-height: 300px;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    border: 1px solid rgba(var(--chapter-accent), 0.15);
    background:
      radial-gradient(circle at 72% 24%, rgba(var(--chapter-accent), 0.11), transparent 14rem),
      #050505;
  }

  .story-scene__word {
    font-size: clamp(5.5rem, 28vw, 10rem);
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-scene,
  .story-chapter__step-meter span {
    transition: none;
  }

  .story-chapter__sticky::before,
  .story-chapter__sticky::after,
  .story-chapter__number,
  .story-scene__word {
    transform: none;
  }
}
