/* Area Explorer — map-free DLD sales & rental visualization gallery.
   Inherits design tokens (--bg, --gold, --text, .glass) from styles.css.
   This page scrolls, so it overrides the fixed app-shell body rules. */

.areas-body {
  position: static;
  inset: auto;
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(212, 175, 55, 0.06), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(76, 141, 255, 0.05), transparent 55%),
    var(--bg);
}

/* Chart-local palette roles (validated against the dark card surface). */
.areas-body {
  --surface-card: #10131A;
  --seq: #D4AF37;          /* sequential magnitude / "goodness" hue (gold) */
  --pos: #3FBF7F;          /* growth up */
  --neg: #E05555;          /* growth down */
  --div-hi: #4C8DFF;       /* diverging cool pole (blue) — CVD-safe */
  --div-lo: #E05555;       /* diverging warm pole (red) */
  --grid: rgba(255, 255, 255, 0.07);
  --axis: rgba(255, 255, 255, 0.18);
  --tick: rgba(242, 239, 230, 0.5);
}

/* ---------- Top bar ---------- */
#areas-hud {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: 58px;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
}
#areas-hud .home-link {
  color: var(--gold-2);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
#areas-hud .hud-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.01em;
}
.hud-sub { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
#section-nav {
  margin-left: auto;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
#section-nav::-webkit-scrollbar { display: none; }
#section-nav a {
  font-size: 11.5px;
  color: var(--text-dim);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
#section-nav a:hover { color: var(--gold); border-color: rgba(212, 175, 55, 0.3); background: rgba(212, 175, 55, 0.08); }
#gen-badge { white-space: nowrap; }

/* ---------- Layout ---------- */
#areas-main { max-width: 1220px; margin: 0 auto; padding: 28px 22px 80px; }
.lede { color: var(--text-dim); font-size: 14.5px; line-height: 1.6; max-width: 780px; margin: 4px 0 30px; }
.lede strong { color: var(--gold-2); font-weight: 600; }

.viz-section { margin: 0 0 40px; scroll-margin-top: 72px; }
.viz-head { margin-bottom: 14px; }
.viz-num {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--gold);
  text-transform: uppercase;
}
.viz-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  margin: 3px 0 4px;
}
.viz-sub { color: var(--text-dim); font-size: 13px; line-height: 1.55; max-width: 760px; }
.viz-card { padding: 22px; }
@media (max-width: 640px) { .viz-card { padding: 16px 12px; } #areas-main { padding: 20px 12px 60px; } }

/* ---------- KPI tiles ---------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.kpi-tile {
  padding: 16px 16px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}
.kpi-label { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); }
.kpi-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 27px;
  margin-top: 6px;
  line-height: 1.05;
}
.kpi-value .unit { font-size: 13px; color: var(--text-dim); font-weight: 500; margin-left: 3px; }
.kpi-foot { font-size: 11.5px; color: var(--text-dim); margin-top: 5px; }
.kpi-foot .up { color: var(--pos); }
.kpi-foot .down { color: var(--neg); }

/* ---------- Controls ---------- */
.viz-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.viz-controls .grow { flex: 1 1 auto; }
.viz-input, .viz-select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  padding: 8px 11px;
  font: 500 13px var(--font-body);
  min-width: 0;
}
.viz-select { cursor: pointer; }
.viz-input:focus, .viz-select:focus { outline: none; border-color: var(--gold-2); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button {
  font-size: 12px; padding: 7px 12px; color: var(--text-dim); background: transparent;
  border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: none; }
.seg button.on { color: var(--bg); background: var(--gold); font-weight: 600; }

/* ---------- Master table ---------- */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); }
table.master { border-collapse: collapse; width: 100%; font-size: 13px; }
table.master thead th {
  position: sticky; top: 0; z-index: 2;
  background: #0e1117;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: right;
  padding: 11px 12px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--line);
}
table.master thead th:first-child { text-align: left; }
table.master thead th:hover { color: var(--gold); }
table.master thead th .arrow { color: var(--gold); margin-left: 4px; font-size: 10px; }
table.master tbody td {
  padding: 9px 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}
