/*
  VOICE   Calm, factual, a little monumental: a museum's chronology wall.
  IDEA    A printed wall chronology: a ruled time axis with hanging years, era panels, landmarks set huge.
  PICTURE A time strip of all discoveries (they pile up after 1900); a tick ruler on the right edge to scrub.
  COLOUR  Ink on white paper, black era panels, one electric blue for landmarks and "now". Same idea at night.
  TYPE    Archivo only. Condensed heavy numerals for years and eras, regular width for reading.
  LAYOUT  One column. Year column | rule | text. Landmarks break the grid; minor entries read like an index.
*/
:root {
  color-scheme: light dark;
  --paper: light-dark(#fbfaf6, #0f1013);
  --ink: light-dark(#141414, #ecebe5);
  --mute: light-dark(#5b5a56, #a3a29b);
  --faint: light-dark(#8b8a84, #6d6c66);
  --rule: light-dark(#bcbab1, #3a3b42);
  --hair: light-dark(#e3e1da, #24252b);
  --accent: light-dark(#1f3bff, #8b9bff);
  --panel: light-dark(#141414, #1b1c21);
  --panel-ink: #f1f0ea;
  --panel-mute: #a9a8a1;
  --panel-accent: #8b9bff;

  --top: calc(48px + env(safe-area-inset-top));
  --bot: calc(60px + env(safe-area-inset-bottom));
  --yc: 54px;       /* year column */
  --g: 22px;        /* gap holding the rule */
  --rail: calc(20px + var(--yc) + var(--g) / 2);
  --sans: "Archivo", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; min-width: 0; }
html { overflow-anchor: none; -webkit-text-size-adjust: 100%; background: var(--paper); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
  font-stretch: 100%;
  overflow-x: clip;
  touch-action: pan-x pan-y;
  -webkit-tap-highlight-color: transparent;
}
.num { font-stretch: 72%; font-variant-numeric: tabular-nums lining-nums; }

/* ---------- Top bar ---------- */
.bar-top {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  height: var(--top);
  padding: env(safe-area-inset-top) 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
  view-transition-name: bar-top;
}
.where {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.when {
  font-size: 24px;
  font-weight: 800;
  font-stretch: 72%;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--top) 34px calc(var(--bot) + 40px) 0;
}

/* ---------- Hero ---------- */
.hero { padding: 40px 0 36px 20px; }
.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(44px, 13vw, 76px);
  line-height: 0.95;
  font-weight: 800;
  font-stretch: 75%;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.lede { margin: 0 0 28px; font-size: 17px; max-width: 34ch; color: var(--mute); }
.lede strong { color: var(--ink); font-weight: 700; }
.how { margin: 18px 0 0; font-size: 15px; color: var(--mute); max-width: 40ch; }

.strip { position: relative; height: 150px; margin: 0; }
.strip .bars { position: absolute; left: 0; right: 0; top: 40px; bottom: 26px; border-bottom: 1px solid var(--ink); }
.strip .b { position: absolute; bottom: 0; width: 2px; margin-left: -1px; background: var(--ink); }
.strip .b.k1 { height: 100%; background: var(--accent); }
.strip .b.k2 { height: 58%; }
.strip .b.k3 { height: 30%; background: var(--faint); }
.strip .grid { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px dashed var(--hair); }
.strip .ax {
  position: absolute; bottom: 0;
  font-size: 13px; font-weight: 600; font-stretch: 75%;
  color: var(--mute); white-space: nowrap; transform: translateX(-50%);
}
.strip .ax.first { transform: none; }
.strip .ax.last { transform: translateX(-100%); }
.strip .brk {
  position: absolute; top: 22px; right: 0; height: 9px;
  border: 1px solid var(--ink); border-bottom: 0;
}
.strip .brk-label {
  position: absolute; top: 0; right: 0;
  font-size: 13px; font-weight: 700; white-space: nowrap;
}

/* ---------- Era panels ---------- */
.era-open {
  margin: 0 0 0 0;
  padding: 26px 20px 24px;
  background: var(--panel);
  color: var(--panel-ink);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 16px;
  align-items: start;
}
.roman {
  font-size: 64px;
  line-height: 0.82;
  font-weight: 900;
  font-stretch: 62%;
  color: var(--panel-accent);
}
.era-open h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.1;
  font-weight: 800;
  font-stretch: 85%;
  text-wrap: balance;
}
.range { margin: 4px 0 0; font-size: 14px; font-weight: 600; color: var(--panel-mute); font-variant-numeric: tabular-nums; }
.sum { grid-column: 1 / -1; margin: 14px 0 0; font-size: 16px; line-height: 1.45; color: var(--panel-ink); opacity: 0.86; }
.shown { grid-column: 1 / -1; margin: 10px 0 0; font-size: 13px; color: var(--panel-mute); }

/* ---------- Rule & entries ---------- */
.entries { list-style: none; margin: 0; padding: 20px 0 28px; position: relative; }
.entries::before {
  content: ""; position: absolute; top: 0; bottom: 0;
  left: var(--rail); width: 1px; background: var(--rule);
}
.entry, .gap {
  display: grid;
  grid-template-columns: var(--yc) minmax(0, 1fr);
  column-gap: var(--g);
  padding-left: 20px;
  position: relative;
}
.mark {
  position: absolute; left: var(--rail); top: 9px;
  width: 7px; height: 7px; transform: translateX(-50%);
  background: var(--ink); box-shadow: 0 0 0 3px var(--paper);
}
.yr {
  display: block;
  text-align: right;
  font-weight: 800;
  font-stretch: 72%;
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1;
  letter-spacing: -0.01em;
  transition: color 0.2s;
}
.body h3 { margin: 0; font-weight: 700; line-height: 1.2; }
.who { margin: 3px 0 0; font-size: 14px; color: var(--mute); }
.desc { margin: 6px 0 0; }

/* Major */
.t2 { padding-block: 12px; }
.t2 .yr { font-size: 20px; padding-top: 2px; }
.t2 h3 { font-size: 18px; }
.t2 .desc { font-size: 16px; }

/* Minor: an index line */
.t3 { padding-block: 6px; }
.t3 .mark { top: 10px; width: 9px; height: 1.5px; background: var(--ink); box-shadow: none; }
.t3 .yr { font-size: 15px; font-weight: 700; padding-top: 3px; color: var(--mute); }
.t3 h3 { font-size: 15px; font-weight: 600; }
.t3 .who { font-size: 13px; margin-top: 1px; }
.t3 .desc { font-size: 14px; color: var(--mute); margin-top: 2px; }

/* Landmark: breaks the grid */
.t1 { padding-block: 22px 18px; }
.t1 .mark { top: 30px; width: 13px; height: 13px; background: var(--accent); box-shadow: 0 0 0 4px var(--paper); }
.t1 .yr {
  grid-column: 2;
  text-align: left;
  font-size: clamp(58px, 17vw, 104px);
  white-space: nowrap;
  font-weight: 900;
  font-stretch: 66%;
  line-height: 0.86;
  letter-spacing: -0.025em;
  margin: 0 0 12px -3px;
}
.t1 .body { grid-column: 2; }
.t1 h3 { font-size: 24px; line-height: 1.12; font-weight: 800; letter-spacing: -0.01em; text-wrap: balance; }
.t1 .who { font-size: 15px; margin-top: 5px; }
.t1 .desc { font-size: 17px; margin-top: 10px; }
.t1 + .gap, .gap + .t1 { border: 0; }

.yr small { font-size: 0.5em; font-weight: 700; margin-left: 0.08em; letter-spacing: 0; }
.t1 .yr small { font-size: 0.36em; vertical-align: 0.12em; margin-left: 0.15em; }
.entry.active .yr { color: var(--accent); }
.entry.active:not(.t1) .mark { background: var(--accent); }

/* ---------- Tap to expand ---------- */
.entry { cursor: pointer; }
.tap {
  all: unset;
  display: inline;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.nw { white-space: nowrap; }
.tap:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.pm {
  display: inline-block;
  position: relative;
  width: 0.62em; height: 0.62em;
  margin-left: 0.4em;
  vertical-align: 0.04em;
}
.pm::before, .pm::after {
  content: ""; position: absolute; left: 0; right: 0; top: 50%;
  height: 2px; margin-top: -1px; background: var(--accent);
  transition: transform 0.25s;
}
.pm::after { transform: rotate(90deg); }
.open .pm::after { transform: rotate(0deg); }
.t3 .pm::before, .t3 .pm::after { height: 1.5px; background: var(--mute); }

.more {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s cubic-bezier(.2, .8, .2, 1);
}
.open .more { grid-template-rows: 1fr; }
.more-inner { overflow: hidden; cursor: auto; }
.more dl {
  margin: 16px 0 6px;
  padding-top: 14px;
  border-top: 2px solid var(--ink);
}
.more dt {
  font-size: 13px; font-weight: 800;
  color: var(--accent);
  margin-top: 14px;
}
.more dt:first-child { margin-top: 0; }
.more dd { margin: 3px 0 0; font-size: 16px; line-height: 1.55; color: var(--ink); max-width: 62ch; }
.more-wait { margin: 14px 0 4px; font-size: 14px; color: var(--mute); }
.t3.open .desc { color: var(--ink); }
.open .yr { color: var(--accent); }

@media (prefers-reduced-motion: reduce) { .more, .pm::before, .pm::after { transition: none; } }

/* Silence between entries */
.gap { min-height: var(--h); align-items: center; }
.gap span {
  grid-column: 2;
  font-size: 13px; font-weight: 600; font-stretch: 80%;
  color: var(--faint);
}
.gap.long::before {
  content: ""; position: absolute; left: var(--rail); top: 2px; bottom: 2px; width: 1px;
  background: repeating-linear-gradient(var(--paper) 0 3px, transparent 3px 7px);
}

/* ---------- End ---------- */
.end { position: relative; padding: 24px 0 0 20px; }
.end-mark { position: absolute; left: var(--rail); top: 0; height: 30px; width: 1px; background: var(--rule); }
.end-mark::after { content: ""; position: absolute; left: -7px; bottom: -14px; width: 15px; height: 15px; background: var(--ink); }
.end-year {
  margin: 34px 0 6px;
  font-size: clamp(80px, 26vw, 140px);
  line-height: 0.85;
  font-weight: 900;
  font-stretch: 62%;
  letter-spacing: -0.03em;
}
.end h2 { margin: 0 0 8px; font-size: 24px; font-weight: 800; }
.end p:not(.end-year) { margin: 0 0 22px; color: var(--mute); max-width: 36ch; }
.to-top {
  font: 700 15px/1 var(--sans);
  color: var(--paper); background: var(--ink);
  border: 0; border-radius: 0;
  padding: 0 20px; min-height: 48px; cursor: pointer;
}
.to-top:focus-visible, .zoom button:focus-visible, .scrub:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Scrubber ruler ---------- */
.scrub {
  position: fixed; z-index: 15;
  right: 0; top: calc(var(--top) + 10px); bottom: calc(var(--bot) + 10px);
  width: 32px;
  touch-action: none; cursor: ns-resize;
}
.scrub::before { content: ""; position: absolute; right: 8px; top: 0; bottom: 0; width: 1px; background: var(--hair); }
.ticks { position: absolute; inset: 0; }
.ticks i { position: absolute; right: 8px; height: 1px; background: var(--faint); }
.ticks i.k1 { width: 16px; height: 2px; background: var(--accent); }
.ticks i.k2 { width: 9px; background: var(--ink); }
.ticks i.k3 { width: 5px; }
.thumb {
  position: absolute; right: 2px; width: 4px;
  background: var(--accent); min-height: 10px;
}

/* ---------- Zoom bar ---------- */
.zoom {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  height: var(--bot);
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--panel);
  view-transition-name: zoombar;
}
.zoom button {
  appearance: none; border: 0; border-radius: 0; margin: 0;
  background: transparent; color: var(--panel-mute);
  font: 700 15px/1.1 var(--sans);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  cursor: pointer; transition: background 0.15s, color 0.15s;
  border-left: 1px solid #2c2d33;
}
.zoom button:first-child { border-left: 0; }
.zoom button span { font-size: 13px; font-weight: 600; font-stretch: 75%; opacity: 0.8; font-variant-numeric: tabular-nums; }
.zoom button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: transparent; }
:root .zoom button[aria-pressed="true"] { background: light-dark(#1f3bff, #8b9bff); color: light-dark(#fff, #0f1013); }

.hint {
  position: fixed; left: 50%; bottom: calc(var(--bot) + 14px); z-index: 30;
  transform: translate(-50%, 6px);
  padding: 9px 14px;
  background: var(--ink); color: var(--paper);
  font-size: 14px; font-weight: 700; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  view-transition-name: hint;
}
.hint.show { opacity: 1; transform: translate(-50%, 0); }

.timeline { transform-origin: 50% var(--oy, 50%); }
.timeline.settle { transition: transform 0.2s ease-out; }

/* ---------- Zoom transition ---------- */
::view-transition-group(*) { animation-duration: 0.36s; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
::view-transition-new(*):only-child { animation: vt-in 0.36s cubic-bezier(.2, .8, .2, 1) both; }
::view-transition-old(*):only-child { animation: vt-out 0.2s ease-in both; }
@keyframes vt-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes vt-out { to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-new(*), ::view-transition-old(*) { animation: none !important; }
  .yr, .hint, .zoom button { transition: none; }
}

@media (min-width: 720px) {
  :root { --yc: 96px; --g: 36px; }
  .hero { padding-top: 72px; }
  .era-open { padding: 36px 28px 32px; }
  .roman { font-size: 88px; }
  .era-open h2 { font-size: 34px; }
  .t2 .yr { font-size: 26px; }
  .t1 h3 { font-size: 30px; }
}
