/* Map-first atlas: a paper-toned panel beside a muted map, schools in clay to deep teal. */
:root {
  --paper: #f6f3ec;
  --paper-2: #ece7dc;
  --ink: #1f2a2a;
  --muted: #5d6766;
  --line: #d9d2c3;
  --teal: #176b6b;
  --clay: #c8794a;
  --focus: #e0a526;
  --display: Fraunces, Georgia, serif;
  --body: "Public Sans", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 14px/1.5 var(--body); }

.layout { display: grid; grid-template-columns: 400px minmax(0, 1fr); height: 100%; }
.panel { display: flex; flex-direction: column; gap: 16px; overflow-y: auto; padding: 24px 22px; border-right: 1px solid var(--line); }
.map-wrap { position: relative; min-width: 0; }
.map { position: absolute; inset: 0; }

.eyebrow { margin: 0 0 6px; color: var(--teal); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
h1 { margin: 0; font: 650 30px/1.08 var(--display); letter-spacing: -0.01em; text-wrap: balance; }
.lede { margin: 10px 0 0; color: var(--muted); }

.filters { display: grid; gap: 14px; padding: 14px; background: var(--paper-2); border-radius: 8px; }
.search input, select {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--ink); font: inherit;
}
fieldset { margin: 0; padding: 0; border: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
legend { width: 100%; margin-bottom: 4px; font-weight: 600; }
.row { display: grid; gap: 4px; }
.row label { display: flex; justify-content: space-between; font-weight: 600; }
output { color: var(--teal); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--teal); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.select { display: grid; gap: 4px; font-weight: 600; }
.toggle { display: flex; gap: 8px; align-items: center; }
input[type="checkbox"] { accent-color: var(--teal); }

.count { margin: 0; color: var(--muted); }
.count-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; }
.link-button { padding: 0; border: 0; background: none; color: var(--teal); font: 600 13px var(--body); text-decoration: underline; cursor: pointer; }
.search-area {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 2;
  padding: 9px 16px; border: 0; border-radius: 999px; background: var(--ink); color: var(--paper);
  font: 600 14px var(--body); box-shadow: 0 6px 18px rgb(31 42 42 / 0.25); cursor: pointer;
}
.search-area:hover { background: var(--teal); }
.results { list-style: none; margin: 0; padding: 0; display: grid; }
.results li { border-top: 1px solid var(--line); }
.results button {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  width: 100%; padding: 10px 4px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.results button:hover { background: var(--paper-2); }
.results li.selected { border-top-color: transparent; }
.results li.selected > button { background: #e3eeea; box-shadow: inset 4px 0 0 var(--teal); }
.results li.selected + li { border-top-color: transparent; }
.detail.preview { pointer-events: none; }
.detail.preview .close { visibility: hidden; }
.hint { font-style: italic; }
.facts.college { grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); margin: 10px 0 4px; }
.facts.college .fact b { font-size: 18px; }
.score {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  color: #fff; font: 600 14px var(--body); font-variant-numeric: tabular-nums;
}
.score.none { background: var(--line); color: var(--muted); }
.name { font-weight: 600; overflow-wrap: anywhere; }
.where { display: block; color: var(--muted); font-size: 12px; }
.home { color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.more { margin-top: 8px; padding: 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font: inherit; cursor: pointer; }

.sources { display: grid; gap: 6px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.sources p { margin: 0; }
.sources strong { color: var(--ink); }

.map-error { max-width: 360px; margin: 40px auto; padding: 16px; background: var(--paper-2); border-radius: 8px; color: var(--muted); }
.legend {
  position: absolute; left: 12px; bottom: 28px; padding: 10px 12px; width: 190px;
  background: rgb(246 243 236 / 0.94); border: 1px solid var(--line); border-radius: 8px; font-size: 12px;
}
.ramp { height: 10px; margin: 6px 0 4px; border-radius: 5px; background: linear-gradient(90deg, #c8794a, #e3c58f, #7fb3a3, #176b6b, #0b3d3d); }
.ticks { display: flex; justify-content: space-between; color: var(--muted); }

.detail {
  position: absolute; top: 12px; right: 12px; width: min(360px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow-y: auto;
  padding: 18px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 30px rgb(31 42 42 / 0.18);
}
.detail h2 { margin: 0 32px 4px 0; font: 650 22px/1.15 var(--display); }
.detail .close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--paper-2); font-size: 18px; cursor: pointer; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(95px, 1fr)); gap: 10px; margin: 14px 0; }
.fact { padding: 10px; background: var(--paper-2); border-radius: 6px; }
.fact b { display: block; font: 650 22px var(--display); font-variant-numeric: tabular-nums; }
.fact span { color: var(--muted); font-size: 12px; }
.links { display: grid; gap: 8px; }
.links a {
  display: block; padding: 10px 12px; border-radius: 6px; text-decoration: none; font-weight: 600;
  background: var(--teal); color: #fff;
}
.links a.profile { background: var(--ink); }
.detail h2 a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.links a.secondary { background: #fff; color: var(--teal); border: 1px solid var(--teal); }
.note { margin: 12px 0 0; color: var(--muted); font-size: 12px; }
.handoff { margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.handoff h3 { margin: 0 0 6px; font: 650 15px var(--display); }
.handoff ol { margin: 0 0 10px; padding-left: 18px; color: var(--muted); font-size: 13px; }
.handoff-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.handoff-actions a { color: var(--teal); font-weight: 600; }
.copy { padding: 7px 12px; border: 1px solid var(--teal); border-radius: 6px; background: var(--teal); color: #fff; font: 600 13px var(--body); cursor: pointer; }
.copy-status { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: 55vh auto; height: auto; }
  .map-wrap { grid-row: 1; height: 55vh; }
  .panel { grid-row: 2; overflow: visible; border-right: 0; padding-inline: max(16px, env(safe-area-inset-left)); }
  .detail { top: auto; bottom: 8px; right: 8px; left: 8px; width: auto; max-height: 70%; }
  .legend { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
