/* ============================================================================
   Design system. One neutral dark surface set, one accent, one typeface.
   Chart hues are the validated dark-surface categorical steps (blue / orange /
   aqua) assigned in fixed order and never cycled; verified with the palette
   validator on the all-pairs list (worst CVD dE 9.4, worst normal dE 20.9,
   all >= 3:1 against the chart surface).
   ========================================================================= */

:root {
  /* Inter everywhere. Framework's default body face is a serif, which is what
     made the site read as a notebook rather than a product; overriding the
     font variables retypes every element it owns, prose and UI alike. */
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: var(--sans);
  --sans-serif: var(--sans);

  /* Surfaces: page plane darkest, raised cards one step up, hairline borders.
     The choropleth's SURFACE constant must equal --surface-2 (it paints gaps
     between communes in this colour). */
  --page: #111110;
  --surface-2: #1a1a19;
  --surface-3: #222221;
  --border-1: rgba(255, 255, 255, 0.08);
  --border-2: rgba(255, 255, 255, 0.14);

  --ink-1: #f2f1ee;
  --ink-2: #c7c5c0;
  --ink-3: #8b8983;

  --accent: #f5a623; /* carried over from the previous dashboard */

  /* categorical - fixed order */
  --series-1: #3987e5; /* Flanders  / House */
  --series-2: #d95926; /* Wallonia  / Apartment */
  --series-3: #199e70; /* Brussels  */

  /* status */
  --good: #199e70;
  --warn: #c98500;
  --bad: #e66767;

  /* Framework token overrides: everything Framework derives (muted/faint
     steps, card colours, link colour) follows from these. */
  --theme-background-b: var(--page);
  --theme-background-a: var(--page);
  --theme-background: var(--page);
  --theme-background-alt: var(--surface-2);
  --theme-foreground: var(--ink-2);
  --theme-foreground-alt: var(--ink-1);
  --theme-foreground-focus: var(--accent);

  --observablehq-max-width: 1360px;
  --observablehq-header-height: 3.4rem;
}

/* ---------- base type ---------- */

body {
  font: 400 16px/1.6 var(--sans);
  letter-spacing: 0.001em;
  background: var(--page);
  text-rendering: optimizeLegibility;
}

h1 {
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -0.018em;
  color: var(--ink-1);
  margin-bottom: 0.35rem;
}

h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--ink-1);
  margin-top: 3rem;
}

h3 {
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.008em;
  color: var(--ink-1);
  margin-top: 2rem;
}

a[href] { color: var(--accent); }
#observablehq-main a[href]:not(.wordmark) { text-underline-offset: 3px; }
#observablehq-main a[href]:hover { text-decoration: underline; }

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

::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

* { scrollbar-width: thin; scrollbar-color: #3a3a38 transparent; }

/* Page kicker + standfirst under each h1. */
.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 10px;
}
.eyebrow::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 9px;
  background: var(--accent);
  border-radius: 2px;
  transform: rotate(45deg) translateY(-1px);
}
.dek {
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 720px;
}

/* ---------- layout ---------- */

/* Framework caps `p, table, figure, figcaption, h1..h6` at a 640px reading
   measure. On a dashboard the charts are the content; running prose keeps a
   bounded measure because very long lines are genuinely hard to read. */
#observablehq-main :is(figure, table, figcaption, h1, h2, h3, h4, h5, h6) { max-width: none; }
#observablehq-main :is(p, ul, ol, blockquote) { max-width: 760px; }
#observablehq-main .note { max-width: none; }
#observablehq-main figure svg { max-width: 100%; }

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

#observablehq-header {
  left: 0;
  right: 0;
  margin: 0 0 2rem;
  padding: 0;
  height: var(--observablehq-header-height);
  display: block;
  background: color-mix(in srgb, var(--page) 78%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-1);
}

.hd-inner {
  /* The content column is the body max-width minus Framework's 2rem side insets; matching it
     here lines the wordmark up with every page's h1. */
  width: min(calc(100% - 4rem), calc(var(--observablehq-max-width) - 4rem));
  margin: 0 auto;
  padding: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -0.008em;
  color: var(--ink-1) !important;
  white-space: nowrap;
}
.wordmark .mark {
  width: 9px;
  height: 9px;
  background: var(--accent);
  border-radius: 2.5px;
  transform: rotate(45deg);
  flex: none;
}

