/* =================================================================
   NZ Rental Market dashboard
   Layout: one reading column of panels; charts are hand-built SVG.
   Tokens follow amirghorbani.dev (dark-first, single theme).
   ================================================================= */
:root {
  color-scheme: dark;
  --bg: #050505;
  --surface: #111112;
  --surface-2: #161617;
  --text: #f3efe7;
  --text-dim: #c8c2b8;
  --muted: #9f998f;
  --muted-2: #857f74;
  --line: rgba(255, 255, 255, 0.08);
  --grid: rgba(255, 255, 255, 0.07);
  --accent: #ef5a1e;
  --gold: #c9a04c;
  /* data colours: validated for the dark surface (CVD-safe) */
  --s1: #3987e5;   /* blue */
  --s2: #d95926;   /* orange */
  --s3: #199e70;   /* aqua */
  --nz: #c8c2b8;   /* New Zealand reference line: neutral ink */
  --rise: #e66767; /* diverging: rent up */
  --fall: #3987e5; /* diverging: rent down */
  --b1: #b7d3f6; --b2: #6da7ec; --b3: #3987e5; --b4: #256abf; /* bedrooms ramp */
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Hanken Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(1200px 500px at 85% -10%, rgba(239, 90, 30, .10), transparent 60%), var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text); text-decoration-color: rgba(239, 90, 30, .6); text-underline-offset: 3px; }
a:hover { color: #ff7d3a; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: 10px; left: 10px; z-index: 300; padding: 8px 16px; border-radius: 999px; background: var(--accent); color: #140802; font-weight: 600; transform: translateY(-160%); transition: transform .2s; }
.skip-link:focus { transform: none; }

/* ---------- nav (matches the other project pages) ---------- */
.portfolio-nav {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: rgba(5, 5, 5, .86); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.portfolio-nav__back { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 12px; letter-spacing: .5px; color: var(--accent); text-decoration: none; }
.portfolio-nav__back:hover { color: var(--text); }
.portfolio-nav__label { font-family: var(--font-mono); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted-2); }

/* ---------- layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) 80px; }
.intro { padding-block: clamp(40px, 7vw, 80px) 28px; max-width: 820px; }
.eyebrow { font-family: var(--font-mono); font-size: 12px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--accent); margin: 0 0 16px; }
h1 { font-family: var(--font-display); font-weight: 600; font-size: clamp(34px, 5.4vw, 60px); line-height: 1.05; letter-spacing: -.5px; margin: 0 0 20px; text-wrap: balance; }
.lede { font-size: clamp(16px, 1.6vw, 18px); color: var(--text-dim); max-width: 66ch; margin: 0; }
h2 { font-family: var(--font-display); font-weight: 600; font-size: 20px; line-height: 1.25; margin: 0 0 4px; text-wrap: balance; }
h3 { font-family: var(--font-display); font-weight: 600; font-size: 16px; margin: 0 0 6px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 20px; }
.grid-2 > * { min-width: 0; }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 14px; margin: 8px 0 22px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.tile-label { font-size: 13px; color: var(--muted); }
.tile-value { font-family: var(--font-display); font-weight: 600; font-size: 34px; line-height: 1.1; letter-spacing: -.3px; }
.tile-value small { font-size: 16px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.tile-sub { font-size: 13px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.delta { font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- findings ---------- */
.findings { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 14px; margin-bottom: 22px; }
.finding { padding: 18px 20px; border-left: 2px solid var(--gold); background: linear-gradient(90deg, rgba(201, 160, 76, .07), transparent 70%); border-radius: 0 12px 12px 0; }
.finding p { margin: 0; font-size: 14.5px; color: var(--text-dim); }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: clamp(18px, 2.5vw, 26px); margin-bottom: 20px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px 20px; margin-bottom: 14px; }
.panel-head > div:first-child { min-width: 0; flex: 1 1 280px; }
.panel-sub { margin: 0; font-size: 14px; color: var(--muted); max-width: 62ch; }
.panel-flag { border-color: rgba(201, 160, 76, .28); }
.flag-label { font-family: var(--font-mono); font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--gold); margin: 0 0 8px; }
.note { font-size: 13.5px; color: var(--text-dim); margin: 12px 0 0; }

