/*
 * The page's tokens, both modes, from the org's validated palette.
 *
 * Dark is the default because this is a map and the moving marks are the
 * data; light is a selected set of steps from the same ramps rather than an
 * automatic flip. The two categorical hues — blue for vehicles, orange for
 * pedestrians — were validated as a pair against both surfaces (all-pairs
 * CVD ΔE 26.8 dark, 24.7 light, both far above the 8 target), and shape
 * carries the same distinction so identity is never colour alone.
 *
 * The canvas reads these same custom properties at draw time, so there is
 * one palette in the page and not two.
 */
:root {
  --surface: #1a1a19;
  --plane: #0d0d0d;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --ink-muted: #898781;
  --hairline: #2c2c2a;
  --rule: #383835;
  --border: rgba(255, 255, 255, 0.1);

  --vehicle: #3987e5;
  --pedestrian: #d95926;

  --good: #0ca30c;
  --critical: #d03b3b;
  --warning: #fab219;

  /* The basemap: neutral steps between the rule and the muted ink, so the
   * road hierarchy is carried by width and lightness and the only hues on
   * screen belong to the agents. */
  --road-casing: #232322;
  --road-major: #7c7b74;
  --road-minor: #625f59;
  --road-other: #55534d;
  --road-foot: #4d4b46;
  --node: #4a4944;

  --radius: 10px;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --surface: #fcfcfb;
  --plane: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-muted: #898781;
  --hairline: #e1e0d9;
  --rule: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);

  --vehicle: #2a78d6;
  --pedestrian: #eb6834;

  --good: #006300;
  --critical: #d03b3b;
  --warning: #b07400;

  --road-casing: #e6e5df;
  --road-major: #a9a7a0;
  --road-minor: #bcbab3;
  --road-other: #c8c6bf;
  --road-foot: #cfcdc6;
  --node: #b5b3ac;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

/* A column that owns the viewport: the header takes the height its text
 * needs and the stage takes the rest, so the attribution at the foot of the
 * canvas is never pushed off the bottom by a subtitle that wrapped. */
body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font: 14px / 1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ---- the header ---- */

.bar {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.bar-title {
  flex: 1;
  min-width: 0;
}

h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.sub {
  margin: 2px 0 0;
  color: var(--ink-2);
  font-size: 12.5px;
  max-width: 78ch;
}

/* ---- the two columns ---- */

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 0;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

@media (max-width: 900px) {
  body {
    height: auto;
    overflow: visible;
  }

  main {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---- the canvas and its overlays ---- */

.stage {
  position: relative;
  background: var(--surface);
  min-height: 420px;
  overflow: hidden;
}

/* The canvas fills the stage; every overlay sits above it in the same box,
 * so the padding below keeps the picture clear of the readouts. */
.stage {
  --overlay-foot: 82px;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

.overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  min-width: 168px;
}

.overlay-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: baseline;
}

.overlay-row + .overlay-row {
  margin-top: 3px;
}

.k {
  color: var(--ink-muted);
  font-size: 11.5px;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.v {
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
}

.tab {
  font-variant-numeric: tabular-nums;
}

.swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}

.swatch.vehicle {
  background: var(--vehicle);
}

.swatch.pedestrian {
  background: var(--pedestrian);
  border-radius: 50%;
}

.scalebar {
  position: absolute;
  bottom: 52px;
  right: 14px;
  text-align: right;
}

.scalebar-line {
  height: 6px;
  display: flex;
  justify-content: flex-end;
}

.scalebar-line span {
  display: block;
  height: 6px;
  border: 1px solid var(--ink-2);
  border-top: none;
  min-width: 20px;
}

.scalebar-label {
  color: var(--ink-2);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.compass {
  position: absolute;
  top: 14px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--ink-2);
  font-size: 10.5px;
  letter-spacing: 0.08em;
}

.compass svg {
  fill: var(--ink-2);
  margin-top: 2px;
}

.attribution {
  position: absolute;
  bottom: 9px;
  left: 12px;
  right: 12px;
  margin: 0;
  color: var(--ink-2);
  font-size: 11px;
  line-height: 1.4;
  /* ODbL requires this beside the derived product, so it is part of the
   * picture rather than something a narrow window can scroll away
   * (LEGAL-LOG.md). */
  text-shadow: 0 0 6px var(--surface);
}

.attribution strong {
  color: var(--ink);
  font-weight: 600;
}

.legend {
  position: absolute;
  bottom: 52px;
  left: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  max-width: 60%;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  font-size: 11px;
}

.mark {
  display: inline-block;
  flex: none;
}

.mark.vehicle {
  width: 12px;
  height: 7px;
  border-radius: 2px;
  background: var(--vehicle);
}

.mark.pedestrian {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pedestrian);
}

.mark.drivable {
  width: 16px;
  height: 4px;
  border-radius: 2px;
  background: var(--road-major);
}

.mark.footway {
  width: 16px;
  height: 0;
  border-top: 2px dashed var(--road-foot);
}

.banner {
  position: absolute;
  inset: auto 12px 86px 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--critical);
  background: color-mix(in srgb, var(--critical) 16%, var(--surface));
  color: var(--ink);
  font-size: 12.5px;
}

