/* SF Rent Trends — Airbnb-inspired chrome over a validated dataviz core.
   Two color layers, kept separate on purpose:
   - BRAND (warm coral) dresses the chrome: header, buttons, focus, links.
   - SERIES 1-3 (blue/aqua/yellow) are the validated, CVD-safe data colors and
     also carry neighborhood identity (chips, tiles, chart lines). Never mixed.
   Dark mode is its own selected steps, not an automatic flip. */

:root {
  --page:           #fbf8f6;
  --surface-1:      #ffffff;
  --surface-2:      #fbfafa;
  --text-primary:   #1a1717;
  --text-secondary: #55514e;
  --text-muted:     #8a8681;
  --grid:           #ece8e3;
  --baseline:       #d9d4ce;
  --border:         rgba(26, 23, 23, 0.09);
  --brand:          #ff385c;
  --brand-strong:   #e11d48;
  --brand-ink:      #ffffff;
  --brand-wash:     rgba(255, 56, 92, 0.08);
  --series-1:       #2a78d6;
  --series-2:       #1baf7a;
  --series-3:       #eda100;
  --accent:         #2a78d6;   /* data accent (links/values tied to charts) */
  --wash:           rgba(26, 23, 23, 0.04);
  --delta-up:       #007a3d;
  --shadow-sm:      0 1px 2px rgba(26, 23, 23, 0.06), 0 2px 8px rgba(26, 23, 23, 0.05);
  --shadow-md:      0 6px 18px rgba(26, 23, 23, 0.09);
  --shadow-lg:      0 14px 40px rgba(26, 23, 23, 0.14);
  --radius:         18px;
  --radius-sm:      12px;
  --pill:           999px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page:           #121011;
    --surface-1:      #1c1a1b;
    --surface-2:      #222021;
    --text-primary:   #f6f4f2;
    --text-secondary: #c3beb8;
    --text-muted:     #928d87;
    --grid:           #2e2b2c;
    --baseline:       #3a3738;
    --border:         rgba(255, 255, 255, 0.10);
    --brand:          #ff5a6a;
    --brand-strong:   #ff7885;
    --brand-ink:      #1a1011;
    --brand-wash:     rgba(255, 90, 106, 0.14);
    --series-1:       #3987e5;
    --series-2:       #199e70;
    --series-3:       #c98500;
    --accent:         #4f97ea;
    --wash:           rgba(255, 255, 255, 0.05);
    --delta-up:       #34c77b;
    --shadow-sm:      0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md:      0 8px 22px rgba(0, 0, 0, 0.45);
    --shadow-lg:      0 16px 46px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 22px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  background: var(--wash);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.88em;
}
h1, h2, h3 { letter-spacing: -0.02em; }

/* ---------- Header / hero ---------- */
.site-header {
  position: relative;
  overflow: hidden;
  padding: 26px 0 22px;
  background:
    radial-gradient(120% 140% at 88% -10%, var(--brand-wash), transparent 60%),
    var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap { position: relative; z-index: 1; }
/* slow-drifting aurora — the header's ambient motion */
.aurora {
  position: absolute;
  inset: -40% -10% auto auto;
  width: 60vw;
  height: 320px;
  background:
    radial-gradient(closest-side, rgba(255, 56, 92, 0.20), transparent),
    radial-gradient(closest-side, rgba(42, 120, 214, 0.16), transparent);
  background-position: 20% 30%, 70% 60%;
  background-repeat: no-repeat;
  background-size: 55% 80%, 60% 70%;
  filter: blur(28px);
  animation: aurora 22s ease-in-out infinite alternate;
  z-index: 0;
  pointer-events: none;
}
@keyframes aurora {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); opacity: .8; }
  50%  { transform: translate3d(-6%, 6%, 0) rotate(8deg) scale(1.15); opacity: 1; }
  100% { transform: translate3d(4%, -4%, 0) rotate(-6deg) scale(1.05); opacity: .75; }
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.01em;
  color: var(--brand);
  background: var(--brand-wash);
  padding: 5px 12px 5px 9px;
  border-radius: var(--pill);
  margin-bottom: 12px;
}
.brand-mark { font-size: 16px; }
.site-header h1 {
  margin: 0 0 6px;
  font-size: clamp(21px, 2.6vw, 27px);
  line-height: 1.15;
  font-weight: 750;
}
.tagline { margin: 0; color: var(--text-secondary); max-width: 62ch; font-size: 15px; }