/* ---------- controls ---------- */
.controls { display: flex; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
.seg button { font: 500 12.5px var(--font-body); color: var(--muted); background: none; border: 0; padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { font: 500 12.5px var(--font-body); color: var(--text-dim); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px 5px 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip .sw { width: 9px; height: 9px; border-radius: 50%; background: transparent; box-shadow: inset 0 0 0 1px var(--muted-2); }
.chip[aria-pressed="true"] { color: var(--text); border-color: rgba(255, 255, 255, .22); }
.chip[aria-pressed="true"] .sw { background: var(--c); box-shadow: none; }
.chip:disabled { opacity: .4; cursor: not-allowed; }
.search input { font: 14px var(--font-body); color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; width: min(260px, 100%); }
.search input::placeholder { color: var(--muted-2); }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.axis text, .lbl { font: 11.5px var(--font-mono); fill: var(--muted); font-variant-numeric: tabular-nums; }
.lbl-strong { font: 600 12px var(--font-body); fill: var(--text); }
.gridline { stroke: var(--grid); stroke-width: 1; }
.zero { stroke: rgba(255, 255, 255, .28); stroke-width: 1; }
.crosshair { stroke: rgba(255, 255, 255, .35); stroke-width: 1; }
.series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dot { stroke: var(--surface); stroke-width: 2; }
.shade { fill: rgba(201, 160, 76, .09); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 13px; color: var(--text-dim); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 14px; height: 2px; border-radius: 2px; background: var(--c); }
.legend i.dash { background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); }
.tooltip { position: fixed; z-index: 200; pointer-events: none; min-width: 150px; padding: 10px 12px; border-radius: 10px; background: rgba(20, 20, 21, .97); border: 1px solid rgba(255, 255, 255, .12); box-shadow: 0 12px 30px rgba(0, 0, 0, .5); font-size: 13px; }
.tooltip .tt-title { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .tt-row span:first-child { display: inline-flex; align-items: center; gap: 7px; color: var(--text-dim); }
.tooltip .tt-row i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.tooltip .tt-row b { font-family: var(--font-mono); font-weight: 500; font-variant-numeric: tabular-nums; color: var(--text); }

/* ---------- small multiples ---------- */
.multiples { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 900px) { .multiples { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mult { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 2px; padding: 12px 12px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); min-width: 0; }
.mult:hover { border-color: rgba(255, 255, 255, .2); }
.mult:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.mult[aria-pressed="true"] { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }
.mult-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.mult-name { font: 600 13.5px var(--font-display); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mult-val { font: 12px var(--font-mono); color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mult-chg { font: 12px var(--font-mono); color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.mult-chg i { width: 7px; height: 7px; border-radius: 2px; background: var(--c); }
.mult svg { display: block; width: 100%; height: 56px; margin-top: 4px; }

/* ---------- events on the main chart ---------- */
.event-line { stroke: rgba(201, 160, 76, .55); stroke-width: 1; stroke-dasharray: 2 3; }
.event-lbl { font: 500 11px var(--font-body); fill: var(--gold); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); max-height: 520px; overflow-y: auto; }
.dtable, .mini-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.dtable th, .mini-table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; border-bottom: 1px solid var(--line); padding: 0; white-space: nowrap; }
.dtable th button { all: unset; cursor: pointer; display: block; padding: 10px 14px; }
.dtable th button::after { content: ""; margin-left: 6px; }
.dtable th[aria-sort="ascending"] button::after { content: "▲"; font-size: 9px; }
.dtable th[aria-sort="descending"] button::after { content: "▼"; font-size: 9px; }
.dtable th.num, .mini-table th.num { text-align: right; }
.dtable th.num button { text-align: right; width: 100%; box-sizing: border-box; }
.dtable td, .mini-table td { padding: 9px 14px; border-bottom: 1px solid var(--line); color: var(--text-dim); }
.mini-table th { padding: 8px 12px; }
.dtable td.num, .mini-table td.num { text-align: right; font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text); }
.dtable tr:hover td { background: rgba(255, 255, 255, .025); }
.chg { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
.chg i { width: 7px; height: 7px; border-radius: 2px; background: var(--c); }
.data-view { margin-top: 12px; font-size: 13.5px; color: var(--muted); }
.data-view summary { cursor: pointer; }
.data-view > div { margin-top: 10px; max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }

/* ---------- method ---------- */
.method { padding: clamp(18px, 2.5vw, 26px) 0 0; border-top: 1px solid var(--line); margin-top: 12px; }
.method > h2 { margin-bottom: 14px; }
.method-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 20px; }
.method p { font-size: 14.5px; color: var(--text-dim); margin: 0; }
.method .source { margin-top: 20px; font-size: 13px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
