/* Civilization Readers — styles */

:root {
  --ink: #1f2430;
  --ink-soft: #4b5563;
  --ink-faint: #8a94a6;
  --paper: #ffffff;
  --paper-2: #f6f7f9;
  --line: #e6e8ee;
  --line-strong: #d4d8e0;
  --accent: #0f6ab4;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, #ffffff);
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-md: 0 10px 30px -12px rgba(16, 24, 40, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, #fbfbfd 0%, #f4f5f8 100%);
  line-height: 1.55;
  font-size: 17px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */
.civ-header {
  padding: 28px 0 18px;
}
.civ-header .crumbs {
  font-size: 13.5px;
  color: var(--ink-faint);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.civ-header .crumbs a { color: var(--ink-faint); }
.civ-header .crumbs a:hover { color: var(--accent); }
.civ-header h1 {
  margin: 0 0 6px;
  font-size: clamp(1.9rem, 5vw, 2.7rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 14px;
}
.civ-header h1 .flag { font-size: 1.1em; }
.civ-header .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 10px 0 4px;
  color: var(--ink-soft);
  font-size: 15px;
}
.civ-header .meta .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  color: var(--ink-soft);
}
.civ-header .meta .chip.span { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); font-weight: 600; }
.civ-header .tagline {
  margin: 12px 0 0;
  font-size: 1.05rem;
  color: var(--ink-soft);
  max-width: 60ch;
}

/* ---------- hero / landing ---------- */
.hero { padding: 44px 0 10px; }
.hero .kicker {
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 10px;
}
.hero h1 {
  font-size: clamp(2rem, 6vw, 3.1rem);
  margin: 0 0 14px;
  letter-spacing: -0.03em;
  line-height: 1.08;
}
.hero p.lede {
  font-size: 1.12rem;
  color: var(--ink-soft);
  max-width: 62ch;
  margin: 0 0 8px;
}
.hero p.lede strong { color: var(--ink); }
.hero .how {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.hero .how .step {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 13.5px;
  color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
}
.hero .how .step b { color: var(--ink); }

.group-head {
  margin: 40px 0 14px;
  font-size: 15px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 700;
}

/* ---------- search ---------- */
.search-wrap { margin-top: 22px; max-width: 560px; }
.search-wrap input {
  width: 100%;
  padding: 13px 18px;
  font-size: 16px;
  font-family: var(--font);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}
.search-wrap input::placeholder { color: var(--ink-faint); }
.search-wrap input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.no-results {
  display: none;
  color: var(--ink-faint);
  margin: 18px 0;
  font-size: 15px;
}

/* ---------- master timeline ---------- */
.mt-panel { margin-top: 26px; }
.mt-group {
  font-size: 11.5px;
  font-weight: 800;
  fill: var(--ink-faint);
  letter-spacing: .06em;
}
.mt-name { font-size: 12.5px; fill: var(--ink-soft); }
.mt-tick { font-size: 10.5px; fill: var(--ink-faint); }
.mt-bar { cursor: pointer; transition: fill-opacity .12s ease; }
.mt-bar:hover { fill-opacity: 1; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding-bottom: 30px;
}
.card {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  position: relative;
  overflow: hidden;
}
.card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}
.card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--c, var(--accent));
}
.card .card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.card .card-emoji {
  font-size: 1.7rem;
  line-height: 1;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: var(--c-soft, var(--accent-soft));
  border-radius: 12px;
}
.card h2 {
  margin: 0;
  font-size: 1.18rem;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--ink);
}
.card .card-span {
  font-size: 12.5px;
  color: var(--ink-faint);
  font-weight: 600;
  letter-spacing: .02em;
}
.card .card-region {
  font-size: 13px;
  color: var(--ink-faint);
  margin: 2px 0 10px;
}
.card p {
  margin: 0 0 14px;
  font-size: 14.5px;
  color: var(--ink-soft);
  flex: 1;
}
.card .card-go {
  font-weight: 600;
  font-size: 14px;
  color: var(--c, var(--accent));
}

