/* =========================================================================
   My Story
   ------------------------------------------------------------------------
   Vertical timeline; each year is a chapter with a huge outlined numeral, a
   photo (or short stack of photos), and prose. On desktop the chapters
   alternate left/right around a thin yellow rail that acts as a literal
   timeline spine; on mobile the rail slides to the left margin and every
   chapter stacks in a single column.
   ========================================================================= */

.story-main {
  background: var(--ink);
  color: var(--cream);
  overflow: hidden; /* year numerals overshoot horizontally by design */
}

/* -----------------------------------------------------------------------
   Opener
   ----------------------------------------------------------------------- */
.story-opener {
  padding-block: clamp(6rem, 12vh, 10rem) clamp(3rem, 6vh, 5rem);
  border-bottom: 1px solid rgba(240, 233, 214, 0.08);
}
.story-opener-inner {
  max-width: 960px;
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 3rem);
}
.story-eyebrow {
  font-family: var(--sans);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--yellow);
  margin: 0 0 var(--space-5);
}
.story-title {
  font-family: var(--display);
  font-weight: 800;
  line-height: 0.86;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-6);
  font-size: clamp(3rem, 9vw, 8rem);
  text-transform: uppercase;
}
.story-title-line { display: block; }
.story-title-outline {
  color: transparent;
  -webkit-text-stroke: 1.4px var(--cream);
  font-weight: 500;
}
.story-title-solid {
  color: var(--cream);
  font-weight: 800;
  text-shadow: 0.06em 0.06em 0 var(--yellow);
}
.story-lede {
  font-family: var(--slab);
  font-size: clamp(1.125rem, 0.9rem + 0.7vw, 1.375rem);
  line-height: 1.5;
  color: var(--cream-dim);
  max-width: 40em;
  margin: 0;
}

/* -----------------------------------------------------------------------
   Timeline layout
   -----------------------------------------------------------------------
   Desktop grid: 1fr | rail | 1fr. Each chapter chooses which columns to
   occupy based on data-side. On narrower screens we collapse to a single
   column and the rail becomes a left-margin bar.
   ----------------------------------------------------------------------- */
.timeline {
  position: relative;
  padding-block: clamp(4rem, 8vh, 6rem) clamp(6rem, 12vh, 10rem);
}
.timeline-shell {
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 3rem);
  position: relative;
}
/* Yellow spine. Absolute so chapters can overlap its ends without pushing
   it. On browsers that support scroll-driven animations, the fill grows
   as the reader scrolls, so the timeline literally draws itself. */
