/* =============================================================
   Redesigned /properties/ (templates/public/search_rd.html).
   Loads AFTER static/css/public/properties-search.css, which still
   styles every widget the search JS builds (popovers, mobile sheet,
   modals, compare tray). This file only restyles and re-lays them out
   in the redesign's look: tokens from static/css/redesign/rd.css,
   mockup docs/redesign/mockups/search.dc.html.

   Breakpoints follow the search JS, not the header: the map-first
   phone shell starts at 768px (isPhoneViewport), the header's compact
   menu at 899px (rd.css). Between the two the desktop search layout
   runs under the compact header, as the live page does today.
   ============================================================= */

body.rd { background: var(--brand-base); }

/* ---------- chrome above the map ----------
   .rd-search-top carries the class .header on purpose: the search JS
   sizes the map as "viewport minus .header (+ phone search bar + chips)"
   (syncMobileChromeHeight), so everything above the map lives in it. */
.rd-search-top.header {
  display: block; padding: 0; gap: 0;
  background: var(--brand-base); color: var(--brand-body);
  border: 0; border-bottom: 1px solid var(--rd-line); box-shadow: none;
  position: relative; z-index: 1010;
}
/* An open header menu must cover the phone search bar (z 1500) below it. */
.rd-search-top.header:has(.rd-menu[open]) { z-index: 2500; }

/* Saved homes / Log in / Sign up / account menu (same buttons and ids as
   search.html), in the header's page slot (rd_header_actions) before the phone.
   Below 1200px the five nav links, phone and gold button already fill the
   bar, so they take their own row under it; nothing is dropped at any width. */
.rd-account { display: flex; align-items: center; }
.rd-account .header-actions {
  margin: 0; padding: 0; display: flex; justify-content: flex-end; align-items: center; gap: 8px;
}
@media (max-width: 1199px) {
  .rd-search-top .rd-header__actions { flex-wrap: wrap; justify-content: flex-end; row-gap: 8px; }
  .rd-search-top .rd-account { order: 10; flex: 1 0 100%; justify-content: flex-end; }
}
/* Phone: one header row. Log in / Sign up (this page's lead step for a buyer)
   take the gold home-value button's place; "Home value" is still the second
   link in the menu and the link stays in the HTML. A second row cost the map
   55px of an iPhone's 664 (11/20/26). The account row wraps under the bar
   only when it truly does not fit (a long signed-in name). */
@media (max-width: 560px) {
  .rd-search-top .rd-header__cta { display: none; }
  .rd-search-top .rd-account { order: 0; flex: 0 1 auto; }
}
.rd-account .btn-saved-filter,
.rd-account .btn-login,
.rd-account .btn-save-search,
.rd-account #header-user-btn {
  min-height: var(--rd-tap); margin: 0; padding: 0 16px;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  border-radius: var(--rd-radius-btn); font-family: inherit; font-size: 15px; font-weight: 600;
  background: transparent !important; color: var(--brand-base);
  border: 1px solid rgba(255, 255, 255, .45);
}
.rd-account .btn-saved-filter:hover,
.rd-account .btn-login:hover,
.rd-account .btn-save-search:hover,
.rd-account #header-user-btn:hover { border-color: var(--brand-warm); color: var(--brand-base); }
.rd-account .btn-saved-filter.active { border-color: var(--brand-warm); color: var(--brand-base); }
.rd-account .user-dropdown { z-index: 1020; }
.rd-account .user-dropdown a { color: var(--brand-body); min-height: var(--rd-tap); }

/* ---------- filter bar (its own row now, no longer floating on the map) ---------- */
.rd-filters { padding: 14px var(--rd-gutter) 10px; display: flex; flex-direction: column; gap: 10px; }
.rd-filters__row { position: relative; }   /* the popover anchors here (initFilterBar) */

