/* Two colours. Everything that would have been a grey is a pattern or a
   line weight instead. `i` swaps them. */
:root {
  --ink:   #000;
  --paper: #fff;
  --mono:  "Berkeley Mono", "IBM Plex Mono", "JetBrains Mono", ui-monospace,
           "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
}
html.inverse { filter: invert(1); }

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; background: var(--paper); }
body {
  color: var(--ink);
  font: 12px/1.5 var(--mono);
  -webkit-font-smoothing: none;
  font-smooth: never;
}

button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; text-align: left; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }

/* ── map ───────────────────────────────────────────────────────── */
#map {
  position: fixed; inset: 0 0 22px 0;
  width: 100%; height: calc(100% - 22px);
  display: block;
  cursor: crosshair;
  touch-action: none;
  outline: none;
}
#map.dragging { cursor: move; }

/* ── panel ─────────────────────────────────────────────────────── */
#panel {
  position: fixed; top: 10px; left: 10px;
  width: 268px;
  max-height: calc(100% - 42px);
  display: flex; flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}
#panel header {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--ink); color: var(--paper);
  padding: 2px 4px 2px 8px;
}
#panel h1 { font-size: 12px; font-weight: 700; }
#fold {
  width: 18px; height: 16px; line-height: 14px; text-align: center;
  color: var(--paper); border: 1px solid var(--paper);
}
#fold:focus-visible { outline-color: var(--paper); outline-offset: -3px; }
#panel-body { overflow-y: auto; padding: 8px 8px 10px; }
#panel.folded { width: auto; }
#panel.folded #panel-body { display: none; }
#panel.folded h1 { margin-right: 10px; }

#summary { margin-bottom: 8px; }

section + section, #summary + section { border-top: 1px dashed var(--ink); padding-top: 7px; margin-top: 8px; }
h2 { font-size: 12px; font-weight: 700; margin-bottom: 3px; }

/* layers: [x] sample name ........ count */
#layers { list-style: none; }
#layers button {
  display: grid; grid-template-columns: 26px 34px 1fr auto; align-items: center;
  width: 100%; padding: 1px 2px; white-space: nowrap;
}
#layers button:hover, #goto button:hover, .link:hover { background: var(--ink); color: var(--paper); }
#layers button:hover svg { filter: invert(1); }
#layers .box::before { content: "[x]"; }
#layers button[aria-pressed="false"] .box::before { content: "[ ]"; }
#layers button[aria-pressed="false"] .name { text-decoration: line-through; }
#layers .n { text-align: right; padding-left: 6px; }
#layers .waiting .n { font-size: 0; }
#layers .waiting .n::before { content: "zoom in to see"; font-size: 12px; font-style: italic; }
#layers svg { display: block; }
#layers .hint { display: none; }

.check { display: flex; gap: 6px; align-items: baseline; margin-top: 5px; cursor: pointer; }
.check + .check { margin-top: 1px; }
.check input {
  appearance: none; flex: none;
  width: 11px; height: 11px; border: 1px solid var(--ink); position: relative; top: 1px;
}
.check input:checked { background: var(--ink); box-shadow: inset 0 0 0 2px var(--paper); }

/* years: one bar per year, height = journeys that year */
#years { display: flex; align-items: flex-end; gap: 1px; height: 58px; margin: 4px 0 2px; touch-action: none; }
#years button {
  flex: 1; min-width: 0; height: 100%;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch;
  text-align: center; font-size: 9px; line-height: 12px;
}
#years .bar { border: 1px solid var(--ink); background: var(--ink); min-height: 2px; }
#years button[aria-pressed="false"] .bar { background: var(--paper); }
#years.filtered button[aria-pressed="true"] .yy { background: var(--ink); color: var(--paper); }
#years button:hover .yy { background: var(--ink); color: var(--paper); }
.link { text-decoration: underline; padding: 0 2px; }
.link[hidden] { display: none; }

#goto { display: flex; flex-wrap: wrap; gap: 0 4px; }
#goto button { text-decoration: underline; padding: 0 2px; }
#goto .sep { flex-basis: 100%; height: 3px; }

.keys dl { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; }
.keys dt { white-space: nowrap; }

/* ── hover label ───────────────────────────────────────────────── */
#tip {
  position: fixed; z-index: 5; pointer-events: none;
  max-width: 320px; padding: 2px 6px;
  background: var(--paper); border: 1px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  white-space: pre-line;
}

/* ── status line ───────────────────────────────────────────────── */
#status {
  position: fixed; left: 0; right: 0; bottom: 0; height: 22px;
  display: flex; align-items: center; gap: 18px;
  padding: 0 10px;
  background: var(--ink); color: var(--paper);
  white-space: nowrap; overflow: hidden;
}
#st-pos { min-width: 19ch; }
#st-scale { display: inline-flex; align-items: center; gap: 6px; }
#st-bar {
  display: inline-block; height: 6px;
  border: 1px solid var(--paper); border-top: 0;
}
#st-note { margin-left: auto; overflow: hidden; text-overflow: ellipsis; }

#fatal {
  position: fixed; inset: 0; display: grid; place-content: center;
  padding: 20px; background: var(--paper); white-space: pre-wrap;
}

@media (max-width: 640px) {
  #panel { top: 6px; left: 6px; width: min(268px, calc(100% - 12px)); max-height: calc(100% - 34px); }
  .keys { display: none; }
  #st-note { display: none; }
  #status { gap: 12px; }
}
