/* Stories — shared visual foundation.
   Light warm ivory paper, deep burgundy editorial serif, and one real raster
   paper-cut route layer on the homepage. No CSS-drawn lines or nodes. */

:root {
  --ivory: #fbf2df;
  --paper: #fffdf6;
  --burgundy: #6b1f2e;
  --burgundy-deep: #4a1520;
  --ochre: #a0642a;
  --thread: #b06a72;
  --thread-soft: #d9b3b6;
  --ink: #332c27;
  --muted: #7c7168;
  --serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Times New Roman', serif;
  --meta: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ivory);
  background-image: url("/assets/optimized/decor/ivory-paper-texture-v1.webp");
  background-repeat: repeat;
  background-size: 512px 512px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.06rem;
  line-height: 1.65;
  overflow-x: clip;
}

.wrap {
  max-width: 66rem;
  margin: 0 auto;
  padding: 2.75rem 2.5rem 4.5rem;
}

a { color: var(--burgundy); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--burgundy-deep); }

a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--burgundy);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: -10000px;
  top: 0;
  background: var(--paper);
  color: var(--burgundy-deep);
  padding: 0.6rem 1rem;
  z-index: 10;
}
.skip:focus { left: 1rem; top: 1rem; }

.kicker {
  font-family: var(--meta);
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--thread);
  margin: 0 0 0.75rem;
}

.stories-title {
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1.0;
  letter-spacing: -0.02em;
  color: var(--burgundy-deep);
  margin: 0;
}

.lede {
  font-size: 1.2rem;
  line-height: 1.6;
  color: var(--muted);
  max-width: 34rem;
  margin: 0;
}

.crumb { font-family: var(--meta); font-size: 0.85rem; color: var(--muted); margin: 0 0 1.5rem; }
.crumb a { color: var(--thread); }

.book-meta {
  font-family: var(--meta);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0.35rem 0 0.9rem;
}

.goto { font-style: italic; }

/* ---- Homepage: one loose deckled story leaf on a quiet ivory field ---- */

/* The whole viewport stays the shared warm ivory paper field; the page is a
   single centered loose paper leaf, not a bound book on a desk. */
body.page-home .wrap { max-width: 72rem; }

/* Far-left navigator: three real paper-cut story anchors, fixed at the
   viewport's vertical midpoint, outside the leaf and clear of the reading
   column. Real raster art, keyboard-focusable, opaque. */
.leaf-rail {
  position: fixed;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  width: 3.4rem;
}
.rail-btn { display: block; width: 100%; }
.rail-btn img { display: block; width: 100%; height: auto; }

/* The loose leaf itself: a real transparent handmade-paper raster supplies
   the deckled perimeter and embedded fibers. The center slice stretches only
   as a quiet paper grain; its edge slices retain the tangible torn-paper
   character all the way down the long reading page. */
.loose-leaf {
  position: relative;
  isolation: isolate;
  width: min(100%, 60rem);
  margin: 0 auto;
  padding: 3.85rem 4.15rem 3.6rem;
  /* The deckled paper raster fills the page. Do not add a CSS rectangle
     beneath it: alpha around its torn edge must reveal the outer field. */
  background: transparent;
  box-sizing: border-box;
  border: 0.85rem solid transparent;
  border-image: url("/assets/optimized/decor/stories-loose-paper-v3.webp") 86 fill stretch;
  box-shadow: 0 2px 4px rgba(74, 21, 32, 0.12), 0 16px 34px rgba(74, 21, 32, 0.2);
}

/* One real, transparent, continuous route raster. It keeps its native aspect
   ratio at the full leaf height so the red nodes remain circular. */
.leaf-route-layer {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: auto;
  z-index: 0;
  pointer-events: none;
}
.loose-leaf > :not(.leaf-route-layer) { position: relative; z-index: 1; }

/* The swallow is an independent paper-cut accent so it can retain its own
   natural proportions rather than being stretched together with the route. */
.leaf-swallow {
  position: absolute;
  top: 2.2rem;
  right: 1.6rem;
  width: 7.2rem;
  height: auto;
}
.loose-leaf > .leaf-swallow { position: absolute; z-index: 2; }