/* ---------- timeline ---------- */
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin: 18px 0;
}
.panel .panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.panel .panel-head h2 {
  margin: 0;
  font-size: 1.02rem;
  letter-spacing: .01em;
}
.panel .panel-head .hint {
  font-size: 12.5px;
  color: var(--ink-faint);
}
.panel .panel-body { padding: 14px 18px 16px; }

.tl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tl-scroll svg { display: block; min-width: 860px; }
.tl-svg text { font-family: var(--font); }
.tl-era-label { font-size: 13px; font-weight: 700; fill: var(--accent); }
.tl-era-years { font-size: 10.5px; fill: var(--ink-soft); }
.tl-ev-label { font-size: 11.5px; fill: var(--ink-soft); }
.tl-year { font-size: 11px; fill: var(--ink-faint); }
.tl-dot { cursor: pointer; transition: r .1s ease; }
.tl-dot:hover { r: 7; }

.tl-detail {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--paper-2);
  min-height: 58px;
}
.tl-detail .tl-detail-title {
  margin: 0 0 3px;
  font-size: 14.5px;
  font-weight: 700;
}
.tl-detail .tl-detail-year {
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: .03em;
}
.tl-detail p { margin: 4px 0 0; font-size: 14.5px; color: var(--ink-soft); }

.world-band-label { font-size: 12px; font-weight: 700; fill: var(--ink-soft); }
.world-anchor-label { font-size: 10.5px; fill: var(--ink-faint); }

/* ---------- context grid ---------- */
.ctx-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (max-width: 720px) { .ctx-grid { grid-template-columns: 1fr; } }
.ctx-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.ctx-card h3 {
  margin: 0 0 10px;
  font-size: .95rem;
  letter-spacing: .01em;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}
.ctx-card p { margin: 0; font-size: 14.5px; color: var(--ink-soft); }
.ctx-card ul { margin: 0; padding: 0; list-style: none; }
.ctx-card li {
  font-size: 14.5px;
  color: var(--ink-soft);
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
}
.ctx-card li:last-child { border-bottom: none; }
.ctx-card li b { color: var(--ink); font-weight: 600; }

