/* One Public Budget.
   Plain, high-contrast, and readable at 200% zoom. The table is the interface;
   the chart is decoration. Colour is never the only carrier of meaning. */

:root {
  --ink: #16191d;
  --muted: #4a5159;
  --rule: #d5d9de;
  --bg: #ffffff;
  --panel: #f5f6f8;
  --accent: #14507d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 1rem 4rem;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

main, header, footer { max-width: 62rem; margin: 0 auto; }

a { color: var(--accent); }
a:focus-visible, .skip:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  position: static;
  display: inline-block;
  padding: .5rem;
  background: var(--panel);
}

header { padding: 1.5rem 0 .5rem; border-bottom: 1px solid var(--rule); }
.wordmark { margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: .01em; }
.wordmark a { color: var(--ink); text-decoration: none; }
.tagline { margin: .2rem 0 0; color: var(--muted); font-size: .95rem; }

h1 { font-size: 1.9rem; margin: 1.6rem 0 .4rem; }
h2 { font-size: 1.25rem; margin: 2rem 0 .3rem; }
h3 { font-size: 1.05rem; margin: 1.4rem 0 .3rem; }

.lede { font-size: 1.05rem; max-width: 46rem; }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: .95rem; max-width: 46rem; }
.breadcrumb { margin: 1.2rem 0 0; font-size: .9rem; color: var(--muted); }

/* Filters ---------------------------------------------------------------- */
.filters {
  margin: 1.4rem 0;
  padding: .8rem 1rem;
  background: var(--panel);
  border: 1px solid var(--rule);
}
.filters p { margin: 0 0 .4rem; font-weight: 600; }
.filters ul { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; margin: 0; padding: 0; }
.filters li a {
  display: inline-block;
  padding: .3rem .7rem;
  border: 1px solid var(--rule);
  background: var(--bg);
  text-decoration: none;
}
.filters li a[aria-current="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
}
.filters .note { margin: .7rem 0 0; font-weight: 400; }

/* Figures ---------------------------------------------------------------- */
.figure { margin: 2.4rem 0; padding-top: .5rem; border-top: 2px solid var(--ink); }
.caption { margin: .2rem 0 1rem; max-width: 46rem; }
.stamp {
  display: inline-block;
  margin-left: .4rem;
  padding: .05rem .45rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  font-size: .85rem;
  color: var(--muted);
}

table.figures { width: 100%; border-collapse: collapse; margin: .5rem 0; }
table.figures th, table.figures td {
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
}
table.figures thead th { border-bottom: 2px solid var(--ink); font-size: .9rem; }
table.figures .num { text-align: right; font-variant-numeric: tabular-nums; }
table.figures tbody tr:hover { background: var(--panel); }
table.figures tfoot th, table.figures tfoot td {
  border-top: 2px solid var(--ink);
  border-bottom: none;
  font-weight: 700;
}
table.compare { max-width: 34rem; }
table.compare .delta th, table.compare .delta td { border-top: 2px solid var(--ink); }
table caption { text-align: left; color: var(--muted); font-size: .9rem; padding: .3rem 0; }

.computed-note {
  margin: .4rem 0 0;
  font-size: .88rem;
  color: var(--muted);
  max-width: 46rem;
}

.headline { margin: 1.5rem 0; }
.bignum { font-size: 2.4rem; font-weight: 700; margin: 0; font-variant-numeric: tabular-nums; }

/* Chart.js runs with maintainAspectRatio:false, so it sizes the canvas to its parent.
   The parent must therefore declare a height, and the canvas must NOT be sized by us -
   styling the canvas directly fights Chart.js's own resize and the two grow each other
   without bound (observed: an 818px chart became 16,675px). This is the wrapper pattern
   Chart.js documents: a positioned box with a fixed height, and a bare canvas inside. */
.chartwrap { margin: 1.4rem 0 0; padding: 0; }
.chartbox { position: relative; height: 26rem; }
.chartbox.short { height: 11rem; }
.chartwrap figcaption { font-size: .85rem; margin-top: .4rem; }

.actions { margin: 1rem 0 0; }