/* Visually-hidden accessible equivalents. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.leaf-masthead { margin: 0 0 0.9rem; }
.leaf-masthead .stories-title { font-size: clamp(3rem, 7.5vw, 4.8rem); }
.leaf-tagline { font-style: italic; font-size: 1.18rem; color: var(--burgundy); margin: 0.4rem 0 0; }

.leaf-intro { margin: 0.9rem 0 0; font-size: 0.98rem; line-height: 1.6; color: var(--ink); }
.leaf-intro p { margin: 0; }

.leaf-series { margin-top: 2.1rem; max-width: 16rem; }
.leaf-series .series-line { font-size: clamp(1.9rem, 4vw, 2.6rem); line-height: 1.12; margin: 0 0 0.35rem; }
.leaf-series .series-line a { text-decoration: none; color: var(--burgundy-deep); }
.leaf-series .series-line a:hover { text-decoration: underline; }
.series-lede { color: var(--muted); margin: 0; max-width: 24rem; }

/* Book 1: a compact left reading column beside the raised rabbit window. */
.leaf-book1 {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 1.6rem 2.2rem;
  align-items: center;
  margin-top: 2.4rem;
}
.book1-copy { max-width: 16rem; }
.book1-copy .book1-title { font-size: clamp(1.7rem, 3.4vw, 2.2rem); line-height: 1.18; margin: 0 0 0.5rem; }
.book1-copy .book1-title a { text-decoration: none; color: var(--burgundy-deep); }
.book1-copy .book1-title a:hover { text-decoration: underline; }
.book1-copy .blurb { margin: 0; max-width: 22rem; }

/* The hero: the real scene raised inside the rabbit-shaped paper-cut window. */
.book1-hero {
  margin: 0;
  width: min(23rem, 100%);
  justify-self: end;
  aspect-ratio: 620 / 1000;
  -webkit-mask-image: url("/assets/decor/night-hero-bunny-mask.svg");
  mask-image: url("/assets/decor/night-hero-bunny-mask.svg");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  filter: drop-shadow(0 0 2px #fbf2df) drop-shadow(0 0 4px #f3e3c0) drop-shadow(0 12px 20px rgba(74, 21, 32, 0.24));
  background: #9d744a var(--hero-placeholder) center / cover no-repeat;
}
.book1-hero img {
  border-radius: 0;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 180ms ease-out;
}
.book1-hero img.is-loaded { opacity: 1; }

/* Paired night spread: two real pages joined inside one wide wavy cut. */
.leaf-spread {
  width: 100%;
  aspect-ratio: 1440 / 620;
  margin: 2.6rem 0 0;
  -webkit-mask-image: url("/assets/decor/night-spread-wave-mask.svg");
  mask-image: url("/assets/decor/night-spread-wave-mask.svg");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  filter: drop-shadow(0 0 2px #fbf2df) drop-shadow(0 0 4px #f3e3c0) drop-shadow(0 12px 20px rgba(74, 21, 32, 0.24));
}
.leaf-spread .spread-row { display: flex; width: 100%; height: 100%; }
.leaf-spread .spread-half { margin: 0; width: 50%; height: 100%; }
.leaf-spread .spread-half img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 0;
  object-fit: cover;
}

/* Books 2 and 3 continue ON THE SAME loose sheet as Book 1: the trail lives
   inside .loose-leaf, so the torn paper edge finishes only after the final
   stop, ad study, and route end — never between story stops. */
.leaf-trail {
  width: 100%;
  margin: 2.7rem 0 0;
}

.route-content {
  display: flex;
  flex-direction: column;
  gap: 2.1rem;
}

.stop-kicker {
  font-family: var(--meta);
  font-size: 0.76rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ochre);
  margin: 0 0 0.5rem;
}

.stop-copy h2 { font-size: clamp(1.65rem, 2.9vw, 2.35rem); line-height: 1.16; margin: 0 0 0.1rem; }
.stop-copy h2 a { text-decoration: none; color: var(--burgundy-deep); }
.stop-copy h2 a:hover { text-decoration: underline; }
.stop-copy .blurb { max-width: 27rem; }

