/* Results pages only (area, postcode district, search, group): loaded after
   tokens.css and app.css. Compact header, sticky filter bar with pill
   popovers (one sheet on phones), horizontal result cards, sticky map with
   price pins (research/UI-REDESIGN-V3.md §3). */
@layer pages {
/* ---- header ---- */
.res-head-wrap { padding-block: var(--sp-5) var(--sp-4); }
.res-head-wrap h1 { font-size: clamp(1.75rem, 3.4vw, 2.5rem); line-height: 1.15; letter-spacing: -.015em; }
.res-sum { margin-top: var(--sp-2); color: var(--muted-foreground); }
.res-sum span:first-child { font-weight: 600; color: var(--foreground); }
.dots-sep > span + span::before { content: " · "; color: var(--subtle-foreground); }
.facet-intro { margin-top: var(--sp-3); }
.facet-note { margin: var(--sp-4) 0 0; font-size: var(--text-sm); color: var(--muted-foreground); }
.facet-note a { font-weight: 600; color: var(--primary); }

/* search page box: query, radius, button in one row */
.sbox { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-2); max-width: 46rem; margin-top: var(--sp-4); }
.sbox-q { grid-column: 1 / -1; }
.sbox input { min-height: var(--h-control-lg); border-radius: var(--radius-full); }
.sbox select { min-height: var(--h-control-lg); border-radius: var(--radius-full); width: auto; }
.sbox .btn { min-height: var(--h-control-lg); padding-inline: var(--sp-8); }
.res-head-wrap .geo { margin-top: var(--sp-2); }
@media (min-width: 640px) { .sbox { grid-template-columns: minmax(0, 1fr) auto auto; } .sbox-q { grid-column: auto; } }

/* ---- filter bar: sticks under the site header ---- */
.fbar:has(.fsheet.is-open) { z-index: 70; }
.fbar { position: sticky; top: var(--h-header); z-index: 25; background: var(--background); border-block: 1px solid var(--border); }
.fbar-in { display: flex; align-items: center; gap: var(--sp-2); min-height: 64px; padding-block: var(--sp-2); }
.fbar-q { display: none; flex: 0 1 17rem; }
.fbar-q input { min-height: 40px; border-radius: var(--radius-full); font-size: var(--text-sm); }
.fbar-f { display: flex; align-items: center; gap: var(--sp-2); flex: 1; min-width: 0; }
.fsort { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; font-size: var(--text-sm); font-weight: 600; color: var(--muted-foreground); }
.fsort select { width: auto; min-height: 40px; padding-block: 0; border-radius: var(--radius-full); font-size: var(--text-sm); font-weight: 600; color: var(--foreground); }
.fb-open { display: none; min-height: 40px; }
.fb-open .count { margin-left: var(--sp-1); }
.fsheet-head, .fsheet-foot { display: none; }
.fsheet-body { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

/* without JS: every group shows as a compact fieldset and "Apply" submits */
.fpill { display: none; }
.fpop { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); padding: var(--sp-2) 0; border: 0; }
.fpop-h { font-size: var(--text-sm); font-weight: 700; padding: 0; margin-bottom: var(--sp-1); }
.fopt { display: flex; align-items: center; gap: var(--sp-2); min-height: 40px; font-size: .9375rem; cursor: pointer; }
.fopt input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--primary); }
.fbar-f:not(.js *) { flex-wrap: wrap; }

/* with JS: pills that open small popovers */
.js .fpill { position: relative; display: inline-flex; align-items: center; gap: var(--sp-1_5); min-height: 40px; padding: 0 var(--sp-3) 0 var(--sp-4);
  border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--card); color: var(--foreground); font: inherit; font-size: var(--text-sm); font-weight: 600; white-space: nowrap; cursor: pointer; }