/* Provenance ------------------------------------------------------------- */
footer { margin-top: 3rem; border-top: 1px solid var(--rule); padding-top: 1rem; }
.provenance {
  margin: 1.2rem 0;
  padding: 1rem 1.2rem;
  background: var(--panel);
  border: 1px solid var(--rule);
}
.provenance h2, .provenance h3 { margin-top: 0; }
.provenance dl { display: grid; grid-template-columns: minmax(9rem, 14rem) 1fr; gap: .3rem 1rem; margin: 0; }
.provenance dt { font-weight: 600; color: var(--muted); }
.provenance dd { margin: 0; overflow-wrap: anywhere; }
.provenance code { font-size: .9em; }
.method { max-width: 46rem; }
.colophon { color: var(--muted); font-size: .9rem; max-width: 46rem; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 34rem) {
  .provenance dl { grid-template-columns: 1fr; }
  .provenance dt { margin-top: .5rem; }
  .bignum { font-size: 1.9rem; }
}

/* Navigation ------------------------------------------------------------- */
.mainnav { margin: .4rem 0 0; display: flex; flex-wrap: wrap; gap: 1rem; font-size: .95rem; }
.mainnav a { text-decoration: none; padding-bottom: .1rem; border-bottom: 2px solid transparent; }
.mainnav a:hover { border-bottom-color: var(--accent); }

/* Capital projects map --------------------------------------------------- */
/* Leaflet sizes itself to its container, exactly like Chart.js, so the container
   states a height and the map element is never styled directly. */
#capital-map {
  height: 34rem;
  border: 1px solid var(--rule);
  background: var(--bg);
}
.attribution { font-size: .8rem; margin-top: .4rem; }

.warnbox {
  margin: 1.4rem 0;
  padding: .9rem 1.1rem;
  border: 2px solid var(--ink);
  background: var(--panel);
  max-width: 52rem;
}
.warnbox h2 { margin: 0 0 .3rem; font-size: 1.05rem; }
.warnbox p { margin: 0; font-size: .95rem; }

.offmap { margin-top: 2.5rem; padding-top: .6rem; border-top: 2px solid var(--ink); }
.small { font-size: .85rem; }
.mt { margin-top: .8rem !important; }

