/* Cities of Australia — light, simple, one page.
 *
 * Chart/map colours come from the validated data-viz palette (light steps against
 * the #fcfcfb card surface): slot 1 blue #2a78d6 for cities and population bars,
 * slot 2 orange #eb6834 for capitals. Capitals also carry a ring and a label, so
 * colour never carries the distinction alone.
 */

*, *::before, *::after { box-sizing: border-box; }

:root {
  color-scheme: light;

  --plane:        #f9f9f7;
  --surface-1:    #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted:        #898781;
  --grid:         #e1e0d9;
  --axis:         #c3c2b7;
  --border:       rgba(11, 11, 11, 0.10);

  --city:    #2a78d6;   /* palette slot 1 */
  --capital: #eb6834;   /* palette slot 2 */

  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --wrap: 62rem;
  --r: 10px;
}

html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  background: var(--plane);
  color: var(--text-secondary);
  font: 400 1rem/1.6 var(--sans);
}

h1, h2, h3 { color: var(--text-primary); line-height: 1.15; margin: 0; letter-spacing: -0.02em; }
p { margin: 0 0 1rem; }
a { color: #1c5cab; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--city); outline-offset: 2px; border-radius: 4px;
}

.wrap { width: min(100% - 2.5rem, var(--wrap)); margin-inline: auto; }

/* ───────────────────────── header ───────────────────────── */

.head {
  padding: clamp(2.5rem, 7vw, 4.5rem) 0 2rem;
  background:
    radial-gradient(120% 90% at 85% 0%, rgba(235, 104, 52, 0.16) 0%, transparent 62%),
    radial-gradient(90% 80% at 8% 10%, rgba(42, 120, 214, 0.10) 0%, transparent 60%),
    var(--plane);
  border-bottom: 1px solid var(--border);
}
.eyebrow {
  color: #b3400f;
  font-size: 0.72rem; letter-spacing: 0.2em; text-transform: uppercase;
  font-weight: 700; margin: 0 0 0.7rem;
}
h1 { font-size: clamp(2rem, 6vw, 3.1rem); font-weight: 800; }
.lede { max-width: 46ch; margin: 1rem 0 0; font-size: 1.03rem; }

.stats {
  display: flex; flex-wrap: wrap; gap: 0.75rem 2.25rem;
  margin: 1.9rem 0 0;
}
.stats > div { min-width: 5.5rem; }
.stats dt {
  font-size: 0.68rem; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
}
.stats dd {
  margin: 0.25rem 0 0; color: var(--text-primary);
  font-size: 1.7rem; font-weight: 800; line-height: 1; letter-spacing: -0.03em;
}

/* ───────────────────────── cards ───────────────────────── */

main { padding: 2rem 0 3rem; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.35rem 1.4rem 1.15rem;
}
.card-head { margin-bottom: 1rem; }
.card-head h2 { font-size: 1.15rem; }
.card-head p { margin: 0.35rem 0 0; font-size: 0.88rem; color: var(--muted); max-width: 48ch; }

/* cap the width — the map is nearly square, so full-bleed would make it
   taller than the viewport and push the list off the page */
.map-card svg {
  display: block; width: 100%; max-width: 40rem; height: auto;
  margin-inline: auto; overflow: visible;
}

.legend {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem;
  list-style: none; margin: 0.9rem 0 0; padding: 0;
  font-size: 0.82rem; color: var(--text-secondary);
}
.legend li { display: inline-flex; align-items: center; gap: 0.45rem; }
/* namespaced k-* — a bare .city here would inherit the city-list item's own
   .city rule (display:grid, padding) and blow the swatch up */
.key { width: 0.7rem; height: 0.7rem; border-radius: 50%; flex: none; display: block; }
.key.k-city { background: var(--city); }
.key.k-cap { background: var(--capital); box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 3.5px var(--capital); }
.key-note { color: var(--muted); }

/* map marks */
.dot { fill: var(--city); fill-opacity: 0.78; stroke: var(--surface-1); stroke-width: 1; }
.dot.is-cap { fill: var(--capital); fill-opacity: 0.9; stroke-width: 1.5; }
.dot-hit { fill: transparent; cursor: default; }
.dot-g:hover .dot, .dot-g:focus-visible .dot { fill-opacity: 1; stroke: var(--text-primary); }
.graticule { stroke: var(--grid); stroke-width: 1; fill: none; }
.grat-lbl { fill: var(--muted); font-size: 9.5px; font-family: var(--sans); }
.map-lbl {
  fill: var(--text-primary); font-size: 11px; font-weight: 600;
  font-family: var(--sans); paint-order: stroke;
  stroke: var(--surface-1); stroke-width: 3px; stroke-linejoin: round;
}

