:root {
  --page-gutter: clamp(16px, 2.4vw, 36px);
  --parchment: #f4ead8;
  --parchment-deep: #eadcc3;
  --parchment-dark: #e2d1b3;
  --ivory: #fbf6eb;
  --paper: #f8f0e1;
  --ink: #2b2118;
  --ink-soft: #4a3b2d;
  --muted: #695744;
  --border: rgba(90, 62, 34, 0.22);
  --border-strong: rgba(90, 62, 34, 0.38);
  --rule: rgba(90, 62, 34, 0.28);
  --bronze: #8a6724;
  --gold: #b8892d;
  --deep-brown: #3a2b1e;
  --focus: #2f5f5a;
  --olive: #5f6f52;
  --teal: #3f6f6a;
  --terracotta: #8c5a3c;
  --shadow: 0 10px 30px rgba(43, 33, 24, 0.08);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", "Georgia", "Times New Roman", serif;
  --sans: "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
  --col-w: 360px;
  --spine-h: 56px;
  --content-max: 100%;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
  background-color: var(--parchment);
  background-image:
    radial-gradient(ellipse at top, rgba(251,246,235,0.92), rgba(244,234,216,0.97) 55%, rgba(234,220,195,0.98)),
    repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(90,62,34,0.025) 32px),
    repeating-linear-gradient(90deg, transparent, transparent 31px, rgba(90,62,34,0.018) 32px);
}
img { max-width: 100%; display: block; }
a { color: #5b4420; }
a:hover { color: var(--ink); }
:focus-visible {
  outline: 3px solid rgba(47,95,90,0.45);
  outline-offset: 2px;
}
.skip-link {
  position: absolute; left: 12px; top: -48px; background: var(--ivory); color: var(--ink);
  padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 6px; z-index: 100;
}
.skip-link:focus { top: 12px; }

.section-inner { max-width: none; margin: 0; padding: 0 var(--page-gutter); }
.narrow { max-width: 900px; margin-left: auto; margin-right: auto; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(244,234,216,0.94);
  backdrop-filter: blur(4px);
  border-bottom: 1px solid var(--rule);
}
.masthead {
  max-width: none; margin: 0; padding: 0 var(--page-gutter);
  min-height: 72px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px 24px;
}
.brand {
  font-family: var(--serif); font-size: 20px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--deep-brown); text-decoration: none; white-space: nowrap;
}
.story-mark {
  justify-self: center; font-family: var(--serif); font-size: 13px; letter-spacing: 0.14em;
  color: var(--muted); text-decoration: none;
}
.story-mark:hover { color: var(--ink); }
.primary-nav { display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap; justify-content: flex-end; }
.primary-nav a {
  font-family: var(--serif); font-size: 13px; letter-spacing: 0.08em; color: var(--ink-soft);
  text-decoration: none; font-weight: 600;
}
.primary-nav a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
.primary-nav .download-utility {
  font-family: var(--sans); font-size: 13px; letter-spacing: 0.01em; font-weight: 700;
  color: var(--deep-brown); border: 1px solid var(--border-strong); background: rgba(251,246,235,0.7);
  padding: 7px 12px; border-radius: 999px; text-decoration: none;
}
.primary-nav .download-utility:hover { background: var(--ivory); text-decoration: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 28px; border-radius: 8px; border: 1px solid var(--border-strong);
  font-weight: 700; font-size: 0.95rem; letter-spacing: 0.04em; text-decoration: none; cursor: pointer;
  font-family: var(--sans); text-align: center;
}
.btn-primary { background: var(--deep-brown); color: var(--ivory); border-color: #241b13; }
.btn-primary:hover { background: #241b13; color: #fff; }
.btn-secondary { background: rgba(251,246,235,0.75); color: var(--ink); }
.btn-secondary:hover { background: var(--ivory); color: var(--ink); }

/* Hero */
.hero { padding: 72px 0 40px; border-bottom: 1px solid rgba(90,62,34,0.12); }
.hero-inner { max-width: 920px; margin: 0 auto; padding: 0 var(--page-gutter); text-align: center; }
.eyebrow, .section-kicker {
  margin: 0 0 10px; font-family: var(--serif); font-size: 12px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--bronze); font-weight: 700;
}
.hero h1 {
  margin: 0 0 16px; font-family: var(--serif); font-weight: 700; color: #1f1711;
  font-size: clamp(2.4rem, 4.2vw, 4rem); line-height: 1.05; letter-spacing: 0.01em;
}
.hero-subhead { margin: 0 0 14px; font-family: var(--serif); font-size: 1.45rem; line-height: 1.4; color: var(--ink-soft); }
.hero-lede { margin: 0 auto 24px; font-size: 1.08rem; color: var(--muted); max-width: 72ch; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* Timeline section */
.timeline-section { padding: 56px 0 32px; }
.timeline-intro { max-width: 760px; margin-inline: auto; margin-bottom: 20px; text-align: left; }
.timeline-intro h2 {
  margin: 0 0 10px; font-family: var(--serif); font-size: 2rem; color: #1f1711; letter-spacing: 0.02em;
}
.section-lede { margin: 0 0 10px; color: var(--muted); max-width: 72ch; font-size: 1.02rem; }
.approx-note { margin: 8px 0 0; color: var(--muted); font-size: 0.93rem; max-width: 80ch; }
.scroll-hint { margin: 12px 0 0; font-size: 0.85rem; color: var(--muted); font-style: italic; }

.atlas-frame {
  position: relative; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(251,246,235,0.88), rgba(244,234,216,0.94));
  box-shadow: var(--shadow); overflow: hidden;
}
.atlas-frame::before, .atlas-frame::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 36px; z-index: 5; pointer-events: none; opacity: 0;
  transition: opacity .2s ease;
}
.atlas-frame::before { left: 0; background: linear-gradient(90deg, rgba(244,234,216,0.95), rgba(244,234,216,0)); }
.atlas-frame::after { right: 0; background: linear-gradient(270deg, rgba(244,234,216,0.95), rgba(244,234,216,0)); }
.atlas-frame.can-scroll-left::before { opacity: 1; }
.atlas-frame.can-scroll-right::after { opacity: 1; }
.atlas-viewport {
  overflow-x: auto; overflow-y: visible; -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain; scroll-snap-type: x proximity; padding: 18px 16px 14px;
}
.atlas-viewport:focus { outline: none; }
.atlas-viewport:focus-visible { outline: 3px solid rgba(47,95,90,0.35); outline-offset: -3px; }

