/* flatradar — per-city street map page (/city/{slug}). Zillow-style split: a Mapbox street map
   (left) + a scrollable list of listing cards (right), with a Map⇄List toggle on phones.
   Self-contained, theme-aware, same design-system tokens as /map. Mapbox tiles are the only
   third-party requests (basemap); our sold-data source is never named. */

:root {
  --bg:        #f6f4ee;
  --bg-soft:   #efece3;
  --surface:   #fffefb;
  --surface-2: #faf8f2;
  --ink:       #14201b;
  --ink-soft:  #47554e;
  --ink-faint: #7c8880;
  --line:      #e2ddd0;
  --line-soft: #eae5d9;
  --accent:    #0f9d6b;
  --accent-2:  #0b7d54;
  --accent-ink:#053322;
  --amber:     #c9741a;
  --brick:     #a23c1a;
  --shadow-md: 0 14px 34px -20px rgba(9,40,29,.30), 0 4px 12px -8px rgba(20,32,27,.12);
  --shadow-sm: 0 6px 16px -12px rgba(9,40,29,.32), 0 2px 6px -5px rgba(20,32,27,.14);
  --radius: 16px;
  --display: 'Space Grotesk', 'Hanken Grotesk', system-ui, sans-serif;
  --body:    'Hanken Grotesk', system-ui, -apple-system, sans-serif;
  --mono:    'Space Mono', ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* point deal colours (theme-aware) — read by city.js for the Mapbox layers */
  --pt-below:  #0f9d6b;                   /* listing below market (deal-green) */
  --pt-above:  #9aa39b;                   /* listing at/above market (muted) */
  --pt-none:   #b9c0b8;                   /* no benchmark match */
  --pt-stroke: #fffefb;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0a1310;
    --bg-soft:   #0d1a15;
    --surface:   #101e18;
    --surface-2: #13251d;
    --ink:       #eaf2ec;
    --ink-soft:  #a7b8ad;
    --ink-faint: #6f8177;
    --line:      #21362c;
    --line-soft: #1a2c23;
    --accent:    #2fd4a0;
    --accent-2:  #46e0b0;
    --accent-ink:#04140d;
    --amber:     #e59a4a;
    --brick:     #e0653c;
    --shadow-md: 0 18px 40px -22px rgba(0,0,0,.7), 0 6px 16px -10px rgba(0,0,0,.55);
    --shadow-sm: 0 8px 20px -14px rgba(0,0,0,.72), 0 2px 8px -6px rgba(0,0,0,.6);
    --pt-below:  #2fd4a0;
    --pt-above:  #6f8177;
    --pt-none:   #37473d;
    --pt-stroke: #0a1310;
  }
}
:root[data-theme="light"] { color-scheme: light; --bg:#f6f4ee; --ink:#14201b; --accent:#0f9d6b;
  --amber:#c9741a; --brick:#a23c1a; --pt-below:#0f9d6b; --pt-above:#9aa39b; --pt-none:#b9c0b8; --pt-stroke:#fffefb; }
:root[data-theme="dark"] { color-scheme: dark; --bg:#0a1310; --ink:#eaf2ec; --accent:#2fd4a0;
  --amber:#e59a4a; --brick:#e0653c; --pt-below:#2fd4a0; --pt-above:#6f8177; --pt-none:#37473d; --pt-stroke:#0a1310; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--body); background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }

/* ---------- brand mark (shared with /map) ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark { display: inline-flex; }
.brand-word { font-family: var(--display); font-weight: 700; font-size: 20px; letter-spacing: -.03em; }
.brand-word span { color: var(--accent-2); }
.bm-ring-o { fill: var(--accent-ink); }
@media (prefers-color-scheme: dark) { .bm-ring-o { fill: #06140e; } }
.bm-ring { fill: none; stroke: var(--accent); stroke-width: 1.3; opacity: .85; }
.bm-dot  { fill: var(--accent); }
.bm-sweep{ stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; }

/* ---------- header ---------- */
.city-header {
  position: sticky; top: 0; z-index: 20; height: 60px; display: flex; align-items: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.city-header-inner { width: 100%; max-width: 1360px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 16px; }
.city-header-actions { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.city-home { font-size: 14px; font-weight: 600; color: var(--ink-soft); transition: color .16s; white-space: nowrap; }
.city-home:hover { color: var(--ink); }
.city-open { padding: 7px 14px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); }
.city-open:hover { background: var(--accent-2); color: var(--accent-ink); }
.city-lang { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600;
  color: var(--ink-faint); font-family: var(--mono); letter-spacing: .04em; }
.city-lang a { color: var(--ink-faint); transition: color .16s; }
.city-lang a.on { color: var(--ink); }
.city-lang a:hover { color: var(--accent-2); }

/* ---------- main ---------- */
.city-main { max-width: 1360px; margin: 0 auto; padding: 22px 24px 28px; position: relative; }
.city-intro { margin: 0 0 16px; }
.city-title { margin: 0 0 6px; font-family: var(--display); font-size: clamp(1.45rem, 3.4vw, 2rem);
  font-weight: 700; letter-spacing: -.03em; line-height: 1.08; }
.city-sub { margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--ink-soft); max-width: 74ch; }

/* ---------- mode switcher (coverage globe ⇄ district price maps) — top-center, in-flow ---------- */
.city-modeswitch { display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 10px 14px; margin: 0 0 16px; }
.ms-seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); }
.ms-seg-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 36px; padding: 7px 17px; border-radius: 999px;
  font-family: var(--display); font-weight: 700; font-size: 14px; letter-spacing: -.01em;
  color: var(--ink-soft); white-space: nowrap; cursor: pointer;
  transition: background .16s, color .16s, transform .14s;
}
.ms-seg-btn.is-active { background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 4px 12px -6px color-mix(in srgb, var(--accent) 70%, transparent); }
a.ms-seg-btn:hover { color: var(--accent-2); }
a.ms-seg-btn:focus-visible, .ms-city:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ms-seg-back::before { content: "\2190\00a0"; }         /* "\2190 " — explicit back-to-globe */
.ms-cities { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.ms-city {
  display: inline-flex; align-items: center; min-height: 36px; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  font-size: 13.5px; font-weight: 600; transition: border-color .18s, background .18s, transform .14s;
}
.ms-city:hover { border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, var(--surface-2)); transform: translateY(-1px); }
.ms-city.is-current { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.ms-city.is-current::after { content: "\00a0\2192"; }   /* " \2192" — current-city affordance */

/* ---------- Map ⇄ List toggle (phones only) ---------- */
.city-view-toggle { display: none; margin: 0 0 12px; padding: 3px; gap: 3px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; }
.city-view-toggle[hidden] { display: none; }         /* ЛОВУШКА №16 — pair hidden with the author display */
.cv-btn { flex: 1; padding: 9px 10px; border: 0; border-radius: 999px; background: transparent;
  color: var(--ink-soft); font-family: var(--display); font-weight: 700; font-size: 14px;
  letter-spacing: -.01em; cursor: pointer; transition: background .16s, color .16s; }
.cv-btn.is-on { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }

/* ---------- split ---------- */
.city-split { display: flex; gap: 18px; height: calc(100dvh - 216px); min-height: 520px; max-height: 840px; }
.city-mapcol { flex: 1 1 58%; min-width: 0; }
.city-listcol { flex: 1 1 42%; min-width: 0; max-width: 480px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-md); overflow: hidden; }

