/* Rentals search (templates/marketplace/rentals/search.html): the sticky filter bar, the result head and
   filter chips, the Sponsored block (rn-sponsored / rn-strip / rn-grid: tests read those names), the
   results grid, the map beside the list (an overlay below 1100px) and its price pins. Tokens only. */

.rs-body { --rs-bar-h: 76px; }
.rs-body .s-footer { margin-top: 72px; }
.rs-wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }

/* ---------- Filter bar ------------------------------------------------------------------ */

.rs-bar {
  position: sticky; top: var(--header-h); z-index: 40;
  background: var(--bg); border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 18px -16px rgba(14, 23, 38, .35);
}
.rs-bar:has(.rs-pop[open]) { z-index: 60; }
.rs-bar-form { display: flex; align-items: center; gap: 10px; min-height: var(--rs-bar-h); padding-block: 14px; }

.rs-where { position: relative; flex: 1 1 340px; max-width: 460px; min-width: 0; }
.rs-where > .s-ic { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--ink-3); pointer-events: none; }
.rs-where-input {
  width: 100%; height: 48px; padding: 0 16px 0 44px; border-radius: var(--pill);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-size: 0.97rem; font-weight: 600; transition: border-color .15s, box-shadow .15s;
}
.rs-where-input::placeholder { color: var(--ink-4); font-weight: 500; }
.rs-where-input:hover { border-color: var(--ink-4); }
.rs-where-input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.rs-where-input::-webkit-search-cancel-button { cursor: pointer; }

.rs-pops { display: flex; align-items: center; gap: 8px; }
.rs-pop-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 16px;
  border-radius: var(--pill); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-size: 0.92rem; font-weight: 700; white-space: nowrap; user-select: none;
  transition: border-color .15s, background-color .15s, color .15s;
}
.rs-pop-btn:hover { border-color: var(--ink-3); }
.rs-pop-btn .s-ic { width: 16px; height: 16px; }
.rs-pop-btn .s-ic--chev { width: 14px; height: 14px; color: var(--ink-3); }
.rs-pop-btn.is-on { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary); }
.rs-pop-btn.is-on .s-ic--chev { color: currentColor; }
.rs-pop[open] > .rs-pop-btn { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
.rs-pop-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.rs-pop-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--pill); background: var(--primary); color: var(--primary-ink); font-size: 0.72rem; font-weight: 800; }
button.rs-pop-btn { cursor: pointer; }

.rs-pop-panel {
  position: absolute; left: 0; top: calc(100% + 10px); z-index: 61; width: 360px; max-width: calc(100vw - 32px);
  padding: 20px; display: grid; gap: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-3);
}
.rs-pop-panel--end { left: auto; right: 0; }
.rs-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 12px; }
.rs-pop-title { padding: 0; font-size: 0.78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.rs-pop-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }

/* Bedrooms: a segmented choice (radios; picking one searches). */
.rs-seg { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.rs-seg-opt { position: relative; }
.rs-seg-opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.rs-seg-opt span {
  display: grid; place-items: center; height: 44px; padding: 0 6px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  font-size: 0.88rem; font-weight: 700; white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s;
}
.rs-seg-opt:hover span { border-color: var(--ink-3); color: var(--ink); }
.rs-seg-opt input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.rs-seg-opt input:focus-visible + span { box-shadow: var(--ring); }

/* Price: two boxes with a "$" in front. */
.rs-price { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: 10px; }
.rs-price-to { padding-bottom: 13px; font-size: 0.85rem; color: var(--ink-3); font-weight: 600; }
.rs-money { position: relative; display: block; }
.rs-money > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-weight: 700; pointer-events: none; }
.rs-money .s-input { padding-left: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* More: switches. */
.rs-toggle { position: relative; display: flex; align-items: center; gap: 14px; padding: 6px 0; cursor: pointer; }
.rs-toggle input { position: absolute; left: 0; top: 50%; width: 44px; height: 26px; margin: 0; transform: translateY(-50%); opacity: 0; cursor: pointer; }
.rs-toggle-ui { position: relative; flex: none; width: 44px; height: 26px; border-radius: var(--pill); background: var(--line-strong); transition: background-color .18s var(--ease); }
.rs-toggle-ui::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(14, 23, 38, .3); transition: transform .18s var(--ease); }
.rs-toggle input:checked + .rs-toggle-ui { background: var(--primary); }
.rs-toggle input:checked + .rs-toggle-ui::after { transform: translateX(18px); }
.rs-toggle input:focus-visible + .rs-toggle-ui { box-shadow: var(--ring); }
.rs-toggle-words { display: grid; gap: 1px; }
.rs-toggle-words strong { font-size: 0.95rem; color: var(--ink); }
.rs-toggle-words small { font-size: 0.8rem; color: var(--ink-3); }

.rs-go { height: 48px; min-height: 48px; padding: 0 22px; }
.rs-map-chip { display: none; }

/* ---------- Layout: the list, and the map beside it ------------------------------------- */

