:root {
  --ink: #1b1b1b;        /* primary text */
  --ink-2: #5f5f5f;      /* secondary text */
  --ink-3: #6b6b6b;      /* tertiary / labels: 5.3:1 on white, 4.8:1 on map grey */
  --rule: #e4e4e4;       /* hairlines (decorative only) */
  --edge: #b5b5b5;       /* borders that outline a control or tag */
  --paper: #ffffff;
  --accent: #2563eb;     /* the one blue */
  --c-known: #2563eb;    /* Known */
  --c-approx: #5f5f5f;   /* Known place, approximate date */
  --c-probable: #b8b8b8; /* Probable (with dark edge for 3:1 against the map) */
  --c-probable-edge: #5f5f5f;
  --font: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: var(--font); color: var(--ink); }
#map { position: fixed; inset: 0; background: #f2f2f2; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Sidebar: intro, time filters, event list (popups are panned clear of it, see panelPadding in map.js) */
.panel {
  position: absolute; top: 16px; left: 16px; bottom: 16px; z-index: 1000;
  width: min(360px, calc(100vw - 32px));
  display: flex; flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--rule); box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.side-head { padding: 18px 20px 12px; }
.side-time { padding: 12px 20px 14px; border-top: 1px solid var(--rule); }
.side-list { flex: 1; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--rule); }
.panel > .credit { padding: 10px 20px 12px; border-top: 1px solid var(--rule); }
.side-h { margin: 0; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink); font-weight: 600; }
.side-h-sub { font-size: 12px; color: var(--ink-3); padding: 0; margin-bottom: 6px; }
.hint { color: var(--ink-3); }
.lede { margin-bottom: 0 !important; }
.eyebrow { margin: 0 0 6px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.panel h1 { margin: 0 0 8px; font-size: 20px; line-height: 1.2; font-weight: 600; letter-spacing: -.01em; }
.lede { margin: 0 0 10px; font-size: 15px; line-height: 1.45; color: var(--ink-2); }
.credit { margin: 0; font-size: 13px; color: var(--ink-3); }
#count { color: var(--ink); font-weight: 600; }

/* Leaflet zoom control: move out from under the panel, greyscale */
.leaflet-top.leaflet-left { display: none; }  /* zoom control moved to top right in map.js */
.leaflet-bar a { color: var(--ink); }
.leaflet-control-attribution { font-size: 11px; color: var(--ink-2); background: rgba(255,255,255,.9) !important; }
.leaflet-control-attribution a { color: var(--ink-2); }

/* Popup */
.leaflet-popup-content-wrapper { border-radius: 0; box-shadow: 0 2px 10px rgba(0,0,0,.12); border: 1px solid var(--rule); }
.leaflet-popup-tip { box-shadow: none; border: 1px solid var(--rule); }
.leaflet-popup-content { margin: 16px 18px 14px; width: 300px !important; font-family: var(--font); }
.leaflet-container a.leaflet-popup-close-button { color: var(--ink-2); width: 32px; height: 32px; font-size: 22px; line-height: 30px; top: 2px; right: 2px; }

.pp-date { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
.pp-place { font-size: 18px; font-weight: 600; line-height: 1.25; margin: 0 0 8px; }
.pp-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.pp-tag { font-size: 12px; padding: 2px 7px; border: 1px solid var(--edge); color: var(--ink-2); }
.pp-tag.known { border-color: var(--accent); color: var(--accent); }
.pp-activity { font-size: 15px; line-height: 1.45; margin: 0 0 8px; }
.pp-note { font-size: 13.5px; line-height: 1.45; color: var(--ink-2); margin: 0 0 10px; }
.pp-sources-h { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); border-top: 1px solid var(--rule); padding-top: 10px; margin: 4px 0 6px; }
.pp-sources { list-style: none; margin: 0; padding: 0; max-height: 180px; overflow-y: auto; }
.pp-sources li { font-size: 13.5px; line-height: 1.4; padding: 5px 0; border-bottom: 1px solid #f1f1f1; }
.pp-sources li:last-child { border-bottom: 0; }
.pp-src-head { color: var(--ink); }
.pp-src-meta { color: var(--ink-3); font-size: 12.5px; }
.pp-geo { font-size: 12px; color: var(--ink-3); margin-top: 8px; }

/* Keyboard focus */
a:focus-visible, .leaflet-bar a:focus-visible, .leaflet-popup-close-button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.leaflet-container:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
path.leaflet-interactive:focus { outline: none; }
path.leaflet-interactive:focus-visible { stroke: var(--accent); stroke-width: 4px; }
.leaflet-popup-content:focus { outline: none; }

/* Screen-reader-only text */
.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; }
/* Typography: balanced headings and labels, pretty body text (no orphans) */
h1, h2, h3, summary, .eyebrow, .pp-date, .pp-tag, .lg-h, .pp-back { text-wrap: balance; }
p, li, .pp-item-text, .pp-src-meta, .pp-note, .pp-activity, .lede, .credit { text-wrap: pretty; }

/* ---------- Markers ---------- */
.pp-marker { background: none; border: 0; display: flex; align-items: center; justify-content: center; }
.pp-marker:focus { outline: none; }
.pp-dot {
  display: inline-block; flex: none; border-radius: 50%;
  border: 1.5px solid #fff; box-sizing: border-box;
  box-shadow: 0 0 0 0.5px rgba(0,0,0,.25);
}
.pp-dot.c-known    { background: var(--c-known); }
.pp-dot.c-approx   { background: var(--c-approx); }
.pp-dot.c-probable { background: var(--c-probable); border-color: var(--c-probable-edge); box-shadow: none; }
/* ring = place known only to a state or region */
.pp-dot.ring { background: rgba(255,255,255,.75); border-width: 2.5px; box-shadow: none; }
.pp-dot.ring.c-known    { border-color: var(--c-known); }
.pp-dot.ring.c-approx   { border-color: var(--c-approx); }
.pp-dot.ring.c-probable { border-color: var(--c-probable-edge); border-style: dashed; }
/* size = how exact the date is */
.pp-dot.s-day   { width: 10px; height: 10px; }
.pp-dot.s-week  { width: 13px; height: 13px; }
.pp-dot.s-month { width: 17px; height: 17px; }
.pp-dot.s-long  { width: 22px; height: 22px; }
.pp-marker .pp-dot.s-month, .pp-marker .pp-dot.s-long { opacity: .85; }
/* several events at one place */
.pp-dot.pp-count {
  width: 22px; height: 22px; color: #fff; font: 600 11px/19px var(--font); text-align: center;
  border-width: 1.5px;
}
.pp-dot.pp-count.c-probable { color: var(--ink); }
.pp-dot.pp-count.ring { color: var(--ink); }
/* hover, keyboard focus, selected */
.pp-marker:hover .pp-dot { transform: scale(1.2); }
.pp-marker:focus-visible .pp-dot, .pp-marker.is-selected .pp-dot {
  transform: scale(1.25); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink);
}
.pp-dot { transition: transform .12s ease; }