.js .fpill .i { width: .875rem; height: .875rem; transform: rotate(90deg); color: var(--muted-foreground); }
.js .fpill:hover { border-color: var(--input); }
.js .fpill[aria-expanded="true"] { border-color: var(--foreground); }
.js .fpill[aria-expanded="true"] .i { transform: rotate(-90deg); }
.js .fg:has(input:checked:not([value=""])) .fpill { border-color: var(--primary); background: var(--brand-soft); color: var(--primary); }
.js .fg:has(input:checked:not([value=""])) .fpill .i { color: var(--primary); }
.js .fpill:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.fg { position: relative; }
.js .fpop { position: absolute; z-index: 30; top: calc(100% + 8px); left: 0; display: none; flex-direction: column; gap: 0; min-width: 17rem; padding: var(--sp-3) var(--sp-4); white-space: nowrap;
  background: var(--popover); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.js .fg.open .fpop { display: flex; }
.js .fpop-h { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (prefers-reduced-motion: no-preference) { .js .fg.open .fpop { animation: pop-in var(--dur-med) var(--ease-out); } }

/* phones: "Filters (2)" + Sort; the groups open as one full-height sheet */
@media (max-width: 899px) {
  .js .fb-open { display: inline-flex; }
  .js .fsheet { display: none; }
  .js .fsheet.is-open { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: var(--popover); }
  .js .fsheet.is-open .fsheet-head { display: flex; align-items: center; justify-content: space-between; min-height: 60px; padding: 0 var(--sp-2) 0 var(--gutter); border-bottom: 1px solid var(--border); }
  .js .fsheet.is-open .fsheet-body { flex: 1; display: block; overflow-y: auto; padding: 0 var(--gutter); }
  .js .fsheet.is-open .fpill { display: none; }
  .js .fsheet.is-open .fpop { position: static; display: flex; min-width: 0; padding: var(--sp-4) 0; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; box-shadow: none; background: none; animation: none; }
  .js .fsheet.is-open .fpop-h { position: static; width: auto; height: auto; clip: auto; margin: 0; padding-top: var(--sp-4); font-size: var(--text-lg); }
  .js .fsheet.is-open .fpop { padding-top: 0; }
  .js .fsheet.is-open .fsheet-foot { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--gutter) calc(var(--sp-3) + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
  .js .fsheet.is-open .fsheet-foot .btn:last-child { flex: 1; }
  .fsort span { display: none; }
  @media (prefers-reduced-motion: no-preference) { .js .fsheet.is-open { animation: sheet-in var(--dur-med) var(--ease-out); } }
}
@keyframes sheet-in { from { transform: translateY(100%); } }
@media (min-width: 1280px) { .fbar-q { display: block; } .fbar-in:has(.fg input:checked:not([value=""])) .fbar-q { display: none; } }

/* ---- active filters ---- */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.token { position: relative; display: inline-flex; align-items: center; gap: var(--sp-1); min-height: 32px; padding: 0 var(--sp-1) 0 var(--sp-3);
  border-radius: var(--radius-full); background: var(--brand-soft); color: var(--primary); font-size: var(--text-sm); font-weight: 600; text-decoration: none; }
.token .x { display: grid; place-items: center; width: 24px; height: 24px; }
.token::after, .clear::after { content: ""; position: absolute; inset: -6px -4px; }
.token:hover { background: color-mix(in oklab, var(--brand-soft) 80%, var(--primary)); }
.clear { position: relative; font-size: var(--text-sm); font-weight: 600; color: var(--muted-foreground); }

/* ---- list + sticky map ---- */
.res-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-6); }
.res-col { min-width: 0; padding-bottom: var(--sp-8); }
.res-top { display: grid; gap: var(--sp-3); padding-block: var(--sp-4) var(--sp-3); }
.res-count { font-family: var(--font-sans); font-size: 1.0625rem; line-height: 1.4; font-weight: 700; letter-spacing: 0; }
.res-areas { margin-top: var(--sp-4); }
.res-map { display: none; }
@media (min-width: 1024px) {
  .res-layout.has-map { grid-template-columns: minmax(0, 58fr) minmax(0, 42fr); gap: var(--sp-8); }
  .res-map { display: block; position: sticky; top: calc(var(--h-header) + 66px); height: calc(100dvh - var(--h-header) - 66px); padding-block: var(--sp-4); }
  .res-map .map { height: 100%; aspect-ratio: auto; border-radius: var(--radius-xl); }
}
.htmx-request #results, #results.htmx-request { opacity: .55; transition: opacity var(--dur-fast) linear .2s; }

/* phones: a floating List | Map switch; the map fills the screen under the bars */
.viewswitch { position: fixed; left: 50%; bottom: calc(var(--sp-4) + env(safe-area-inset-bottom)); z-index: 35; transform: translateX(-50%);
  display: flex; gap: 4px; padding: 4px; background: var(--ink-band); border-radius: var(--radius-full); box-shadow: var(--shadow-lg); }
.viewswitch button { display: inline-flex; align-items: center; gap: var(--sp-1_5); min-height: 44px; padding: 0 var(--sp-4); border: 0; border-radius: var(--radius-full); background: transparent;
  color: var(--ink-band-muted); font: inherit; font-size: var(--text-sm); font-weight: 700; cursor: pointer; }
.viewswitch [aria-pressed="true"] { background: var(--primary); color: var(--primary-foreground); }
.viewswitch[hidden] { display: none; }
.map-view .res-map { display: block; position: fixed; inset: calc(var(--h-header) + 66px) 0 0 0; z-index: 24; padding: 0; background: var(--muted); }
.map-view .res-map .map { height: 100%; aspect-ratio: auto; border-radius: 0; }
@media (min-width: 1024px) { .viewswitch { display: none; } }

/* ---- result card: picture left, values right; the whole card is one link ---- */
.cardlist { display: grid; gap: var(--sp-2); }
.ncard { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); overflow: hidden; border-radius: var(--radius-xl); background: var(--card); border: 1px solid var(--border); }
.ncard-img { height: 120px; }
.ncard-img svg { width: 100%; height: 100%; }
.ncard-body { display: grid; align-content: start; gap: var(--sp-1); padding: var(--sp-3) var(--sp-4) var(--sp-4); min-width: 0; }
.ncard h3 { padding-right: var(--sp-8); font-size: var(--text-card); line-height: var(--leading-card); font-weight: 700; letter-spacing: -.005em; }
.ncard h3 a { color: var(--foreground); text-decoration: none; }
.ncard h3 a::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: var(--radius-xl); }
.ncard h3 a:focus-visible { outline: none; }
.ncard h3 a:focus-visible::after { outline: 2px solid var(--ring); outline-offset: -2px; }
.ncard:hover h3 a, .ncard.is-hot h3 a { color: var(--primary); }
.ncard:hover, .ncard.is-hot { border-color: var(--input); box-shadow: var(--shadow-md); }
.ncard-sub, .ncard-meta { font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--muted-foreground); }
.ncard-sig { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); margin-top: 2px; font-size: var(--text-sm); font-weight: 600; }
.sig { display: inline-flex; align-items: center; gap: var(--sp-1_5); }
.sig .gdot { width: 8px; height: 8px; border-radius: var(--radius-full); background: var(--g-mid); }
.sig[data-variant="ok"] .gdot { background: var(--g-good); }
.sig[data-variant="warn"] .gdot { background: var(--g-low); }
.sig[data-variant="bad"] .gdot { background: var(--g-bad); }
.sig[data-variant="outline"] .gdot { background: var(--sky-deep); }
.sig .star { color: var(--star); }
.sig .muted { font-weight: 400; }
.ncard-foot { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--sp-1) var(--sp-4); margin-top: var(--sp-1); }
.ncard-price { display: flex; align-items: baseline; gap: var(--sp-1); margin-left: auto; font-size: var(--text-sm); color: var(--muted-foreground); white-space: nowrap; }
.ncard-price b { font-size: 1.1875rem; font-weight: 700; color: var(--foreground); font-variant-numeric: tabular-nums; }
.ncard-ask { font-weight: 600; color: var(--muted-foreground); }
.save { position: absolute; right: var(--sp-1); top: var(--sp-1); z-index: 2; display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--radius-full); color: var(--foreground); }
.save::before { content: ""; position: absolute; inset: 6px; border-radius: inherit; background: var(--card); box-shadow: var(--shadow-xs); }
.save .i { position: relative; width: 1.125rem; height: 1.125rem; }
.save:hover { color: var(--bad-solid); }
@media (max-width: 639px) { .ncard .save { top: var(--sp-2); right: var(--sp-2); } .ncard h3 { padding-right: 0; } }
@media (min-width: 640px) {
  .ncard { grid-template-columns: 11rem minmax(0, 1fr); }
  .ncard-img { height: calc(100% - var(--sp-4)); min-height: 120px; margin: var(--sp-2); border-radius: 14px; }
  .ncard-body { gap: 2px; padding: var(--sp-3) var(--sp-4) var(--sp-3) var(--sp-2); }
  .save { top: var(--sp-2); right: var(--sp-2); }
  .save::before { box-shadow: none; }
}