.rs-layout { padding-top: 26px; }
.rs-list { min-width: 0; }

.rs-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 18px; }
.rs-head-text { min-width: 0; }
.rs-title { font-size: clamp(1.4rem, 1.15rem + .9vw, 1.9rem); line-height: 1.15; font-weight: 800; letter-spacing: -0.03em; color: var(--ink); }
.rs-count { margin-top: 6px; font-size: 0.93rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rs-count strong { color: var(--ink-2); font-weight: 700; }
.rs-head-tools { display: flex; align-items: center; gap: 10px; }
.rs-sort { display: inline-flex; align-items: center; gap: 8px; font-size: 0.88rem; font-weight: 600; color: var(--ink-3); }
.rs-sort-select {
  height: 40px; padding: 0 34px 0 14px; border-radius: var(--pill); border: 1px solid var(--line-strong);
  background-color: var(--surface); color: var(--ink); font-size: 0.9rem; font-weight: 700; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23667285' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.rs-sort-select:hover { border-color: var(--ink-3); }
.rs-sort-select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.rs-map-btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.rs-chips { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin: -4px 0 22px; }
.rs-chip { min-height: 36px; padding: 0 10px 0 14px; background: var(--bg-soft); border-color: var(--line); color: var(--ink); }
.rs-chip .s-ic { width: 14px; height: 14px; color: var(--ink-3); }
.rs-chip:hover .s-ic { color: var(--ink); }
.rs-clear { font-size: 0.88rem; font-weight: 700; color: var(--link); }

/* ---------- Sponsored ------------------------------------------------------------------- */

.rs-sponsored { margin-bottom: 30px; padding: 20px; border-radius: var(--r-lg); background: var(--ad-soft); border: 1px solid var(--ad-line); }
.rs-sponsored-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.rs-sponsored-title { display: flex; align-items: center; gap: 8px; font-size: 1.08rem; font-weight: 800; letter-spacing: -0.015em; color: var(--ink); }
.rs-sponsored-title .s-ic { width: 18px; height: 18px; color: var(--ad); }
.rs-sponsored .s-sponsored-note { margin-top: 4px; }
.rs-sponsored .s-rail-btn { background: var(--surface); }

.rn-strip {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 296px); gap: 16px;
  overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain;
  padding: 4px 2px 6px; margin: -4px -2px -6px;
}
.rn-strip::-webkit-scrollbar { display: none; }
.rn-strip > * { scroll-snap-align: start; }

.rn-grid, .rs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 264px), 1fr)); gap: 24px 20px; }
.rs-grid .s-card.is-picked { box-shadow: 0 0 0 2px var(--primary), var(--sh-3); border-color: transparent; transform: translateY(-3px); }

.rs-empty { margin-top: 8px; }

/* ---------- Map ------------------------------------------------------------------------- */

.rs-map { position: relative; background: var(--bg-sunk); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.rs-map-canvas { position: absolute; inset: 0; }
.rs-map-note:empty { display: none; }
.rs-map-note {
  position: absolute; left: 50%; top: 14px; z-index: 2; transform: translateX(-50%); width: max-content; max-width: calc(100% - 28px);
  padding: 8px 14px; border-radius: var(--pill); background: var(--surface); color: var(--ink-2); box-shadow: var(--sh-2);
  font-size: 0.84rem; font-weight: 600; text-align: center;
}
.rs-map-close { display: none; }

@media (min-width: 1100px) {
  .rs-layout.is-map-open { display: grid; grid-template-columns: minmax(0, 1fr) clamp(400px, 40%, 860px); gap: 24px; align-items: start; }
  .rs-layout.is-map-open .rs-map {
    position: sticky; top: calc(var(--header-h) + var(--rs-bar-h) + 18px);
    height: calc(100vh - var(--header-h) - var(--rs-bar-h) - 36px); height: calc(100dvh - var(--header-h) - var(--rs-bar-h) - 36px);
    min-height: 420px;
  }
}
@media (max-width: 1099px) {
  .rs-map:not([hidden]) { position: fixed; inset: var(--header-h) 0 0 0; z-index: 45; border: 0; border-radius: 0; }
  .rs-map-close { display: inline-flex; position: absolute; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 3; box-shadow: var(--sh-3); }
  body.rs-map-full { overflow: hidden; }
}

/* Price pins (drawn by static/site/rentals.js over the map). */
.rs-pin {
  position: absolute; transform: translate(-50%, calc(-100% - 6px)); z-index: 1;
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: var(--pill);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); box-shadow: var(--sh-2);
  font: 800 0.8rem/1.2 var(--font); font-variant-numeric: tabular-nums; white-space: nowrap; cursor: pointer;
  transition: background-color .12s, color .12s, transform .12s;
}
.rs-pin::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 10px; height: 10px; margin-left: -5px; background: inherit; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); transform: rotate(45deg); border-bottom-right-radius: 2px; }
.rs-pin.is-hot, .rs-pin:hover, .rs-pin:focus-visible { background: var(--ink); color: var(--bg); border-color: var(--ink); z-index: 3; outline: none; }
.rs-pin.is-hot::after, .rs-pin:hover::after, .rs-pin:focus-visible::after { border-color: var(--ink); }
.rs-pin-n { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--pill); background: var(--primary); color: var(--primary-ink); font-size: 0.7rem; }