/* ---------- Popup additions ---------- */
.pp-tag.c-known { border-color: var(--c-known); color: var(--c-known); }
.pp-tag.c-approx { border-color: var(--c-approx); color: var(--ink); }
.pp-tag.c-probable { border-style: dashed; border-color: var(--c-probable-edge); color: var(--ink-2); }
.pp-back {
  font: inherit; font-size: 13px; color: var(--accent); background: none; border: 0; padding: 4px 0; margin: 0 0 8px; cursor: pointer;
}
.pp-back:hover { text-decoration: underline; }
.pp-list { list-style: none; margin: 4px 0 0; padding: 0; max-height: 300px; overflow-y: auto; border-top: 1px solid var(--rule); }
.pp-list li { border-bottom: 1px solid #f1f1f1; }
.pp-item {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left;
  font: inherit; color: var(--ink); background: none; border: 0; padding: 9px 4px; cursor: pointer;
}
.pp-item:hover { background: #f6f6f6; }
.pp-item-body { display: flex; flex-direction: column; gap: 2px; }
.pp-item-date { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.pp-item-text { font-size: 14px; line-height: 1.4; }
.pp-swatch { flex: none; width: 11px; height: 11px; border-radius: 50%; margin-top: 4px; border: 1.5px solid #fff; box-shadow: 0 0 0 .5px rgba(0,0,0,.3); }
.pp-swatch.c-known { background: var(--c-known); }
.pp-swatch.c-approx { background: var(--c-approx); }
.pp-swatch.c-probable { background: var(--c-probable); border-color: var(--c-probable-edge); box-shadow: none; }
.pp-swatch.ring { background: #fff; border-width: 2px; box-shadow: none; }
.pp-swatch.ring.c-known { border-color: var(--c-known); }
.pp-swatch.ring.c-approx { border-color: var(--c-approx); }
.pp-swatch.ring.c-probable { border-color: var(--c-probable-edge); border-style: dashed; }
.pp-back:focus-visible, .pp-item:focus-visible, .pp-legend summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Legend ---------- */
.pp-legend {
  background: var(--paper); border: 1px solid var(--rule); box-shadow: 0 1px 3px rgba(0,0,0,.06);
  padding: 10px 14px; width: 272px; font-size: 13px; color: var(--ink-2);
}
.pp-legend summary { cursor: pointer; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink); font-weight: 600; }
.pp-legend details[open] summary { margin-bottom: 4px; }
.pp-legend .lg-h { font-size: 12px; color: var(--ink-3); margin: 10px 0 4px; }
.pp-legend ul { list-style: none; margin: 0; padding: 0; }
.pp-legend li { display: flex; align-items: center; gap: 10px; padding: 2px 0; line-height: 1.35; }
.pp-legend li .pp-dot { margin-left: calc((22px - var(--w, 13px)) / 2); }
.pp-legend li > .pp-dot { width: 13px; height: 13px; }
.pp-legend li > .pp-dot.s-day { width: 10px; height: 10px; margin: 0 6px 0 6px; }
.pp-legend li > .pp-dot.s-week { width: 13px; height: 13px; margin: 0 4.5px; }
.pp-legend li > .pp-dot.s-month { width: 17px; height: 17px; margin: 0 2.5px; }
.pp-legend li > .pp-dot.s-long { width: 22px; height: 22px; margin: 0; }
.pp-legend li > .pp-dot.pp-count { width: 22px; height: 22px; margin: 0; }
.pp-legend .lg-sizes { display: flex; gap: 8px; flex-wrap: nowrap; justify-content: space-between; }
.pp-legend .lg-sizes li { gap: 5px; }
.pp-legend .lg-sizes li > .pp-dot { margin: 0; }
/* ---------- Time controls ---------- */
.range-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 6px; }
.range-label { flex: 1; min-width: 0; font-size: 15px; line-height: 1.3; font-weight: 600; color: var(--ink); text-wrap: balance; }
.btn-play { flex: none; }
.btn-play {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--edge); padding: 5px 10px 5px 8px; cursor: pointer; min-height: 32px;
}
.btn-play:hover { border-color: var(--ink-2); }
.btn-play.is-playing { border-color: var(--accent); color: var(--accent); }
.play-icon { width: 0; height: 0; border-left: 8px solid currentColor; border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.btn-play.is-playing .play-icon { width: 8px; height: 10px; border: 0; border-left: 3px solid currentColor; border-right: 3px solid currentColor; }

.range { position: relative; height: 28px; }
.range-track { position: absolute; left: 9px; right: 9px; top: 12px; height: 4px; background: var(--rule); }
.range-fill { position: absolute; top: 0; height: 100%; background: var(--accent); }
.range input[type=range] {
  position: absolute; left: 0; right: 0; top: 0; width: 100%; height: 28px; margin: 0;
  background: none; pointer-events: none; -webkit-appearance: none; appearance: none;
}
.range input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; width: 18px; height: 18px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--ink); cursor: pointer; margin-top: 0;
}
.range input[type=range]::-moz-range-thumb {
  pointer-events: auto; width: 14px; height: 14px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink); cursor: pointer;
}
.range input[type=range]::-webkit-slider-runnable-track { height: 28px; background: none; }
.range input[type=range]::-moz-range-track { background: none; }
.range input[type=range]:focus { outline: none; }
.range input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--accent); }
.range input[type=range]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--accent); }
.range-ticks { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); margin: 0 2px 12px; }

