/* Trebuchet site: design system.
   Layout concept: a museum corridor of ten stops. Each stop pairs one large plate (photo, diagram or
   instrument) with a short column of text and one thing to try. Neutrals are the warm greys of the
   paper's figures; blue belongs to the Jerusalem 1187 design and pink to the Optimal design, and the
   other layouts keep their figure colours. Narrative is set in a serif, instruments in a grotesque. */
:root {
  --bg: #ffffff;
  --bg-2: #f6f5f1;        /* figure band */
  --bg-3: #eeede7;        /* deeper band */
  --line: #d6d4cb;
  --line-2: #e9e8e2;
  --ink: #1d1d1b;
  --ink-2: #4b4a46;
  --muted: #7a7871;
  --accent: #184f95;      /* links and controls: the deep blue of the 1187 design */
  --accent-ink: #ffffff;
  --jer: #2a78d6;  --jer-dark: #184f95;  --jer-light: #a9cbf4;
  --opt: #e87ba4;  --opt-dark: #b84d7a;  --opt-light: #f4c6d8;
  --fcw: #eb6834; --whcw: #1baf7a; --wfcw: #c99400; --trac: #8a8880;
  --wood: #c9a46a; --iron: #55544f; --stone: #b3b1a8; --violet: #6250d6; --teal: #0f7c86;
  --plate: #ffffff;       /* the ground behind a figure */
  --shadow: 0 1px 2px rgba(29, 29, 27, 0.08), 0 8px 24px rgba(29, 29, 27, 0.06);
  --serif: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 4px;
  --gutter: clamp(16px, 4vw, 40px);
  --measure: 36rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161614; --bg-2: #1f1f1c; --bg-3: #2a2a26; --line: #3b3b36; --line-2: #2e2e2a;
    --ink: #ecebe5; --ink-2: #c4c2b9; --muted: #8f8d85;
    --accent: #8db8f0; --accent-ink: #0e1a2b;
    --jer: #4e94e8; --jer-dark: #8db8f0; --jer-light: #1d3b63;
    --opt: #ec8fb3; --opt-dark: #f0a9c6; --opt-light: #4a2436;
    --plate: #f6f5f1; --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161614; --bg-2: #1f1f1c; --bg-3: #2a2a26; --line: #3b3b36; --line-2: #2e2e2a;
  --ink: #ecebe5; --ink-2: #c4c2b9; --muted: #8f8d85;
  --accent: #8db8f0; --accent-ink: #0e1a2b;
  --jer: #4e94e8; --jer-dark: #8db8f0; --jer-light: #1d3b63;
  --opt: #ec8fb3; --opt-dark: #f0a9c6; --opt-light: #4a2436;
  --plate: #f6f5f1; --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; } }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--serif); font-size: 1.0625rem; line-height: 1.55;
  font-variant-numeric: lining-nums proportional-nums;
  -webkit-font-smoothing: antialiased;
}
img, svg, canvas, video { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.14em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: -0.005em; }
h1 { font-size: clamp(2rem, 4.5vw, 3.1rem); font-weight: 500; }
h2 { font-size: clamp(1.55rem, 2.6vw, 2.1rem); font-weight: 500; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.0625rem; }
p { margin: 0; }
p + p { margin-top: 0.8em; }
.measure { max-width: var(--measure); }
.sans { font-family: var(--sans); }
.num, .tnum { font-family: var(--sans); font-variant-numeric: tabular-nums; }
.small { font-size: 0.9rem; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
sub, sup { line-height: 0; }
em.sym { font-style: italic; }
button { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: 0.9em; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.45em 0.7em 0.45em 0; border-bottom: 1px solid var(--line-2); vertical-align: top; }
th { font-family: var(--sans); font-weight: 600; font-size: 0.8rem; letter-spacing: 0.03em; text-transform: uppercase; color: var(--ink-2); }
td.n, th.n { text-align: right; font-family: var(--sans); font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-2);
  font-family: var(--sans); font-size: 0.9rem;
}
.topbar-in { display: flex; align-items: center; gap: 1.2rem; padding: 0.55rem var(--gutter); min-height: 52px; }
.brand { display: flex; align-items: baseline; gap: 0.6rem; text-decoration: none; color: var(--ink); white-space: nowrap; }
.brand b { font-weight: 600; letter-spacing: 0.01em; }
.brand span { color: var(--muted); font-size: 0.82rem; }
.topnav { display: flex; gap: 0.15rem; margin-left: auto; align-items: center; }
.topnav a { color: var(--ink-2); text-decoration: none; padding: 0.45rem 0.65rem; border-radius: var(--radius); }
.topnav a:hover { background: var(--bg-2); color: var(--ink); }
.topnav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.topnav a.pg { background: var(--ink); color: var(--bg); font-weight: 600; padding: 0.45rem 0.8rem; }
.topnav a.pg:hover { background: var(--accent); color: var(--accent-ink); }
.iconbtn { background: none; border: 1px solid transparent; border-radius: var(--radius); padding: 0.35rem; cursor: pointer; color: var(--ink-2); display: inline-flex; }
.iconbtn:hover { background: var(--bg-2); color: var(--ink); }
.menubtn { display: none; }
@media (max-width: 760px) {
  .topnav { display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; background: var(--bg); border-bottom: 1px solid var(--line); padding: 0.5rem var(--gutter) 0.9rem; gap: 0.1rem; align-items: stretch; }
  .topnav.open { display: flex; }
  .topnav a.pg { text-align: center; }
  .menubtn { display: inline-flex; margin-left: auto; }
  .topbar .theme { margin-left: 0; }
}

