/* History Here (HI-4). All colours are theme tokens; sizes in rem so large text works. */
:root, [data-theme="light"] {
  --bg: #fbfaf7; --surface: #ffffff; --text: #1f1f1f; --muted: #5b5b5b; --line: #dedad2;
  --accent: #0b6aa8; --accent-text: #ffffff; --accent-soft: #e3f0f8;
  --bar: #0b6aa8; --bar-empty: #e8e4dc; --bar-now: #c45a00;
  --notice-bg: #fff4dc; --notice-text: #5a3d00; --shadow: 0 1px 3px rgba(0,0,0,.08);
  --focus: #c45a00;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg: #1b1c1e; --surface: #25272a; --text: #ecebe8; --muted: #b0aea8; --line: #3a3c40;
    --accent: #6cb8e8; --accent-text: #0e1a22; --accent-soft: #23384a;
    --bar: #6cb8e8; --bar-empty: #34363a; --bar-now: #f0a040;
    --notice-bg: #3a2f17; --notice-text: #f3dfae; --shadow: none; --focus: #f0a040;
    color-scheme: dark;
  }
}
[data-theme="dark"] {
  --bg: #1b1c1e; --surface: #25272a; --text: #ecebe8; --muted: #b0aea8; --line: #3a3c40;
  --accent: #6cb8e8; --accent-text: #0e1a22; --accent-soft: #23384a;
  --bar: #6cb8e8; --bar-empty: #34363a; --bar-now: #f0a040;
  --notice-bg: #3a2f17; --notice-text: #f3dfae; --shadow: none; --focus: #f0a040;
  color-scheme: dark;
}
/* black & white, high contrast: no meaning in colour at all */
[data-theme="contrast"] {
  --bg: #ffffff; --surface: #ffffff; --text: #000000; --muted: #000000; --line: #000000;
  --accent: #000000; --accent-text: #ffffff; --accent-soft: #ffffff;
  --bar: #000000; --bar-empty: #ffffff; --bar-now: #000000;
  --notice-bg: #ffffff; --notice-text: #000000; --shadow: none; --focus: #000000;
  color-scheme: light;
}
[data-theme="contrast"] .card, [data-theme="contrast"] button, [data-theme="contrast"] select { border-width: 2px; }
@media (prefers-contrast: more) {
  [data-theme="auto"] { --muted: var(--text); --line: var(--text); }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wrap { max-width: 46rem; margin: 0 auto; padding: 0 .75rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; } .skip:focus { left: .5rem; top: .5rem; z-index: 10; background: var(--surface); padding: .25rem .5rem; }
.js-only { display: none !important; }
html.js .js-only { display: revert !important; }
.place { display: flex; }
html.js .radius.js-only, html.js .jumps { display: flex !important; }
html:not(.js) .brand { display: block !important; font-size: 1.2rem; }

button, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: .5rem; padding: .35rem .6rem; min-height: 2.5rem; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* header */
.top { position: sticky; top: 0; z-index: 3; background: var(--bg); border-bottom: 1px solid var(--line);
  padding: .4rem 0 .5rem; }
.brand { font-size: .9rem; margin: 0; font-weight: 600; color: var(--muted); white-space: nowrap; flex: 0 0 auto; }
.place { gap: .4rem; align-items: center; }
.place select { flex: 1 1 8rem; min-width: 0; }
.place { flex-wrap: nowrap; }
@media (max-width: 30rem) { .brand { display: none; } }
.notice { background: var(--notice-bg); color: var(--notice-text); border-radius: .5rem; padding: .4rem .6rem;
  margin: .4rem 0 0; font-size: .9rem; }
.yearline { text-align: center; margin: .3rem 0 .2rem; }
.year { display: block; font-size: 2.2rem; line-height: 1.1; font-weight: 700; font-variant-numeric: tabular-nums; }
.era { margin: 0; color: var(--muted); font-size: .9rem; min-height: 1.2em; }
.count { margin: .1rem 0 0; font-weight: 600; }
.radius { gap: .35rem; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: .3rem; }
.radius .lbl { color: var(--muted); font-size: .9rem; }
.radius button { min-height: 2.2rem; padding: .2rem .6rem; border-radius: 1.1rem; }

/* cards */
.cards { padding-top: .75rem; padding-bottom: 1rem; min-height: 40vh; }
.cards:focus { outline: none; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: .75rem; box-shadow: var(--shadow);
  padding: .7rem .8rem; margin: 0 0 .75rem; overflow-wrap: anywhere; }
.card .meta { display: flex; justify-content: space-between; gap: .5rem; font-size: .85rem; color: var(--muted); }
.card h3 { font-size: 1.05rem; margin: .25rem 0 .2rem; }
.card .when { font-size: .85rem; color: var(--muted); margin: 0 0 .35rem; }
.card p { margin: .3rem 0; }
.card img { display: block; width: 100%; max-height: 22rem; object-fit: cover; border-radius: .5rem; margin: .4rem 0;
  background: var(--bar-empty); }
.card blockquote { margin: .4rem 0; padding: .2rem .6rem; border-left: 3px solid var(--line); color: var(--muted);
  font-size: .9rem; }
.card details { font-size: .9rem; margin: .3rem 0; }
.card details summary { cursor: pointer; color: var(--accent); }
.card .credit { font-size: .8rem; color: var(--muted); margin-top: .4rem; }
.card .credit a { white-space: nowrap; }
.card.special { border-style: dashed; }
.card ul.names { margin: .3rem 0; padding-left: 1.2rem; font-size: .9rem; }
.empty { text-align: center; color: var(--muted); padding: 2rem 0; }

/* bottom bar */
.bottom { position: sticky; bottom: 0; z-index: 3; background: var(--bg); border-top: 1px solid var(--line);
  padding: .4rem 0 calc(.4rem + env(safe-area-inset-bottom)); }
.jumps { gap: .35rem; justify-content: space-between; }
.jumps #older, .jumps #newer { flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jumps button { padding: .35rem .45rem; }
.jumps #back, .jumps #fwd { width: 2.4rem; padding: 0; flex: 0 0 auto; }
#density { display: block; width: 100%; height: 1.75rem; margin-top: .35rem; touch-action: none; cursor: pointer; }
#slider { display: block; width: 100%; margin: .15rem 0 0; height: 2rem; accent-color: var(--accent); }
.zones { position: relative; height: 1.1rem; line-height: 1.1rem; overflow: hidden; font-size: .7rem; color: var(--muted); }
.zones span { position: absolute; top: 0; border-left: 1px solid var(--line); padding-left: 2px; white-space: nowrap;
  overflow: hidden; }
.finehint { margin: .2rem 0 0; font-size: .8rem; color: var(--muted); text-align: center; }

.links { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; font-size: .85rem; color: var(--muted);
  padding-top: .75rem; padding-bottom: 1.5rem; }

dialog { width: min(46rem, 96vw); max-height: 92vh; border: 1px solid var(--line); border-radius: .75rem;
  background: var(--surface); color: var(--text); padding: .6rem; }
dialog::backdrop { background: rgba(0,0,0,.4); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.dlg-head h2 { font-size: 1.1rem; margin: 0; }
.hint { font-size: .9rem; color: var(--muted); margin: .3rem 0; }
#map { height: min(60vh, 32rem); border-radius: .5rem; }

ol.nojs, ul.nojs { padding-left: 1.4rem; } ol.nojs li, ul.nojs li { margin: .2rem 0; }

@media (min-width: 48rem) {
  .year { font-size: 3.2rem; }
  .top { padding-top: .6rem; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
table.src { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.src th, table.src td { border-bottom: 1px solid var(--line); padding: .35rem .4rem; text-align: left; vertical-align: top; }
@media (max-width: 24rem) { .jumps button { font-size: .9rem; padding: .3rem .3rem; } .jumps { gap: .25rem; } }

/* HI-5: fixed frame with JS on: year at the top, slider always at the bottom, only the cards scroll */
html.js, html.js body { height: 100%; }
html.js body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
html.js .top, html.js .bottom { position: static; flex: 0 0 auto; }
html.js .scroller { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; }
.zones .hint { position: static; border: 0; line-height: 1.1rem; font-size: .7rem; display: block; text-align: center; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.count { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