@media (min-width: 769px) {
  .rd-search-top .fbar {
    position: static; display: flex; align-items: center; gap: 8px;
  }
  .rd-search-top .fbar-scroll { gap: 8px; padding: 2px 0; }
  /* The mockup's order. The JS inserts the city control in front of the
     status pill; order moves status to just before "More Tahoe filters". */
  .rd-search-top .fbar-scroll > .fbar-search { order: 0; }
  .rd-search-top .fbar-scroll > .fbar-city { order: 1; }
  .rd-search-top #fbpill-price { order: 2; }
  .rd-search-top #fbpill-beds { order: 3; }
  .rd-search-top #fbpill-status { order: 4; }
  .rd-search-top #fbpill-tahoe { order: 5; }

  /* Search box: always in the bar on desktop (the bar is full width now). */
  .rd-search-top .fbar-search {
    display: flex; flex: 1 1 260px; min-width: 200px; max-width: 420px; height: var(--rd-input-h);
    border: 1px solid var(--rd-input-line); border-radius: var(--rd-radius-btn);
    box-shadow: none; padding: 0 14px; color: var(--rd-muted);
  }
  .rd-search-top .fbar-search input { font-size: 16px; color: var(--brand-primary); }
  .rd-search-top .fbar-search input::placeholder { color: #64748B; }
  .rd-search-top .fbar-search:focus-within { outline: 3px solid rgba(212, 168, 67, .55); border-color: var(--brand-primary); min-width: 260px; }
  .rd-search .filters .search-row { display: none; }

  .rd-search-top .fbar-pill,
  .rd-search-top .fbar-scroll > .fbar-city .mf-button {
    height: var(--rd-input-h); padding: 0 16px; gap: 8px;
    border: 1px solid var(--rd-line-strong); border-radius: var(--rd-radius-btn);
    background: var(--brand-base); color: var(--brand-primary);
    font-family: inherit; font-size: 15px; font-weight: 600; box-shadow: none;
  }
  .rd-search-top .fbar-scroll > .fbar-city { min-width: 120px; max-width: 200px; }
  .rd-search-top .fbar-pill:hover,
  .rd-search-top .fbar-scroll > .fbar-city .mf-button:hover { border-color: var(--brand-primary); }
  .rd-search-top .fbar-pill.open,
  .rd-search-top .fbar-pill.has,
  .rd-search-top .fbar-scroll > .fbar-city[aria-expanded="true"] .mf-button {
    background: var(--brand-tint); border-color: var(--brand-accent); color: var(--rd-ok);
  }
  .rd-search-top .fbar-caret { flex: none; }
  /* The one gold button. Same handler as before: openSaveSearchModal(). */
  .rd-search-top .fbar > .fbar-save,
  .rd-search-top .fbar > .fbar-save:hover {
    background: var(--brand-warm); color: var(--brand-primary); border: 0;
    padding: 0 20px; font-weight: 700;
  }
  .rd-search-top .fbar > .fbar-save:hover { background: #C69833; }

  .rd-search-top .fbar-pop {
    top: calc(100% + 8px); max-height: min(70vh, 640px);
    border-radius: var(--rd-radius-card); border-color: var(--rd-line);
    box-shadow: var(--rd-shadow); z-index: 1012;
  }
  /* The bar no longer covers the map's top edge. */
  .rd-search .leaflet-top .leaflet-control { margin-top: 10px; }

  .rd-search-top .fbar-chips {
    position: static; display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  }
  .rd-search-top .fbar-chips:empty { display: none; }
}

/* Popover controls in the redesign colours (the panels are search.html's). */
.rd-search-top .fchip.on,
.rd-search-top .ftile.on,
.rd-search-top .fseg.on { background: var(--brand-accent); border-color: var(--brand-accent); color: var(--brand-base); }
.rd-search-top .fhisto div { background: var(--brand-accent); }
.rd-search-top .fapply { background: var(--brand-primary); color: var(--brand-base); min-height: var(--rd-tap); padding: 0 20px; }
.rd-search-top .fapply:hover { background: var(--brand-accent); }
.rd-search-top .freset { min-height: var(--rd-tap); color: var(--rd-muted); }
.rd-search-top .fbar-chip { background: var(--brand-tint); color: var(--rd-ok); box-shadow: none; min-height: 36px; font-size: 14px; font-weight: 600; }
.rd-search-top .fbar-chip:hover { background: #DCEFE2; }
.rd-search-top .fbar-chips .fbar-reset { background: none; color: var(--rd-muted); font-size: 14px; min-height: 36px; }

/* ---------- quick chips: filters only this site has ---------- */
.rd-quick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rd-quick__label { font-size: 13px; font-weight: 600; color: var(--rd-muted); margin-right: 4px; }
.rd-qchip {
  min-height: var(--rd-tap); padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--rd-line-strong); background: var(--brand-base); color: var(--brand-primary);
  font-family: inherit; font-size: 14px; font-weight: 600;
}
.rd-qchip[data-rd-qf="str"] { border-color: var(--brand-accent); color: var(--rd-ok); }
.rd-qchip:hover { border-color: var(--brand-primary); }
.rd-qchip[aria-pressed="true"] { background: var(--brand-accent); border-color: var(--brand-accent); color: var(--brand-base); }

/* Phones keep today's controls: the search bar + Filters sheet (restyled
   below). The desktop bar and the chip row stay out of the way, as the
   floating bar did on the live page. */
@media (max-width: 768px) {
  .rd-filters { display: none; }
}

/* ---------- H1 + map + results ---------- */
.rd-results-head { padding: 20px 24px 6px; }
.rd-results-head__h1 {
  font-family: var(--rd-serif); font-weight: 400; font-size: 28px; line-height: 1.2;
  color: var(--brand-primary); margin: 0;
}
.rd-results-head__sub { margin: 6px 0 0; font-size: 14px; line-height: 1.5; color: var(--rd-muted); max-width: 640px; }

@media (min-width: 769px) {
  /* Map left over the full height; the H1 heads the results column. */
  .rd-search-main {
    display: grid; grid-template-columns: 50% minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
    /* --rd-map-top: where this grid starts (search_rd.html measures it). */
    height: calc(100dvh - var(--rd-map-top, var(--mobile-chrome-h, 220px))); min-height: 360px;
  }
  .rd-search-main > .main-layout { display: contents; }
  .rd-search .map-container { grid-column: 1; grid-row: 1 / span 2; width: auto; min-height: 0; }
  .rd-search .rd-results-head { grid-column: 2; grid-row: 1; border-left: 1px solid var(--rd-line); }
  .rd-search .sidebar { grid-column: 2; grid-row: 2; min-height: 0; overflow-y: auto; }
}
@media (min-width: 769px) and (max-width: 1024px) {
  .rd-search-main { grid-template-columns: 45% minmax(0, 1fr); }
}

.rd-search .sidebar { background: var(--brand-base); border-left: 1px solid var(--rd-line); }
.rd-search .filters { background: var(--brand-base); border-bottom: 0; padding: 4px 24px 8px; }
.rd-search .results-count { font-size: 14px; color: var(--rd-muted); gap: 12px; }
.rd-search #sort-filter {
  height: var(--rd-tap); border: 1px solid var(--rd-line-strong); border-radius: var(--rd-radius-btn);
  padding: 0 12px; font-family: inherit; font-size: 15px; color: var(--brand-primary); background: var(--brand-base);
}

/* ---------- result cards: the shared rd card look (rd.css .rd-card) on the
   JS-built .listing-card, keeping every control it has ---------- */
.rd-search .listings-container {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; padding: 8px 24px 16px;
}
.rd-search .listing-card {
  border: 1px solid var(--rd-line); border-radius: var(--rd-radius-card);
  box-shadow: none; background: var(--brand-base); display: flex; flex-direction: column;
}
.rd-search .listing-card:hover { transform: none; border-color: var(--rd-line-strong); box-shadow: var(--rd-shadow); }
.rd-search .listing-card.active { border-color: var(--brand-accent); box-shadow: 0 0 0 2px var(--brand-accent); }
.rd-search .listing-card .listing-photo { height: auto; aspect-ratio: 16 / 10; display: block; }
.rd-search .listing-info { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 5px; }
.rd-search .listing-price {
  font-family: var(--rd-serif); font-weight: 400; font-size: 24px; line-height: 1.15;
  color: var(--brand-primary); margin: 0;
}
.rd-search .price-was { font-family: var(--rd-sans); font-size: 13px; color: var(--rd-muted); }
.rd-search .price-cut-badge { font-family: var(--rd-sans); font-size: 12px; background: var(--rd-warn-bg); color: var(--rd-warn); border-radius: 999px; padding: 2px 8px; }
.rd-search .listing-address { font-size: 15px; font-weight: 500; color: var(--brand-primary); margin: 0; white-space: normal; }
.rd-search .listing-details { font-size: 14px; color: var(--rd-muted); flex-wrap: wrap; gap: 4px 8px; align-items: center; }
/* Gold rule above the rental line, as on the rd card. */
.rd-search .listing-str {
  border-top: 1px solid var(--brand-warm); margin-top: 8px; padding-top: 8px; flex-wrap: wrap; gap: 6px 8px;
}
.rd-search .str-revenue { font-size: 14px; font-weight: 400; color: var(--brand-body); }
.rd-search .str-zone {
  font-size: 12px; font-weight: 700; text-transform: none; letter-spacing: 0;
  padding: 4px 10px; border-radius: 999px;
}
.rd-search .str-zone.green { background: var(--brand-tint); color: var(--rd-ok); }
.rd-search .str-zone.yellow { background: var(--rd-warn-bg); color: var(--rd-warn); }
.rd-search .str-zone.red, .rd-search .str-zone.unknown { background: var(--rd-no-bg); color: var(--rd-no); }
.rd-search .str-permit-note { font-size: 13px; color: var(--rd-warn); }
.rd-search .str-permit-note.ok { color: var(--rd-ok); }
.rd-search .str-permit-pill { font-size: 12px; border-radius: 999px; padding: 2px 8px; background: var(--brand-tint); color: var(--rd-ok); border-color: transparent; }
.rd-search .walkthrough-pill { font-size: 12px; border-radius: 999px; padding: 2px 8px; background: var(--brand-primary); border-color: var(--brand-primary); }
.rd-search .highlight-badge { font-size: 12px; background: var(--rd-no-bg); color: var(--rd-no); border-radius: 999px; padding: 2px 8px; }
.rd-search .listing-meta { border-top: 0; margin-top: auto; padding-top: 6px; }
.rd-search .listing-status { font-size: 12px; }
.rd-search .listing-mls { font-size: 12px; color: var(--rd-muted); }
.rd-search .listing-status-ribbon { text-transform: none; letter-spacing: 0; font-size: 12px; background: var(--rd-warn-bg); color: var(--rd-warn); box-shadow: none; }
.rd-search .listing-status-ribbon.backup-offers,
.rd-search .listing-status-ribbon.accepting-backup-offers { background: var(--brand-primary); color: var(--brand-base); }
/* Save, compare: 44px targets. */
.rd-search .saved-heart,
.rd-search .compare-card-btn { width: var(--rd-tap); height: var(--rd-tap); top: 8px; }
.rd-search .compare-card-btn { right: 8px !important; }
.rd-search .saved-heart ~ .compare-card-btn { right: 58px !important; }
.rd-search .saved-heart { right: 8px; }
.rd-search .compare-card-btn.active { background: var(--brand-primary); color: var(--brand-base); }
/* Buyer match badge: words, not a bare percentage (properties-search.js). */
.rd-search .ai-match-pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; backdrop-filter: none; }
.rd-search .ai-match-pill.high { background: var(--brand-primary); color: var(--brand-base); }
.rd-search .ai-match-pill.medium { background: var(--brand-tint); color: var(--rd-ok); }
.rd-search .ai-match-pill.low { background: var(--rd-no-bg); color: var(--rd-no); }
.rd-search .ai-personalized-bar { background: var(--brand-tint); color: var(--rd-ok); border-bottom-color: var(--rd-line); }