/* ---------- page frame ---------- */
.wrap { padding-inline: var(--gutter); }
.page { padding-block: 2.5rem 4rem; }
.lede { font-size: 1.2rem; line-height: 1.45; color: var(--ink-2); }
.kicker { font-family: var(--sans); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* ---------- the stops ---------- */
.stop { padding-block: clamp(2.5rem, 7vh, 5rem); border-top: 1px solid var(--line-2); scroll-margin-top: 60px; }
.stop:first-of-type { border-top: 0; }
.stop-in { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(1.5rem, 4vw, 4rem); align-items: start; padding-inline: var(--gutter); max-width: 1320px; margin-inline: auto; }
.stop.flip .stop-in > .plate { order: 2; }
.stop-text { display: flex; flex-direction: column; gap: 1.1rem; max-width: var(--measure); }
.stop-text .stopnum { font-family: var(--sans); font-size: 0.8rem; letter-spacing: 0.06em; color: var(--muted); display: flex; gap: 0.7rem; align-items: baseline; }
.stop-text .stopnum b { font-weight: 600; color: var(--ink-2); }
.stop-text h2 { margin-top: -0.3rem; }
.stop-text .more { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; font-family: var(--sans); font-size: 0.88rem; align-items: center; }
.plate { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }
.plate figure { margin: 0; }
.plate figcaption, .cap { font-family: var(--sans); font-size: 0.8rem; line-height: 1.45; color: var(--muted); }
.plate .fig { background: var(--plate); border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; }
.plate .fig img { width: 100%; }
.photo img { border-radius: var(--radius); }
.photo-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.photo-row figure { margin: 0; min-width: 0; }
.photo-row img { aspect-ratio: 4 / 3; object-fit: cover; width: 100%; border-radius: var(--radius); }
.photo-row.tall img { aspect-ratio: 3 / 4; }
@media (max-width: 900px) {
  .stop-in { grid-template-columns: minmax(0, 1fr); }
  .stop.flip .stop-in > .plate { order: 0; }
}

/* ---------- try it ---------- */
.try { background: var(--bg-2); border-radius: var(--radius); padding: 1rem 1.1rem 1.1rem; font-family: var(--sans); font-size: 0.92rem; display: flex; flex-direction: column; gap: 0.7rem; }
.try .try-h { display: flex; align-items: baseline; gap: 0.6rem; }
.try .try-h b { font-weight: 600; }
.try .try-h span { color: var(--muted); font-size: 0.82rem; }
.try label { display: block; }
.try .row { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
.try .readout { font-variant-numeric: tabular-nums; font-size: 1.35rem; font-weight: 600; }
.try .readout small { font-size: 0.8rem; font-weight: 400; color: var(--muted); margin-left: 0.3rem; }
.try p { font-family: var(--serif); font-size: 1rem; }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 0.3rem 0; }
.btn { font-family: var(--sans); font-size: 0.9rem; font-weight: 600; background: var(--ink); color: var(--bg); border: 0; border-radius: var(--radius); padding: 0.5rem 0.9rem; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 0.4rem; }
.btn:hover { background: var(--accent); color: var(--accent-ink); }
.btn.quiet { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.quiet:hover { background: var(--bg-2); color: var(--ink); }
.btn:disabled { opacity: 0.5; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-family: var(--sans); font-size: 0.85rem; }
.seg button { background: transparent; border: 0; padding: 0.4rem 0.7rem; cursor: pointer; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.try label.switch, .switch { display: flex; align-items: center; gap: 0.6rem; cursor: pointer; padding: 0.35rem 0; border-top: 1px solid var(--line-2); }
.switch:first-of-type { border-top: 0; }
.switch input { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; margin: 0; }
.switch .sw-l { flex: 1; }
.switch .sw-v { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 4.5ch; text-align: right; }
.switch .sw-v.on { color: var(--ink); font-weight: 600; }

/* ---------- sourced marks ---------- */
.src { cursor: pointer; text-decoration: underline dotted; text-decoration-color: var(--muted); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
.src:hover { text-decoration-color: var(--accent); color: var(--accent); }
.src.num { font-family: inherit; }
.mark { display: inline-block; width: 0.42em; height: 0.42em; border-radius: 50%; background: var(--muted); margin-left: 0.25em; vertical-align: 0.15em; cursor: pointer; opacity: 0.75; }
.mark:hover { background: var(--accent); opacity: 1; }
body.show-sources .src { text-decoration-color: var(--accent); }
body.show-sources .mark { background: var(--accent); }
.srctoggle { display: inline-flex; align-items: center; gap: 0.5rem; font-family: var(--sans); font-size: 0.82rem; color: var(--muted); cursor: pointer; }
.srctoggle input { accent-color: var(--accent); }

/* ---------- the panel (How we know / how we worked it out) ---------- */
.panel-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.25); z-index: 60; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.panel-back.open { opacity: 1; pointer-events: auto; }
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--bg); color: var(--ink);
  z-index: 70; box-shadow: var(--shadow); transform: translateX(104%); transition: transform 0.25s ease;
  display: flex; flex-direction: column; border-left: 1px solid var(--line);
}
.panel.open { transform: none; }
.panel-h { display: flex; align-items: center; gap: 0.6rem; padding: 0.8rem var(--gutter) 0.6rem; border-bottom: 1px solid var(--line-2); font-family: var(--sans); }
.panel-h h3 { font-family: var(--sans); font-size: 1rem; font-weight: 600; flex: 1; }
.panel-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line-2); font-family: var(--sans); font-size: 0.88rem; padding-inline: var(--gutter); }
.panel-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 0.6rem 0.8rem 0.5rem; cursor: pointer; color: var(--ink-2); margin-bottom: -1px; }
.panel-tabs button[aria-selected="true"] { border-color: var(--ink); color: var(--ink); font-weight: 600; }
.panel-b { overflow-y: auto; padding: 1rem var(--gutter) 2rem; display: flex; flex-direction: column; gap: 1.1rem; font-size: 0.97rem; }
.fact { border-top: 1px solid var(--line-2); padding-top: 0.8rem; display: flex; flex-direction: column; gap: 0.45rem; }
.fact:first-child { border-top: 0; padding-top: 0; }
.fact .claim { font-weight: 500; }
.fact .val { font-family: var(--sans); font-size: 0.85rem; color: var(--ink-2); }
.fact blockquote { margin: 0; padding-left: 0.8rem; border-left: 2px solid var(--line); color: var(--ink-2); font-style: italic; font-size: 0.95rem; }
.fact .who { font-family: var(--sans); font-size: 0.85rem; line-height: 1.5; }
.fact .who a { word-break: break-word; }
.grade { display: inline-block; font-family: var(--sans); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; padding: 0.1em 0.45em; border-radius: 3px; border: 1px solid var(--line); color: var(--ink-2); vertical-align: 0.1em; white-space: nowrap; }
.grade.A { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.grade.B { background: var(--bg-3); }
.conf { font-family: var(--sans); font-size: 0.78rem; color: var(--muted); }
.conf b { color: var(--ink-2); font-weight: 600; }
.working { display: flex; flex-direction: column; gap: 0.5rem; }
.working .eq { font-family: var(--serif); font-size: 1.05rem; padding: 0.6rem 0.8rem; background: var(--bg-2); border-radius: var(--radius); overflow-x: auto; }
.working .eq i { font-style: italic; }
.working dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 0.9rem; font-family: var(--sans); font-size: 0.86rem; }
.working dt { color: var(--muted); }
.working dd { margin: 0; }
.working .note { font-size: 0.9rem; color: var(--ink-2); }
.modelnote { font-family: var(--sans); font-size: 0.82rem; color: var(--muted); border-top: 1px solid var(--line-2); padding-top: 0.6rem; }

