/* Colour tokens. Level ramp: single-hue blue, validated as an ordinal ramp
   (dataviz validate_palette.js --ordinal) against each theme's surface. */
:root {
  color-scheme: light;
  --bg: #fcfcfb;
  --text: #0b0b0b;
  --muted: #52514e;
  --border: #fcfcfb;          /* region borders use the surface colour */
  --hairline: rgba(11, 11, 11, 0.10);
  --unvisited: #e1e0d9;
  --level-1: #86b6ef;         /* passed through */
  --level-2: #5598e7;         /* visited */
  --level-3: #2a78d6;         /* stayed overnight */
  --level-4: #1c5cab;         /* stayed a while */
  --level-5: #0d366b;         /* lived */
  --warn-accent: #fab219;
  --error-accent: #d03b3b;
  --panel: #f3f2ee;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #1a1a19;
    --text: #f0efec;
    --muted: #c3c2b7;
    --border: #1a1a19;
    --hairline: rgba(255, 255, 255, 0.10);
    --unvisited: #383835;
    /* Same direction as light mode: Passed through lightest, Lived darkest. */
    --level-1: #b7d3f6;
    --level-2: #6da7ec;
    --level-3: #3987e5;
    --level-4: #256abf;
    --level-5: #184f95;
    --panel: #242422;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  line-height: 1.2;
}

.summary {
  margin: 4px 0 16px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Banners */
.banner {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-left: 4px solid var(--warn-accent);
  background: var(--panel);
  border-radius: 4px;
}
.banner.error { border-left-color: var(--error-accent); }
.banner p { margin: 0; font-weight: 600; }
.banner ul { margin: 4px 0 0; padding-left: 20px; }

/* Map */
.map-wrap {
  position: relative;
}

#map {
  display: block;
  width: 100%;
  height: auto;
}

.region {
  fill: var(--unvisited);
  stroke: var(--border);
  stroke-width: 0.75;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.region.lvl-passed-through { fill: var(--level-1); }
.region.lvl-visited        { fill: var(--level-2); }
.region.lvl-overnight      { fill: var(--level-3); }
.region.lvl-stayed-a-while { fill: var(--level-4); }
.region.lvl-lived          { fill: var(--level-5); }
.region.active {
  stroke: var(--text);
  stroke-width: 1.5;
}


/* Hover box */
.tooltip {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-direction: column;
  max-width: 240px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  font-size: 0.9rem;
  pointer-events: none;
}
.tooltip[hidden] { display: none; }
.tooltip span { color: var(--muted); }

.inset-frame {
  fill: none;
  stroke: var(--hairline);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

/* Legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  font-variant-numeric: tabular-nums;
}
.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}
.swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex: none;
}
.legend .count { color: var(--muted); }