/* ---------- detail (accordion) ---------- */
details.period {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 10px;
  background: var(--paper);
  overflow: hidden;
}
details.period[open] { border-color: var(--accent-soft); box-shadow: var(--shadow-sm); }
details.period summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  font-weight: 600;
  font-size: 15.5px;
}
details.period summary::-webkit-details-marker { display: none; }
details.period summary .p-name { flex: 1; }
details.period summary .p-years {
  font-size: 12.5px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
details.period summary .p-summary {
  font-weight: 400;
  font-size: 13px;
  color: var(--ink-faint);
  display: none;
}
@media (min-width: 640px) { details.period summary .p-summary { display: inline; } }
details.period summary .chev { color: var(--ink-faint); transition: transform .15s ease; }
details.period[open] summary .chev { transform: rotate(180deg); }
details.period .p-body {
  padding: 2px 16px 14px;
  font-size: 14.5px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
details.period .p-body .p-summary-mobile {
  font-weight: 600;
  color: var(--ink);
  font-size: 14.5px;
  margin-bottom: 6px;
}

/* key dates list */
.dates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
  margin-top: 4px;
}
.date-row {
  display: flex;
  gap: 10px;
  font-size: 13.5px;
  padding: 7px 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.date-row .d-year {
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  min-width: 74px;
}
.date-row .d-text { color: var(--ink-soft); }

/* ---------- museum cheat sheet ---------- */
.museum {
  background: linear-gradient(180deg, var(--accent-soft), var(--paper) 160px);
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin: 22px 0;
}
.museum h2 {
  margin: 0 0 4px;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.museum .m-sub { margin: 0 0 16px; color: var(--ink-soft); font-size: 14.5px; }
.museum .m-cols {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
}
@media (max-width: 820px) { .museum .m-cols { grid-template-columns: 1fr; gap: 14px; } }
.museum h3 {
  margin: 0 0 8px;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
}
.museum ul { margin: 0; padding-left: 18px; }
.museum li { font-size: 14px; color: var(--ink-soft); margin: 5px 0; }
.museum li b { color: var(--ink); font-weight: 600; }

/* ---------- prev / next ---------- */
.pager {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: stretch;
  margin: 26px 0 40px;
}
.pager a.pager-link {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.pager a.pager-link:hover { text-decoration: none; border-color: var(--line-strong); }
.pager a.next { text-align: right; }
.pager .pager-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); font-weight: 700; }
.pager .pager-name { font-weight: 700; font-size: 15px; }
.pager .pager-all {
  display: flex;
  align-items: center;
  font-size: 13.5px;
  color: var(--ink-faint);
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- footer ---------- */
.foot {
  padding: 26px 0 46px;
  color: var(--ink-faint);
  font-size: 13.5px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
}
.foot a { color: var(--ink-soft); }

/* section heading for context/detail */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 30px 0 4px;
}
.section-title h2 { margin: 0; font-size: 1.35rem; letter-spacing: -0.01em; }
.section-title .sub { color: var(--ink-faint); font-size: 14px; margin-top: 2px; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .hero { padding-top: 26px; }
}

/* ---------- route page (Met) ---------- */
.route-links {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.route-btn {
  display: inline-block;
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 14.5px;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.route-btn:hover { text-decoration: none; filter: brightness(1.06); }
.route-btn.subtle {
  background: var(--paper);
  color: var(--accent);
  border: 1px solid var(--accent-soft);
}
.route-note {
  color: var(--ink-soft);
  font-size: 14.5px;
  margin: -26px 0 14px;
}
.route-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  padding-bottom: 10px;
}
.route-area {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 17px;
  box-shadow: var(--shadow-sm);
}
.route-area-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.route-area-name {
  font-weight: 700;
  font-size: 15.5px;
  color: var(--ink);
}
.route-area-gal {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: .02em;
  white-space: nowrap;
}
.route-area-note {
  margin: 6px 0 12px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.route-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.route-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: var(--c-soft, var(--accent-soft));
  border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 35%, transparent);
  text-decoration: none;
}
.route-pill:hover {
  text-decoration: none;
  border-color: var(--c, var(--accent));
}

/* ---------- museum blocks & cards ---------- */
.museum-block {
  margin: 26px 0;
  padding: 18px 20px 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.museum-block-head { display: flex; align-items: center; gap: 12px; }
.museum-block-emoji {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  font-size: 1.6rem;
  background: var(--accent-soft);
  border-radius: 12px;
}
.museum-block-head h2 { margin: 0; font-size: 1.3rem; }
.museum-block-city { font-size: 13px; color: var(--ink-faint); font-weight: 600; }
.museum-block-tag { margin: 10px 0 0; font-size: 15px; color: var(--ink-soft); }
.museum-block-note { margin: 6px 0 0; font-size: 13.5px; color: var(--accent); }
.museum-floor {
  margin: 22px 0 4px;
  font-size: .92rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-faint);
}

.museum-card {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.museum-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}
.museum-card-top { display: flex; align-items: center; gap: 10px; }
.museum-card-emoji { font-size: 1.5rem; line-height: 1; }
.museum-card h3 { margin: 0; font-size: 1.1rem; color: var(--ink); }
.museum-card-city { font-size: 12.5px; color: var(--ink-faint); margin: 3px 0 8px; font-weight: 600; }
.museum-card p { margin: 0 0 12px; font-size: 14px; color: var(--ink-soft); flex: 1; }
.museum-card-meta { font-size: 12.5px; color: var(--ink-faint); margin-bottom: 8px; }
.museum-card .card-go { font-weight: 600; font-size: 14px; color: var(--accent); }

/* ---------- graph ---------- */
.graph-panel { margin-top: 22px; }
.graph-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  margin-bottom: 10px;
}
.graph-legend { display: flex; flex-wrap: wrap; gap: 12px; }
.graph-legend .lg { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-soft); }
.graph-legend .lg-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.graph-legend .lg-line { width: 18px; height: 2px; border-radius: 2px; display: inline-block; }
.graph-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filt-chip {
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink-soft);
  font: 600 12px/1 var(--font);
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: all .12s;
}
.filt-chip:hover { border-color: var(--accent); color: var(--accent); }
.filt-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.filt-sep { width: 8px; }