hr.hairline {
  border: none;
  border-top: 1px solid var(--thread-soft);
  width: 11rem;
  margin: 1.05rem 0 0.75rem;
}
.book-status {
  font-family: var(--meta);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 0.9rem;
}
.chapter-cta {
  font-style: italic;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.cta-book {
  display: inline-block;
  width: 0.95em;
  height: 0.72em;
  border: 1.5px solid currentColor;
  border-radius: 1px 3px 3px 1px;
  box-shadow: -2px 0 0 -0.5px currentColor;
  margin-right: 0.45em;
  vertical-align: -0.05em;
}


/* Later stops inherit the same cut-paper vocabulary. */
.paper-cut {
  width: fit-content;
  max-width: 100%;
  filter:
    drop-shadow(0 0 2px #fbf2df)
    drop-shadow(0 0 4px #f3e3c0)
    drop-shadow(0 12px 20px rgba(74, 21, 32, 0.24));
}
.stop--later {
  display: grid;
  grid-template-columns: minmax(0, 6fr) minmax(0, 6fr);
  gap: 1.9rem 2.6rem;
  align-items: center;
}
.stop--b { padding-right: 2%; }
.stop--b .stop-art { width: min(31rem, 100%); }
.stop--c { padding-left: 8%; }
.stop--c .stop-art { width: min(30rem, 100%); order: 2; }
.stop--c .stop-copy { order: 1; }

.route-end { margin-top: 1rem; }

/* ---- Visual-only advertisement placement study (after the last stop) ---- */

.ad-study {
  margin: 3.5rem auto 0;
  text-align: center;
  width: min(100%, 45.5rem);
}
.ad-study-box {
  width: 100%;
  aspect-ratio: 728 / 90;
  background: var(--paper);
  border: 1px dashed var(--thread);
}
.ad-study-cap {
  font-family: var(--meta);
  font-size: 0.76rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0.6rem 0 0.1rem;
}
.ad-study-note {
  font-family: var(--meta);
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0;
}
@media (max-width: 760px) {
  /* On a narrow reading column there is no safe route gutter. The long
     decorative thread would cross text, so keep the swallow and story rail
     but remove only this nonessential background layer. */
  .leaf-route-layer { display: none; }
  .ad-study { margin-left: 0; margin-right: 0; }
  .ad-study-box { aspect-ratio: 4 / 5; max-height: 40vh; }
}

/* Story sections: hash jumps land with breathing room above the heading. */
#story-night, #story-tv, #story-dumpling { scroll-margin-top: 4rem; }

/* ---- Homepage story-object windows (detail pages keep their own crops) ---- */

/* Book 2: wide home game-console/controller silhouette. */
.stop--b .stop-art.tv-game-window {
  width: min(29rem, 100%);
  aspect-ratio: 620 / 940;
}
.tv-game-window {
  -webkit-mask-image: url("/assets/decor/tv-game-console-mask.svg");
  mask-image: url("/assets/decor/tv-game-console-mask.svg");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
}
.stop--b .tv-game-window img {
  clip-path: none;
  border-radius: 0;
  height: 100%;
  object-fit: cover;
}

/* Book 3: broad horizontal folded-dumpling half-moon. */
.stop--c .stop-art.dumpling-window {
  width: min(28rem, 100%);
  aspect-ratio: 640 / 900;
}
.dumpling-window {
  -webkit-mask-image: url("/assets/decor/dumpling-crescent-mask.svg");
  mask-image: url("/assets/decor/dumpling-crescent-mask.svg");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
}
.stop--c .dumpling-window img {
  border-radius: 0;
  height: 100%;
  object-fit: cover;
}

/* ---- Narrative windows on the real image elements ---- */

.window img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

/* Night: one generous rounded paper-cut window, crisp edge, no fade. */
.window--night img {
  border-radius: 47% 53% 52% 48% / 44% 40% 60% 56%;
}

/* TV: screen/water-wave-like band. */
.window--tv img {
  clip-path: polygon(0% 20%, 12% 9%, 25% 17%, 37% 7%, 50% 16%, 62% 6%, 75% 15%, 87% 7%, 100% 17%, 100% 83%, 87% 93%, 75% 85%, 62% 95%, 50% 86%, 37% 96%, 25% 86%, 12% 95%, 0% 85%);
}

/* Dumpling: folded wrapper window, softly pinched organic corners. */
.window--dumpling img {
  border-radius: 62% 48% 55% 45% / 46% 62% 38% 54%;
}

/* ---- Series page: stops along the route ---- */

.route {
  list-style: none;
  margin: 3.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5rem;
}
.stop {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 3.5rem;
  align-items: center;
}
.stop:nth-child(even) .stop-art { order: 2; }
.stop-art { position: relative; padding: 0 0 2.2rem 1.2rem; }
.stop-art .window--lg { width: min(22rem, 100%); }
.stop-art .window--chip {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 31%;
}
.stop-no {
  font-family: var(--meta);
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--thread);
  margin: 0 0 0.5rem;
}
.stop-text h2 { font-size: 1.85rem; line-height: 1.2; margin: 0 0 0.1rem; }
.stop-text h2 a { text-decoration: none; }
.stop-text h2 a:hover { text-decoration: underline; }
.stop-text p { max-width: 30rem; }

.backlink { margin-top: 4rem; }

/* ---- Book detail pages ---- */

.book-page .book-title { font-size: clamp(2.1rem, 5vw, 3.3rem); line-height: 1.12; color: var(--burgundy-deep); margin: 0 0 0.4rem; }
.book-open { margin-top: 2.75rem; }

.book-hero {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 3.5rem;
  align-items: center;
}
.book-hero--flip { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.book-hero--flip .book-art { order: 1; }
.book-hero--flip .book-head { order: 2; }
.book-art { position: relative; padding: 0 0 2.6rem 1.4rem; }
.book-art .window--main { width: min(24rem, 100%); }
.book-art .window--tuck {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 40%;
}
.book-blurb p { max-width: 30rem; }

.solo {
  margin-top: 4rem;
  display: grid;
  grid-template-columns: minmax(0, 8fr) minmax(0, 4fr);
  gap: 2.5rem;
  align-items: end;
}
.solo .solo-fig { margin: 0 0 0 2.5rem; }
.solo figcaption {
  font-family: var(--meta);
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.6rem;
  max-width: 26rem;
}

.story-nav {
  margin-top: 5rem;
  border-top: 1px solid var(--thread-soft);
  padding-top: 1.6rem;
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}
.story-nav a { text-decoration: none; }
.story-nav a:hover { text-decoration: underline; }
.story-nav .nav-dir {
  display: block;
  font-family: var(--meta);
  font-size: 0.76rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--thread);
  margin-bottom: 0.25rem;
}
.story-nav .nav-next { text-align: right; margin-left: auto; }

/* ---- Availability ledger ---- */

.ledger {
  width: 100%;
  border-collapse: collapse;
  margin: 2.2rem 0 3rem;
  font-size: 0.98rem;
}
.ledger caption {
  text-align: left;
  font-family: var(--meta);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--thread);
  padding-bottom: 0.8rem;
}
.ledger th, .ledger td {
  text-align: left;
  vertical-align: top;
  padding: 0.9rem 1rem 0.9rem 0;
  border-bottom: 1px solid var(--thread-soft);
}
.ledger th {
  font-family: var(--meta);
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--burgundy);
}
.ledger .ed-note { font-family: var(--meta); font-size: 0.8rem; color: var(--muted); display: block; margin-top: 0.2rem; }
.ledger .date { white-space: nowrap; }

