/* Market area analysis site. Colors are tokens; dark mode is its own set
   (validated: the four model colors pass the color-blind separation checks
   in both modes; light-mode aqua and yellow sit below 3:1, so every chart
   with several models carries line labels and a table). */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --m1: #2a78d6; /* primary GAM */
  --m2: #eb6834; /* best MARS */
  --m3: #1baf7a; /* elastic net */
  --m4: #eda100; /* other GAM */
  --neg: #e34948; /* diverging: value below the typical house */
  --mid: #f0efec;
  --na-bg: #e9dcc3; /* not analysed: sand, hatched */
  --na-fg: #a8875a;
  --pos: #2a78d6; /* diverging: value above the typical house */
  --band: rgba(42, 120, 214, 0.16);
  --accent: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --m1: #3987e5;
    --m2: #d95926;
    --m3: #199e70;
    --m4: #c98500;
    --neg: #e66767;
    --mid: #383835;
    --na-bg: #6b5a3e;
    --na-fg: #a8875a;
    --pos: #3987e5;
    --band: rgba(57, 135, 229, 0.22);
    --accent: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --ring: rgba(255, 255, 255, 0.10);
  --m1: #3987e5;
  --m2: #d95926;
  --m3: #199e70;
  --m4: #c98500;
  --neg: #e66767;
  --mid: #383835;
  --na-bg: #6b5a3e;
  --na-fg: #a8875a;
  --pos: #3987e5;
  --band: rgba(57, 135, 229, 0.22);
  --accent: #3987e5;
}

* { box-sizing: border-box; }
html { background: var(--page); }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}
main { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
header.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--page);
  border-bottom: 1px solid var(--ring);
}
header.top .bar {
  max-width: 1120px; margin: 0 auto; padding: 10px 16px;
  display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center;
}
header.top a.home { color: var(--ink-2); text-decoration: none; font-size: 14px; }
header.top a.home:hover { color: var(--ink); }
header.top .title { font-weight: 650; font-size: 18px; margin-right: auto; }
h1 { font-size: 30px; line-height: 1.2; margin: 8px 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 22px; margin: 44px 0 6px; padding-top: 8px; border-top: 1px solid var(--ring); }
h3 { font-size: 17px; margin: 24px 0 4px; }
p.lead { color: var(--ink-2); margin: 0 0 16px; max-width: 72ch; }
p, li { max-width: 78ch; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
nav.toc { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; margin: 12px 0 8px; }
nav.toc a { color: var(--ink-2); }

/* Segmented controls (log / price; 2D / 3D). */
.seg { display: inline-flex; border: 1px solid var(--ring); border-radius: 8px; overflow: hidden; }
.seg button {
  font: inherit; font-size: 14px; padding: 5px 12px; border: 0; cursor: pointer;
  background: transparent; color: var(--ink-2);
}
.seg button + button { border-left: 1px solid var(--ring); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin: 10px 0 14px; font-size: 14px; }
.controls label { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); }
select, input[type="number"] {
  font: inherit; font-size: 14px; padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--axis); background: var(--surface); color: var(--ink);
}
button.plain {
  font: inherit; font-size: 14px; padding: 4px 10px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--axis); background: var(--surface); color: var(--ink);
}

/* Stat tiles. */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 14px 0; }
.tile { background: var(--surface); border: 1px solid var(--ring); border-radius: 10px; padding: 12px 14px; }
.tile .k { font-size: 13px; color: var(--ink-2); }
.tile .v { font-size: 24px; font-weight: 650; margin-top: 2px; }
.tile .s { font-size: 13px; color: var(--muted); }
.nowrap { white-space: nowrap; }

/* Tables. */
.tablewrap { overflow-x: auto; margin: 10px 0; border: 1px solid var(--ring); border-radius: 10px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { color: var(--ink-2); font-weight: 600; background: var(--surface); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.swatch { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* Charts. */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 16px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
figure.chart { margin: 0; background: var(--surface); border: 1px solid var(--ring); border-radius: 10px; padding: 12px 12px 10px; }
figure.chart .plot { width: 100%; height: 330px; }
figure.chart.tall .plot { height: 560px; }
figure.chart h4 { margin: 0 0 2px; font-size: 15px; }
figure.chart figcaption { font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.readout { font-size: 13px; color: var(--ink); min-height: 1.4em; margin-top: 4px; }

/* Equations. */
pre.eq {
  white-space: pre-wrap; word-break: break-word; font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface); border: 1px solid var(--ring); border-radius: 10px; padding: 12px 14px; margin: 8px 0;
}
details { margin: 8px 0; }
summary { cursor: pointer; color: var(--ink-2); }

/* Definitions. */
dl.defs dt { font-weight: 650; margin-top: 10px; }
dl.defs dd { margin: 2px 0 0 0; color: var(--ink-2); max-width: 78ch; }

.map { width: 100%; height: 760px; background: var(--surface); border: 1px solid var(--ring); border-radius: 10px; }
footer { margin-top: 48px; font-size: 13px; color: var(--muted); }

@media print {
  header.top { position: static; }
  .controls, .seg, nav.toc { display: none; }
  figure.chart { break-inside: avoid; }
}
/* A tile with both scales side by side. */
.tile .pairs { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 2px; }
.tile .pair .pk { font-size: 12px; color: var(--muted); }
.tile .pair .v { font-size: 22px; }
/* The curves' hover box, drawn beside the pointer. */
.tip {
  position: fixed; z-index: 50; display: none; pointer-events: none;
  max-width: 340px; padding: 8px 10px; border-radius: 8px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--axis);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); font-size: 13px; line-height: 1.45;
}
.tip .tiprow { margin-top: 6px; color: var(--ink-2); font-weight: 600; }

/* A caution under the tiles: a note, not a status color. */
.caution { border-left: 3px solid var(--axis); padding: 6px 12px; margin: 10px 0; background: var(--surface); border-radius: 0 8px 8px 0; font-size: 14px; max-width: none; }