.badge {
  display: inline-block;
  padding: 0 .4rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
/* Confidence is carried by the WORD in the badge, never by its colour alone. */
.badge-high { background: #e8f0e8; border-color: #7a9a7a; }
.badge-medium { background: #f5efe0; border-color: #b09a55; }
.badge-low { background: #f7e6e0; border-color: #c08163; }
.badge-exact { background: #e8eef5; border-color: #6d89aa; }
.badge-none { background: var(--panel); }

.locationtext {
  margin: .4rem 0;
  padding: .5rem .9rem;
  border-left: 4px solid var(--rule);
  font-size: 1.05rem;
}

.leaflet-popup-content h3 { margin: 0 0 .2rem; font-size: 1rem; }
.leaflet-popup-content .amount { margin: 0 0 .4rem; font-size: 1.25rem; font-weight: 700; }
.leaflet-popup-content .quoted { margin: 0 0 .4rem; font-style: italic; }
.leaflet-popup-content .located { margin: 0 0 .3rem; font-size: .85rem; }
.leaflet-popup-content .src { margin: 0; font-size: .8rem; color: var(--muted); }
.leaflet-container { font: inherit; }

@media (max-width: 34rem) {
  #capital-map { height: 22rem; }
}

/* 2D / 3D switch and the 3D scene ----------------------------------------- */
.viewswitch { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; margin: 0 0 .6rem; }
.viewswitch a {
  display: inline-block;
  padding: .3rem .8rem;
  border: 1px solid var(--rule);
  background: var(--bg);
  text-decoration: none;
}
.viewswitch a[aria-current="true"] {
  background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700;
}
.viewswitch .small { flex-basis: 100%; }

/* deck.gl, like Leaflet and Chart.js, sizes itself to its parent - so the parent
   states a height and the canvas inside is never styled by us.

   `position: relative` is load-bearing, not tidiness: deck.gl absolutely positions its
   canvas, so a container without a positioning context lets the canvas escape and float
   over the whole document. Every 3D host element must be listed here - a new scene whose
   id is missing from these selectors renders as a canvas loose on the page. */
#capital-3d,
#permits-3d,
#site-3d {
  position: relative;
  height: 38rem;
  border: 1px solid var(--rule);
  background: #eef1f4;
  overflow: hidden;
}
/* A single property fills the frame at close range, so it needs far less of the page
   than a view of the whole city does. */
#site-3d { height: 26rem; }
#capital-3d canvas,
#permits-3d canvas,
#site-3d canvas { outline: none; }
#capital-3d:focus-visible,
#permits-3d:focus-visible,
#site-3d:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
#map3d-status { min-height: 1.4rem; }
.t-note { opacity: .8; }

@media (max-width: 34rem) {
  #capital-3d,
  #permits-3d { height: 24rem; }
  #site-3d { height: 18rem; }
}

/* 3D map legend ----------------------------------------------------------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem 2.4rem;
  margin: .8rem 0 0;
  padding: .8rem 1rem;
  background: var(--panel);
  border: 1px solid var(--rule);
}
.legend-group h3 { margin: 0 0 .3rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.legend-group ul { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.legend-group li { display: flex; align-items: center; gap: .45rem; padding: .1rem 0; }
.legend .sw {
  display: inline-block;
  width: 1rem; height: 1rem;
  border: 1px solid rgba(0, 0, 0, .28);
  flex: none;
}
.legend .sw-stack {
  background: linear-gradient(to top, #1c844a 0 34%, #38b068 34% 67%, #60ca8c 67% 100%);
}
.legend > .small { flex-basis: 100%; margin: 0; }


/* Site pages -------------------------------------------------------------- */
/* One place, its records on the left, the selected record on the right.

   The split is a PROGRESSIVE ENHANCEMENT and the CSS has to keep that true: the server
   renders every panel visible, and `site-3d.js` hides all but one. So nothing here may
   hide a panel - if it did, a reader without JavaScript would lose the record, which is
   the one thing this site never does. */
.sitescene { margin: 1.2rem 0; }

.sitesplit {
  display: grid;
  grid-template-columns: minmax(14rem, 20rem) 1fr;
  gap: 1.6rem;
  align-items: start;
  margin-top: 1.6rem;
}

.sitelist { position: sticky; top: 1rem; }
.sitelist h3 { margin: 0 0 .4rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sitelist ol {
  list-style: none;
  margin: 0;
  padding: 0;
  /* Long enough to scroll on a busy parcel, short enough that the panel beside it stays
     on screen. The list scrolls; the page does not have to. */
  max-height: 32rem;
  overflow-y: auto;
  border: 1px solid var(--rule);
}
.sitelist li + li { border-top: 1px solid var(--rule); }
.sitelist a {
  display: block;
  padding: .5rem .7rem;
  text-decoration: none;
  color: inherit;
  border-left: 4px solid transparent;
}
.sitelist a:hover { background: var(--panel); }
.sitelist a[aria-current="true"] {
  background: var(--panel);
  border-left-color: var(--accent);
  font-weight: 700;
}
.sitelist-amount { display: block; font-size: 1.05rem; }
.sitelist-what { display: block; font-size: .9rem; }
.sitelist-when { display: block; }

.sitepanel {
  border: 1px solid var(--rule);
  padding: 1rem 1.2rem;
  background: var(--bg);
}
.sitepanel + .sitepanel { margin-top: 1.2rem; }
.sitepanel h3 { margin: 0 0 .2rem; }
.sitepanel h4 { margin: 1.2rem 0 .3rem; font-size: .95rem; }
.sitepanel .bignum { margin: 0; }
.sitepanel[hidden] { display: none; }

@media (max-width: 48rem) {
  .sitesplit { grid-template-columns: 1fr; }
  .sitelist { position: static; }
  .sitelist ol { max-height: 18rem; }
}

/* The 3D tooltip's breakdown list, on the permits map. */
.t-list { margin: .35rem 0; padding-left: 1.1rem; }
.t-list li { margin: 0; }

/* Flat capital map: the heat scale ---------------------------------------- */
/* One hue, light to dark, five quantile bands. Validated against the white the map is
   drawn on - the palest step still clears 2:1, so a low-value site is visible rather
   than lost in the background. Keep these in step with HEAT in capital-map.js. */
.sw-heat-0 { background: #86b6ef; }
.sw-heat-1 { background: #5598e7; }
.sw-heat-2 { background: #2a78d6; }
.sw-heat-3 { background: #1c5cab; }
.sw-heat-4 { background: #104281; }
.sw-line {
  background: linear-gradient(to bottom, transparent 0 35%, #2a78d6 35% 65%, transparent 65% 100%);
  border-color: transparent;
}
.sw-marker { background: rgba(42, 120, 214, .12); border: 2px dashed #2a78d6; }
/* A lot One Public Budget matched outside Arcadia: same shade, hollow, finely dashed. */
.sw-outside { background: rgba(28, 92, 171, .1); border: 2px dashed #1c5cab; }
.heatscale li { gap: .45rem; }

.leaflet-popup-content .titles {
  margin: 0 0 .4rem;
  padding-left: 1.1rem;
  font-size: .9rem;
}