.timeline-rail {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  background: rgba(240, 233, 214, 0.08);
  pointer-events: none;
  overflow: hidden;
}
.timeline-rail::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 0,
    var(--yellow) 4%,
    var(--yellow) 96%,
    transparent 100%
  );
  transform-origin: top;
  transform: scaleY(0);
}
@supports (animation-timeline: scroll()) {
  .timeline-rail::before {
    animation: rail-fill linear both;
    animation-timeline: scroll(nearest);
    animation-range: 0 100%;
  }
}
@keyframes rail-fill { to { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) {
  .timeline-rail::before { transform: scaleY(1); animation: none; }
}

/* -----------------------------------------------------------------------
   Chapter
   ------------------------------------------------------------------------
   Two columns: one holds the photo(s) + copy stacked together, the other
   holds the giant year numeral as an editorial header. This keeps the
   year fully readable while still overlapping/tucking behind the photo
   at the seam. `align-items: start` prevents the copy column from being
   stretched to fill blank vertical space next to a tall photo, which was
   the source of the "arbitrary blank areas" complaint.
   ----------------------------------------------------------------------- */
.chapter {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: clamp(3rem, 6vw, 6rem);
  row-gap: var(--space-6);
  padding-block: clamp(3.5rem, 6vw, 5.5rem);
  align-items: start;
}
.chapter + .chapter { border-top: 1px solid rgba(240, 233, 214, 0.06); }

/* Rail dot — anchored near the top of each chapter (aligned with the year
   numeral) so the eye tracks a rhythm as it scrolls, not a floating midpoint. */
.chapter::before {
  content: "";
  position: absolute;
  top: clamp(3.5rem, 6vw, 5.5rem);
  left: 50%;
  width: 12px; height: 12px;
  transform: translate(-50%, 0) scale(0.4);
  border-radius: 999px;
  background: var(--yellow);
  box-shadow: 0 0 0 4px var(--ink), 0 0 24px rgba(255, 209, 0, 0);
  z-index: 4;
  opacity: 0.4;
  transition:
    transform 0.7s cubic-bezier(.2,.6,.2,1),
    opacity 0.5s cubic-bezier(.2,.6,.2,1),
    box-shadow 0.7s cubic-bezier(.2,.6,.2,1);
}
.chapter.is-visible::before {
  transform: translate(-50%, 0) scale(1);
  opacity: 1;
  box-shadow: 0 0 0 4px var(--ink), 0 0 24px rgba(255, 209, 0, 0.55);
}

/* Year numeral: lives inside its own grid column as an editorial header,
   NOT absolutely positioned. Sits at the top of the empty column opposite
   the photo. This makes it a legible design element, not a hidden Easter
   egg. It's still oversized and outlined for cinematic scale, and hangs
   slightly toward the rail so photo and numeral kiss at the seam. */
.chapter-year {
  font-family: var(--display);
  font-weight: 500;
  line-height: 0.82;
  font-size: clamp(5rem, 11vw, 10.5rem);
  letter-spacing: -0.02em;
  color: transparent;
  -webkit-text-stroke: 1.25px rgba(240, 233, 214, 0.55);
  user-select: none;
  pointer-events: none;
  z-index: 2;
  white-space: nowrap;
  margin: 0;
  will-change: transform, opacity, letter-spacing;
  align-self: start;
  /* Nudge toward the rail so the photo & year kiss visually without
     the year being swallowed. */
}

/* Layout per side.
   Row 1: photo in one column, year numeral in the opposite column.
   Row 2: copy spans BOTH columns so there’s no dead vertical band.
   Copy is offset (indent from the photo side) so it reads as a caption
   that flows out from under the year toward the photo. */
.chapter[data-side="left"]  .chapter-media { grid-column: 1; grid-row: 1; }
.chapter[data-side="left"]  .chapter-year  { grid-column: 2; grid-row: 1; justify-self: start; margin-left: -0.18em; }
.chapter[data-side="left"]  .chapter-copy  { grid-column: 1 / -1; grid-row: 2; padding-left: clamp(0px, 3vw, 3rem); }
.chapter[data-side="right"] .chapter-media { grid-column: 2; grid-row: 1; }
.chapter[data-side="right"] .chapter-year  { grid-column: 1; grid-row: 1; justify-self: end;   margin-right: -0.18em; text-align: right; }
.chapter[data-side="right"] .chapter-copy  { grid-column: 1 / -1; grid-row: 2; padding-right: clamp(0px, 3vw, 3rem); display: flex; justify-content: flex-end; flex-direction: column; align-items: flex-end; }
.chapter[data-side="right"] .chapter-copy p { text-align: left; }

/* Media */
.chapter-media {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  position: relative;
  z-index: 3; /* over the year numeral */
}
.chapter-media-stack {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  grid-template-rows: auto auto;
  gap: var(--space-4);
}
.chapter-media-stack .story-photo-lead {
  grid-column: 1 / -1;
}

/* Photo frame — warm cream mat + a hair of yellow underline so images
   feel documentary rather than dropped-in. */
.story-photo {
  position: relative;
  margin: 0;
  background: #f5eeda;
  padding: 10px 10px 12px;
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.6),
    0 20px 40px -20px rgba(0, 0, 0, 0.9);
  transform: rotate(-0.4deg);
  overflow: hidden; /* clip the Ken Burns scale to the mat */
}
.chapter[data-side="right"] .story-photo { transform: rotate(0.4deg); }
.story-photo img {
  display: block;
  width: 100%;
  height: auto;
  filter: contrast(1.02) saturate(0.98);
}
.story-photo::after {
  /* subtle grain overlay unifies with page grain */
  content: "";
  position: absolute;
  inset: 10px 10px 12px;
  pointer-events: none;
  background:
    radial-gradient(1200px 400px at 50% 100%, rgba(0, 0, 0, 0.15), transparent 60%);
  mix-blend-mode: multiply;
}
.story-photo figcaption {
  font-family: var(--sans);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: rgba(10, 10, 10, 0.7);
  padding-top: 8px;
  text-align: left;
}