/* Server-rendered cards (crawlers, first byte) use the shared rd card itself. */
.rd-search .listings-container > .rd-card { height: auto; }

/* Save-search band at the end of the results. */
.rd-save-cta {
  margin: 8px 24px 32px; border-top: 1px solid var(--brand-warm); padding-top: 16px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
}
.rd-save-cta__text { margin: 0; font-size: 15px; font-weight: 500; color: var(--brand-primary); }
.rd-save-cta .rd-btn { min-height: var(--rd-input-h); border: 0; cursor: pointer; font-family: inherit; }

/* ---------- map controls: bottom-left, "Draw your own area" + County lines ---------- */
.rd-search .leaflet-bottom.leaflet-left {
  display: flex; flex-direction: row-reverse; justify-content: flex-end; align-items: flex-end;
  gap: 8px; padding: 0 0 16px 16px;
}
.rd-search .leaflet-bottom.leaflet-left .leaflet-control { margin: 0; float: none; clear: none; }
.rd-search .leaflet-bottom .draw-control-group { border: 0; box-shadow: 0 6px 16px rgba(0,0,0,.25); border-radius: var(--rd-radius-btn); overflow: hidden; }
.rd-search .leaflet-bar a.draw-toggle {
  height: var(--rd-tap) !important; line-height: var(--rd-tap) !important; padding: 0 16px !important;
  background: var(--brand-primary); color: var(--brand-base); font-size: 14px; font-weight: 700; border: 0;
}
.rd-search .leaflet-bar a.draw-toggle:hover { background: var(--brand-accent); color: var(--brand-base); }
.rd-search .leaflet-bar a.draw-toggle.active { background: var(--brand-warm) !important; color: var(--brand-primary) !important; }
.rd-search .leaflet-bar a.draw-clear-toggle {
  height: var(--rd-tap) !important; line-height: var(--rd-tap) !important; padding: 0 16px !important;
  font-size: 14px; font-weight: 700; background: var(--brand-base); border-top: 1px solid var(--rd-line);
}
.rd-search .leaflet-bottom .leaflet-bar:has(.county-toggle) {
  border: 0 !important; background: none !important; box-shadow: none !important; overflow: visible !important;
}
.rd-search .leaflet-bar a.county-toggle {
  min-height: var(--rd-tap) !important; display: inline-flex !important; align-items: center;
  padding: 0 16px !important; border-radius: var(--rd-radius-btn) !important; border: 0 !important;
  background: var(--brand-base) !important; color: var(--brand-primary) !important;
  font-size: 14px !important; font-weight: 700 !important; box-shadow: 0 6px 16px rgba(0,0,0,.25) !important;
}
.rd-search .leaflet-bar a.county-toggle.active,
.rd-search .leaflet-bar a.county-toggle.active:hover { background: var(--brand-primary) !important; color: var(--brand-base) !important; }
/* The county key sat bottom-left; it now opens above the two buttons. */
.rd-search .county-legend { bottom: 76px; left: 16px; }