.tip {
  position: fixed; z-index: 40; pointer-events: none;
  background: #16150f; color: #fff;
  border-radius: 8px; padding: 0.45rem 0.65rem;
  font-size: 0.8rem; line-height: 1.4; max-width: 15rem;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.25);
  opacity: 0; transition: opacity 0.1s;
}
.tip.on { opacity: 1; }
.tip span { color: #c3c2b7; }

/* ───────────────────────── controls ───────────────────────── */

.controls {
  display: flex; flex-wrap: wrap; gap: 1rem 1.6rem; align-items: flex-end;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.05rem 1.25rem;
  margin: 1.5rem 0 1rem;
}
.ctl { display: flex; flex-direction: column; gap: 0.4rem; }
.ctl.grow { flex: 1 1 12rem; }
.ctl-lbl {
  font-size: 0.68rem; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
}
label.ctl-lbl { display: flex; align-items: center; gap: 0.45rem; cursor: pointer; }
label.ctl-lbl input { accent-color: var(--city); width: 1rem; height: 1rem; }
input[type="search"], select {
  font: inherit; font-size: 0.92rem;
  color: var(--text-primary); background: #fff;
  border: 1px solid var(--axis); border-radius: 8px;
  padding: 0.5rem 0.65rem; min-height: 2.4rem; width: 100%;
}
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip {
  font: inherit; font-size: 0.8rem;
  background: #fff; color: var(--text-secondary);
  border: 1px solid var(--axis); border-radius: 999px;
  padding: 0.32rem 0.7rem; cursor: pointer; min-height: 1.95rem;
}
.chip:hover { border-color: var(--muted); color: var(--text-primary); }
.chip[aria-pressed="true"] {
  background: var(--city); border-color: var(--city); color: #fff; font-weight: 600;
}
.count {
  font-size: 0.82rem; color: var(--muted); margin: 0 0 1.1rem;
  font-variant-numeric: tabular-nums;
}

/* ───────────────────────── city list ───────────────────────── */

.cities { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.city {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0.95rem 1.15rem 1rem;
  display: grid; gap: 0.5rem 1rem;
  grid-template-columns: 1fr auto;
  align-items: baseline;
}
.city-name { display: flex; align-items: baseline; gap: 0.55rem; flex-wrap: wrap; }
.city h3 { font-size: 1.05rem; font-weight: 700; }
.badge {
  font-size: 0.65rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700;
  border-radius: 4px; padding: 0.14rem 0.4rem; white-space: nowrap;
}
.badge.cap { background: rgba(235, 104, 52, 0.14); color: #a53a0c; }
.badge.st { background: #eeede8; color: var(--text-secondary); }
.pop {
  color: var(--text-primary); font-weight: 700;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  text-align: right; font-size: 1rem;
}
.pop small { display: block; font-weight: 400; font-size: 0.68rem; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.note { grid-column: 1 / -1; margin: 0; font-size: 0.88rem; color: var(--text-secondary); }
/* population bar — one series, so no legend; the number beside it is the label */
.bar { grid-column: 1 / -1; height: 4px; background: var(--grid); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--city); border-radius: 2px; }
.city.is-cap .bar i { background: var(--capital); }

.empty {
  padding: 2.5rem 1rem; text-align: center; color: var(--muted);
  background: var(--surface-1);
  border: 1px dashed var(--axis); border-radius: var(--r);
}

/* ───────────────────────── footer ───────────────────────── */

.foot {
  border-top: 1px solid var(--border); background: #f4f3ef;
  padding: 2rem 0 3rem; font-size: 0.86rem; color: var(--muted);
}
.foot strong { color: var(--text-secondary); }
.foot p { max-width: 62ch; }
.foot p:last-child { margin-bottom: 0; }

/* The map SVG scales with the card, so on a narrow screen its type shrinks with
   it. Sizes are in user units, so scale them up to land back near 10px on screen. */
@media (max-width: 40rem) {
  .map-lbl { font-size: 19px; stroke-width: 4px; }
  .grat-lbl { font-size: 16px; }
}

@media (max-width: 34rem) {
  .city { grid-template-columns: 1fr; }
  .pop { text-align: left; }
}
