/* Roboto (SIL Open Font License, assets/fonts/LICENSE-Roboto.txt): the typeface of web maps; used for town names. */
@font-face { font-family: "Roboto"; font-weight: 400; font-display: swap; src: url("fonts/roboto-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Roboto"; font-weight: 500; font-display: swap; src: url("fonts/roboto-latin-500-normal.woff2") format("woff2"); }

:root {
  --ink: #1d1d1f;
  --muted: #5f6368;
  --line: #e3e3e6;
  --bg: #f6f6f7;
  --card: #ffffff;
  --accent: #c62828;
  --nodata: #dcdcdc;
  --tab: #e9e9ec;
  --tabstrip: #f3f3f5;
  font-family: Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
/* Same page width on every page: the scrollbar's space is always reserved, so the header never shifts between
   the map (no scrolling) and the other pages (scrolling). */
html { scrollbar-gutter: stable; }
body { margin: 0; line-height: 1.5; }
a { color: var(--accent); }
/* Side margins are half of what a fixed 1040px column leaves: width = 50vw + 520px. */
.wrap { max-width: calc(50vw + 520px); margin: 0 auto; padding: 0 16px; }

.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 52px; gap: 16px; }
.brand { font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; }
.site-header nav { display: flex; gap: 6px; }
.site-header nav a { color: var(--muted); text-decoration: none; font-size: 14px; padding: 6px 12px; border-radius: 999px; display: inline-grid; }
/* each link reserves the width of its bold text, so highlighting the current page moves nothing */
.site-header nav a::after { content: attr(data-label); font-weight: 700; height: 0; visibility: hidden; overflow: hidden; grid-area: 1 / 1; }
.site-header nav a > span { grid-area: 1 / 1; text-align: center; }
.site-header nav a:hover { color: var(--ink); background: #f1f1f3; }
.site-header nav a.donate { background: #1d1d1f; color: #fff; font-weight: 600; margin-left: 8px; }
.site-header nav a.donate:hover { background: #3a3a3e; color: #fff; }
.site-header nav a[aria-current="page"] { color: var(--ink); font-weight: 700; background: #fbe9e5; box-shadow: inset 0 0 0 1px #f2c4b8; }

h1 { font-size: 32px; margin: 28px 0 4px; }
.lede { color: var(--muted); margin: 0 0 18px; }

/* ---------- map page: one screen, no page scroll ---------- */
body.map-body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body.map-body > main { flex: 1; min-height: 0; display: flex; padding-top: 10px; padding-bottom: 10px; width: 100%; }
.map-card { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Metric tabs sit straight on the page above the map, from its left edge (browser-style, all the same width);
   the selected tab joins the map card below it. */
.card-top { display: flex; flex: none; position: relative; z-index: 1; }
.tabs { width: 96%; display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; flex: none; margin-bottom: -1px; }
.tabs button {
  font: inherit; font-size: clamp(12px, 1.25vw, 16px); height: 44px; padding: 0 8px; cursor: pointer;
  background: var(--tab); color: #44444a; border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.tabs button:hover { background: #f4f4f6; color: var(--ink); }
.tabs button[aria-selected="true"] {
  background: var(--card); color: var(--ink); font-weight: 600; box-shadow: inset 0 3px 0 var(--accent);
  border-bottom: 1px solid var(--card);
}

.card-body {
  flex: 1; min-height: 0; display: flex;
  background: var(--card); border: 1px solid var(--line); border-radius: 0 10px 10px 10px; overflow: hidden;
}
.map-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.map-box { position: relative; flex: 1; min-height: 0; }
#map { width: 100%; height: 100%; display: block; cursor: grab; }
#map:active { cursor: grabbing; }
/* Map shapes, names and city dots are drawn on the canvas by map.js (colours and fonts are set there). */
.legend .sw.warn { width: 13px; height: 13px; border-radius: 50%; background: #c62828; color: #fff; font: 700 9px/13px Roboto, sans-serif; text-align: center; margin: 0 1.5px; }
.tooltip .tip-note { margin-top: 6px; font-size: 12.5px; line-height: 1.35; color: var(--muted); }
.tooltip .tip-note strong { color: #b71c1c; font-weight: 700; }
.tooltip .tip-distress { margin-top: 6px; color: #b71c1c; font-size: 12.5px; line-height: 1.35; }
.legend .sw.agg { background: none; border: 1.5px dashed #3b3b40; height: 10px; }

.overlay-left { position: absolute; left: 12px; top: 10px; max-width: 380px; pointer-events: none; }
.overlay-left > * { pointer-events: auto; }
.subtitle { margin: 0 0 8px; color: var(--muted); font-size: 12px; line-height: 1.35; background: rgba(255,255,255,.85); border-radius: 4px; }
.layer-switch { display: inline-flex; margin-bottom: 8px; }
.layer-switch button { white-space: nowrap; font: inherit; font-size: 12px; border: 1px solid var(--line); background: var(--card); padding: 5px 10px; cursor: pointer; color: var(--ink); }
.layer-switch button:first-child { border-radius: 6px 0 0 6px; }
.layer-switch button + button { border-left: 0; }
.layer-switch button:last-child { border-radius: 0 6px 6px 0; }
.layer-switch button[aria-pressed="true"] { background: #fde7e3; border-color: #f3b8ab; color: var(--accent); font-weight: 600; }
.legend { background: rgba(255,255,255,.92); padding: 6px 8px; border-radius: 6px; font-size: 12px; display: inline-block; }
.legend .row { display: flex; align-items: center; gap: 6px; line-height: 18px; }
.legend .sw { width: 16px; height: 12px; border-radius: 2px; flex: none; }

/* Ranking panel on the right, always open. */
.side { width: 360px; flex: none; display: flex; flex-direction: column; border-left: 1px solid var(--line); min-height: 0; }
.side-head { padding: 12px 14px 8px; border-bottom: 1px solid var(--line); }
.side-head h2 { margin: 0; font-size: 16px; }
#search { font: inherit; width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; margin-top: 8px; }
.side-scroll { flex: 1; min-height: 0; overflow: auto; padding: 0 14px 14px; }
.side table { font-size: 13px; margin-top: 0; }
.side thead th { position: sticky; top: 0; background: var(--card); z-index: 1; }
.side td { padding: 6px 6px; }
.side td .t { display: block; color: var(--muted); font-size: 11px; line-height: 1.2; }
.side .rank { width: 34px; color: var(--muted); }
button.sort { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button.sort::after { content: " ↕"; color: #b8b8bd; }
button.sort[data-dir="asc"]::after { content: " ▲"; color: var(--accent); }
button.sort[data-dir="desc"]::after { content: " ▼"; color: var(--accent); }
.side .seo-text { font-size: 13px; color: #444; }
.side .seo-text h2 { font-size: 15px; margin: 18px 0 4px; }

.zoom { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: #fff; }
.zoom button { font-size: 22px; width: 40px; height: 40px; border: 0; background: #fff; cursor: pointer; color: var(--muted); }
.zoom button + button { border-top: 1px solid var(--line); }
.attribution { position: absolute; left: 12px; bottom: 4px; margin: 0; font-size: 11px; color: var(--muted); }
.attribution a { color: var(--muted); }

.tooltip {
  position: absolute; pointer-events: none; background: #fff; border: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(0,0,0,.12); padding: 10px 14px; font-size: 14px; min-width: 220px; max-width: 280px; z-index: 7;
  white-space: normal; overflow-wrap: break-word;
}
.tooltip h3 { margin: 0 0 2px; font-size: 16px; }
.tooltip .kind { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.tooltip dl { margin: 0; display: grid; grid-template-columns: auto auto; gap: 1px 12px; }
.tooltip dt { color: var(--muted); }
.tooltip dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.tooltip .tip-chart { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.tooltip .tip-chart svg { display: block; }
.tooltip dt.on, .tooltip dt.on + dd { color: var(--ink); font-weight: 600; }

/* Date slider: custom track painted by map.js (white = no data for this metric, red = up to the current date). */
.slider { display: flex; align-items: center; gap: 14px; padding: 10px 16px 6px; border-top: 1px solid var(--line); flex: none; }
#play { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 14px; flex: none; }
.slider-track { flex: 1; position: relative; min-width: 0; }
#year {
  -webkit-appearance: none; appearance: none; width: 100%; height: 10px; margin: 6px 0 4px; border-radius: 5px;
  background: var(--track, #d9d9de); border: 1px solid #cfcfd4; outline: none; cursor: pointer;
}
#year::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--accent); }
#year::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--accent); }
#year::-moz-range-track { background: transparent; }
.ticks { position: relative; height: 18px; font-size: 11px; color: var(--muted); margin: 0 10px; }
.ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; cursor: pointer; }
.ticks span.first { transform: translateX(-10px); }
.ticks span.last { transform: translateX(calc(-100% + 10px)); }
.ticks span.off { color: #c4c4c8; cursor: default; }
#year-label { font-weight: 700; flex: none; min-width: 84px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- council pages ---------- */
.crumbs { font-size: 13px; color: var(--muted); margin-top: 18px; }
.crumbs a { color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin: 18px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.card .k { color: var(--muted); font-size: 13px; }
.card .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card .s { color: var(--muted); font-size: 12px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin: 16px 0; }
.panel h2 { margin: 0 0 8px; font-size: 20px; }
.chart svg { width: 100%; max-width: 960px; height: auto; display: block; }
.chart [data-tip] { cursor: default; }
.chart [data-tip]:hover { opacity: .8; }
.chart-tip { position: fixed; z-index: 20; pointer-events: none; background: #1d1d1f; color: #fff; font-size: 13px; padding: 5px 9px; border-radius: 5px; white-space: nowrap; }
.chart .bar { fill: #e5906b; }
.chart .bar.last { fill: #d2625a; }
.chart text { font-size: 11px; fill: var(--muted); }
.chart .grid { stroke: var(--line); }
.note { color: var(--muted); font-size: 13px; }
.spend .legend-row { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin: 6px 0 4px; }
.spend .lg { display: inline-flex; align-items: center; gap: 5px; }
.spend .lg i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.spend svg text { font-size: 11px; fill: var(--muted); }
.panel.notice { border-color: #e7d9a8; background: #fffbea; }
table.sources td { vertical-align: top; font-size: 13px; }
dl.defs dt { font-weight: 700; margin-top: 10px; }
dl.defs dd { margin: 2px 0 0; }
.lender-note { display: block; color: var(--muted); font-size: 12px; line-height: 1.35; margin-top: 2px; }
.panel.distress { border-color: #f1b8b0; background: #fff7f5; }
.panel.distress h2 { color: #b71c1c; }
.az { columns: 3 240px; font-size: 14px; }
.az h2 { break-after: avoid; font-size: 18px; margin: 14px 0 4px; }
.az a { display: block; padding: 2px 0; }
.az .t { color: var(--muted); font-size: 12px; }

.site-footer { border-top: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: 12px; padding: 14px 0; margin-top: 30px; }

@media (max-width: 1000px) {
  .side { width: 300px; }
  .card-top h1 { font-size: 18px; }
}
@media (max-width: 760px) {
  h1 { font-size: 26px; }
  .site-header nav { gap: 10px; }
  .card-top { flex-direction: column; align-items: stretch; gap: 4px; padding: 6px 6px 0; }
  .card-top h1 { font-size: 17px; margin: 0; }
  .tabs { width: 100%; gap: 2px; }
  .tabs button { font-size: 11px; padding: 0 3px; height: 36px; }
  .card-body { flex-direction: column; }
  .side { width: auto; height: 34%; border-left: 0; border-top: 1px solid var(--line); }
  .overlay-left { max-width: 190px; }
  .subtitle { display: none; }
  .legend { font-size: 11px; }
}