table.master tbody td:first-child { text-align: left; font-weight: 500; font-variant-numeric: normal; }
table.master tbody tr:hover td { background: rgba(255, 255, 255, 0.03); }
.cell-heat { border-radius: 6px; }
.muted-cell { color: var(--text-dim); }

/* ---------- Ranked lists (small multiples) ---------- */
.rank-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 22px; }
.rank-block h4 {
  font-family: var(--font-display); font-size: 13px; font-weight: 600; margin-bottom: 12px;
  display: flex; justify-content: space-between; align-items: baseline;
}
.rank-block h4 .unit { color: var(--text-dim); font-size: 11px; font-weight: 400; }
.rank-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; margin-bottom: 9px; }
.rank-bar-name { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-bar-track { grid-column: 1 / -1; height: 7px; border-radius: 4px; background: rgba(255,255,255,0.05); overflow: hidden; margin-top: -3px; }
.rank-bar-fill { height: 100%; border-radius: 4px; }
.rank-val { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--text); font-weight: 600; }

/* ---------- SVG charts ---------- */
.chart-host { width: 100%; overflow-x: auto; }
svg.chart { display: block; width: 100%; height: auto; }
svg .grid line { stroke: var(--grid); stroke-width: 1; }
svg .axis line, svg .axis path { stroke: var(--axis); stroke-width: 1; }
svg .tick text { fill: var(--tick); font: 400 11px var(--font-body); }
svg .axis-title { fill: var(--text-dim); font: 500 11px var(--font-body); }
svg .qline { stroke: rgba(212,175,55,0.4); stroke-width: 1; stroke-dasharray: 4 4; }
svg .qlabel { fill: rgba(212,175,55,0.75); font: 500 10px var(--font-body); }
svg .dot { cursor: pointer; }
svg .dot:hover { stroke: #fff; stroke-width: 1.5; }
svg .lbl { fill: var(--text); font: 500 10.5px var(--font-body); }
svg .bar { cursor: pointer; }

/* legend */
.legend { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 12px; font-size: 12px; color: var(--text-dim); }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .grad { width: 120px; height: 10px; border-radius: 3px; vertical-align: -1px; display: inline-block; }
.legend-ends { display: inline-flex; gap: 6px; align-items: center; }

/* ---------- Bedroom matrix ---------- */
.bed-matrix { overflow-x: auto; }
table.beds { border-collapse: separate; border-spacing: 3px; font-size: 12.5px; }
table.beds th { color: var(--text-dim); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; padding: 4px 8px; }
table.beds th.rowh { text-align: left; }
table.beds td {
  text-align: center; padding: 9px 12px; border-radius: 7px; font-variant-numeric: tabular-nums;
  min-width: 78px;
}
table.beds td.rowh { text-align: left; font-weight: 500; white-space: nowrap; min-width: auto; }
table.beds td .n { display: block; font-size: 10px; color: var(--text-dim); margin-top: 1px; }

/* ---------- histogram ---------- */
.hist-note { font-size: 12px; color: var(--text-dim); margin-top: 10px; }

/* ---------- Trend explorer ---------- */
.trend-charts { display: flex; flex-direction: column; gap: 6px; }

/* ---------- tooltip ---------- */
#tooltip {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -110%);
  transition: opacity 0.1s;
  background: rgba(8, 10, 14, 0.96);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.5;
  max-width: 250px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
#tooltip.show { opacity: 1; }
#tooltip .tt-title { font-weight: 600; color: var(--gold-2); margin-bottom: 3px; font-family: var(--font-display); }
#tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; }
#tooltip .tt-row span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- footer ---------- */
.areas-footer { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--text-dim); font-size: 12px; line-height: 1.6; }
.areas-footer a { color: var(--gold-2); }
.areas-footer .honesty { margin-top: 6px; opacity: 0.8; }