.hd-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.hd-nav::-webkit-scrollbar { display: none; }
.hd-nav a {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-3) !important;
  padding: 7px 12px;
  border-radius: 7px;
  white-space: nowrap;
  transition: color 0.12s, background 0.12s;
}
.hd-nav a:hover { color: var(--ink-1) !important; background: rgba(255, 255, 255, 0.05); text-decoration: none; }
.hd-nav a[aria-current="page"] {
  color: var(--ink-1) !important;
  background: rgba(255, 255, 255, 0.07);
}

/* ---------- footer ---------- */

#observablehq-footer {
  margin-top: 6rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--border-1);
}
.ft-inner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--ink-3);
}

/* ---------- cards ---------- */

.card {
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: 14px;
  padding: 20px 22px 16px;
  margin: 1.25rem 0 1.5rem;
  font: 400 14px/1.5 var(--sans);
  color: var(--ink-2);
}

.card h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.008em;
  color: var(--ink-1);
  margin: 0 0 2px;
}
.card h3,
.card .card-sub {
  font-size: 13.5px;
  font-weight: 400;
  color: var(--ink-3);
  margin: 0 0 4px;
}
.card form { margin-top: 10px; }
.card figure { margin-block: 6px; }

/* ---------- KPI tiles ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 12px;
  margin: 1.1rem 0 1.6rem;
}

.kpi {
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: 14px;
  padding: 16px 18px 14px;
}

.kpi h3 {
  margin: 0 0 8px;
  font-size: 11.5px;
  font-weight: 550;
  letter-spacing: 0.09em;
  color: var(--ink-3);
  text-transform: uppercase;
}

/* Proportional figures on the big number: tabular-nums gives every digit the
   width of a 0, which makes a value like 121 look loose at display size. */
.kpi .value {
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -0.022em;
  line-height: 1.1;
  color: var(--ink-1);
}

.kpi .delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 550;
  margin-top: 9px;
  padding: 2.5px 8px;
  border-radius: 999px;
}
.kpi .delta.up   { color: #4fc596; background: color-mix(in srgb, var(--good) 13%, transparent); }
.kpi .delta.down { color: #ef8f8f; background: color-mix(in srgb, var(--bad) 13%, transparent); }
.kpi .delta.flat { color: var(--ink-3); background: rgba(255, 255, 255, 0.05); }
.kpi .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 8px; }

/* ---------- notices ---------- */

.note {
  border: 1px solid color-mix(in srgb, var(--warn) 32%, transparent);
  border-left: 3px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 6%, transparent);
  padding: 13px 18px;
  border-radius: 10px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 1.25rem 0;
}
.note strong { color: var(--ink-1); }
/* Framework's note component injects a bold "Note" heading; these callouts explain themselves. */
.note::before { display: none; }
.note.info {
  border-color: color-mix(in srgb, var(--series-1) 32%, transparent);
  border-left-color: var(--series-1);
  background: color-mix(in srgb, var(--series-1) 6%, transparent);
}

/* ---------- inputs ---------- */

#observablehq-main form {
  font: 400 14px var(--sans);
  color: var(--ink-2);
  accent-color: var(--accent);
}
#observablehq-main select,
#observablehq-main input[type="number"] {
  font: 400 13.5px var(--sans);
  color: var(--ink-1);
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 7px;
  padding: 4px 8px;
}

/* ---------- tables ---------- */

.tbl { width: 100%; max-width: 1180px; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 550;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--border-2);
  padding: 9px 14px 9px 0;
  position: sticky;
  top: 0;
  background: var(--surface-2);
}
.tbl td {
  padding: 8px 14px 8px 0;
  border-bottom: 1px solid var(--border-1);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.tbl tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }
.tbl td.name { color: var(--ink-1); font-weight: 500; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl-scroll { max-height: 560px; overflow-y: auto; overflow-x: auto; border-radius: 4px; }

/* Wide content must scroll inside its own box, never the page body. */
.scroll-x { overflow-x: auto; }

/* Plot's generated legends (swatches and colour ramps) default to 10px system type; lift them
   to match the axis text. The class name is hash-suffixed, hence the attribute match. */
#observablehq-main [class*="-swatches"] {
  font-family: var(--sans) !important;
  font-size: 13px !important;
  color: var(--ink-2);
}
#observablehq-main [class*="-ramp"] {
  font-family: var(--sans) !important;
  font-size: 12.5px !important;
  color: var(--ink-2);
}

/* ---------- chart legend ---------- */

.legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 13.5px;
  color: var(--ink-2);
  margin: 2px 0 10px;
}
.legend .item { display: flex; align-items: center; gap: 7px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }

/* ---------- small screens ---------- */

@media (max-width: 720px) {
  .hd-inner { width: calc(100% - 2rem); }
  .wordmark span + span { display: none; }
  h1 { font-size: 25px; }
  .kpi .value { font-size: 26px; }
}

/* ============================================================================
   Motion, hero, skeletons. Everything that MOVES is gated behind html.anim,
   which a head script adds only when the visitor has not asked for reduced
   motion, so the no-JS and reduced-motion experiences are simply static.
   ========================================================================= */

/* ---------- micro-interactions ---------- */

.card,
.kpi {
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}
.card:hover,
.kpi:hover {
  transform: translateY(-2px);
  border-color: var(--border-2);
}

/* ---------- scroll reveal ---------- */
/* Direct children only: notes and captions inserted later by reactive cells sit
   inside .observablehq wrappers and must never start hidden. */

html.anim #observablehq-main > :is(.card, .kpi-grid, .note, h2, h3) {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.55s ease, transform 0.55s cubic-bezier(0.2, 0.7, 0.3, 1);
}
html.anim #observablehq-main > .in-view {
  opacity: 1;
  transform: none;
}

/* Tiles stagger in once their grid reveals. */
html.anim .kpi-grid .kpi { opacity: 0; transform: translateY(10px); }
html.anim .kpi-grid.in-view .kpi {
  opacity: 1;
  transform: none;
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.2, 0.7, 0.3, 1),
    border-color 0.16s ease;
}
html.anim .kpi-grid.in-view .kpi:nth-child(2) { transition-delay: 60ms; }
html.anim .kpi-grid.in-view .kpi:nth-child(3) { transition-delay: 120ms; }
html.anim .kpi-grid.in-view .kpi:nth-child(4) { transition-delay: 180ms; }

/* Re-rendered cells (a filter change swaps the chart) fade in rather than pop. */
html.anim .card .observablehq--block > :not(observablehq-loading) {
  animation: chart-in 0.3s ease both;
}
@keyframes chart-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* First-load line drawing: the head script normalises each line's pathLength
   to 1 and tags it, so one keyframe fits every chart. */
html.anim path.draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: line-draw 1.1s 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes line-draw {
  to { stroke-dashoffset: 0; }
}

/* ---------- hero (overview) ---------- */

.hero {
  position: relative;
  padding: 10px 0 6px;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -160px -60px auto -220px;
  height: 440px;
  background:
    radial-gradient(620px 300px at 20% 32%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    radial-gradient(560px 300px at 60% 8%, rgba(57, 135, 229, 0.09), transparent 72%);
  pointer-events: none;
  z-index: -1;
}
.hero::after {
  content: "";
  position: absolute;
  inset: -60px 0 -20px -40px;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.05) 1px, transparent 1.4px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(480px 300px at 22% 40%, #000 0%, transparent 78%);
  mask-image: radial-gradient(480px 300px at 22% 40%, #000 0%, transparent 78%);
  pointer-events: none;
  z-index: -1;
}
.hero h1 {
  font-size: clamp(32px, 3.4vw, 44px);
  background: linear-gradient(180deg, #ffffff 28%, #b6b3ad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-bottom: 3px;
}

/* ---------- KPI sparklines ---------- */

.kpi .spark {
  display: block;
  width: 100%;
  height: 36px;
  margin-top: 12px;
}
.kpi .spark .line {
  fill: none;
  stroke: #6e6c66;
  stroke-width: 1.6;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.kpi .spark .dot {
  fill: none;
  stroke: var(--accent);
  stroke-width: 5;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
}

/* ---------- skeleton loading ---------- */
/* Replace the spinner glyph with a chart-sized shimmer block inside cards, so a
   page assembles from placeholders instead of popping from nothing. */

.card .observablehq--block observablehq-loading {
  display: block;
  height: 300px;
  border-radius: 10px;
  color: transparent;
  background: linear-gradient(100deg, #1f1f1e 40%, #2a2a29 50%, #1f1f1e 60%) 0 0 / 200% 100%;
  transform: none;
  animation: none;
}
.card .observablehq--block observablehq-loading::before { content: ""; }
html.anim .card .observablehq--block observablehq-loading {
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer {
  to { background-position: -200% 0; }
}
