/* ZipCodeComps: shared styles. Plain CSS, no build step. Mobile first; test at 390 px. */

:root {
  color-scheme: light;
  /* ink and surfaces */
  --ink: #13283d;          /* harbor navy: text and outlines */
  --ink-2: #44566a;
  --muted: #6b7a89;
  --page: #f3f6f8;
  --paper: #ffffff;
  --line: #d9e1e7;
  --sea: #dce6ec;          /* map background: reads as bay and ocean */
  --kw-red: #b40101;       /* brokerage only: strip and primary button */
  --kw-red-dark: #8f0000;
  --focus: #2a78d6;

  /* data colours: blue = signals pointing to firmer prices, orange = softer, grey = neutral */
  --b1: #9ec5f4; --b2: #5598e7; --b3: #256abf; --b4: #104281;
  --o0: #fbd7bf; --o1: #eeb38c; --o2: #da7827; --o3: #a25200; --o4: #693302;
  --mid: #e7e5df;
  --nodata: #f7f7f5;
  --context: #f3f6f8;      /* land outside the area shown */
  --series: #2a78d6;
  --band: rgba(68, 86, 106, 0.16);

  --display: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Fonts are served from this site (assets/fonts, SIL Open Font License), so no visitor data goes to a font service. */
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/montserrat-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/montserrat-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/montserrat-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/montserrat-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Playfair Display"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/playfair-display-latin-700-normal.woff2") format("woff2"); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
}
img { max-width: 100%; }  /* not canvas or svg: Leaflet sizes its own map layers */
a { color: var(--b3); text-underline-offset: 2px; }
a:hover { color: var(--b4); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.15; margin: 0; }
h2 { font-size: 1.563rem; }
h3 { font-size: 1.25rem; }
p { margin: 0 0 0.75rem; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: -999px; top: 0; background: var(--paper); padding: 8px 12px; z-index: 2000; }
.skip:focus { left: 8px; }
.fine { font-size: 0.8rem; color: var(--ink-2); line-height: 1.5; }

/* ---------------------------------------------------------------- header */
.brand-strip { background: var(--kw-red); color: #fff; }
.brand-strip .wrap { padding-top: 6px; padding-bottom: 6px; }
.brokerage { font-size: 1rem; font-weight: 700; letter-spacing: 0.01em; }
.masthead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; padding-top: 12px; padding-bottom: 12px; }
.wordmark { font-family: var(--display); font-size: 1.4rem; font-weight: 700; color: var(--ink); text-decoration: none; }
.wordmark:hover { color: var(--ink); }
.nav { display: flex; gap: 14px; font-size: 0.85rem; font-weight: 600; }
.nav a { color: var(--ink-2); text-decoration: none; padding: 6px 0; }
.nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }

/* ---------------------------------------------------------------- map page */
.intro { padding-top: 20px; padding-bottom: 8px; }
.intro h1 { font-size: 1.953rem; max-width: 18ch; }
.lede { margin-top: 10px; max-width: 60ch; color: var(--ink-2); }
.stamp { font-size: 0.875rem; color: var(--muted); }

.controls { display: grid; gap: 10px; margin: 8px 0 12px; }
.search { position: relative; }
.search input {
  width: 100%; font: inherit; font-size: 1rem; padding: 11px 14px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--paper); color: var(--ink);
}
.search ul {
  position: absolute; z-index: 1200; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px 0;
  list-style: none; background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(19, 40, 61, 0.14); max-height: 320px; overflow-y: auto;
}
.search li { padding: 9px 14px; cursor: pointer; display: flex; gap: 10px; }
.search li[aria-selected="true"], .search li:hover { background: var(--page); }
.search li .z { font-weight: 700; }
.search li .t { color: var(--ink-2); }

.toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); padding: 3px; }
.toggle button {
  font: inherit; font-size: 0.875rem; font-weight: 600; border: 0; background: transparent; color: var(--ink-2);
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
}
.toggle button[aria-checked="true"] { background: var(--ink); color: #fff; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.chips button {
  flex: 0 0 auto; font: inherit; font-size: 0.875rem; font-weight: 500; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px; cursor: pointer;
}
.chips button[aria-checked="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); font-weight: 700; }

.explore { display: grid; gap: 16px; }
.map-wrap { position: relative; }
#map { height: 62vh; min-height: 360px; max-height: 640px; border-radius: 12px; border: 1px solid var(--line); }
.leaflet-container { background: var(--sea); font-family: var(--sans); }
.leaflet-control-attribution { font-size: 0.7rem; }
.zip-label {
  font-size: 0.72rem; font-weight: 700; color: var(--ink); white-space: nowrap; pointer-events: none;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff;
}
.map-tip { font-family: var(--sans); font-size: 0.8rem; }

.zip-card {
  position: absolute; z-index: 1000; left: 10px; right: 10px; bottom: 10px;
  background: var(--paper); border-radius: 12px; border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(19, 40, 61, 0.22); padding: 14px 16px 12px;
}
.zip-card .close {
  position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; border: 0; background: transparent;
  font-size: 1.4rem; line-height: 1; color: var(--ink-2); cursor: pointer; border-radius: 8px;
}
.card-head { display: flex; align-items: baseline; gap: 10px; padding-right: 36px; }
.card-zip { font-family: var(--display); font-size: 1.953rem; font-weight: 700; line-height: 1; }
.card-town { font-weight: 600; color: var(--ink-2); }
.card-score { display: flex; align-items: center; gap: 10px; margin: 10px 0 8px; }
.score-chip {
  display: inline-flex; align-items: baseline; gap: 6px; border-radius: 8px; padding: 4px 10px;
  font-weight: 700; color: #fff; background: var(--b4);
}
.score-chip .n { font-size: 1.25rem; }
.score-chip.light { color: var(--ink); }
.card-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 10px; }
.card-stats > div { min-width: 0; }
.card-stats dt { font-size: 0.72rem; color: var(--muted); }
.card-stats dd { margin: 0; font-weight: 700; font-size: 0.95rem; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-note { font-size: 0.75rem; color: var(--muted); margin: 6px 0 0; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.8rem; color: var(--ink-2); margin-top: 10px; }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(19, 40, 61, 0.15); }
.legend-title { width: 100%; font-weight: 700; color: var(--ink); }
.metric-note { font-size: 0.85rem; color: var(--ink-2); margin-top: 8px; max-width: 70ch; }

