:root {
  --writing-route-height: 58px;
  --writing-sticky-offset: calc(var(--navigation-header-size, 72px) + var(--writing-route-height));
}

/* The artwork is sampled by editorial.js. Source images never become rectangular cards. */
body[data-surface="writing"] .writing-route {
  top: var(--navigation-header-size, 72px);
}

body[data-surface="writing"] > .site-header.site-header--continuous {
  position: sticky;
  top: 0;
  z-index: 80;
}

body[data-surface="writing"] .editorial-canvas {
  --writing-particle-opacity: 0.88;
  opacity: var(--writing-particle-opacity);
  filter: saturate(1.2) brightness(1.25);
}

body[data-surface="writing"].particle-transitioning .editorial-canvas,
body[data-surface="writing"].particle-chapter-pulse .editorial-canvas {
  opacity: var(--writing-particle-opacity);
  filter: saturate(1.2) brightness(1.25);
  transform: scale(1);
  animation: none;
  transition: filter 240ms ease, opacity 180ms linear;
}

@media (max-width: 700px) {
  body[data-surface="writing"] .editorial-canvas {
    --writing-particle-opacity: calc(var(--page-mobile-particle-opacity, 0.76) + 0.06);
    filter: saturate(1.36) brightness(1.4) contrast(1.12);
  }
}

html.save-data body[data-surface="writing"] .editorial-canvas {
  --writing-particle-opacity: 0.46;
}

body[data-surface="writing"].particle-transitioning .editorial-grain::after {
  opacity: 0.16;
  filter: none;
}

body[data-surface="writing"] .story-chapter {
  scroll-margin-top: var(--writing-sticky-offset);
  background: transparent;
}

body[data-surface="writing"] .story-chapter__sticky {
  top: var(--writing-sticky-offset);
  height: calc(100svh - var(--writing-sticky-offset));
  background:
    radial-gradient(ellipse at 72% 47%, rgba(var(--chapter-accent), 0.075), transparent 38%),
    linear-gradient(105deg, rgba(2, 2, 2, 0.94) 0 32%, rgba(2, 2, 2, 0.54) 55%, rgba(2, 2, 2, 0.2) 100%);
}

body[data-surface="writing"] .story-chapter__stage {
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

body[data-surface="writing"] .story-chapter__identity h2 {
  max-width: 11ch;
  font-size: clamp(3rem, 6vw, 6.4rem);
  line-height: 0.84;
}

body[data-surface="writing"] .story-chapter__number {
  margin-bottom: 18px;
  font-size: clamp(4rem, 9vw, 8rem);
}

body[data-surface="writing"] .story-chapter--signal .story-chapter__sticky {
  background:
    radial-gradient(ellipse at 70% 45%, rgba(var(--chapter-accent), 0.07), transparent 38%),
    linear-gradient(105deg, rgba(2, 3, 4, 0.94) 0 32%, rgba(2, 3, 4, 0.54) 55%, rgba(2, 3, 4, 0.2) 100%);
}

body[data-surface="writing"] .story-chapter__sticky::before,
body[data-surface="writing"] .story-chapter__sticky::after {
  border: 0;
  filter: blur(1px);
  background: radial-gradient(ellipse, rgba(var(--chapter-accent), 0.09), transparent 68%);
  clip-path: polygon(8% 8%, 72% 0, 100% 31%, 88% 82%, 52% 100%, 7% 79%, 0 35%);
}

body[data-surface="writing"] .story-scene__media {
  display: none !important;
}

body[data-surface="writing"] .story-scene {
  background: transparent;
  border: 0;
}

body[data-surface="writing"] .story-scene__copy {
  width: min(100%, 620px);
  padding: clamp(24px, 3.2vw, 42px) clamp(20px, 3vw, 38px);
  border: 0;
  background:
    linear-gradient(90deg, rgba(var(--chapter-accent), 0.62), rgba(var(--chapter-accent), 0)) left top / 72% 1px no-repeat,
    radial-gradient(ellipse at 12% 50%, rgba(2, 2, 2, 0.88), rgba(2, 2, 2, 0.54) 53%, transparent 82%);
  backdrop-filter: none;
}

body[data-surface="writing"] .story-scene__copy p {
  max-width: 54ch;
  margin-top: 0;
  color: rgba(244, 238, 224, 0.88);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.2vw, 1.17rem);
  line-height: 1.62;
  text-wrap: pretty;
}

body[data-surface="writing"] .story-scene__copy span + p {
  margin-top: 14px;
}

body[data-surface="writing"] .story-scene__word {
  color: rgba(var(--chapter-accent), 0.075);
  mix-blend-mode: screen;
}

@media (max-width: 900px) {
  body[data-surface="writing"] .story-chapter__identity h2 {
    max-width: 11ch;
    font-size: clamp(2.7rem, 7vw, 5.4rem);
    line-height: 0.9;
  }
}