/* ---------- map stage ---------- */
.city-stage { position: relative; height: 100%; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow-md); background: var(--surface-2); }
.city-map { position: absolute; inset: 0; }
.city-stage.no-map .city-map { display: none; }
.mapboxgl-map { font-family: var(--body); }

/* keep Mapbox controls on-brand + out of the way of the legend (bottom-left) */
.mapboxgl-ctrl-group { border-radius: 11px !important; overflow: hidden; box-shadow: var(--shadow-sm) !important; }
.mapboxgl-ctrl-attrib { font-size: 10.5px; }

/* ---------- legend overlay (bottom-left over the map) ---------- */
.city-legend { position: absolute; left: 12px; bottom: 26px; z-index: 3;
  display: flex; flex-direction: column; gap: 10px; max-width: min(300px, 66vw);
  padding: 11px 13px; border-radius: 13px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(1.3) blur(10px); -webkit-backdrop-filter: saturate(1.3) blur(10px);
  border: 1px solid var(--line); box-shadow: var(--shadow-md); }
.city-legend[hidden] { display: none; }              /* ЛОВУШКА №16 */
.cl-block { min-width: 0; }
.cl-h { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-faint); margin-bottom: 7px; }
.cl-ramp-bar { display: block; height: 10px; width: min(240px, 54vw); border-radius: 999px; border: 1px solid var(--line-soft); }
.cl-ramp-labels { display: grid; grid-template-columns: auto 1fr 1fr auto; align-items: center;
  gap: 8px; margin-top: 6px; font-size: 11.5px; color: var(--ink-soft); }