/* ---------- rail (stop navigation) ---------- */
.rail { position: fixed; left: 0.6rem; top: 50%; transform: translateY(-50%); z-index: 30; display: flex; flex-direction: column; gap: 0.35rem; font-family: var(--sans); }
.rail a { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; color: var(--muted); font-size: 0.72rem; padding: 0.15rem 0.25rem; border-radius: 3px; }
.rail a i { width: 14px; height: 2px; background: var(--line); display: block; transition: width 0.2s, background 0.2s; }
.rail a span { opacity: 0; transition: opacity 0.15s; white-space: nowrap; background: var(--bg); padding: 0.1rem 0.3rem; border-radius: 3px; }
.rail:hover a span, .rail a:focus-visible span { opacity: 1; }
.rail a.on i { width: 26px; background: var(--ink); }
.rail a.on { color: var(--ink); }
@media (max-width: 1180px) { .rail { display: none; } }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.card { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }
.card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); }
.card h4 { font-size: 1.05rem; }
.card .meta { font-family: var(--sans); font-size: 0.8rem; color: var(--muted); }
.card .nums { font-family: var(--sans); font-size: 0.85rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0.15rem 0.8rem; }
.card .nums b { font-weight: 600; font-variant-numeric: tabular-nums; }
.card .nums span { color: var(--muted); }
.card .actions { display: flex; gap: 0.5rem; margin-top: auto; padding-top: 0.3rem; }

