:root {
  --ink: #1c2430;
  --paper: #faf8f4;
  --line: #e3ddd2;
  --muted: #6b7280;
  --national: #0f3d5c;
  --london: #0e7a6d;
  --borough: #b45309;
  --mark: #ffe9a8;
  --hit: #d81f26;   /* search-hit ring; reads against all three tier fills */
  /* One page width for every tab. The map needs the room; switching tabs
     must not reflow the whole page around the reader. */
  --page: 1180px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino", Georgia, serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
}

main { max-width: var(--page); margin: 0 auto; padding: 0 20px 64px; }

.site-header {
  max-width: var(--page);
  margin: 0 auto;
  padding: 48px 20px 24px;
  border-bottom: 1px solid var(--line);
}
.kicker {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}
h1 { font-size: 32px; font-weight: 600; margin: 0 0 6px; }
.subtitle { color: var(--muted); margin: 0; }

.search { display: flex; gap: 8px; margin-top: 28px; }
.search input {
  flex: 1;
  font: inherit;
  font-size: 17px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.search input:focus { outline: 2px solid var(--national); outline-offset: 1px; }
.search button {
  font: inherit;
  padding: 12px 20px;
  border: none;
  border-radius: 6px;
  background: var(--national);
  color: #fff;
  cursor: pointer;
}
.search button:hover { filter: brightness(1.15); }

.tier-filters { display: flex; gap: 18px; margin: 14px 2px; font-size: 14px; color: var(--muted); }
.tier-filters label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

.status { color: var(--muted); font-size: 14px; margin: 18px 2px 8px; }

.results { list-style: none; margin: 0; padding: 0; }
.result {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.result-meta { display: flex; align-items: center; gap: 10px; font-size: 13px; margin-bottom: 6px; }
.badge {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  padding: 2px 8px;
  border-radius: 999px;
}
.tier-national { background: var(--national); }
.tier-london { background: var(--london); }
.tier-borough { background: var(--borough); }
.doc-name { font-weight: 600; }
.section-title { color: var(--muted); font-style: italic; }
.page {
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.passages { list-style: none; margin: 4px 0 8px; padding: 0; }
.passages li { margin-bottom: 8px; }
.passages .snippet { margin: 2px 0 0; }
.req-badge {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--national);
  border: 1px solid var(--national);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: 1px;
}
.req-toggle { margin-left: auto; font-weight: 600; color: var(--ink); }
.more { color: var(--muted); font-size: 13px; margin: 4px 0 8px; }
.snippet { margin: 0 0 8px; font-size: 15.5px; }
mark { background: var(--mark); padding: 0 1px; border-radius: 2px; }
.source-link { font-size: 13px; color: var(--national); text-decoration: none; }
.source-link:hover { text-decoration: underline; }

.site-footer {
  border-top: 1px solid var(--line);
  max-width: var(--page);
  margin: 0 auto;
  padding: 16px 20px 40px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- tabs ---------- */

.tabs { display: flex; gap: 4px; margin-top: 20px; }
.tabs [role="tab"] {
  font: inherit;
  font-size: 15px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--muted);
}
.tabs [role="tab"]:hover { color: var(--ink); }
.tabs [role="tab"][aria-selected="true"] {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--national);
}
.tabs [role="tab"]:focus-visible { outline: 2px solid var(--national); outline-offset: 2px; }

/* ---------- map view ---------- */

.map-frame { margin-top: 20px; }
.map-head h2 { font-size: 24px; font-weight: 600; margin: 0 0 4px; }
.map-sub { color: var(--muted); font-size: 14.5px; margin: 0 0 12px; }

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px 2px;
}
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.swatch { width: 12px; height: 12px; border-radius: 50%; }
.tier-national-bg { background: var(--national); }
.tier-london-bg { background: var(--london); }
.tier-borough-bg { background: var(--borough); }
.legend-note { margin-left: auto; color: var(--hit); font-weight: 600; }

/* Map and detail panel sit side by side. The panel is a column in normal
   flow, not an overlay — floating it over the map hid a large part of the
   graph, which is the one thing this view exists to show. The SVG has a
   viewBox, so giving up width simply rescales it; no node is ever lost. */