/* ---------- Caveats ---------- */
.caveats {
  margin: 22px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  box-shadow: var(--shadow-sm);
  padding: 6px 20px;
  overflow: hidden;
}
.caveats summary {
  cursor: pointer;
  font-weight: 650;
  color: var(--text-primary);
  padding: 12px 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 9px;
}
.caveats summary::-webkit-details-marker { display: none; }
.caveats summary::before {
  content: "ⓘ";
  color: var(--brand);
  font-size: 16px;
}
.caveats[open] summary { border-bottom: 1px solid var(--grid); }
.caveats ul { margin: 12px 0 14px; padding-left: 20px; color: var(--text-secondary); }
.caveats li { margin: 8px 0; }
.caveats strong { color: var(--text-primary); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  margin: 18px 0;
}
.chart-card { transition: box-shadow .25s ease; }
.chart-card:hover { box-shadow: var(--shadow-md); }

/* ---------- Controls ---------- */
.controls-row { display: flex; gap: 30px; flex-wrap: wrap; }
.hood-picker { flex: 1 1 380px; }
.use-picker { flex: 0 1 auto; }
.context-controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-top: 44px;
}
.context-heading h2 { margin: 0 0 4px; font-size: 19px; }
.context-heading p { margin: 0; color: var(--text-muted); font-size: 13px; }
label { display: block; font-weight: 650; margin-bottom: 8px; }
.hint { font-weight: 400; color: var(--text-muted); font-size: 13px; }
.hood-input-row { display: flex; gap: 8px; }
.quick-hoods {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.quick-hood {
  min-height: 44px;
  border: 1px solid var(--baseline);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-secondary);
  padding: 9px 11px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  transition: background .16s, border-color .16s, color .16s, transform .12s;
}
.quick-hood:hover { border-color: var(--text-muted); color: var(--text-primary); }
.quick-hood:active { transform: scale(.98); }
.quick-hood.active {
  border-color: var(--brand);
  background: var(--brand-wash);
  color: var(--brand-strong);
}
.quick-hood:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--brand-wash); }
.hood-note { margin: 9px 0 0; color: var(--text-muted); font-size: 12px; line-height: 1.45; }
input {
  background: var(--surface-1);
  border: 1.5px solid var(--baseline);
  border-radius: var(--pill);
  color: var(--text-primary);
  padding: 11px 18px;
  font: inherit;
  flex: 1;
  min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--text-muted); }
input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-wash);
}

.btn {
  background: var(--surface-1);
  border: 1.5px solid var(--baseline);
  border-radius: var(--pill);
  color: var(--text-primary);
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .18s, background .18s, border-color .18s;
}
.btn:hover { border-color: var(--text-muted); box-shadow: var(--shadow-sm); }
.btn:active { transform: scale(0.96); }
.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
  background-image: linear-gradient(135deg, var(--brand), var(--brand-strong));
}
.btn.primary:hover { box-shadow: var(--shadow-md); filter: brightness(1.04); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--wash); border-color: transparent; box-shadow: none; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--brand-wash); }

.segmented {
  display: inline-flex;
  background: var(--wash);
  border-radius: var(--pill);
  padding: 4px;
  gap: 2px;
}
.seg {
  background: transparent;
  border: none;
  border-radius: var(--pill);
  color: var(--text-secondary);
  padding: 8px 15px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s, color .18s, box-shadow .18s;
}
.seg:hover { color: var(--text-primary); }
.seg.active {
  background: var(--surface-1);
  color: var(--brand);
  box-shadow: var(--shadow-sm);
}

