/*
 * LONGDEN / SCROLL STORY
 * A warm, moody editorial layer for the source-to-cinematic transformation.
 * Load after longden-cinematic.css and longden-transformation.css.
 */

:root {
  --scroll-paper: #f1eadc;
  --scroll-paper-deep: #e7dcc8;
  --scroll-ink: #122a2b;
  --scroll-ink-soft: #385252;
  --scroll-gold: #c69a51;
  --scroll-gold-bright: #e1bd78;
  --scroll-line: rgba(18, 42, 43, .18);
  --scroll-night: #0b1e20;
  --scroll-width: 1360px;
  --reading-progress: 0;
}

/* The scroll experience is deliberately a calm, non-animated base layer. */
.transformation {
  position: relative;
  isolation: isolate;
  overflow: visible;
  background:
    radial-gradient(circle at 10% 12%, rgba(198, 154, 81, .08), transparent 30rem),
    var(--scroll-paper);
  color: var(--scroll-ink);
}

.transformation-inner {
  width: min(var(--scroll-width), calc(100% - clamp(2rem, 8vw, 9rem)));
  margin-inline: auto;
}

.transformation-heading {
  position: relative;
  z-index: 1;
}

.transformation-kicker,
.transformation .eyebrow {
  color: #8d642e;
}

.transformation h2 {
  text-wrap: balance;
}

.transformation-lede {
  color: var(--scroll-ink-soft);
}

/* Persistent chapter rail: the gold rule grows with the document's progress. */
.chapter-rail {
  position: sticky;
  z-index: 20;
  top: 0;
  overflow: hidden;
  background: rgba(11, 30, 32, .96);
  border-bottom: 1px solid rgba(225, 189, 120, .32);
  box-shadow: 0 1rem 2.5rem rgba(7, 25, 27, .12);
}

.chapter-rail::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  transform-origin: left center;
  transform: scaleX(var(--reading-progress));
  background: var(--scroll-gold-bright);
  pointer-events: none;
}

.chapter-rail a {
  position: relative;
  color: rgba(241, 234, 220, .62);
  transition: color .2s ease;
}

.chapter-rail a[aria-current="page"],
.chapter-rail a[aria-current="true"],
.chapter-rail a[aria-current="step"] {
  color: var(--scroll-gold-bright);
}

.chapter-rail a[aria-current="page"]::after,
.chapter-rail a[aria-current="true"]::after,
.chapter-rail a[aria-current="step"]::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -.82rem;
  left: 0;
  height: 1px;
  background: currentColor;
}

/* Controls sit above the two-column reading experience without competing with it. */
.experience-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  margin: 0 0 2rem;
  padding: .85rem 0;
  border-top: 1px solid var(--scroll-line);
  border-bottom: 1px solid var(--scroll-line);
  color: var(--scroll-ink-soft);
  font-size: .72rem;
  letter-spacing: .06em;
}

.experience-hint {
  max-width: 42rem;
  margin: 0;
}

.motion-toggle,
.journey-follow {
  appearance: none;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid currentColor;
  border-radius: 0;
  padding: .65rem .85rem;
  background: transparent;
  color: var(--scroll-ink);
  font: 700 .68rem/1.15 var(--sans, ui-sans-serif, sans-serif);
  letter-spacing: .11em;
  text-transform: uppercase;
  cursor: pointer;
}

.motion-toggle[aria-pressed="true"],
.journey-follow[aria-pressed="true"] {
  border-color: var(--scroll-gold);
  background: var(--scroll-ink);
  color: var(--scroll-paper);
}

.motion-toggle:hover,
.journey-follow:hover {
  border-color: var(--scroll-gold);
}

