/*
 * Maternity edition — page layout: stage, chapters, chapter hero, media breaks.
 */

.stage {
  --frame: 40px;
  --stage-max: 1280px;
  width: min(var(--stage-max), calc(100% - var(--frame) * 2));
  margin: 0 auto;
  padding: calc(var(--nav-h) + var(--frame)) 0 var(--frame);
}
/* Clip sideways overflow at the page, not the stage, so full-bleed pieces
   (journey rail, Care City map) reach the window edges. clip, not hidden:
   it creates no scroll container, so position: sticky keeps working. */
body { overflow-x: clip; }
@media (width <= 860px) { .stage { --frame: 24px; } }
@media (width <= 600px) { .stage { --frame: 16px; } :root { --nav-h: 64px; } }

/* Top bar: fixed, translucent; holds the title and the theme toggle. */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 var(--frame, 40px);
  background: var(--nav-soft-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
}
.topbar-title { font-family: var(--font-display); font-size: 20px; font-weight: 500; }
.topbar-nav { display: flex; gap: 6px; font-family: var(--font-mono); font-size: var(--fs-ui); }
.topbar-nav a { color: rgba(var(--ink-rgb), .7); text-decoration: none; padding: 5px 10px; border-radius: 96px; }
.topbar-nav a:hover, .topbar-nav a[aria-current="page"] { color: var(--ink); background: rgba(var(--ink-rgb), .06); }

/* A chapter: prose measure, with media that breaks out to the figure width. */
.chapter {
  width: 100%;
  max-width: calc(var(--media-max) + 2 * var(--fig-gutter));
  margin: 0 auto;
  padding: 0 var(--fig-gutter);
  container-type: inline-size;
}
.chapter + .chapter { border-top: 1px solid var(--hairline); }

.chapter-page {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--chapter-top) 0 var(--chapter-end);
  color: var(--ink);
}
.chapter-page > .intro { margin-top: var(--block-gap); }
/* after a chart card, give the next section of prose room to start afresh */
.chapter-page > .media-break + .intro { margin-top: var(--chart-gap); }
.chapter-page > .closing { margin-top: var(--spark-gap); }

/* Media that is wider than the prose measure: figures and viewers. */
.media-break, .viewer-break {
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  width: min(var(--media-max), 100cqw);
  margin-top: var(--chart-gap);
  display: flex;
  justify-content: center;
}
.viewer-break {
  width: min(var(--viewer-max), 100cqw);
  margin-top: var(--viewer-gap);
}

/* ---- chapter hero ---------------------------------------------------------- */
.hero { text-align: center; }
.hero-track {
  --hero-w: min(var(--media-max), 100cqw);
  width: var(--hero-w);
  margin: 40px 0 0 calc(50% - var(--hero-w) / 2);
}
.hero-art {
  width: 100%;
  aspect-ratio: 1136 / 284;
  background: center / contain no-repeat;
  background-image: var(--hero-image);
}