.rs-pin-card {
  position: absolute; z-index: 4; transform: translate(-50%, calc(-100% - 44px)); width: 260px; padding: 8px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-3);
  font-family: var(--font);
}
.rs-pin-card ul { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.rs-pin-card a { display: grid; gap: 1px; padding: 9px 10px; border-radius: 10px; color: var(--ink); text-decoration: none !important; }
.rs-pin-card a:hover { background: var(--bg-soft); }
.rs-pin-card strong { font-size: 0.95rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.rs-pin-card span { font-size: 0.82rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs-pin-x { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--ink-3); }
.rs-pin-x:hover { background: var(--bg-soft); color: var(--ink); }
.rs-pin-x .s-ic { width: 14px; height: 14px; }

/* ---------- Narrow screens -------------------------------------------------------------- */

@media (max-width: 1099px) {
  .rs-where { max-width: none; }
}

@media (max-width: 760px) {
  .rs-body { --rs-bar-h: 106px; }
  .rs-bar-form { flex-wrap: wrap; gap: 8px; padding-block: 10px; }
  .rs-where { flex: 1 1 0; order: 1; }
  .rs-where-input { height: 44px; font-size: 1rem; }
  .rs-go { order: 2; width: 44px; height: 44px; min-height: 44px; padding: 0; margin-left: 0; }
  .rs-go-words { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .rs-pops {
    order: 3; flex: 1 0 100%; gap: 6px; overflow-x: auto; scrollbar-width: none;
    margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter);
  }
  .rs-pops::-webkit-scrollbar { display: none; }
  .rs-pop-btn { height: 38px; padding: 0 12px; gap: 6px; font-size: 0.86rem; }
  /* The phone's "Map" button floats over the list. */
  .rs-map-chip:not([hidden]) {
    display: inline-flex; position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 41;
    transform: translateX(-50%); height: 46px; padding: 0 20px;
    background: var(--ink); color: var(--bg); border-color: var(--ink); box-shadow: var(--sh-3);
  }
  .rs-map-chip:not([hidden]):hover { border-color: var(--ink); }

  /* A filter opens as a sheet from the bottom; tapping outside closes it. */
  .rs-pop[open] > .rs-pop-btn::before { content: ""; position: fixed; inset: 0; z-index: 60; background: rgba(5, 8, 15, .5); cursor: default; }
  .rs-pop-panel, .rs-pop-panel--end {
    position: fixed; left: 0; right: 0; top: auto; bottom: 0; z-index: 61; width: auto; max-width: none; max-height: 86vh; overflow-y: auto;
    padding: 22px var(--gutter) calc(18px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; border-bottom: 0;
  }
  .rs-pop-panel::before { content: ""; justify-self: center; width: 40px; height: 4px; margin-top: -8px; border-radius: var(--pill); background: var(--line-strong); }
  .rs-pop-foot .s-btn { flex: 1; min-height: 46px; }
  .rs-seg { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .rs-layout { padding-top: 20px; }
  .rs-head { align-items: center; margin-bottom: 14px; }
  .rs-head-tools { width: 100%; justify-content: space-between; }
  .rs-map-btn { display: none; }
  .rs-sponsored { margin-inline: calc(var(--gutter) * -1); padding: 18px var(--gutter); border-radius: 0; border-inline: 0; }
  .rs-sponsored .s-rail-nav { display: none; }
  .rn-strip { grid-auto-columns: 82%; }
  .rn-grid, .rs-grid { gap: 18px; }
}

/* ---------- Apartments / Buildings switch (marketplace/rentals/_views.html) ------------------ */
.rs-views { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 12px; border-radius: var(--pill); background: var(--bg-soft); border: 1px solid var(--line); }
.rs-view { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 16px; border-radius: var(--pill); font-size: 0.9rem; font-weight: 700; color: var(--ink-3); text-decoration: none !important; transition: background .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease); }
.rs-view .s-ic { width: 16px; height: 16px; }
.rs-view:hover { color: var(--ink); }
.rs-view[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1, 0 1px 2px rgba(15, 23, 42, .08)); }
.rs-view:focus-visible { outline: none; box-shadow: var(--ring); }

/* ---------- A building card (site/partials/_building_card.html) ----------------------------- */
.s-card--building .s-card-media { aspect-ratio: 16 / 11; }
.rs-grid .s-card--building.is-picked { box-shadow: 0 0 0 2px var(--primary), var(--sh-3); border-color: transparent; transform: translateY(-3px); }

@media (max-width: 640px) {
  .rs-head-text:has(.rs-views) { flex: 1 1 100%; }
  .rs-views { display: flex; width: 100%; }
  .rs-view { flex: 1 1 0; justify-content: center; padding: 0 10px; }
}