/* ---- Long-form prose (privacy, terms) ---- */

.prose { max-width: 42rem; }
.prose h2 { font-size: 1.35rem; color: var(--burgundy-deep); margin: 2.4rem 0 0.6rem; }
.prose p, .prose li { line-height: 1.7; }
.prose ul { padding-left: 1.3rem; }
.prose li { margin: 0.4rem 0; }
.prose .lead { font-size: 1.12rem; color: var(--muted); }

/* ---- Locale 404 ---- */

.lost-number {
  font-size: clamp(4.5rem, 14vw, 8rem);
  font-weight: 700;
  line-height: 1;
  color: var(--burgundy);
  margin: 0;
}
.lost-title { font-size: 1.6rem; color: var(--burgundy-deep); margin: 0.4rem 0 1rem; }
.lost-links { list-style: none; margin: 2.2rem 0 0; padding: 0; }
.lost-links li { margin: 0.55rem 0; }

/* ---- Shared page furniture ---- */

.site-foot {
  border-top: 1px solid var(--thread-soft);
  margin-top: 5rem;
  padding-top: 1.4rem;
}
.site-foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.6rem;
  font-family: var(--meta);
  font-size: 0.85rem;
}
.site-foot a { color: var(--muted); text-decoration: none; }
.site-foot a:hover { color: var(--burgundy); text-decoration: underline; }