/* ---------- charts ---------- */
.chart { font-family: var(--sans); font-size: 12px; }
.chart text { fill: var(--ink-2); }
.chart .axis line, .chart .axis path { stroke: var(--line); }
.chart .grid line { stroke: var(--line-2); }
.chart .lbl { fill: var(--muted); font-size: 11px; }
.chart .ttl { fill: var(--ink); font-weight: 600; font-size: 12px; }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--line); margin-top: 3rem; padding-block: 2rem 3rem; font-family: var(--sans); font-size: 0.85rem; color: var(--muted); }
.foot-in { padding-inline: var(--gutter); max-width: 1320px; margin-inline: auto; display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 2rem; }
.foot a { color: var(--ink-2); }
.foot h4 { font-family: var(--sans); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 0.6rem; }
.foot ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.3rem; }
@media (max-width: 760px) { .foot-in { grid-template-columns: 1fr; } }

/* ---------- misc ---------- */
.pill { display: inline-block; font-family: var(--sans); font-size: 0.74rem; padding: 0.15em 0.55em; border-radius: 999px; background: var(--bg-3); color: var(--ink-2); }
.pill.jer { background: var(--jer-light); color: var(--jer-dark); }
.pill.opt { background: var(--opt-light); color: var(--opt-dark); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem 2.5rem; }
@media (max-width: 760px) { .two { grid-template-columns: 1fr; } }
details.deep { border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); font-family: var(--sans); font-size: 0.92rem; }
details.deep summary { cursor: pointer; padding: 0.7rem 0; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 0.5rem; }
details.deep summary::-webkit-details-marker { display: none; }
details.deep summary::before { content: ""; width: 0.5rem; height: 0.5rem; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform 0.15s; }
details.deep[open] summary::before { transform: rotate(45deg); }
details.deep .deep-b { padding: 0 0 1rem; font-family: var(--serif); font-size: 1rem; display: flex; flex-direction: column; gap: 0.7rem; }
.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; font-family: var(--sans); font-size: 0.8rem; color: var(--ink-2); }
.legend i { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 2px; margin-right: 0.35em; vertical-align: -0.05em; }
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); font-family: var(--sans); font-size: 0.85rem; padding: 0.5rem 0.9rem; border-radius: var(--radius); z-index: 80; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.toast.on { opacity: 1; }

/* background music control, bottom left */
.music { position: fixed; left: 0.9rem; bottom: 0.9rem; z-index: 40; display: flex; align-items: center; gap: 0.5rem; font-family: var(--sans); }
.music-btn { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }
.music-btn svg { width: 22px; height: 22px; fill: currentColor; }
.music-btn svg .x, .music-btn svg .w { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.music-btn:hover { color: var(--ink); border-color: var(--ink-2); }
.music.on .music-btn { color: var(--accent); border-color: var(--accent); }
.music-panel { display: flex; align-items: center; gap: 0.7rem; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 0.4rem 0.9rem; font-size: 0.78rem; color: var(--ink-2); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); max-width: calc(100vw - 5rem); }
.music-panel label { display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
.music-panel input[type=range] { width: 110px; margin: 0; }
.music-credit { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-credit a { color: inherit; }
@media (max-width: 600px) { .music-credit { display: none; } }
@media print { .music { display: none; } }