/* ---------- Neighborhood chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; min-height: 4px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  border-radius: var(--pill);
  padding: 7px 9px 7px 14px;
  font-size: 14px;
  font-weight: 600;
  animation: pop-in .32s cubic-bezier(.2, 1.3, .4, 1) both;
}
.chip .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 0%, transparent); }
.chip .meta { color: var(--text-muted); font-size: 12px; font-weight: 400; }
.chip button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 50%;
  line-height: 1;
  transition: background .15s, color .15s;
}
.chip button:hover { background: var(--wash); color: var(--text-primary); }

/* ---------- Rent heat map ---------- */
.map-wrap { position: relative; }
#map-box svg { display: block; width: 100%; height: auto; max-height: 520px; }
#map-box .zip-shape {
  stroke: var(--surface-1);
  stroke-width: 1.2;
  cursor: default;
  transition: filter .15s, stroke-width .15s;
}
#map-box .zip-shape:hover { filter: brightness(1.04); }
#map-box .zip-shape.selected { stroke: var(--text-primary); stroke-width: 2.5; }
#map-box .zip-shape.nodata { cursor: default; }
#map-box .zip-label { pointer-events: none; font-weight: 700; }
#map-box .zip-label .val { font-weight: 600; opacity: .85; }
.map-legend {
  display: flex; align-items: center; gap: 10px;
  margin-top: 10px; color: var(--text-muted); font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.legend-ramp {
  flex: 0 1 220px; height: 10px; border-radius: var(--pill);
  background: linear-gradient(90deg, #cde2fb, #86b6ef, #3987e5, #1c5cab, #0d366b);
}
.map-tip {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 10px 13px;
  font-size: 13px;
  max-width: 260px;
  line-height: 1.45;
}
.map-tip .t-zip { font-weight: 750; font-size: 14px; }
.map-tip .t-rent { font-variant-numeric: tabular-nums; }
.map-tip .t-hoods { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* ---------- Status / progress ---------- */
.status {
  margin-top: 14px;
  color: var(--text-secondary);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.status[hidden] { display: none; }
.status .bar {
  flex: 1;
  max-width: 300px;
  height: 7px;
  border-radius: var(--pill);
  background: var(--wash);
  overflow: hidden;
}
.status .bar span {
  display: block; height: 100%;
  border-radius: var(--pill);
  background: linear-gradient(90deg, var(--brand), var(--brand-strong));
  width: 0;
  transition: width .4s;
}
.status.error { color: var(--brand-strong); }

/* ---------- Summary tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
}
.tile::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 4px;
  background: var(--tile-color, var(--baseline));
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.tile h3 { margin: 4px 0 14px; font-size: 15px; display: flex; align-items: center; gap: 9px; }
.tile h3 .dot { width: 11px; height: 11px; border-radius: 50%; }
.tile .stats { display: flex; gap: 20px; flex-wrap: wrap; }
.tile .stat .v { font-size: 23px; font-weight: 700; letter-spacing: -0.02em; }
.tile .stat .l { color: var(--text-muted); font-size: 12px; margin-top: 1px; }
.tile .stat .d { font-size: 12px; color: var(--text-secondary); margin-top: 3px; font-weight: 600; }

/* ---------- Rent benchmark ---------- */
#card-rent { background: linear-gradient(180deg, var(--brand-wash), transparent 120px), var(--surface-1); }
.rent-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; }
.rent-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
}
.rent-panel::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 4px;
  background: var(--rent-color, var(--baseline));
}
.rent-panel:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.rent-panel h3 { margin: 6px 0 4px; font-size: 15px; display: flex; align-items: center; gap: 9px; }
.rent-panel h3 .dot { width: 11px; height: 11px; border-radius: 50%; }
.rent-hero { display: flex; align-items: baseline; gap: 9px; margin: 8px 0 2px; flex-wrap: wrap; }
.rent-hero .num { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.rent-hero .lbl { color: var(--text-muted); font-size: 13px; }
.rent-hero .est {
  font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); background: var(--wash);
  border-radius: var(--pill); padding: 2px 8px; font-weight: 700;
}
.rent-overall { color: var(--text-secondary); font-size: 13px; margin: 2px 0 12px; }
.rent-overall .yoy-up { color: var(--delta-up); font-weight: 700; }
.rent-overall .yoy-down { color: var(--brand); font-weight: 700; }
.rent-beds { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-bottom: 12px; }
.rent-beds .bed {
  text-align: center; padding: 9px 2px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  transition: transform .15s;
}
.rent-beds .bed:hover { transform: translateY(-2px); }
.rent-beds .bed.hi {
  background: var(--brand-wash);
  border-color: color-mix(in srgb, var(--rent-color) 45%, transparent);
}
.rent-beds .bed .b-v { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.rent-beds .bed .b-l { color: var(--text-muted); font-size: 11px; margin-top: 1px; }
.rent-spark { height: 50px; position: relative; }
.rent-panel .measured-tag { color: var(--delta-up); font-size: 11px; font-weight: 700; }
.rent-panel .none { color: var(--text-muted); font-size: 13px; padding: 14px 0; }
.rent-metro {
  color: var(--text-secondary); font-size: 13px; margin-top: 16px;
  padding-top: 14px; border-top: 1px solid var(--grid);
}
.rent-metro strong { color: var(--text-primary); }
.rent-metro .census-hint {
  color: var(--text-muted); display: block; margin-top: 8px;
  padding: 8px 12px; background: var(--wash); border-radius: var(--radius-sm);
}

/* ---------- Charts ---------- */
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.chart-card h2, #card-rent h2, #lookup-card h2 { margin: 0 0 4px; font-size: 19px; font-weight: 700; }
.chart-sub { margin: 0 0 12px; color: var(--text-muted); font-size: 13px; max-width: 72ch; line-height: 1.5; }
.plot { position: relative; height: 330px; }
.plot-tall { height: 430px; }
.chart-note { color: var(--text-muted); font-size: 12.5px; margin: 12px 0 0; line-height: 1.5; }
.table-toggle { flex: none; font-size: 13px; padding: 7px 15px; }

.table-view { overflow-x: auto; }
.table-view table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.table-view th, .table-view td {
  text-align: right;
  padding: 8px 12px;
  border-bottom: 1px solid var(--grid);
  font-variant-numeric: tabular-nums;
}
.table-view th:first-child, .table-view td:first-child { text-align: left; }
.table-view th { color: var(--text-secondary); font-weight: 650; border-bottom: 1.5px solid var(--baseline); }
.table-view tbody tr { transition: background .12s; }
.table-view tbody tr:hover { background: var(--wash); }
.table-view td { color: var(--text-primary); }
.table-view .na { color: var(--text-muted); }

/* ---------- Lookup ---------- */
.lookup-row { display: flex; gap: 8px; max-width: 500px; }
#lookup-results { margin-top: 14px; }
.parcel-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 12px 16px;
  margin: 7px 0;
  font: inherit;
  cursor: pointer;
  transition: transform .14s, box-shadow .16s, border-color .16s;
}
.parcel-row:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: transparent; }
.parcel-row .loc { font-weight: 650; }
.parcel-row .sub { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.parcel-row .val { font-variant-numeric: tabular-nums; color: var(--text-secondary); white-space: nowrap; font-weight: 650; }
.parcel-row.selected { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-wash); }
#parcel-detail { margin-top: 18px; }
#parcel-detail h3 { margin: 0 0 2px; font-size: 16px; }

/* ---------- Footer ---------- */
.footer { color: var(--text-muted); font-size: 13px; margin: 30px 0 48px; line-height: 1.6; }

/* ---------- Animations ---------- */
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes rise-in {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.enter {
  opacity: 0;
  animation: rise-in .5s cubic-bezier(.22, 1, .36, 1) forwards;
  animation-delay: calc(var(--enter-i, 0) * 80ms);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .aurora { animation: none; }
  .enter, .chip { animation: none; opacity: 1; }
  * { transition: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .wrap { padding-inline: 15px; }
  .site-header { padding-block: 21px 18px; }
  .quick-hoods { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-hood { min-height: 48px; }
  .hood-input-row .btn { padding-inline: 15px; }
  .controls-row { gap: 22px; }
  .context-controls { align-items: stretch; flex-direction: column; gap: 18px; margin-top: 34px; }
  .plot { height: 280px; }
  .segmented { flex-wrap: wrap; }
  .rent-hero .num { font-size: 30px; }
  .card { padding: 18px 16px; }
}