.cl-ramp-labels .cl-num { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); }
.cl-ramp-labels #cl-min { text-align: left; }
.cl-ramp-labels #cl-max, .cl-ramp-labels #cl-pricey { text-align: right; }
.cl-points[hidden] { display: none; }                /* ЛОВУШКА №16 */
.cl-keys { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.cl-key { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-soft); }
.cl-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; border: 1px solid var(--pt-stroke); }
.cl-dot-below { background: var(--pt-below); }
.cl-dot-above { background: var(--pt-above); }

.city-empty { position: absolute; inset: 18px; margin: auto; height: max-content;
  padding: 24px; text-align: center; color: var(--ink-faint); font-size: 14.5px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px dashed var(--line);
  border-radius: var(--radius); z-index: 4; }
.city-empty[hidden] { display: none; }               /* ЛОВУШКА №16 */

/* ---------- list rail ---------- */
.city-list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 14px 16px 12px; border-bottom: 1px solid var(--line-soft); flex: none; }
.clh-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.city-list-count { font-family: var(--display); font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.city-list-sub { font-family: var(--mono); font-size: 11.5px; color: var(--ink-faint); }
.city-list-sub[hidden] { display: none; }             /* ЛОВУШКА №16 */
.city-sort { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); letter-spacing: .02em;
  white-space: nowrap; }
.city-sort[hidden] { display: none; }                 /* ЛОВУШКА №16 */

.city-list { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px; display: flex;
  flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.city-list[hidden] { display: none; }

/* listing card — a column: the thumb+body row on top, the full-width Deep-report CTA below */
.fc-card { display: flex; flex-direction: column; gap: 8px; padding: 8px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--line-soft); transition: transform .12s, border-color .12s, box-shadow .12s, background .12s;
  animation: fc-in .3s ease-out both; }
.fc-row { display: flex; gap: 12px; }
.fc-card:hover { border-color: var(--line); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.fc-card.hi { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  box-shadow: 0 0 0 1px var(--accent) inset, var(--shadow-sm); }
@keyframes fc-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.fc-thumb { position: relative; width: 108px; height: 82px; flex: none; border-radius: 10px;
  overflow: hidden; background: var(--surface-2); border: 1px solid var(--line-soft); }
.fc-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--surface-2); }
.fc-noimg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em; color: var(--ink-faint); text-transform: uppercase; }
.fc-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 2px 2px 2px 0; justify-content: center; }
.fc-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.fc-price { font-family: var(--mono); font-weight: 700; font-size: 15.5px; color: var(--ink); letter-spacing: -.01em; }
.fc-deal { font-family: var(--mono); font-weight: 700; font-size: 11.5px; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.fc-deal.below { color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 82%, transparent); }
.fc-deal.above { color: var(--ink-soft); background: var(--surface-2); border: 1px solid var(--line-soft); }
.fc-meta { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.fc-dist { font-size: 12.5px; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.city-list-empty { margin: 0; padding: 34px 22px; text-align: center; color: var(--ink-faint); font-size: 14px; }
.city-list-empty[hidden] { display: none; }           /* ЛОВУШКА №16 */

/* ---------- ranked coloured list (cities with no listing points) ---------- */
.city-ranked { flex: 1; overflow-y: auto; padding: 14px; }
.city-ranked[hidden] { display: none; }               /* ЛОВУШКА №16 */
.cr-head { margin: 0 0 12px; display: flex; flex-direction: column; gap: 4px; }
.cr-h { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }
.cr-note { font-size: 12.5px; color: var(--ink-faint); line-height: 1.45; }
.cr-rows { display: flex; flex-direction: column; gap: 7px; }
.cr-row { display: grid; grid-template-columns: minmax(78px, 0.9fr) 1.4fr auto; align-items: center;
  gap: 10px; padding: 9px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-soft); }
.cr-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-bar-wrap { height: 11px; border-radius: 999px; background: var(--surface); overflow: hidden; border: 1px solid var(--line-soft); }
.cr-bar { height: 100%; border-radius: 999px; min-width: 4px; }
.cr-val { font-family: var(--mono); font-size: 12.5px; font-weight: 700; text-align: right; white-space: nowrap; }

/* ---------- pin hover popup (Mapbox) ---------- */
.city-pop .mapboxgl-popup-content { background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 14px; padding: 11px 13px; box-shadow: var(--shadow-md); }
.city-pop .mapboxgl-popup-tip { display: none; }
.city-pop .mapboxgl-popup-close-button { color: var(--ink-faint); }
.city-pop .tp-thumb { display: block; width: 176px; max-width: 100%; height: auto; aspect-ratio: 4 / 3;
  object-fit: cover; border-radius: 9px; border: 1px solid var(--line); margin-bottom: 8px; background: var(--surface-2); }
.city-pop .tp-name { font-family: var(--display); font-weight: 700; font-size: 14.5px; letter-spacing: -.01em; margin-bottom: 6px; }
.city-pop .tp-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }
.city-pop .tp-v { font-family: var(--mono); font-weight: 700; color: var(--ink); }
.city-pop .tp-v.below { color: var(--accent-2); }
.city-pop .tp-v.above { color: var(--amber); }
.city-pop .tp-note { margin-top: 7px; font-size: 11px; color: var(--ink-faint); }