/* ---- map pins: price labels, highlighted with their card ---- */
.pin { display: block; padding: 4px 9px; border-radius: var(--radius-full); background: var(--card); color: var(--foreground); box-shadow: 0 0 0 1px var(--border), var(--shadow-md);
  font: 700 13px/1.2 var(--font-sans); white-space: nowrap; text-decoration: none; cursor: pointer; }
.pin.dot { width: 18px; height: 18px; padding: 0; background: var(--primary); border: 3px solid var(--card); }
.pin:hover, .pin.is-hot, .pin:focus-visible { background: var(--foreground); color: var(--background); z-index: 3; transform: scale(1.08); }
.pin.dot:hover, .pin.dot.is-hot { background: var(--coral); }
.pin-card { display: grid; gap: 2px; min-width: 11rem; font-family: var(--font-sans); color: var(--foreground); }
.pin-card b { font-size: var(--text-sm); }
.pin-card span { font-size: var(--text-xs); color: var(--muted-foreground); }
.pin-card a { font-size: var(--text-sm); font-weight: 600; color: var(--primary); }
.map .maplibregl-popup-content { padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-md); background: var(--popover); box-shadow: var(--shadow-lg); }

/* ---- empty state ---- */
.loosen { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }

/* ---- below the results: about the area ---- */
.about-area h2 { margin-bottom: var(--sp-4); }
.about-grid { display: grid; gap: var(--sp-6); align-items: start; }
.intro { max-width: var(--measure); color: var(--muted-foreground); }
.area-chart { display: grid; gap: var(--sp-3); padding: var(--sp-5); border-radius: var(--radius-xl); background: var(--card); border: 1px solid var(--border); }
.mixwrap { max-width: 40rem; margin-top: var(--sp-8); }
@media (min-width: 900px) { .about-grid { grid-template-columns: minmax(0, 1fr) 24rem; gap: var(--sp-12); } }
.more-areas h3 { margin-top: var(--sp-6); }
}