.map-stage {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
#map-svg {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: auto;
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 14px;
}

@media (max-width: 860px) {
  .map-stage { flex-direction: column; }
}

.link { stroke: #ddd5c6; stroke-width: 0.7; }
.link-cites { stroke-width: 1.1; opacity: 0.55; }
.node { transition: opacity 150ms ease-out; }
.link { transition: opacity 150ms ease-out; }
/* Non-matching nodes recede while a search is running. Listed before
   .dim so hover focus still wins over it. */
.node.query-miss { opacity: 0.28; }
.link.query-miss { opacity: 0.1; }

.node.dim, .link.dim { opacity: 0.12; }
/* Tier and requirement filters fade the map rather than deleting nodes:
   a graph with pieces removed misrepresents the structure it exists to
   show, and the officer needs to see that the filtered tier is still
   there and still connected. */
.node.filtered-out, .link.filtered-out { opacity: 0.06; }
.node.filtered-out { pointer-events: none; }
/* The white keyline belongs to the node body alone. Written as `.node
   circle` it also matched rings drawn over the node and outranked them on
   specificity, silently whiting them out — keep it scoped. */
.node > circle:first-of-type { stroke: #fff; stroke-width: 1.2; }
.node[role="button"] { cursor: pointer; }
.node:focus { outline: none; }
.node:focus-visible > circle:first-of-type { stroke: var(--ink); stroke-width: 2.5; }
.hub-label, .node-label {
  fill: #fff;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.hub-label { font-size: 9.5px; font-weight: 600; }
.node-label { font-size: 8px; }
/* Search hits. The stroke widths are declared non-scaling so they stay a
   constant thickness on screen: the SVG is drawn at roughly two-thirds of
   its viewBox and can be zoomed further, which was thinning the old
   outline to under two device pixels on the smaller policy nodes. */
.query-ring {
  fill: none;
  stroke: var(--hit);
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
  opacity: 0;
  pointer-events: none;
}
.node.query-hit .query-ring { opacity: 1; }
.node.query-hit > circle:first-of-type {
  stroke: var(--hit);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.node.query-hit .node-label { font-weight: 700; }

#map-tooltip {
  position: absolute;
  z-index: 3;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  max-width: 280px;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(28, 36, 48, 0.1);
}
#map-tooltip strong { display: block; margin-bottom: 2px; }
#map-tooltip span { color: var(--muted); font-size: 12px; }

#map-panel {
  position: relative;
  flex: 0 0 340px;
  margin-top: 14px;
  max-height: 74vh;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  font-size: 14px;
}
#map-panel:focus { outline: none; }

@media (max-width: 860px) {
  #map-panel { flex: none; width: 100%; max-height: none; }
}
.panel-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
.panel-close:hover { color: var(--ink); }
.panel-kicker { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 0 0 6px; }
#map-panel h3 { margin: 0 24px 4px 0; font-size: 17px; }
.panel-meta { color: var(--muted); font-size: 12.5px; margin: 0 0 4px; }
#map-panel h4 {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 14px 0 6px;
}
.citers { list-style: none; margin: 0; padding: 0; }
.citer-link {
  background: none;
  border: none;
  padding: 2px 0;
  font: inherit;
  font-size: 13px;
  color: var(--national);
  cursor: pointer;
  text-align: left;
}
.citer-link:hover { text-decoration: underline; }
.citer-doc { color: var(--muted); font-size: 12px; margin-left: 6px; }

.map-foot {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 10px 2px 0;
}

/* ---------- pdf overlay viewer ---------- */

body.no-scroll { overflow: hidden; }
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}
.overlay[hidden] { display: none; }
.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 36, 48, 0.45);
}
.overlay-box {
  position: relative;
  width: min(960px, 92vw);
  height: min(88vh, 900px);
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(28, 36, 48, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.overlay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.overlay-head p { margin: 0; font-size: 14px; font-weight: 600; }
.overlay-close {
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
.overlay-close:hover { color: var(--ink); }
#pdf-frame { flex: 1; border: none; width: 100%; }

.page-link {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--national);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.page-link:hover { text-decoration-style: solid; }

@media (prefers-reduced-motion: reduce) {
  .node, .link { transition: none; }
}