.page-body { max-width: 40rem; }
.page-body h1 { font-size: 2.3rem; color: var(--burgundy-deep); margin: 0 0 1rem; }

/* ---- Wide desktop: taller editorial rhythm ---- */

@media (min-width: 900px) {
  body.page-home .wrap { padding-left: 3rem; padding-right: 3rem; }
  .route-content { gap: 3.1rem; }
  .stop--later { gap: 2.6rem 3.5rem; }
}

/* ---- Mid widths: the navigator steps out of the flow ---- */

@media (max-width: 900px) {
  .leaf-rail {
    position: static;
    transform: none;
    flex-direction: row;
    justify-content: center;
    width: auto;
    gap: 2rem;
    margin: 0 0 1.7rem;
  }
  .rail-btn { width: 2.5rem; }
}

/* ---- Narrow phones: a deliberate vertical adaptation ---- */

/* The loose leaf keeps its paper proportions; the navigator becomes a quiet
   static row above the leaf so nothing fixed ever covers story content. The
   trail is overflow-contained so wide art can never push the document past
   the viewport (scrollWidth === innerWidth at 390px). */
@media (max-width: 480px) {
  .wrap { padding: 1.25rem 1rem 2.5rem; }
  .loose-leaf { padding: 2.2rem 1.4rem 2.4rem; }
  .leaf-swallow { width: 5rem; top: -1.7rem; right: -0.5rem; }
  .leaf-masthead .stories-title { font-size: 2.9rem; }
  .leaf-book1 { grid-template-columns: minmax(0, 1fr); gap: 1.6rem; }
  .book1-hero { width: min(15rem, 100%); justify-self: start; }
  .leaf-trail { width: 100%; overflow-x: clip; }
  .route-content { gap: 2.6rem; }
  .stop--later { grid-template-columns: minmax(0, 1fr); gap: 1.6rem; }
  .stop--b, .stop--c { padding-left: 0; padding-right: 0; }
  .stop--b .paper-cut, .stop--c .paper-cut { order: 0; max-width: 100%; }
  .stop--b .stop-art, .stop--c .stop-art { order: 0; width: 100%; max-width: 100%; }
  .stop--c .paper-cut { margin-left: 0; }
  .stop--c .stop-copy { order: 0; }
}

@media (max-width: 390px) {
  .wrap { padding: 2rem 1.1rem 3.5rem; }
  .route-content { gap: 2.6rem; }
  .stop--b .stop-art, .stop--c .stop-art { width: 100%; max-width: 100%; }
  .stop-copy h2 { font-size: 1.55rem; }
  .stop, .book-hero, .book-hero--flip { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
  .stop:nth-child(even) .stop-art { order: 0; }
  .stop-text h2 { font-size: 1.55rem; }
  .ledger th, .ledger td { padding-right: 0.6rem; font-size: 0.9rem; }
  .story-nav { flex-direction: column; gap: 1.2rem; }
  .story-nav .nav-next { text-align: left; margin-left: 0; }
}

@media (max-width: 320px) {
  .wrap { padding: 1.5rem 0.9rem 3rem; }
  .lede { font-size: 1.02rem; }
  .stop--b .stop-art, .stop--c .stop-art { width: 100%; max-width: 100%; }
  .site-foot nav { gap: 0.3rem 1rem; font-size: 0.8rem; }
  .stop-copy h2 { font-size: 1.35rem; }
  .book-page .book-title { font-size: 1.8rem; }
  .book-art .window--tuck { width: 52%; }
  .lost-number { font-size: 4.2rem; }
  .ledger { font-size: 0.85rem; }
  .ledger .date { white-space: normal; }
}

/* ---- Reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .book1-hero img { transition: none; }
}