/* ---------- footer ---------- */
.city-footer { max-width: 1360px; margin: 0 auto; padding: 14px 24px 24px; font-size: 11.5px; color: var(--ink-faint); }
.city-footer a { color: var(--ink-soft); }
.city-footer a:hover { color: var(--accent-2); }

/* ================= deep report: CTA + registration/quota/report modal ================= */
/* list-card CTA — the PRIMARY, always-visible target: full-width, ≥44px, big & obvious (the owner's
   #1 complaint was that the old tiny pill was hard to hit). Click is isolated from the listing link. */
.fc-report { display: block; width: 100%; min-height: 44px; margin-top: 0; padding: 11px 14px; border: 0;
  border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-family: var(--display);
  font-weight: 700; font-size: 14px; letter-spacing: -.01em; cursor: pointer;
  transition: background .15s, transform .1s; }
.fc-report:hover { background: var(--accent-2); }
.fc-report:active { transform: translateY(1px); }

/* pin-popup CTA — inside the CLICK-PERSISTED pin card (stays until dismissed), so it's a real target:
   full-width, ≥44px. The card no longer vanishes on mouse-move, so the cursor can reach this button. */
.city-pop .city-report-cta { display: block; width: 100%; margin-top: 10px; min-height: 44px; padding: 11px 12px;
  border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-family: var(--display);
  font-weight: 700; font-size: 14px; cursor: pointer; }
.city-pop .city-report-cta:hover { background: var(--accent-2); }
.city-pop .city-pop-open { display: block; margin-top: 8px; text-align: center; font-size: 12.5px;
  font-weight: 700; color: var(--accent-2); }
.city-pop .city-pop-open:hover { color: var(--accent); }
/* the click-persisted card carries a ✕ close button — give the content room for it (top-right) */
.city-pop-pinned .mapboxgl-popup-content { padding-top: 22px; }
.city-pop-pinned .mapboxgl-popup-close-button { width: 26px; height: 26px; font-size: 16px; line-height: 1; }

/* The deep-report modal + card CTA styles moved to static/report.css - /app opens the SAME
   report, so its styles are shared (one product, one look). Loaded by templates/city.html. */

/* ================= responsive: stack + Map⇄List toggle ================= */
@media (max-width: 760px) {
  .city-header-inner { gap: 10px; padding: 0 14px; }
  .city-header-actions { gap: 10px; }
  .city-home:not(.city-open) { display: none; }      /* keep Open app + lang; drop back-link text */
  .city-main { padding: 16px 14px 40px; }
  .city-view-toggle:not([hidden]) { display: flex; } /* show the toggle on phones */

  /* compact switcher on phones — ≥40px tap targets; the header back-link is hidden here, so the
     "Pārskats" segment is the primary, obvious back-to-globe path. */
  .city-modeswitch { gap: 8px 10px; margin: 0 0 12px; }
  .ms-seg-btn, .ms-city { min-height: 40px; }

  .city-split { flex-direction: column; height: auto; max-height: none; min-height: 0; gap: 0; }
  .city-mapcol { flex: none; height: calc(100dvh - 224px); min-height: 340px; }   /* room for the switcher */
  .city-listcol { flex: none; max-width: none; height: calc(100dvh - 224px); min-height: 340px; }

  /* one panel at a time (only when the toggle is active — i.e. the city has listing cards) */
  .city-split.has-toggle.is-map .city-listcol { display: none; }
  .city-split.has-toggle.is-list .city-mapcol { display: none; }

  .city-footer { padding: 10px 14px 20px; }
  .cl-ramp-bar { width: min(200px, 60vw); }
  .city-legend { left: 8px; bottom: 32px; padding: 9px 11px; }
  .fc-thumb { width: 92px; height: 72px; }
  /* the deep-report modal's own phone sheet lives in static/report.css (shared with /app) */
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