/* "Back to <town>" chip, shown after a pan away from a ?city= or ?neighborhood= view (the town
   pages link here that way). search.html keeps it bottom-centre; on this page the bottom of the
   map holds Draw + County lines (and the List pill on a phone), so the chip sat on top of them
   and a click meant for County lines re-applied the town instead (11/21/26). Top-centre is free
   at every width: the zoom buttons end 44px from the left, a pin's popup stops 56px below the
   map's top (properties-search.js, RD_POPUP_TOP), and the phone's email card rises from the
   bottom. Long names ("City of South Lake Tahoe") shorten with an ellipsis before they reach
   the zoom buttons. */
.rd-search .nb-back-chip {
  top: 8px; bottom: auto; min-height: var(--rd-tap); max-width: calc(100% - 124px);
  color: var(--brand-primary); border-color: var(--rd-line-strong); font-size: 14px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .25);
}
.rd-search .nb-back-chip:hover { background: var(--brand-tint); }
.rd-search .nb-back-chip svg { flex: none; }
.rd-search .nb-back-chip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* The phone's pin sheet (tap a pin: photo, price, beds, address). Its three text lines have no
   line-height of their own, so they took the redesign's 1.5 and the sheet grew from 317px to
   333px of a 664px screen, over more of the map. search.html's page leaves them at the font's
   own line height; so does this (11/21/26). The photo's 200px comes back with the base image
   rule in rd.css. */
