/* Road-viz applet — light mode only (basemap is a light raster). Palette tokens
   from the dataviz reference instance. */
:root {
  --surface-1: #fcfcfb;
  --page: #f4f4f1;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hair: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #256abf;
  --panel-w: 300px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { color: var(--ink); background: var(--page); font-size: 14px; }

#app {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  height: 100vh;
}

.muted { color: var(--muted); font-size: 12px; }

/* ---- Left control panel ---- */
#controls {
  overflow-y: auto;
  padding: 16px 16px 24px;
  background: var(--surface-1);
  border-right: 1px solid var(--hair);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#title-block h1 { font-size: 18px; margin: 0 0 2px; }
#scenario-name { font-size: 12px; }

.ctl { display: flex; flex-direction: column; gap: 5px; }
.ctl-label { font-weight: 600; font-size: 12px; color: var(--ink-2); }
select, input[type="range"] { width: 100%; }
select {
  font-size: 14px; padding: 7px 8px; border: 1px solid var(--border);
  border-radius: 7px; background: #fff; color: var(--ink);
}
input[type="range"] { accent-color: var(--accent); }

.ctl-group { border: 1px solid var(--hair); border-radius: 8px; padding: 10px 12px; }
.ctl-group > summary { font-weight: 600; cursor: pointer; font-size: 13px; }
.ctl-group > .ctl { margin-top: 12px; }

.ctl-overlays.hidden { display: none; }
#fc-checks { display: flex; flex-direction: column; gap: 4px; }
.fc-check { font-size: 13px; display: flex; align-items: center; gap: 6px; text-transform: capitalize; }

#drawer-toggle {
  text-align: left; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 7px; background: #fff; font-size: 13px; font-weight: 600; cursor: pointer;
}
#drawer-toggle:hover { background: #f6f6f4; }
#scenario-picker-placeholder { margin-top: -6px; }

/* ---- Map ---- */
#map-wrap { position: relative; }
#map { position: absolute; inset: 0; }

/* ---- Legend (bottom-left) ---- */
#legend {
  position: absolute; left: 14px; bottom: 22px; z-index: 2;
  background: rgba(252, 252, 251, 0.94); border: 1px solid var(--border);
  border-radius: 9px; padding: 10px 12px; max-width: 280px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08); font-size: 12px;
}
.lg-title { font-weight: 600; margin-bottom: 7px; }
.lg-ramp-wrap { position: relative; height: 12px; }
.lg-ramp { height: 12px; border-radius: 3px; border: 1px solid var(--border); }
.lg-pivot {
  position: absolute; top: -2px; width: 2px; height: 16px; background: var(--ink);
  transform: translateX(-1px);
}
.lg-pivot::after {
  content: attr(data-pivot); position: absolute; top: -13px; left: 50%; transform: translateX(-50%);
  font-size: 9px; color: var(--ink-2); white-space: nowrap;
}
.lg-ends { display: flex; justify-content: space-between; margin-top: 3px; color: var(--ink-2); }
.lg-clamp { margin-top: 3px; font-size: 10px; }
.lg-cats { display: flex; flex-wrap: wrap; gap: 5px 10px; }
.lg-chip { display: inline-flex; align-items: center; gap: 5px; text-transform: capitalize; }
.lg-chip i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }

/* ---- Link inspector (right) ---- */
#inspector {
  position: absolute; top: 0; right: 0; height: 100vh; width: 320px; z-index: 5;
  background: var(--surface-1); border-left: 1px solid var(--hair);
  box-shadow: -3px 0 14px rgba(0, 0, 0, 0.10); overflow-y: auto; padding: 16px 18px 28px;
}
#inspector.hidden, #drawer.hidden { display: none; }
#inspector-close, #drawer-close {
  position: absolute; top: 10px; right: 12px; border: none; background: none;
  font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted);
}
.ins-head { margin-bottom: 12px; padding-right: 20px; }
.ins-name { font-size: 16px; font-weight: 600; }
.ins-id { margin-top: 2px; }
.ins-group { margin-top: 14px; }
.ins-group-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--accent); border-bottom: 1px solid var(--hair); padding-bottom: 3px; margin-bottom: 5px;
}
.ins-table { width: 100%; border-collapse: collapse; }
.ins-table td { padding: 2px 0; vertical-align: top; font-size: 13px; }
.ins-table td:first-child { color: var(--ink-2); padding-right: 10px; }
.ins-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ins-jump {
  margin-top: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; font-size: 12px; cursor: pointer; width: 100%;
}
.ins-jump:hover { background: #f6f6f4; }

.ins-vot { margin-bottom: 6px; }
.vot-bar {
  display: flex; height: 14px; border-radius: 4px; overflow: hidden; margin: 4px 0;
  border: 1px solid var(--border);
}
.vot-seg { display: block; height: 100%; }
.vot-key { display: flex; gap: 12px; }
.vot-key span { display: inline-flex; align-items: center; gap: 4px; }
.vot-key i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

/* ---- Diagnostics drawer ---- */
#drawer {
  position: absolute; top: 0; right: 0; height: 100vh; width: 360px; z-index: 6;
  background: var(--surface-1); border-left: 1px solid var(--hair);
  box-shadow: -3px 0 14px rgba(0, 0, 0, 0.12); overflow-y: auto; padding: 16px 20px 30px;
}
#drawer h2 { font-size: 17px; margin: 0 0 10px; }
.dr-sec { margin-top: 16px; }
.dr-sec h3 { font-size: 13px; margin: 0 0 6px; color: var(--accent); }
.dr-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dr-table td { padding: 3px 6px 3px 0; border-bottom: 1px solid var(--hair); }
.dr-table td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.dr-th td { font-weight: 600; color: var(--ink-2); }
.dr-flag { color: #d03b3b; font-weight: 700; }

/* modeled-vs-observed scatter */
.sc-svg { width: 100%; height: auto; margin-top: 8px; }
.sc-grid { stroke: var(--hair); stroke-width: 1; }
.sc-frame { fill: none; stroke: var(--border); stroke-width: 1; }
.sc-band30 { fill: #256abf; opacity: 0.08; }
.sc-band10 { fill: #256abf; opacity: 0.12; }
.sc-diag { stroke: #52514e; stroke-width: 1.2; stroke-dasharray: 4 3; }
.sc-tick { fill: var(--muted); font-size: 9px; }
.sc-axis { fill: var(--ink-2); font-size: 10px; }
.sc-pt { cursor: pointer; }
.sc-pt:hover { stroke-width: 1.8; }
.sc-pt:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

@media (max-width: 720px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  #controls { max-height: 42vh; }
  #inspector, #drawer { width: 100vw; }
}