@media (max-width: 720px) {
  :root {
    --writing-sticky-offset: calc(var(--navigation-header-size, 64px) + var(--writing-route-height));
  }

  body[data-surface="writing"] .writing-route-inner {
    min-height: var(--writing-route-height);
    padding-inline: 6px;
  }

  body[data-surface="writing"] .writing-route a {
    padding-inline: 12px;
    font-size: 0.57rem;
  }

  body[data-surface="writing"] .story-chapter {
    min-height: 0;
    padding-block: 0;
  }

  body[data-surface="writing"] .story-chapter__sticky {
    position: sticky;
    top: var(--writing-sticky-offset);
    height: calc(100svh - var(--writing-sticky-offset));
    min-height: 0;
    overflow: hidden;
    background:
      radial-gradient(ellipse at 52% 45%, rgba(var(--chapter-accent), 0.065), transparent 44%),
      linear-gradient(180deg, rgba(2, 2, 2, 0.93) 0 19%, rgba(2, 2, 2, 0.28) 43%, rgba(2, 2, 2, 0.9) 84% 100%);
  }

  body[data-surface="writing"] .story-chapter__sticky::before,
  body[data-surface="writing"] .story-chapter__sticky::after {
    display: block;
    inset: 20% 3% 24%;
    opacity: 0.55;
  }

  body[data-surface="writing"] .story-chapter__stage {
    height: 100%;
    display: block;
    padding: 0;
  }

  body[data-surface="writing"] .story-chapter__identity {
    position: absolute;
    inset: clamp(18px, 3.5svh, 30px) 18px auto;
    z-index: 5;
    display: block;
    max-width: none;
    pointer-events: none;
  }

  body[data-surface="writing"] .story-chapter__number,
  body[data-surface="writing"] .story-chapter__deck,
  body[data-surface="writing"] .story-chapter__meta,
  body[data-surface="writing"] .story-chapter__link {
    display: none;
  }

  body[data-surface="writing"] .story-chapter__kicker {
    margin-bottom: 9px;
    font-size: 0.55rem;
  }

  body[data-surface="writing"] .story-chapter__identity h2 {
    max-width: 12ch;
    font-size: clamp(2.35rem, 10.5vw, 3.75rem);
    line-height: 0.87;
  }

  body[data-surface="writing"] .story-chapter__visual {
    position: absolute;
    inset: 0;
    display: block;
    overflow: hidden;
  }

  body[data-surface="writing"] .story-scene {
    position: absolute;
    inset: 0;
    min-height: 0;
    display: block;
    padding: 0;
    opacity: 0;
    transform: translate3d(0, 5%, 0);
    pointer-events: none;
    background: transparent;
    border: 0;
    z-index: 1;
  }

  body[data-surface="writing"] .story-scene.is-active {
    opacity: 1;
    transform: translate3d(0, 0, 0);
    z-index: 2;
  }

  body[data-surface="writing"] .story-scene__word {
    right: -0.04em;
    bottom: 27%;
    font-size: clamp(5rem, 25vw, 8.5rem);
    transform: none;
  }

  body[data-surface="writing"] .story-scene__copy {
    position: absolute;
    inset: auto 12px 12px;
    width: auto;
    max-height: none;
    overflow: visible;
    padding: 18px 10px 16px;
    background:
      linear-gradient(90deg, rgba(var(--chapter-accent), 0.54), transparent 72%) left top / 80% 1px no-repeat,
      linear-gradient(180deg, rgba(2, 2, 2, 0.18), rgba(2, 2, 2, 0.94) 22%, rgba(2, 2, 2, 0.98));
  }

  body[data-surface="writing"] .story-scene__copy span {
    margin-bottom: 9px;
    font-size: 0.55rem;
  }

  body[data-surface="writing"] .story-scene__copy p {
    font-size: clamp(0.92rem, 3.9vw, 1.02rem);
    line-height: 1.48;
  }

  body[data-surface="writing"] .story-chapter__step-meter {
    right: 10px;
    top: 47%;
    display: grid;
    gap: 8px;
  }

  body[data-surface="writing"] .story-chapter__step-meter span {
    width: 17px;
  }

  body[data-surface="writing"] .story-chapter__step-meter span.is-active {
    width: 28px;
  }

  body[data-surface="writing"] .story-chapter__steps {
    display: block;
  }

  body[data-surface="writing"] .story-step,
  body[data-surface="writing"] .story-step:first-child,
  body[data-surface="writing"] .story-step:last-child {
    height: 92svh;
    min-height: 600px;
  }
}

body[data-surface="writing"] .story-scene,
body[data-surface="writing"] .story-scene.is-active {
  opacity: var(--scene-opacity, 0);
  transform: translate3d(0, var(--scene-translate-y, 0), 0) scale(var(--scene-scale, 1));
  transition: none;
  will-change: opacity, transform;
}

@media (max-width: 720px) and (max-height: 700px) {
  body[data-surface="writing"] .story-chapter__identity h2 {
    font-size: clamp(2rem, 9vw, 3rem);
  }

  body[data-surface="writing"] .story-scene__copy {
    max-height: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  body[data-surface="writing"] .editorial-canvas {
    --writing-particle-opacity: 0.34;
  }

  body[data-surface="writing"] .story-scene {
    transition: none;
  }
}