.atlas-track {
  position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: var(--col-w);
  grid-template-rows: auto auto var(--spine-h) auto; align-items: stretch; min-width: calc(var(--col-w) * 10);
}
.spine {
  grid-row: 3; grid-column: 1 / -1; align-self: center; height: 6px; position: relative; z-index: 1;
  background: linear-gradient(90deg, #8a6724 0%, #5a4a36 35%, #6b5a49 65%, #4a5f7a 100%);
  border-radius: 999px; box-shadow: inset 0 1px 0 rgba(251,246,235,0.25);
}
.spine::before, .spine::after { content: ""; position: absolute; top: 50%; transform: translateY(-50%); }
.spine::before {
  left: -2px; width: 10px; height: 10px; border-radius: 50%; background: #8a6724; border: 2px solid var(--ivory);
  box-shadow: 0 0 0 1px rgba(43,33,24,.2);
}
.spine::after {
  right: -8px; width: 0; height: 0;
  border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-left: 14px solid #4a5f7a;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,0.1));
}

/* Period column */
.period-col {
  display: contents;
}
.period-col > .cell { scroll-snap-align: start; }
.cell { padding: 10px 14px; position: relative; }
.layer-a { grid-row: 1; min-height: 138px; border-bottom: 1px dashed rgba(90,62,34,0.18); }
.layer-b { grid-row: 2; display: flex; align-items: center; justify-content: center; padding: 12px 14px; }
.layer-c { grid-row: 3; display: flex; align-items: center; justify-content: center; z-index: 3; padding: 0; }
.layer-d { grid-row: 4; border-top: 1px dashed rgba(90,62,34,0.18); padding-top: 12px; }

.layer-a .eyebrow-small, .books-label {
  margin: 0 0 6px; font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.tag-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 5px 6px; }
.tag {
  font-size: 12.5px; line-height: 1.25; color: var(--ink-soft); background: rgba(251,246,235,0.92);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 8px;
}
.tag.addl { background: rgba(95,111,82,0.12); border-color: rgba(95,111,82,0.38); color: #2f402b; }
.addl-label { margin: 8px 0 4px; font-size: 10.5px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: #3f5238; }
.disclosure-btn, .inline-toggle {
  appearance: none; border: 0; background: none; padding: 4px 0; margin-top: 4px;
  font: inherit; font-size: 12.5px; font-weight: 700; color: #5b4420; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.disclosure-btn:hover, .inline-toggle:hover { color: var(--ink); }

/* Illustration plate */
.figure-plate {
  width: 100%; max-width: 332px; margin: 0; position: relative;
  border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden;
  background: linear-gradient(180deg, #efe4ce, #e7dac0);
  box-shadow: inset 0 0 0 1px rgba(251,246,235,0.35);
  padding: 8px;
  display: flex; align-items: center; justify-content: center;
}
.figure-plate img {
  width: auto; max-width: 100%; height: 520px; max-height: 520px;
  object-fit: contain; display: block;
}

.marker-btn {
  appearance: none; width: 20px; height: 20px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 2px solid var(--ivory); background: var(--period-color, var(--gold));
  box-shadow: 0 0 0 1px rgba(43,33,24,0.25), 0 2px 4px rgba(0,0,0,0.12);
}
.marker-btn:hover { transform: scale(1.1); }
.marker-btn[aria-pressed="true"], .period-col.is-active .marker-btn {
  width: 28px; height: 28px; box-shadow: 0 0 0 2px var(--ivory), 0 0 0 4px var(--period-color, var(--gold)), 0 3px 8px rgba(0,0,0,0.18);
}

.period-date { margin: 0 0 4px; font-size: 0.88rem; font-weight: 700; color: var(--period-color, var(--bronze)); }
.period-title { margin: 0 0 6px; font-family: var(--serif); font-size: 1.18rem; line-height: 1.2; color: var(--ink); }
.period-desc { margin: 0 0 8px; font-size: 0.9rem; color: var(--muted); line-height: 1.45; }
.period-select {
  appearance: none; border: 1px solid transparent; background: none; padding: 0; margin: 0; font: inherit; color: inherit;
  text-align: left; cursor: pointer; width: 100%; border-radius: 6px;
}
.period-select:hover .period-title { color: #1f1711; }

.period-col.is-active .layer-a,
.period-col.is-active .layer-d { background: rgba(251,246,235,0.55); }
.period-col.is-active .layer-b .figure-plate { box-shadow: 0 0 0 2px rgba(251,246,235,0.8), 0 0 0 4px var(--period-color, var(--gold)); }

/* Detail panel (desktop persistent) */
.detail-panel { margin-top: 18px; }
.detail-inner {
  border: 1px solid var(--border-strong); border-radius: 10px; background: rgba(251,246,235,0.9);
  padding: 20px 22px; box-shadow: 0 4px 14px rgba(43,33,24,0.04);
}
.detail-empty { margin: 0; color: var(--muted); font-style: italic; }
.detail-grid { display: grid; grid-template-columns: minmax(320px, 1.1fr) minmax(320px, 1fr); gap: 22px 40px; align-items: start; }
.detail-date { margin: 0 0 4px; font-weight: 700; color: var(--period-color, var(--bronze)); }
.detail-inner h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 1.6rem; color: #1f1711; }
.detail-context { margin: 0 0 10px; color: var(--ink-soft); }
.detail-caveat { margin: 0 0 14px; font-size: 0.9rem; color: var(--muted); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.detail-actions .btn { min-height: 42px; padding: 0 18px; font-size: 0.9rem; letter-spacing: 0.02em; }
.detail-block-title { margin: 0 0 8px; font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.detail-block-title.addl { color: #3f5238; margin-top: 14px; }
.detail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 8px; }
.detail-list li {
  font-size: 0.92rem; font-weight: 600; color: var(--ink-soft); background: #f8f1e3;
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 10px;
}
.detail-list li.addl { background: rgba(95,111,82,0.13); border-color: rgba(95,111,82,0.38); color: #2f402b; }

/* Mobile inline expansion */
.inline-detail { display: none; }

/* About & closing */
.about-section { padding: 72px 0 40px; }
.about-section h2, .closing-section h2 {
  margin: 0 0 14px; font-family: var(--serif); font-size: 2rem; color: #1f1711; line-height: 1.15;
}
.about-section p { margin: 0 0 14px; color: var(--ink-soft); font-size: 1.02rem; }
.closing-section { padding: 72px 0 56px; border-top: 1px solid rgba(90,62,34,0.12); }
.closing-inner { text-align: center; max-width: 960px; margin: 0 auto; }
.closing-subhead { margin: 0 0 22px; font-family: var(--serif); font-size: 1.25rem; color: var(--ink-soft); }
.closing-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.site-footer { border-top: 1px solid var(--rule); padding: 22px 0 28px; }
.footer-inner { max-width: none; margin: 0; padding: 0 var(--page-gutter); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 10px; }
.site-footer nav a { color: var(--ink-soft); font-weight: 600; text-decoration: none; font-size: 0.95rem; }
.site-footer nav a:hover { color: var(--ink); text-decoration: underline; }
.site-footer p { margin: 0; color: var(--muted); font-size: 0.92rem; }

/* Mobile vertical journey */
@media (max-width: 900px) {
  :root { --page-gutter: 16px; }
  .section-inner, .hero-inner, .masthead, .footer-inner { padding-left: 16px; padding-right: 16px; }
  .masthead { grid-template-columns: 1fr; justify-items: start; gap: 8px; padding-top: 10px; padding-bottom: 10px; min-height: 0; }
  .story-mark { justify-self: start; font-size: 12px; }
  .primary-nav { justify-content: flex-start; gap: 8px 12px; }
  .hero { padding: 44px 0 28px; }
  .hero h1 { font-size: clamp(2rem, 9vw, 2.4rem); }
  .hero-subhead { font-size: 1.2rem; }
  .timeline-section { padding: 40px 0 24px; }
  .timeline-intro h2 { font-size: 1.65rem; }
  .scroll-hint { display: none; }
  .atlas-frame { border-radius: 10px; }
  .atlas-frame::before, .atlas-frame::after { display: none; }
  .atlas-viewport { overflow: visible; padding: 8px 8px 4px; scroll-snap-type: none; }
  .atlas-track { display: block; min-width: 0; }
  .spine { display: none; }

  .period-col {
    display: grid;
    grid-template-columns: 40px 1fr;
    grid-template-areas:
      "marker books"
      "marker image"
      "marker meta"
      "marker detail";
    column-gap: 10px;
    padding: 18px 8px 18px 2px;
    border-bottom: 1px solid var(--border);
    position: relative;
  }
  .period-col::before {
    content: ""; position: absolute; left: 20px; top: 0; bottom: 0; width: 4px;
    background: linear-gradient(180deg, #8a6724 0%, #5a4a36 35%, #6b5a49 65%, #4a5f7a 100%);
    border-radius: 999px; z-index: 0;
  }
  .atlas-track .period-col:first-of-type::before { top: 28px; }
  .atlas-track .period-col:last-of-type { border-bottom: 0; }
  .atlas-track .period-col:last-of-type::before { bottom: calc(100% - 28px); }
  .cell { padding: 0; border: 0 !important; min-height: 0; background: none !important; }
  .layer-c { grid-area: marker; align-items: flex-start; justify-content: center; padding-top: 2px; z-index: 2; }
  .layer-a { grid-area: books; padding-bottom: 8px; }
  .layer-b { grid-area: image; padding: 4px 0 10px; justify-content: flex-start; }
  .layer-d { grid-area: meta; padding-bottom: 6px; }
  .inline-detail { display: block; grid-area: detail; }
  .inline-detail[hidden] { display: none; }
  .figure-plate { max-width: 100%; width: 100%; padding: 6px; }
  .figure-plate img { width: 100%; height: auto; max-height: min(72vh, 640px); }
  .marker-btn { width: 20px; height: 20px; }
  .marker-btn[aria-pressed="true"], .period-col.is-active .marker-btn { width: 26px; height: 26px; }
  .detail-panel { display: none; }
  .inline-detail .detail-inner { margin-top: 10px; padding: 14px 14px; }
  .detail-grid { grid-template-columns: 1fr; gap: 12px; }
  .about-section { padding: 48px 0 28px; }
  .closing-section { padding: 48px 0 40px; }
  .about-section h2, .closing-section h2 { font-size: 1.7rem; }
}