.journey-position {
  margin: 0 0 1rem;
  color: #89612f;
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.transformation-journey {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(16rem, .7fr);
  align-items: start;
  gap: clamp(2rem, 5vw, 6rem);
}

.transformation-view {
  min-width: 0;
}

.transformation-view .scene-tabs {
  position: relative;
  z-index: 2;
}

/* Keep the existing comparison controls inside the viewport while the text advances. */
.transformation-view .transformation-stage {
  width: 100%;
  max-height: 58svh;
  aspect-ratio: 3 / 2;
  min-height: 0;
  background: var(--scroll-night);
  border: 1px solid rgba(18, 42, 43, .4);
  box-shadow: 0 1.5rem 3.5rem rgba(18, 42, 43, .2), 0 0 0 5px rgba(198, 154, 81, .08);
  overflow: hidden;
}

.transformation-view .transformation-stage figure,
.transformation-view .transformation-stage img {
  min-height: 0;
}

/* Existing image behavior is intentionally preserved: both comparison images stay contain. */
.transformation-view .transformation-stage img {
  object-fit: contain;
}

.transformation-view .transformation-caption {
  color: var(--scroll-ink-soft);
}

.transformation-view .transformation-controls {
  flex-wrap: wrap;
}

.journey-beats {
  position: relative;
  min-width: 0;
}

.journey-beats::before {
  content: "";
  position: absolute;
  top: .45rem;
  bottom: .45rem;
  left: .6rem;
  width: 1px;
  background: linear-gradient(var(--scroll-gold), rgba(198, 154, 81, .08));
}

.journey-beat {
  position: relative;
  display: flex;
  min-height: 65svh;
  flex-direction: column;
  justify-content: center;
  margin: 0;
  padding: clamp(1.5rem, 3vw, 2.5rem) 1rem clamp(1.5rem, 3vw, 2.5rem) 2.5rem;
  border: 1px solid transparent;
  border-left: 1px solid rgba(198, 154, 81, .35);
  scroll-margin-top: 5.5rem;
}

.journey-beat::before {
  content: "";
  position: absolute;
  top: 2.15rem;
  left: -.34rem;
  width: .6rem;
  height: .6rem;
  border: 1px solid var(--scroll-gold);
  border-radius: 50%;
  background: var(--scroll-paper);
}

.journey-beat.is-active {
  border-color: rgba(198, 154, 81, .42);
  background: linear-gradient(90deg, rgba(198, 154, 81, .1), transparent 76%);
  box-shadow: inset 3px 0 0 var(--scroll-gold), 0 1rem 3rem rgba(18, 42, 43, .06);
}

.journey-beat.is-active::before {
  background: var(--scroll-gold);
  box-shadow: 0 0 0 4px rgba(198, 154, 81, .14);
}

.journey-number {
  display: block;
  color: #986b32;
  font: 500 clamp(2.5rem, 5vw, 4.8rem)/.8 var(--serif, Georgia, serif);
  letter-spacing: -.05em;
}

.journey-beat h3 {
  margin: 1.2rem 0 .8rem;
  color: var(--scroll-ink);
  font: 400 clamp(1.9rem, 3.2vw, 3.4rem)/.95 var(--serif, Georgia, serif);
  letter-spacing: -.035em;
  text-wrap: balance;
}

.journey-beat h3 span,
.journey-beat p span {
  display: block;
  margin-top: .55rem;
  color: #667875;
  font: 400 .43em/1.35 var(--sans, ui-sans-serif, sans-serif);
  letter-spacing: .02em;
}

.journey-beat p {
  max-width: 29rem;
  margin: 0;
  color: var(--scroll-ink-soft);
  font-size: .92rem;
  line-height: 1.75;
}

.journey-preview {
  margin: 1.4rem 0 0;
  border: 1px solid rgba(198, 154, 81, .42);
  background: var(--scroll-night);
  box-shadow: 0 .7rem 1.5rem rgba(18, 42, 43, .12);
}

.journey-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 1.6;
  object-fit: cover;
}

.journey-path {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
  color: #89612f;
  font-size: .65rem;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.journey-path li {
  display: flex;
  align-items: center;
  gap: .55rem;
}

.journey-path li:not(:last-child)::after {
  content: "→";
  color: var(--scroll-gold);
}

.journey-follow {
  display: block;
  margin: 1rem 0 0 auto;
}

/* Desktop: the stage remains a quiet anchor while the beats do the storytelling. */
@media (min-width: 1001px) {
  .transformation-view {
    position: sticky;
    top: 2rem;
    align-self: start;
  }

  .journey-preview {
    max-width: 11rem;
  }

  .journey-preview img {
    aspect-ratio: 1.6;
  }
}

/* Mobile/tablet: return to a comfortable linear reading order. */
@media (max-width: 1000px) {
  .transformation-journey {
    display: block;
  }

  .transformation-view {
    position: static;
  }

  .transformation-view .transformation-stage {
    max-height: none;
  }

  .journey-beats {
    margin-top: clamp(3rem, 9vw, 5rem);
  }

  .journey-beat {
    min-height: auto;
    padding-block: clamp(3.5rem, 10vw, 6rem);
  }

  .journey-preview {
    max-width: none;
  }
}

@media (max-width: 620px) {
  .experience-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .motion-toggle,
  .journey-follow {
    margin-left: 0;
  }

  .transformation-inner {
    width: min(100% - 2rem, var(--scroll-width));
  }

  .scene-tabs {
    scrollbar-width: thin;
  }

  .journey-path {
    flex-wrap: wrap;
    row-gap: .8rem;
  }
}

/* Explicitly keep the no-motion state still: no hidden copy, no transform side effects. */
body:not(.motion-enabled) .chapter-art,
body:not(.motion-enabled) .chapter-art img,
body:not(.motion-enabled) .hero-image img,
body:not(.motion-enabled) .finale-image img,
body:not(.motion-enabled) .transformation-stage {
  transform: none;
}

body.motion-enabled .chapter-art {
  transform: perspective(1200px) rotateY(var(--depth-rotate, 0deg)) translate3d(0, var(--depth-y, 0px), 0);
  transform-origin: center center;
  will-change: transform;
}

body.motion-enabled .chapter-art img {
  transform: none;
}

body.motion-enabled .hero-image img,
body.motion-enabled .finale-image img {
  transform: translate3d(0, var(--scene-y, 0px), 0) scale(1.04);
  will-change: transform;
}

body.motion-enabled .transformation-stage {
  transform: perspective(1200px) translateY(var(--stage-y, 0px)) rotateY(var(--stage-rotate, 0deg));
  transform-origin: center center;
  will-change: transform;
}

/* Do not transform the comparison images themselves: contain framing must stay exact. */
body.motion-enabled .transformation-stage .transformation-original img,
body.motion-enabled .transformation-stage .transformation-cinematic img {
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }

  body.motion-enabled .chapter-art,
  body.motion-enabled .chapter-art img,
  body.motion-enabled .hero-image img,
  body.motion-enabled .finale-image img,
  body.motion-enabled .transformation-stage,
  body.motion-enabled .transformation-stage img {
    transform: none !important;
    will-change: auto;
  }
}