/* The Gazette clipping is precious; give it a touch more presence. */
.story-photo-gazette {
  padding: 14px 14px 14px;
}

.story-photo-lead img { max-height: 640px; object-fit: cover; }
/* Small stack photos keep native aspect so nothing gets awkwardly padded. */

/* Copy */
.chapter-copy {
  position: relative;
  z-index: 3;
}
.chapter-copy p {
  font-family: var(--slab);
  font-size: clamp(1.0625rem, 0.95rem + 0.4vw, 1.25rem);
  line-height: 1.6;
  color: var(--cream);
  max-width: 34em;
}
.chapter-copy p + p { margin-top: var(--space-4); }
/* Copy stays in its column now; no need for a right-align hack. */

/* Pull quote — used sparingly (e.g. grandfather remembrance). */
.story-pull {
  font-family: var(--slab) !important;
  font-style: italic;
  font-size: clamp(1.25rem, 1rem + 0.9vw, 1.625rem) !important;
  line-height: 1.4 !important;
  color: var(--yellow-soft) !important;
  border-left: 2px solid var(--yellow);
  padding-left: var(--space-5);
  margin-top: var(--space-5) !important;
}

/* Final chapter — hold the reader for a beat before the closing block. */
.chapter-final {
  padding-bottom: clamp(6rem, 10vw, 9rem);
}

/* -----------------------------------------------------------------------
   Closing
   ----------------------------------------------------------------------- */
.story-closing {
  border-top: 1px solid rgba(240, 233, 214, 0.08);
  padding-block: clamp(5rem, 10vh, 8rem);
  text-align: center;
}
.story-closing-inner {
  max-width: 720px;
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 3rem);
}
.story-closing-line {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3.75rem);
  line-height: 1;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  color: var(--cream);
  margin: 0 0 var(--space-7);
}
.story-closing-actions {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  flex-wrap: wrap;
}

/* -----------------------------------------------------------------------
   Scroll-reveal states — cinematic entrances.
   ------------------------------------------------------------------------
   Each photo does a clip-path curtain sweep (mask-in) plus a slow Ken
   Burns scale on the image itself for a documentary-film feel. The year
   numeral scales down slightly and tightens its letter-spacing on entry
   — it swells to full size like a title card. Copy fades in a beat later.
   All transforms are on inner elements or clip-paths (not the reserved
   container box) so there’s no CLS.
   ----------------------------------------------------------------------- */
.chapter { opacity: 1; }

/* Photos: reserve their box; the visual reveal is a clip-path curtain. */
.chapter .story-photo {
  clip-path: inset(0 100% 0 0);
  transition: clip-path 1.05s cubic-bezier(.2,.6,.2,1);
}
.chapter[data-side="right"] .story-photo {
  clip-path: inset(0 0 0 100%);
}
.chapter .story-photo img {
  transform: scale(1.08);
  transition: transform 2.4s cubic-bezier(.2,.55,.2,1);
}
.chapter.is-visible .story-photo { clip-path: inset(0 0 0 0); }
.chapter.is-visible .story-photo img { transform: scale(1); }

/* Stagger the stacked photos so they fan open in sequence. */
.chapter .chapter-media-stack .story-photo-small:nth-of-type(2) { transition-delay: 0.18s; }
.chapter .chapter-media-stack .story-photo-small:nth-of-type(3) { transition-delay: 0.34s; }
.chapter .chapter-media-stack .story-photo-small:nth-of-type(2) img { transition-delay: 0.18s; }
.chapter .chapter-media-stack .story-photo-small:nth-of-type(3) img { transition-delay: 0.34s; }

/* Year numeral: scales up from 0.86 and swells letter-spacing tight to
   normal. Reads like a title-card animation on a documentary. The
   `--year-parallax` CSS var is set by story.js on scroll so the numeral
   drifts slightly relative to the photo. */