@media print {
  .fbar, .res-map, .viewswitch, .save { display: none !important; }
}
.fhow { display: inline-grid; place-items: center; width: var(--h-control-sm); height: var(--h-control-sm); border-radius: var(--radius-full); color: var(--muted-foreground); }
.fhow:hover { color: var(--foreground); background: var(--muted); }
.funav { margin: 0 0 var(--sp-2); font-size: var(--text-sm); color: var(--muted-foreground); }
.save[aria-pressed="true"] { color: var(--bad-solid); }
.save[aria-pressed="true"] .i { fill: currentColor; }
.ncard-cmp { position: absolute; left: var(--sp-2); top: var(--sp-2); z-index: 2; display: inline-flex; align-items: center; gap: var(--sp-1_5); min-height: 32px; padding: 0 var(--sp-3) 0 var(--sp-2); border-radius: var(--radius-full); background: var(--card); box-shadow: var(--shadow-xs); font-size: var(--text-sm); font-weight: 500; cursor: pointer; }
.ncard-cmp input { width: 16px; height: 16px; accent-color: var(--primary); }
.kids { margin-top: var(--sp-3); }
.kids .chiplinks { flex-wrap: nowrap; overflow-x: auto; padding-bottom: var(--sp-1); }
.ncard-img { position: relative; }
.ncard-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* price sort: nurseries without fees are their own labelled group at the end (CTO plan F2 rule 6) */
.cl-group { padding: var(--sp-6) 0 var(--sp-2); border-top: 1px solid var(--border); }
.cl-group h3 { font-size: var(--text-lg); line-height: var(--leading-lg); }
.cl-group p { font-size: var(--text-sm); color: var(--muted-foreground); }
/* the distance from the parent's saved postcode (parent.js) */
.ncard-home { font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--muted-foreground); }
