:root {
  color-scheme: light;
  --paper: #f5f0e6;
  --ink: #20211b;
  --muted: #5e574a;
  --blue: #1842a4;
  --rule: #b9af9f;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 1.2rem/1.6 var(--serif); }
::selection { background: #dce4ff; color: var(--ink); }
a { color: var(--blue); text-underline-offset: .24em; }
a:focus-visible { outline: 2px solid var(--blue); outline-offset: 5px; }
[id] { scroll-margin-top: 1.75rem; }
.wrap { width: min(88%, 72rem); margin-inline: auto; }
.skip { position: absolute; top: .5rem; left: .5rem; transform: translateY(-160%); background: var(--paper); padding: .5rem; }
.skip:focus { transform: none; }
.masthead, .footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font: .84rem/1.35 var(--sans); }
.masthead { border-bottom: 1px solid var(--rule); min-height: 4.5rem; }
.masthead a, .footer a, .index-head a, .chapter-nav a { display: inline-flex; align-items: center; min-height: 44px; }
.signature { color: var(--ink); text-decoration: none; font-weight: 650; }
h1, h2, p, figure { margin: 0; }
h1, h2 { font-weight: 400; letter-spacing: -.035em; line-height: 1.02; }
h1 { font-size: clamp(3.8rem, 8.7vw, 6rem); }
h1 i { color: var(--blue); }
h2 { font-size: clamp(2rem, 4.3vw, 3.25rem); text-wrap: balance; }
.cover { padding-block: clamp(1.6rem, 4vw, 3rem); }
.cover-copy p { max-width: 58ch; margin-top: .8rem; }
.cover-copy .cover-byline { color: var(--muted); font: 600 1rem/1.5 var(--sans); }
.story-cover { margin-bottom: clamp(2rem, 5vw, 4rem); }
figcaption { color: var(--muted); font: .75rem/1.45 var(--sans); margin-top: .65rem; }
.button:hover { background: #12317c; }
.index { margin-bottom: clamp(4rem, 8vw, 7rem); }
.index-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem 1.2rem; margin-bottom: 1.4rem; }
.index-head a, .chapter-nav { font: .875rem/1.4 var(--sans); }
.entries { margin: 0; padding: 0; list-style: none; border-bottom: 1px solid var(--rule); }
.entries li { border-top: 1px solid var(--rule); }
.entries a { display: grid; grid-template-columns: 5.5rem 1fr; gap: .75rem; padding-block: 1.3rem; color: var(--ink); text-decoration: none; }
.entries a:hover strong, .entries a:focus-visible strong { color: var(--blue); text-decoration: underline; text-underline-offset: .16em; }
.number { color: var(--blue); font: 600 .76rem/1.5 var(--sans); font-variant-numeric: tabular-nums; padding-top: .45rem; }
.entries strong { display: block; font-size: clamp(1.35rem, 2.8vw, 1.85rem); line-height: 1.15; font-weight: 400; }
.summary { display: block; max-width: 70ch; margin-top: .35rem; color: var(--muted); font-size: 1rem; }
.chapter { display: grid; grid-template-columns: 5.5rem 1fr; gap: .75rem; border-top: 1px solid var(--rule); padding-block: clamp(2rem, 6vw, 4.5rem); }
.chapter p { max-width: 68ch; margin-top: 1rem; }
.chapter-nav { display: flex; flex-wrap: wrap; gap: .4rem 1.75rem; margin-top: 1rem; }
.footer { border-top: 1px solid var(--rule); padding-block: .75rem; color: var(--muted); }
@media (max-width: 42rem) {
  .entries a, .chapter { grid-template-columns: 1fr; gap: .25rem; }
  .entries a { padding-block: 1rem; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@media print {
  .masthead, .skip, .footer, .chapters, .story-cover { display: none; }
  .wrap { width: 100%; }
  h1 { font-size: 2.75rem; }
  .entries a { padding-block: .5rem; break-inside: avoid; }
}

/* The illustrated scene stays beside the passage on wide screens. */
.chapter:has(.chapter-scene:not([hidden])) {
  grid-template-columns: 3rem minmax(0, 1fr) minmax(14rem, 28rem);
  column-gap: clamp(1rem, 3vw, 2.5rem);
}
.chapter-scene {
  position: sticky;
  top: 2rem;
  display: block;
  width: 100%;
  height: auto;
  grid-column: 3;
  grid-row: 1;
  align-self: start;
  background: #382626;
  image-rendering: pixelated;
}
.chapter-scene[hidden] { display: none; }
@media (max-width: 56rem) {
  .chapter:has(.chapter-scene:not([hidden])) { grid-template-columns: minmax(0, 1fr); }
  .chapter-scene {
    position: static;
    grid-column: 1;
    grid-row: 2;
    margin-top: .75rem;
    width: min(100%, 28rem);
  }
  .chapter:has(.chapter-scene:not([hidden])) > div { grid-row: 3; }
}

.cover-art { position: relative; aspect-ratio: 8 / 5; }
.cover-art img { display: block; width: 100%; height: 100%; object-fit: cover; background: #ddd4c0; }
.cover-art img[hidden], .cover-art canvas[hidden] { display: none; }
.cover-art canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  pointer-events: none;
}
.cover-motion {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font: 600 .8rem/1.4 var(--sans);
  text-decoration: underline;
  text-underline-offset: .25em;
  cursor: pointer;
}
.cover-motion:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }
.cover-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0 1rem;
}
.cover-stage { font-weight: 650; }
.cover-detail {
  flex-basis: 100%;
  min-height: 4.5em;
  color: var(--muted);
  font: 1rem/1.5 var(--serif);
}
.cover-detail:empty { display: none; }

.print-contents {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font: .875rem/1.4 var(--sans);
  text-decoration: underline;
  text-underline-offset: .24em;
  cursor: pointer;
}
.print-contents:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }

@media print {
  @page { margin: 16mm 18mm; }
  body { background: white; color: #171717; }
  .print-contents { display: none; }
  #contents { margin: 0; }
  #contents .index-head { margin-bottom: .7rem; }
  #contents h2 { font-size: 1.55rem; }
  #contents .entries li { break-inside: avoid; }
  #contents .entries a { grid-template-columns: 4.5rem 1fr; gap: .5rem; }
  #contents .entries strong { font-size: 1.15rem; }
  #contents .summary { max-width: none; font-size: .9rem; line-height: 1.35; margin-top: .2rem; }
  #contents .number { padding-top: .15rem; }
}

#contents:target { scroll-margin-top: 1.35rem; }
@media print {
  .cover { display: block; padding-block: 0 1rem; }
  .cover .cover-copy p { display: none; }
  .cover .cover-copy .cover-byline {
    display: block;
    max-width: none;
    margin: .35rem 0 0;
  }
}