.chapter .chapter-year {
  --year-parallax: 0px;
  opacity: 0;
  transform: translateY(var(--year-parallax)) scale(0.86);
  letter-spacing: 0.02em;
  transition:
    opacity 0.9s cubic-bezier(.2,.6,.2,1),
    transform 1.1s cubic-bezier(.2,.6,.2,1),
    letter-spacing 1.1s cubic-bezier(.2,.6,.2,1);
}
.chapter[data-side="left"]  .chapter-year { transform-origin: left top; }
.chapter[data-side="right"] .chapter-year { transform-origin: right top; }
.chapter.is-visible .chapter-year {
  opacity: 1;
  transform: translateY(var(--year-parallax)) scale(1);
  letter-spacing: -0.02em;
}
/* Once the entrance animation has run, remove the transition on transform
   so the parallax scroll updates aren’t rate-limited by a 1.1s transition. */
.chapter.is-visible .chapter-year {
  transition:
    opacity 0.9s cubic-bezier(.2,.6,.2,1),
    letter-spacing 1.1s cubic-bezier(.2,.6,.2,1);
}

/* Copy: paragraph-level fade-in with a slight staggered delay. */
.chapter .chapter-copy p {
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 0.8s cubic-bezier(.2,.6,.2,1) 0.25s,
    transform 0.8s cubic-bezier(.2,.6,.2,1) 0.25s;
}
.chapter.is-visible .chapter-copy p { opacity: 1; transform: translateY(0); }
.chapter.is-visible .chapter-copy p + p { transition-delay: 0.4s; }
.chapter.is-visible .chapter-copy p + p + p { transition-delay: 0.55s; }

/* Respect reduced motion. */
@media (prefers-reduced-motion: reduce) {
  .chapter .story-photo,
  .chapter .story-photo img,
  .chapter .chapter-copy p,
  .chapter .chapter-year {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
    letter-spacing: -0.02em !important;
    transition: none !important;
  }
}

/* -----------------------------------------------------------------------
   Responsive: collapse to a single column with a left-edge rail.
   ----------------------------------------------------------------------- */
@media (max-width: 900px) {
  .timeline-rail {
    left: clamp(1rem, 5vw, 2rem);
    transform: none;
    background: linear-gradient(
      to bottom,
      transparent 0,
      rgba(255, 209, 0, 0.5) 4%,
      rgba(255, 209, 0, 0.5) 96%,
      transparent 100%
    );
  }
  .chapter {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    padding-inline-start: clamp(2.5rem, 8vw, 4rem);
    padding-block: clamp(3rem, 7vw, 4.5rem);
    column-gap: 0;
    row-gap: var(--space-5);
  }
  .chapter::before {
    top: clamp(3rem, 7vw, 4.5rem);
    left: clamp(1rem, 5vw, 2rem);
    transform: translate(-50%, 0) scale(0.4);
  }
  .chapter.is-visible::before { transform: translate(-50%, 0) scale(1); }
  /* Everything stacks: year (header), media (photo/photo-stack), copy. */
  .chapter[data-side="left"]  .chapter-year,
  .chapter[data-side="right"] .chapter-year {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    margin: 0 0 var(--space-2) 0;
    text-align: left;
    font-size: clamp(4.5rem, 18vw, 8rem);
    -webkit-text-stroke: 1px rgba(240, 233, 214, 0.55);
  }
  .chapter[data-side="left"]  .chapter-media,
  .chapter[data-side="right"] .chapter-media {
    grid-column: 1; grid-row: 2;
  }
  .chapter[data-side="left"]  .chapter-copy,
  .chapter[data-side="right"] .chapter-copy {
    grid-column: 1; grid-row: 3;
  }
  .chapter[data-side="right"] .story-photo { transform: rotate(-0.4deg); }
  .chapter-media-stack { grid-template-columns: 1fr 1fr; }
  .chapter-media-stack .story-photo-lead { grid-column: 1 / -1; }
  /* On mobile the photo curtain sweeps the same direction on every
     chapter — left to right — since there’s no alternating layout. */
  .chapter[data-side="right"] .story-photo { clip-path: inset(0 100% 0 0); }
  .chapter.is-visible[data-side="right"] .story-photo { clip-path: inset(0 0 0 0); }
}

@media (max-width: 520px) {
  .chapter-media-stack {
    grid-template-columns: 1fr;
  }
  .chapter-media-stack .story-photo-lead { grid-column: 1; }
}

/* Narrow-width topbar polish. The shared mobile hamburger + overlay in
   styles.css now handles navigation, so we no longer force .nav to stay
   visible here — that would double up with the hamburger. */
@media (max-width: 780px) {
  .page-story .topbar .brand-district { display: none; }
}