.list-panel { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 14px 0 6px; }
.list-panel h2 { font-size: 1.25rem; padding: 0 16px; }
.list-panel .sub { font-size: 0.8rem; color: var(--muted); padding: 0 16px; margin: 4px 0 8px; }
.table-scroll { max-height: 520px; overflow-y: auto; }
.zip-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.zip-table th {
  position: sticky; top: 0; background: var(--paper); text-align: left; font-size: 0.75rem; color: var(--muted);
  font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--line);
}
.zip-table td { padding: 8px 10px; border-bottom: 1px solid #eef2f5; vertical-align: middle; }
.zip-table td.num, .zip-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.zip-table tr.sel td { background: #eef4fb; }
.zip-table .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ---------------------------------------------------------------- buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 700;
  font-size: 0.95rem; padding: 11px 18px; border-radius: 10px; border: 1px solid var(--ink); color: var(--ink);
  background: var(--paper); text-decoration: none; cursor: pointer; min-height: 44px;
}
.button:hover { background: var(--page); color: var(--ink); }
.button.primary { background: var(--kw-red); border-color: var(--kw-red); color: #fff; }
.button.primary:hover { background: var(--kw-red-dark); border-color: var(--kw-red-dark); color: #fff; }
.button.small { font-size: 0.85rem; padding: 8px 14px; min-height: 40px; }

/* ---------------------------------------------------------------- ZIP page */
.back { display: inline-block; margin-top: 16px; font-size: 0.875rem; font-weight: 600; }
.zip-hero { padding: 12px 0 8px; display: grid; gap: 18px; }
.zip-title .num {
  font-family: var(--display); font-weight: 700; font-size: clamp(4rem, 22vw, 7.5rem); line-height: 0.9;
  letter-spacing: -0.02em; font-variant-numeric: lining-nums;
}
.zip-title .place { font-size: 1.25rem; font-weight: 600; margin-top: 6px; }
.zip-title .county { color: var(--muted); font-size: 0.9rem; }

.score-block { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.score-top { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.score-big { font-family: var(--display); font-size: 4.2rem; font-weight: 700; line-height: 0.85; }
.score-label { font-size: 1.25rem; font-weight: 700; }
.score-sub { color: var(--ink-2); font-size: 0.9rem; }
.track { position: relative; margin: 22px 0 6px; }
.track-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; }
.track-bar span { display: block; height: 100%; }
.track-bar span + span { border-left: 2px solid var(--paper); }
.track-mark { position: absolute; top: -8px; width: 2px; height: 28px; background: var(--ink); transform: translateX(-1px); }
.track-mark::after {
  content: ""; position: absolute; top: -6px; left: -5px; border: 6px solid transparent; border-top-color: var(--ink);
}
.track-names { display: flex; font-size: 0.7rem; color: var(--muted); margin-top: 6px; }
.track-names span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-block .fine { margin-top: 12px; margin-bottom: 0; }

.callout { border-left: 3px solid var(--o2); background: #fff8f2; padding: 10px 12px; border-radius: 0 8px 8px 0; font-size: 0.9rem; }

.section { padding: 26px 0 6px; }
.section > h2 { margin-bottom: 6px; }
.section > .sub { color: var(--ink-2); font-size: 0.9rem; max-width: 70ch; }
.summary p { font-size: 1.05rem; max-width: 68ch; }

.tiles {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-top: 10px;
}
.tile { background: var(--paper); padding: 14px; }
.tile .k { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.tile .v { font-size: 1.45rem; font-weight: 700; margin: 2px 0; line-height: 1.2; }
.tile .d { font-size: 0.8rem; color: var(--ink-2); }
.defs { margin-top: 10px; font-size: 0.875rem; }
.defs summary { cursor: pointer; font-weight: 600; color: var(--b3); }
.defs dl { margin: 8px 0 0; }
.defs dt { font-weight: 700; margin-top: 8px; }
.defs dd { margin: 0; color: var(--ink-2); }

.parts { margin-top: 12px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; }
.part { display: grid; grid-template-columns: minmax(0, 9.5rem) 1fr 3.4rem; align-items: center; gap: 10px; padding: 7px 0; }
.part + .part { border-top: 1px solid #eef2f5; }
.part .name { font-size: 0.85rem; font-weight: 600; }
.part .pts { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.part .axis { position: relative; height: 14px; }
.part .axis::before { content: ""; position: absolute; left: 50%; top: -6px; bottom: -6px; width: 1px; background: var(--line); }
.part .bar { position: absolute; top: 0; height: 14px; border-radius: 3px; }
.part.total .name, .part.total .pts { font-size: 1rem; }
.part.start .name, .part.start .pts { color: var(--ink-2); font-weight: 500; }

.chart-card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 14px 14px 10px; margin-top: 12px; }
.chart-card h3 { font-size: 1.15rem; }
.chart-card .sub { font-size: 0.82rem; color: var(--ink-2); margin: 4px 0 8px; }
.chart-box { position: relative; height: 240px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.8rem; color: var(--ink-2); margin: 0 0 6px; }
.chart-legend .ln { display: inline-block; width: 18px; height: 3px; border-radius: 2px; background: var(--series); vertical-align: middle; margin-right: 6px; }
.chart-legend .bx { display: inline-block; width: 14px; height: 10px; border-radius: 2px; background: var(--band); vertical-align: middle; margin-right: 6px; }
.table-view { margin-top: 6px; font-size: 0.82rem; }
.table-view summary { cursor: pointer; color: var(--b3); font-weight: 600; }
.table-view table { border-collapse: collapse; margin-top: 6px; }
.table-view td, .table-view th { padding: 3px 12px 3px 0; text-align: left; font-variant-numeric: tabular-nums; }

.cta { background: var(--ink); color: #fff; border-radius: 14px; padding: 20px 18px; margin: 28px 0 8px; }
.cta h2 { color: #fff; }
.cta p { color: #d7e1ea; margin-top: 8px; }
.cta .row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.cta .button { border-color: #fff; }
.cta a.plain { color: #fff; }
.missing { padding: 40px 0; }

/* ---------------------------------------------------------------- forms */
.field {
  width: 100%; font: inherit; font-size: 1rem; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--paper); color: var(--ink);
}
textarea.field { resize: vertical; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.consent { font-size: 0.78rem; line-height: 1.45; margin: 10px 0 0; max-width: 62ch; }
.form-status { font-size: 0.9rem; font-weight: 600; margin: 8px 0 0; min-height: 1.2em; }
.form-done { font-weight: 600; font-size: 1rem; margin: 0; }

.signup { margin-top: 36px; background: #e8eff4; border-top: 1px solid var(--line); padding: 26px 0; }
.signup-inner { display: grid; gap: 14px; }
.signup h2 { font-size: 1.45rem; }
.signup-copy p { color: var(--ink-2); margin: 6px 0 0; max-width: 52ch; }
.signup-row { display: grid; gap: 8px; }
.signup .consent { color: var(--ink-2); }
.signup + .site-footer { margin-top: 0; }

.review-form { margin-top: 14px; }
.form-grid { display: grid; gap: 10px; margin-bottom: 14px; }
.form-grid label { display: grid; gap: 4px; font-size: 0.85rem; font-weight: 600; color: #e6edf3; }
.cta .consent, .cta .form-status { color: #d7e1ea; }
.cta .form-done { color: #fff; }
.cta-alt { margin: 10px 0 0; }
.compare-link { margin: 6px 0 0; font-size: 0.9rem; font-weight: 600; }

/* ---------------------------------------------------------------- rankings and compare */
.table-tools { display: grid; gap: 10px; margin: 8px 0 6px; }
.tool-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.rank-scroll { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; margin-top: 8px; }
.rank-table, .compare-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.rank-table th, .rank-table td, .compare-table th, .compare-table td {
  padding: 9px 10px; border-bottom: 1px solid #eef2f5; text-align: left; white-space: nowrap; vertical-align: middle;
}
.rank-table thead th, .compare-table thead th { font-size: 0.75rem; color: var(--muted); font-weight: 600; border-bottom-color: var(--line); vertical-align: bottom; }
.rank-table .num, .compare-table td { font-variant-numeric: tabular-nums; }
.rank-table .num { text-align: right; }
.rank-table .muted { color: var(--muted); }
.sticky { position: sticky; left: 0; background: var(--paper); z-index: 1; box-shadow: 1px 0 0 #eef2f5; }
.rank-table tbody th, .compare-table tbody th { font-weight: 700; }
button.sort {
  font: inherit; font-weight: 600; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit;
  white-space: normal; min-width: 4.5em;
}
button.sort.on { color: var(--ink); }
.score-pill { display: inline-block; min-width: 2.1em; text-align: center; font-weight: 700; border-radius: 6px; padding: 1px 6px; }
.pill-label { margin-left: 6px; color: var(--ink-2); font-size: 0.8rem; }
.compare-table thead th { white-space: normal; min-width: 7.5rem; }
.compare-table thead th a { font-weight: 700; font-size: 0.95rem; }
.th-town { display: block; font-weight: 500; color: var(--ink-2); }
.compare-table tbody th { white-space: normal; min-width: 8.5rem; max-width: 10rem; }
.tag {
  display: inline-block; margin-left: 6px; font-size: 0.7rem; font-weight: 600; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; vertical-align: 1px;
}

.picker { display: grid; gap: 10px; margin: 8px 0 4px; }
.picked { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 4px 4px 10px; font-size: 0.875rem;
}
.chip a { font-weight: 700; color: var(--ink); }
.chip-town { color: var(--ink-2); }
.chip-sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.chip-x { width: 30px; height: 30px; border: 0; border-radius: 999px; background: transparent; font-size: 1.15rem; line-height: 1; color: var(--ink-2); cursor: pointer; }
.chip-x:hover { background: var(--page); }
.toggle.small { margin: 2px 0 8px; }
.toggle.small button { font-size: 0.8rem; padding: 5px 11px; }
.thanks { padding-top: 36px; padding-bottom: 20px; }
.thanks h1 { font-size: 2.2rem; margin-bottom: 12px; }
.thanks p { max-width: 60ch; }
.prose { padding-top: 36px; padding-bottom: 20px; }
.prose h1 { font-size: 2.2rem; margin-bottom: 6px; }
.prose h2 { font-size: 1.25rem; margin: 26px 0 6px; }
.prose p { max-width: 68ch; }
.nw { white-space: nowrap; }

/* ---------------------------------------------------------------- footer */
.site-footer { margin-top: 40px; background: var(--paper); border-top: 1px solid var(--line); padding: 24px 0 32px; }
.footer-grid { display: grid; gap: 18px; }
.footer-brokerage { font-size: 1.25rem; font-weight: 700; color: var(--kw-red); margin-bottom: 2px; }
.footer-agent { font-size: 0.95rem; font-weight: 600; margin-bottom: 2px; }
.site-footer p { margin-bottom: 8px; }

/* ---------------------------------------------------------------- wider screens */
@media (min-width: 640px) {
  .wordmark { font-size: 1.563rem; }
  .nav { gap: 20px; font-size: 0.875rem; }
  .signup-row { grid-template-columns: minmax(0, 1fr) auto; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .wide { grid-column: 1 / -1; }
  .table-tools { grid-template-columns: auto 1fr; align-items: center; }
  .controls { grid-template-columns: 1fr auto; align-items: center; }
  .chips { grid-column: 1 / -1; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .zip-card { left: auto; right: 12px; top: 12px; bottom: auto; width: 330px; }
  .chart-box { height: 280px; }
  .part { grid-template-columns: 12rem 1fr 3.6rem; }
}
@media (min-width: 960px) {
  .intro h1 { font-size: 2.441rem; max-width: 22ch; }
  .explore { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .list-panel { position: sticky; top: 12px; }
  .table-scroll { max-height: calc(62vh - 40px); }
  .zip-hero { grid-template-columns: minmax(0, 1fr) minmax(0, 440px); align-items: end; }
  .charts { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
  .charts .wide { grid-column: 1 / -1; }
  .footer-grid { grid-template-columns: 1fr 1.4fr; gap: 40px; }
  .signup-inner { grid-template-columns: 1fr 1.2fr; align-items: center; gap: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
@media print {
  .brand-strip { background: none; color: var(--kw-red); }
  .controls, .zip-card .close, .cta .row { display: none; }
}
