:root {
  font-family: system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--gold); text-underline-offset: .23em; }
a:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }
figure, p, h1, h2 { margin: 0; }
img { display: block; max-width: 100%; height: auto; }
.shell { width: min(100% - 3rem, 76rem); margin-inline: auto; }

.skip {
  position: absolute;
  z-index: 1;
  inset: .75rem auto auto 1rem;
  padding: .75rem;
  background: var(--surface);
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-nav, .site-nav nav { display: flex; align-items: center; gap: 1.1rem; }
.site-nav { justify-content: space-between; min-height: 4rem; }
.site-nav nav { justify-content: flex-end; }
.brand {
  color: var(--text);
  font-size: 1.45rem;
  letter-spacing: -.05em;
  line-height: 1.1;
  font-weight: 780;
  text-decoration: none;
}
.brand span { color: var(--gold); }
.play-link {
  padding: .55rem .85rem;
  border-radius: .4rem;
  background: var(--gold);
  color: var(--gold-ink);
  text-decoration: none;
}
.play-link:hover { background: var(--gold-hover); }

.hero {
  display: grid;
  grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr);
  gap: clamp(1.75rem, 4vw, 4rem);
  align-items: center;
  padding-block: clamp(2rem, 5vw, 4rem);
  border-bottom: 1px solid var(--line);
}
.eyebrow, .chapter-heading time {
  display: block;
  color: var(--gold);
  font-weight: 720;
  font-size: .8rem;
  line-height: 1.4;
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1, h2 { font-family: Georgia, serif; font-weight: 700; letter-spacing: -.043em; }
h1 { margin-block: .55rem .85rem; font-size: clamp(2.5rem, 5.15vw, 4.6rem); line-height: .99; }
.intro { max-width: 39ch; font-size: clamp(1.05rem, 1.5vw, 1.24rem); line-height: 1.55; }
.updated { margin-top: 1rem; color: var(--muted); font-size: .88rem; }
.hero figure img { width: 100%; border-radius: .55rem; }
.hero figcaption { padding-top: .55rem; }

.reading-layout { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: clamp(1.6rem, 4vw, 3.4rem); }
.chapter-nav { position: sticky; top: 1.3rem; align-self: start; margin-top: 2.25rem; max-height: calc(100vh - 2.6rem); overflow-y: auto; }
.chapter-nav h2 { font-size: 1.5rem; }
.chapter-nav ol { margin-block: .75rem 0; padding-inline-start: 1.3rem; }
.chapter-nav li { padding-block: .37rem; line-height: 1.35; font-size: .92rem; }
.chapter { padding-block: clamp(2rem, 4vw, 3rem); border-bottom: 1px solid var(--line); scroll-margin-top: 1rem; }
.chapter:last-child { border: 0; }
.chapter h2 { margin-block: .3rem .6rem; font-size: clamp(1.95rem, 3.5vw, 3rem); line-height: 1.03; }
.chapter-lead { font-size: 1.14rem; font-weight: 640; line-height: 1.45; }
.chapter-lead, .chapter-story { max-width: 70ch; }
.chapter-story { margin-top: 1rem; line-height: 1.68; }
.chapter-story p + p { margin-top: .65rem; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: .85rem; margin-top: 1.35rem; }
.media-grid figure { min-width: 0; border: 1px solid var(--line); border-radius: .5rem; background: var(--surface); }
.media-link { display: grid; place-items: center; min-height: 44px; aspect-ratio: 16 / 10; background: var(--bg); border-radius: .5rem .5rem 0 0; }
.media-link:hover { background: var(--line); }
.media-link img { width: 100%; height: 100%; object-fit: contain; min-height: 0; border-radius: inherit; }
figcaption { color: var(--muted); font-size: .82rem; line-height: 1.45; }
.media-grid figcaption { padding: .6rem .7rem .72rem; }
.tools { max-width: 75ch; margin-top: 1rem; padding-left: .85rem; border-left: 3px solid var(--gold); font-size: .9rem; line-height: 1.5; color: var(--muted); }
.tools strong { color: var(--text); }
.site-footer { padding-block: .6rem; border-top: 1px solid var(--line); font-size: .88rem; color: var(--muted); }

@media (max-width: 54rem) {
  .reading-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .chapter-nav { position: static; margin-top: 0; max-height: none; overflow: visible; padding-block: 1.35rem; border-bottom: 1px solid var(--line); }
  .chapter-nav ol { columns: 2; column-gap: 2rem; }
  .chapter-nav li { break-inside: avoid; }
}
@media (max-width: 41rem) {
  .shell { width: calc(100% - 1.75rem); }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .site-nav, .site-nav nav { gap: .55rem; }
  .site-nav nav { font-size: .81rem; }
  .play-link { padding-inline: .55rem; }
  .brand { font-size: 1.25rem; }
  .site-footer .site-nav { flex-wrap: wrap; }
}
@media (max-width: 24rem) {
  .chapter-nav ol { columns: 1; }
}

/* Photo viewer */
.wiki-gallery-open { overflow: hidden; }
.media-link[aria-haspopup="dialog"] { cursor: zoom-in; }

.wiki-gallery {
  --gallery-control: clamp(44px, 5vw, 52px);
  --gallery-gap: clamp(.3rem, 1vw, .9rem);
  --gallery-margin: clamp(.4rem, 2vw, 1.25rem);
  inline-size: min(80rem, calc(100% - 2 * var(--gallery-margin)));
  block-size: min(54rem, calc(100vh - 2 * var(--gallery-margin)));
  block-size: min(54rem, calc(100dvh - 2 * var(--gallery-margin)));
  max-inline-size: none;
  max-block-size: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: .9rem;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1.5rem 5rem rgb(0 0 0 / 55%);
}
.wiki-gallery:not([open]) { display: none; }
.wiki-gallery[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.wiki-gallery::backdrop { background: rgb(12 11 10 / 88%); }

.wiki-gallery-toolbar {
  display: flex;
  align-items: center;
  gap: var(--gallery-gap);
  padding: .45rem clamp(.55rem, 1.6vw, 1.35rem);
}
.wiki-gallery-toolbar h2 {
  flex: 1;
  min-inline-size: 0;
  font-size: clamp(1.05rem, 2.8vw, 1.5rem);
  line-height: 1.12;
  letter-spacing: -.025em;
}
.wiki-gallery-count {
  color: var(--muted);
  font-size: .84rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.wiki-gallery-slide {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-block-size: 0;
}
.wiki-gallery-stage {
  display: grid;
  grid-template-columns: var(--gallery-control) minmax(0, 1fr) var(--gallery-control);
  grid-template-rows: minmax(0, 1fr);
  gap: var(--gallery-gap);
  min-block-size: 0;
  padding-inline: var(--gallery-gap);
}
.wiki-gallery-media {
  position: relative;
  min-inline-size: 0;
  min-block-size: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: #131210;
}
.wiki-gallery-photo, .wiki-gallery-photo img {
  inline-size: 100%;
  block-size: 100%;
}
.wiki-gallery-photo img { object-fit: contain; }
.wiki-gallery-feedback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: .65rem;
  padding: .5rem;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}
.wiki-gallery-caption {
  min-block-size: 3.25rem;
  max-block-size: 25vh;
  overflow: auto;
  padding: .7rem calc(var(--gallery-control) + 2 * var(--gallery-gap));
  color: var(--text);
  font-size: .93rem;
}

.wiki-gallery-button, .wiki-gallery-retry {
  border: 1px solid var(--muted);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.wiki-gallery-button {
  position: relative;
  display: grid;
  place-items: center;
  align-self: center;
  flex: none;
  inline-size: var(--gallery-control);
  block-size: var(--gallery-control);
  padding: 0;
  border-radius: 50%;
}
.wiki-gallery-close::before, .wiki-gallery-close::after {
  content: '';
  position: absolute;
  inline-size: 1rem;
  block-size: 2px;
  border-radius: 1px;
  background: currentColor;
  transform: rotate(45deg);
}
.wiki-gallery-close::after { transform: rotate(-45deg); }
.wiki-gallery-prev::before, .wiki-gallery-next::before {
  content: '';
  grid-area: 1 / 1;
  inline-size: .67rem;
  block-size: .67rem;
  border-block-start: 2px solid;
  border-inline-end: 2px solid;
}
.wiki-gallery-prev::before { transform: translateX(.13rem) rotate(-135deg); }
.wiki-gallery-next::before { transform: translateX(-.13rem) rotate(45deg); }
.wiki-gallery-button:hover, .wiki-gallery-retry:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.wiki-gallery-button:focus-visible, .wiki-gallery-retry:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.wiki-gallery-retry {
  min-block-size: 44px;
  padding: .4rem .85rem;
  border-radius: .45rem;
  font: inherit;
  pointer-events: auto;
}

@media (max-width: 41rem) {
  .wiki-gallery { border-radius: .65rem; }
  .wiki-gallery-caption { padding-inline: .8rem; }
}

@media (max-width: 41rem) and (orientation: portrait) {
  .wiki-gallery {
    inset-block: 50% auto;
    block-size: auto;
    margin-block: 0;
    transform: translateY(-50%);
    max-block-size: calc(100vh - 2 * var(--gallery-margin));
    max-block-size: calc(100dvh - 2 * var(--gallery-margin));
  }
  .wiki-gallery-slide { grid-template-rows: auto auto; }
  .wiki-gallery-stage {
    position: relative;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    padding-inline: .4rem;
  }
  .wiki-gallery-media {
    aspect-ratio: var(--gallery-image-ratio, 16 / 10);
    max-block-size: min(65vh, calc(100vh - 8rem));
    max-block-size: min(65dvh, calc(100dvh - 8rem));
  }
  .wiki-gallery-prev, .wiki-gallery-next {
    position: absolute;
    z-index: 1;
    inset-block-start: 50%;
    transform: translateY(-50%);
    background: rgb(23 23 23 / 94%);
  }
  .wiki-gallery-prev { inset-inline-start: .65rem; }
  .wiki-gallery-next { inset-inline-end: .65rem; }
}