.graph-stage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-2);
  overflow: hidden;
  height: 70vh;
  min-height: 420px;
}
.graph-stage svg.graph-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  transition: transform .05s linear;
}
.graph-stage svg.graph-svg:active { cursor: grabbing; }
.g-node { cursor: pointer; }
.g-label { pointer-events: none; font-size: 11px; fill: var(--ink-soft); }
.g-label-museum { font-size: 13px; font-weight: 700; fill: var(--ink); }
.g-label-civ { font-size: 10px; }

.graph-info {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: 320px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow-md);
  font-size: 14px;
  color: var(--ink-soft);
  display: none;
}
.graph-info.active { display: block; }
.graph-info-title { font-weight: 700; color: var(--ink); font-size: 15px; }
.graph-info-type { font-size: 12.5px; color: var(--ink-faint); margin: 2px 0 8px; }
.graph-info .route-btn { padding: 7px 14px; font-size: 13px; }
.graph-info-hint { margin: 0; }

/* ---------- timeline SVG strokes (theme-aware) ---------- */
.tl-axis { stroke: #d4d8e0; }
.world-anchor { fill: #9aa3b2; }
.mt-grid { stroke: #eceef2; }
.mt-grid.major { stroke: #c9ced8; }

/* ---------- quick read (30 seconds) ---------- */
.quick {
  margin: 6px 0 4px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
}
.quick .quick-head {
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ---------- listen (text-to-speech) ---------- */
.listen-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 5px 13px 5px 10px;
  font: inherit;
  font-size: .74rem;
  letter-spacing: .06em;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft, rgba(0, 0, 0, .05));
  border: 1px solid var(--accent);
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.listen-btn:hover { background: var(--accent); color: #fff; }
.listen-btn.is-speaking { background: var(--accent); color: #fff; }
.listen-btn .listen-icon { font-size: .7em; line-height: 1; }
.listen-btn.is-speaking .listen-icon { animation: listen-pulse 1.1s ease-in-out infinite; }
@keyframes listen-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (pointer: coarse) { .listen-btn { min-height: 40px; padding: 6px 16px 6px 13px; } }
@media (prefers-reduced-motion: reduce) { .listen-btn.is-speaking .listen-icon { animation: none; } }
@media print { .listen-btn { display: none; } }
.quick ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 20px;
}
@media (max-width: 640px) { .quick ul { grid-template-columns: 1fr; } }
.quick li { position: relative; padding-left: 16px; font-size: 14.5px; color: var(--ink-soft); }
.quick li::before { content: "•"; position: absolute; left: 2px; color: var(--accent); font-weight: 700; }

/* ---------- At the Met ---------- */
.met-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0 4px;
  padding: 12px 16px;
  border: 1px solid var(--accent-soft);
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 10px;
  color: var(--ink-soft);
  font-size: 14.5px;
  text-decoration: none;
}
.met-line:hover { text-decoration: none; border-color: var(--accent); }
.met-line b { color: var(--ink); }
.met-line .met-pin { font-size: 1.1rem; line-height: 1.3; }

/* ---------- theme toggle ---------- */
.theme-toggle {
  position: fixed;
  top: 12px;
  right: 14px;
  z-index: 60;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  display: grid;
  place-items: center;
  transition: transform .12s ease;
}
.theme-toggle:hover { transform: scale(1.06); }

/* ---------- dark / low-light mode ---------- */
html[data-theme="dark"] {
  --ink: #e7eaf0;
  --ink-soft: #a9b1c0;
  --ink-faint: #7c8698;
  --paper: #181c24;
  --paper-2: #1f2430;
  --line: #2a3140;
  --line-strong: #3a4254;
  --accent-soft: color-mix(in srgb, var(--accent) 24%, #181c24);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, .6);
}
html[data-theme="dark"] body {
  background: linear-gradient(180deg, #10131a 0%, #0c0e14 100%);
}
html[data-theme="dark"] .tl-axis { stroke: #2f3644; }
html[data-theme="dark"] .world-anchor { fill: #66707f; }
html[data-theme="dark"] .mt-grid { stroke: #232834; }
html[data-theme="dark"] .mt-grid.major { stroke: #303848; }
html[data-theme="dark"] .tl-dot { stroke: #181c24; }

/* ===========================================================================
 * MOBILE-FIRST ADDITIONS
 * This guide is used one-handed, standing up, in a dim gallery, often with
 * no signal. Everything below optimises for that: 44px tap targets, no
 * hover-only affordances, safe-area padding, and readable type at arm's length.
 * ========================================================================= */

:root {
  --nav-h: 58px;
  --tap: 44px;
}

/* Never let a long word or a wide table force a horizontal page scroll. */
html, body { overflow-x: hidden; }
img, svg { max-width: 100%; }

/* ---------- bottom tab bar (phones) / top bar (desktop) ---------- */
.site-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 70;
  display: flex;
  background: var(--paper);
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 16px -8px rgba(16, 24, 40, .22);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.site-nav .nav-item {
  flex: 1;
  min-height: var(--nav-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 2px;
  color: var(--ink-faint);
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .01em;
  -webkit-tap-highlight-color: transparent;
}
.site-nav .nav-item:hover { text-decoration: none; color: var(--accent); }
.site-nav .nav-item.on { color: var(--accent); }
.site-nav .nav-ico { font-size: 19px; line-height: 1; }
.site-nav .nav-item.on .nav-ico { transform: translateY(-1px); }
body.has-nav { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 8px); }

@media (min-width: 861px) {
  .site-nav {
    top: 0; bottom: auto;
    border-top: 0;
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    justify-content: center;
    gap: 4px;
    padding: 6px 12px;
    backdrop-filter: saturate(1.4) blur(8px);
  }
  .site-nav .nav-item {
    flex: 0 0 auto;
    flex-direction: row;
    gap: 7px;
    min-height: 38px;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 14px;
  }
  .site-nav .nav-item.on { background: var(--accent-soft); }
  .site-nav .nav-ico { font-size: 16px; }
  body.has-nav { padding-bottom: 0; padding-top: 58px; }
  .theme-toggle { top: 62px; }
}

/* ---------- back to top ---------- */
.to-top {
  position: fixed;
  right: 14px;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 14px);
  z-index: 65;
  width: var(--tap); height: var(--tap);
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.to-top.show { opacity: 1; pointer-events: auto; }
@media (min-width: 861px) { .to-top { bottom: 20px; } }

/* ---------- stat strip ---------- */
.stat-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 4px 0 18px;
  font-size: 13px;
  color: var(--ink-faint);
}
.stat-strip b { color: var(--ink); font-size: 15px; }
.stat-strip .offline-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
}
.stat-strip .offline-pill::before { content: "●"; font-size: 8px; }

/* ---------- in-page jump links (reader) ---------- */
.jump {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 12px 0 4px;
  margin: 8px -20px 0;
  padding-inline: 20px;
  scroll-snap-type: x proximity;
}
.jump::-webkit-scrollbar { display: none; }
.jump a {
  flex: 0 0 auto;
  scroll-snap-align: start;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.jump a:hover, .jump a:focus-visible {
  text-decoration: none;
  border-color: var(--accent);
  color: var(--accent);
}

/* Anchored sections shouldn't land flush against the top of the viewport.
   On phones the nav sits at the *bottom*, so a small breathing gap is enough;
   on desktop the bar is overhead and the offset has to clear it. */
[id^="sec-"], .museum-block, .route-area, .tour, .mp-card { scroll-margin-top: 14px; }
@media (min-width: 861px) {
  [id^="sec-"], .museum-block, .route-area, .tour, .mp-card { scroll-margin-top: 74px; }
}

/* ---------- masterpiece cards ---------- */
.mp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin: 8px 0 24px;
}
.mp-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--c, var(--accent));
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  margin: 10px 0 22px;
}
.mp-head { display: flex; gap: 13px; align-items: flex-start; }
.mp-emoji {
  font-size: 1.9rem;
  line-height: 1;
  flex: 0 0 auto;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--c-soft, var(--accent-soft));
}
.mp-titles { min-width: 0; }
.mp-titles h3 { margin: 0 0 3px; font-size: 1.2rem; letter-spacing: -0.01em; }
.mp-meta { font-size: 12.5px; color: var(--ink-faint); font-weight: 600; }
.mp-where { font-size: 12.5px; color: var(--c, var(--accent)); font-weight: 700; margin-top: 3px; }
.mp-hook {
  margin: 14px 0 10px;
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.42;
  color: var(--ink);
}
.mp-read { margin: 0 0 14px; font-size: 15px; color: var(--ink-soft); }
.mp-look {
  background: var(--paper-2);
  border-radius: 10px;
  padding: 12px 15px 12px 14px;
}
.mp-look h4 {
  margin: 0 0 7px;
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c, var(--accent));
}
.mp-look ul { margin: 0; padding-left: 17px; }
.mp-look li { font-size: 14px; color: var(--ink-soft); margin: 5px 0; }
.mp-more {
  display: inline-block;
  margin-top: 13px;
  font-size: 14px;
  font-weight: 700;
  color: var(--c, var(--accent));
}

/* ---------- where to see it (reader) ---------- */
.where-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
  margin: 10px 0 6px;
}
.where-card {
  display: block;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 15px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  min-height: var(--tap);
}
.where-card:hover { text-decoration: none; border-color: var(--accent); }
.where-museum { font-size: 12.5px; color: var(--ink-faint); font-weight: 700; }
.where-area { font-weight: 700; font-size: 15px; margin: 2px 0 1px; }
.where-gal { font-size: 13px; color: var(--accent); font-weight: 600; }

/* ---------- related civilizations (reader) ---------- */
.rel-list { display: grid; gap: 8px; margin: 10px 0 6px; }
.rel-row {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 4px 12px;
  align-items: baseline;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 15px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
}
.rel-row:hover { text-decoration: none; border-color: var(--c, var(--accent)); }
.rel-type {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-faint);
  white-space: nowrap;
}
.rel-trade { color: #0284c7; }
.rel-script { color: #db2777; }
.rel-conquest { color: #dc2626; }
.rel-religion { color: #7c3aed; }
.rel-influenced { color: #b45309; }
.rel-name { font-weight: 700; font-size: 15px; }
.rel-note { grid-column: 2; font-size: 13.5px; color: var(--ink-soft); }
@media (max-width: 560px) {
  .rel-row { grid-template-columns: 1fr; }
  .rel-note { grid-column: 1; }
}

/* ---------- tours ---------- */
.tour-cards {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 4px 0 16px;
  scroll-snap-type: x proximity;
}
.tour-cards::-webkit-scrollbar { display: none; }
.tour-card {
  flex: 0 0 auto;
  scroll-snap-align: start;
  min-width: 210px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
}
.tour-card:hover { text-decoration: none; border-color: var(--accent); }
.tour-card-top { font-size: 15px; }
.tour-card-meta { font-size: 12.5px; color: var(--ink-faint); margin-top: 3px; font-weight: 600; }

.tour {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px 22px;
  margin: 22px 0;
  box-shadow: var(--shadow-sm);
}
.tour-head { display: flex; gap: 13px; align-items: center; }
.tour-emoji {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  font-size: 1.6rem;
  background: var(--accent-soft);
  border-radius: 12px;
  flex: 0 0 auto;
}
.tour-head h2 { margin: 0; font-size: 1.3rem; letter-spacing: -0.01em; }
.tour-sub { font-size: 12.5px; color: var(--ink-faint); font-weight: 600; margin-top: 2px; }
.tour-blurb { margin: 14px 0 4px; font-size: 15px; color: var(--ink-soft); }

.tour-stops { list-style: none; margin: 16px 0 0; padding: 0; }
.tour-stop {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}
.tour-stop-rail { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.tour-num {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
}
.tour-clock { font-size: 11px; color: var(--ink-faint); font-weight: 700; white-space: nowrap; }
.tour-stop-body h3 { margin: 2px 0 3px; font-size: 1.05rem; }
.tour-gal { font-size: 12.5px; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.tour-what { margin: 0 0 7px; font-size: 14.5px; color: var(--ink-soft); }
.tour-why { margin: 0 0 9px; font-size: 14px; color: var(--ink-soft); }
.tour-why b { color: var(--ink); }
.tour-time {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 9px;
}
.tour-tips {
  margin-top: 18px;
  background: var(--paper-2);
  border-radius: 10px;
  padding: 13px 16px;
}
.tour-tips h4 {
  margin: 0 0 7px;
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
}
.tour-tips ul { margin: 0; padding-left: 17px; }
.tour-tips li { font-size: 14px; color: var(--ink-soft); margin: 5px 0; }
.tour .route-btn.subtle { margin-top: 16px; }
@media (max-width: 560px) {
  .tour { padding: 16px 15px 18px; }
  .tour-stop { grid-template-columns: 44px 1fr; gap: 10px; }
  .tour-num { width: 27px; height: 27px; font-size: 13px; }
}

/* ---------- guide: how-to, glossary, resources ---------- */
.howto { margin: 0; padding-left: 20px; }
.howto li { font-size: 15px; color: var(--ink-soft); margin: 10px 0; }
.howto li b { color: var(--ink); }

.gloss-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  margin: 12px 0 6px;
}
.gloss {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 15px;
  box-shadow: var(--shadow-sm);
}
.gloss b { display: block; font-size: 15px; color: var(--ink); }
.gloss span { display: block; font-size: 14px; color: var(--ink-soft); margin-top: 3px; }
.gloss-civs { display: flex !important; flex-wrap: wrap; gap: 4px 10px; margin-top: 7px !important; }
.gloss-civs a { font-size: 12.5px; font-weight: 600; }

.res-group {
  margin: 26px 0 8px;
  font-size: .92rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-faint);
}
.res-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.res-card {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  min-height: var(--tap);
}
.res-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.res-name { font-weight: 700; font-size: 15px; color: var(--accent); }
.res-card p { margin: 6px 0 10px; font-size: 14px; color: var(--ink-soft); flex: 1; }
.res-host { font-size: 12px; color: var(--ink-faint); font-weight: 600; }
.src-note { font-size: 14.5px; color: var(--ink-soft); margin: 0 0 12px; }
.src-note code {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 13px;
}

/* ---------- graph: time slider & touch affordances ---------- */
.graph-timeslider {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 10px;
  padding: 10px 13px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.graph-timeslider label {
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-faint);
}
.graph-timeslider input[type="range"] {
  flex: 1 1 200px;
  min-width: 150px;
  accent-color: var(--accent);
  height: 28px;
}
.graph-timeslider output {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--accent);
  min-width: 88px;
  text-align: right;
}
.time-btn {
  min-width: var(--tap);
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: 700 14px/1 var(--font);
  cursor: pointer;
  padding: 0 14px;
}
.time-btn.subtle { background: var(--paper); color: var(--accent); }

.graph-stage { touch-action: none; }
.g-node:focus-visible .g-circle { stroke: var(--accent); stroke-width: 3; outline: none; }
.g-node.faded { opacity: .12; }
.g-node.focused .g-circle { stroke: var(--accent); stroke-width: 3; }
.g-node.out-of-time { opacity: .1; }
.g-edge { transition: opacity .12s ease; }
.g-edge.faded { opacity: .05; }
.g-edge.lit { opacity: .95; stroke-width: 2.6; }
.g-edge.out-of-time { opacity: .06; }

.graph-info {
  max-width: min(340px, calc(100% - 24px));
  padding-right: 34px;
}
.graph-info-close {
  position: absolute;
  top: 6px; right: 6px;
  width: 30px; height: 30px;
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
}
.graph-info-close:hover { background: var(--paper-2); color: var(--ink); }
.graph-info-links { margin: 0 0 10px; padding-left: 16px; }
.graph-info-links li { font-size: 12.5px; color: var(--ink-soft); margin: 4px 0; }
.graph-info-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.graph-hint {
  position: absolute;
  left: 12px; top: 12px;
  font-size: 12px;
  color: var(--ink-faint);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  pointer-events: none;
  transition: opacity .3s ease;
}
.graph-hint.gone { opacity: 0; }

/* ===========================================================================
 * PHONE LAYOUT
 * ========================================================================= */
@media (max-width: 860px) {
  .wrap { padding: 0 16px; }
  .graph-stage { height: 62vh; min-height: 340px; }
  .graph-toolbar { gap: 8px 12px; }
  .graph-legend { gap: 8px; font-size: 11.5px; }
  .graph-filters {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  .graph-filters::-webkit-scrollbar { display: none; }
  .filt-chip { flex: 0 0 auto; padding: 8px 13px; font-size: 12.5px; }
  .graph-info { left: 8px; right: 8px; bottom: 8px; max-width: none; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .hero h1 { font-size: clamp(1.65rem, 7.6vw, 2.2rem); }
  .lede { font-size: 16px; }
  .mp-grid, .res-grid, .gloss-grid, .where-grid { grid-template-columns: 1fr; }
  .mp-card { padding: 15px 16px; }
  .mp-hook { font-size: 15.5px; }
  .route-btn { padding: 12px 18px; }         /* keep buttons thumb-sized */
  .filt-chip, .jump a { min-height: 38px; display: inline-flex; align-items: center; }
  .section-title { margin-top: 26px; }
  .museum-block { padding: 15px 15px 6px; }
  .route-grid { grid-template-columns: 1fr; }
  .route-area { padding: 13px 14px; }
  .route-pill { padding: 8px 13px; font-size: 13.5px; }   /* was too small to tap */
  .pager { grid-template-columns: 1fr; gap: 8px; }
  .pager a.next { text-align: left; }
  .pager .pager-all { justify-content: center; padding: 6px 0; }
  .stat-strip { gap: 6px 14px; font-size: 12.5px; }
  .graph-timeslider { gap: 8px; padding: 9px 11px; }
  .graph-timeslider output { min-width: 74px; font-size: 12.5px; }
  details.period summary { padding: 13px 14px; }
  .quick { padding: 13px 15px; }
  .quick li { font-size: 15px; }
  .civ-header h1 { gap: 10px; }
  .tl-scroll { margin: 0 -16px; padding: 0 16px; }
}

/* The SVG timelines are the one thing that genuinely needs a wide viewport —
   give them a proper horizontal scroller with a visible hint on phones. */
@media (max-width: 860px) {
  .tl-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  .tl-scroll > svg { min-width: 760px; }
  .mt-panel .tl-scroll > svg { min-width: 880px; }
  .panel-head .hint { font-size: 12px; }
}

/* Bigger hit areas everywhere touch is the primary input. */
@media (pointer: coarse) {
  a, button, summary, .filt-chip, .route-pill, .nav-item { -webkit-tap-highlight-color: rgba(0, 0, 0, .04); }
  details.period summary { min-height: var(--tap); }
  .theme-toggle { width: 48px; height: 48px; }
}

/* Respect reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* Print / save-as-PDF: strip the chrome, keep the words. */
@media print {
  .site-nav, .to-top, .theme-toggle, .jump, .search-wrap, .route-links, .graph-panel { display: none !important; }
  body { font-size: 11pt; background: #fff; }
  .panel, .mp-card, .tour, .museum-block { break-inside: avoid; box-shadow: none; }
  details.period[open] .p-body, details.period .p-body { display: block !important; }
}

/* ---------- dark mode additions ---------- */
html[data-theme="dark"] .site-nav {
  background: rgba(24, 28, 36, .96);
  border-color: #2a3140;
}
html[data-theme="dark"] .to-top { background: var(--paper); }
html[data-theme="dark"] .mp-look,
html[data-theme="dark"] .tour-tips { background: #131720; }
html[data-theme="dark"] .graph-hint { background: rgba(24, 28, 36, .92); }
html[data-theme="dark"] .g-node.faded { opacity: .16; }
html[data-theme="dark"] .g-circle { stroke: #181c24; }
html[data-theme="dark"] .src-note code { background: #131720; }