/* Strong, dark-on-cream keyboard focus treatment. */
.transformation a:focus-visible,
.transformation button:focus-visible,
.chapter-rail a:focus-visible {
  outline: 3px solid var(--scroll-ink);
  outline-offset: 4px;
  box-shadow: 0 0 0 6px var(--scroll-paper), 0 0 0 8px var(--scroll-gold);
}

/* Final typography and layout calibration for the bilingual production copy. */
.transformation-inner{width:100%;max-width:var(--scroll-width)}
.experience-hint span{display:block;margin-top:.3rem;letter-spacing:0}
.journey-navigation{display:flex;align-items:center;justify-content:space-between;gap:1rem;margin:1.5rem 0 2rem}
.journey-navigation .journey-position,.journey-navigation .journey-follow{margin:0}
.journey-beat .journey-number{font:600 .64rem/1.65 var(--sans);letter-spacing:.1em;color:#805b2b}
.journey-beat h3 em{font-weight:400;color:#926032}
.journey-beat h3 span{font-size:1rem;line-height:1.6;color:#425d59;letter-spacing:0}
.journey-beat p span{font:400 .86rem/1.85 var(--sans);letter-spacing:0;color:#425d59}
.journey-preview img{aspect-ratio:3/2;object-fit:contain}
.journey-preview figcaption{padding:.5rem .6rem;font-size:.52rem;letter-spacing:.05em;color:var(--scroll-paper);line-height:1.6}
.journey-next{display:block;margin-top:2rem;font-size:.72rem;color:#765327;text-decoration:underline;text-underline-offset:.3em}
.motion-toggle:disabled,.journey-follow:disabled{cursor:default;color:#52615c;border-color:#9a9e92;background:transparent}
.chapter,.week,.finale{scroll-margin-top:4.5rem}
html:has(body.motion-disabled){scroll-behavior:auto}
@media(max-width:1000px){.chapter-rail{overflow-x:auto;overflow-y:hidden}.transformation-stage{touch-action:pan-y}.transformation-inner{width:100%}.journey-beat{padding-left:1.5rem;padding-right:.75rem}.journey-beat h3{font-size:clamp(2.5rem,7vw,3.4rem)}}
@media(max-width:620px){.journey-navigation{align-items:flex-start;flex-direction:column}.journey-path{font-size:.6rem;letter-spacing:.04em}.transformation{padding-top:4rem;padding-bottom:4rem}.transformation-view .scene-tabs{margin-right:0;padding-right:0;gap:.4rem}.scene-tab{font-size:.65rem;padding:.65rem .7rem}.transformation-caption{font-size:.76rem}.transformation-label{bottom:.5rem;font-size:.5rem;padding:.3rem}.transformation-label.original{right:.5rem}.transformation-label.cinematic{left:.5rem}.chapter-rail a{min-height:44px;display:flex;align-items:center}.chapter-rail{padding-top:0;padding-bottom:0}}
@media(min-width:1001px) and (max-height:760px){.transformation-view{top:1rem}.transformation-view .transformation-stage{max-height:45svh}.transformation-view .scene-tabs{margin-bottom:1rem;padding-bottom:.6rem}.transformation-caption{flex-direction:column;gap:.15rem}.transformation-controls{margin-top:.75rem}}

.journey-preview img{height:auto}