.chips { border: 0; margin: 0; padding: 0; min-width: 0; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: 13px; color: var(--ink-2); background: var(--paper);
  border: 1px solid var(--edge); padding: 4px 10px; min-height: 30px; cursor: pointer;
}
.chip:hover { border-color: var(--ink-2); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip:focus-visible, .btn-play:focus-visible, .ev:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Event list ---------- */
.list-head { display: flex; align-items: baseline; justify-content: space-between; padding: 12px 20px 8px; }
.list-count { font-size: 12px; color: var(--ink-3); }
.event-list { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; flex: 1; min-height: 0; }
.event-list li { border-bottom: 1px solid #f1f1f1; }
.ev {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left;
  font: inherit; color: var(--ink); background: none; border: 0; padding: 9px 12px; cursor: pointer;
}
.ev:hover { background: #f6f6f6; }
.ev-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ev-date { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.ev-place { font-size: 14px; font-weight: 600; }
.ev-text { font-size: 13.5px; line-height: 1.4; color: var(--ink-2); }
.ev-empty { padding: 16px 12px; font-size: 14px; color: var(--ink-2); }
.ev-place, .ev-text, .ev-date { text-wrap: pretty; }

/* Legend: pretty wrapping on every line of the key */
.pp-legend, .pp-legend * { text-wrap: pretty; }

/* ---------- Small screens: sidebar on top, map below ---------- */
@media (max-width: 759px) {
  .panel { top: 8px; left: 8px; right: 8px; bottom: auto; width: auto; max-height: 52vh; }
  .side-head { padding: 12px 14px 8px; }
  .side-head .lede { display: none; }
  .side-time { padding: 8px 14px 10px; }
  .list-head { padding: 8px 14px 6px; }
  .panel > .credit { display: none; }
  .leaflet-top.leaflet-right { top: auto; bottom: 64px; }
}
.ev.is-current { background: #eef3fe; box-shadow: inset 3px 0 0 var(--accent); }

/* ---------- Path toggles and legend lines ---------- */
.toggles { border: 0; margin: 12px 0 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); cursor: pointer; min-height: 28px; text-wrap: pretty; }
.toggle input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }
.toggle input:disabled + * , .toggle:has(input:disabled) { color: var(--ink-3); }
.toggle input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lg-line { flex: none; width: 22px; height: 0; border-top: 2px solid #3d3d3d; }
.lg-line.dashed { border-top: 1.6px dashed #6b6b6b; }
.lg-line.none { border-top: 2px dotted transparent; position: relative; }
.lg-line.none::before, .lg-line.none::after { content: ""; position: absolute; top: -4px; width: 6px; height: 6px; border-radius: 50%; background: #5f5f5f; }
.lg-line.none::before { left: 0; } .lg-line.none::after { right: 0; }
.lg-line.dotted { border-top: 2px dotted #6b6b6b; }