.rd-search .mobile-bottom-sheet { line-height: normal; }

/* Map pins and popups in brand colours are search.html's; untouched. */

/* ---------- phones (map-first shell, today's behaviour) ---------- */
@media (max-width: 768px) {
  /* One line of H1 over the map, as the live page's header had. Fixed height
     so the map's height calc (which counts .header + bar + chips) stays exact. */
  .rd-results-head { height: 40px; padding: 0 12px; display: flex; align-items: center; background: var(--brand-base); }
  .rd-results-head__h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rd-results-head__sub { display: none; }
  /* --rd-map-top (search_rd.html) includes the app-download strip, which the
     search JS's --mobile-chrome-h does not; the body is pinned here, so a map
     taller than the screen would hide Draw behind the List pill for good. */
  .rd-search .map-container { height: calc(100dvh - var(--rd-map-top, var(--mobile-chrome-h, 108px)) - 40px); }
  body.mobile-list-view .rd-results-head { height: auto; padding: 12px 16px 0; flex-direction: column; align-items: flex-start; }
  body.mobile-list-view .rd-results-head__h1 { white-space: normal; font-size: 24px; }
  body.mobile-list-view .rd-results-head__sub { display: block; }

  .rd-account .btn-saved-filter,
  .rd-account .btn-login,
  .rd-account .btn-save-search,
  .rd-account #header-user-btn { padding: 0 12px; font-size: 14px; }

  .rd-search .mobile-search-bar { background: var(--brand-base); border-bottom: 1px solid var(--rd-line); }
  .rd-search .msb-search { border-radius: var(--rd-radius-btn); border-color: var(--rd-input-line); min-height: var(--rd-tap); }
  .rd-search .msb-search input { font-size: 16px; }
  .rd-search .msb-filter-btn { border-radius: var(--rd-radius-btn); min-width: var(--rd-tap); min-height: var(--rd-tap); }
  .rd-search .mobile-chips .fbar-chip { background: var(--brand-tint); color: var(--rd-ok); }
  .rd-search .mfp-apply { background: var(--brand-warm); color: var(--brand-primary); border-radius: var(--rd-radius-btn); min-height: var(--rd-input-h); font-weight: 700; }
  .rd-search .mobile-view-toggle { background: var(--brand-primary); white-space: nowrap; }
  .rd-search .listings-container { grid-template-columns: 1fr; padding: 8px 16px 16px; }
  .rd-search .filters { padding: 8px 16px; }
  .rd-save-cta { margin: 8px 16px 96px; }

  /* Draw + County lines sit side by side above the List / Map pill. Stacked,
     they and the pill covered a third of an iPhone's map (11/20/26); they
     still wrap to two rows on a 320px phone. */
  .rd-search .leaflet-bottom.leaflet-left {
    flex-direction: row-reverse; flex-wrap: wrap-reverse; justify-content: flex-end; align-items: flex-end;
    padding: 0 12px calc(84px + env(safe-area-inset-bottom)) 12px;
  }
  .rd-search .county-legend { bottom: calc(144px + env(safe-area-inset-bottom)); left: 12px; }
}