/* ---- the panel ---- */

.panel {
  border-left: 1px solid var(--border);
  background: var(--plane);
  overflow-y: auto;
  min-height: 0;
}

@media (max-width: 900px) {
  .panel {
    border-left: none;
    border-top: 1px solid var(--border);
    overflow-y: visible;
  }
}

.card {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.card h2 {
  margin: 0 0 10px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-muted);
}

.card h3 {
  margin: 18px 0 6px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-muted);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.controls + .controls {
  margin-top: 8px;
}

button {
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 7%, var(--surface));
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 11px;
  cursor: pointer;
}

button:hover {
  background: color-mix(in srgb, var(--ink) 13%, var(--surface));
}

button:focus-visible {
  outline: 2px solid var(--vehicle);
  outline-offset: 1px;
}

button.primary {
  background: color-mix(in srgb, var(--vehicle) 20%, var(--surface));
  border-color: color-mix(in srgb, var(--vehicle) 50%, transparent);
}

button.primary:hover {
  background: color-mix(in srgb, var(--vehicle) 30%, var(--surface));
}

button.ghost {
  background: transparent;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}

.segmented button {
  border: none;
  border-radius: 0;
  background: transparent;
}

.segmented button + button {
  border-left: 1px solid var(--border);
}

.segmented button.on {
  background: color-mix(in srgb, var(--vehicle) 24%, var(--surface));
  font-weight: 600;
}

.field {
  display: block;
  margin-bottom: 10px;
}

.field .k {
  display: block;
  margin-bottom: 4px;
}

.row {
  display: flex;
  gap: 8px;
}

input,
select {
  font: inherit;
  font-size: 12.5px;
  font-family: var(--mono);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 6px 9px;
  width: 100%;
  min-width: 0;
}

select {
  font-family: var(--sans);
}

input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--vehicle);
  outline-offset: -1px;
}

.note {
  margin: 10px 0 0;
  color: var(--ink-muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.note code,
code {
  font-family: var(--mono);
  font-size: 0.94em;
  color: var(--ink-2);
}

.error,
.message {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.45;
}

.error {
  border: 1px solid var(--critical);
  background: color-mix(in srgb, var(--critical) 14%, var(--surface));
}

.message {
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink-2);
}

.message.found {
  border-color: color-mix(in srgb, var(--good) 60%, transparent);
}

.message.absent {
  border-color: color-mix(in srgb, var(--warning) 60%, transparent);
}

/* ---- the digests ---- */

.digest {
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  word-break: break-all;
  color: var(--ink);
}

.digest.live {
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: var(--surface);
}

table.receipts {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

table.receipts th {
  text-align: left;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: lowercase;
  letter-spacing: 0.02em;
  padding: 4px 6px 4px 0;
  border-bottom: 1px solid var(--rule);
}

table.receipts td {
  padding: 5px 6px 5px 0;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

table.receipts td.verdict {
  font-family: var(--sans);
  white-space: nowrap;
}

.verdict-match {
  color: var(--good);
  font-weight: 600;
}

.verdict-mismatch {
  color: var(--critical);
  font-weight: 600;
}

.verdict-pending {
  color: var(--ink-muted);
}

table.receipts button {
  padding: 2px 7px;
  font-size: 11px;
}

/* ---- the facts ---- */

.facts {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 10px;
}

.facts.wide {
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
}

.facts div {
  min-width: 0;
}

.facts dt {
  color: var(--ink-muted);
  font-size: 10.5px;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

.facts dd {
  margin: 1px 0 0;
  font-size: 13px;
  font-weight: 600;
}

.facts.wide dd {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink-2);
}

.mono {
  font-family: var(--mono);
}

.break {
  word-break: break-all;
}

details {
  margin-top: 12px;
}

summary {
  color: var(--ink-muted);
  font-size: 11.5px;
  cursor: pointer;
}

ul.objects {
  margin: 8px 0 0;
  padding: 0 0 0 2px;
  list-style: none;
}

ul.objects li {
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--ink-2);
  word-break: break-all;
  padding: 4px 0;
  border-top: 1px solid var(--hairline);
}

@media (prefers-reduced-motion: reduce) {
  .overlay {
    backdrop-filter: none;
  }
}
