/*
 * Listings archive — ported from the design prototype's Listings.dc.html.
 * Reuses design tokens from main.css (not redefined here). Breakpoints
 * match the rest of the site: single responsive breakpoint at 1024px
 * (tablet uses the same styling as mobile — no separate tablet treatment).
 */

/* ---------- Sticky filter bar ---------- */

.rpr-lst-filterbar {
  border-bottom: 1px solid var(--rpr-border);
  position: sticky;
  top: var(--rpr-header-height);
  z-index: 20;
  background: #fff;
}

.rpr-lst-filterbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 10px 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.rpr-lst-filterbar.is-scrolled .rpr-lst-chips {
  display: none;
}

.rpr-lst-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.rpr-lst-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--rpr-border-strong);
  background: #fff;
  color: var(--rpr-text-body);
  border-radius: var(--rpr-radius-pill);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.rpr-lst-chip:hover {
  border-color: var(--rpr-blue);
}

.rpr-lst-chip.is-active,
.rpr-lst-chip-radio:checked + .rpr-lst-chip {
  border-color: var(--rpr-blue);
  background: var(--rpr-blue);
  color: #fff;
}

.rpr-lst-chip-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.rpr-lst-chip.is-active .rpr-lst-chip-icon,
.rpr-lst-chip-radio:checked + .rpr-lst-chip .rpr-lst-chip-icon {
  filter: invert(1) brightness(2);
}

.rpr-lst-filterbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.rpr-lst-clear {
  border: 0;
  background: none;
  color: var(--rpr-blue);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.rpr-lst-count {
  font-size: 13px;
  color: var(--rpr-text-tertiary);
  white-space: nowrap;
}

/* Compact mobile trigger bar (replaces the desktop chip row on small screens) */
.rpr-lst-filterbar-mobile {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
}

.rpr-lst-filterbar-mobile-btn {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: 1px solid var(--rpr-border-strong);
  border-radius: var(--rpr-radius-pill);
  padding: 8px 16px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
}

.rpr-lst-filterbar-mobile-title {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--rpr-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rpr-lst-filterbar-mobile-sub {
  display: block;
  font-size: 12px;
  color: var(--rpr-text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Mobile filter sheet ---------- */

.rpr-lst-sheet {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #fff;
  display: none;
  flex-direction: column;
}

.rpr-lst-sheet.is-open {
  display: flex;
}

.rpr-lst-sheet-form {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.rpr-lst-sheet-header {
  flex: 0 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-bottom: 1px solid var(--rpr-border-faint);
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
}

.rpr-lst-sheet-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--rpr-text);
}

.rpr-lst-sheet-close {
  position: absolute;
  right: 12px;
  top: calc(10px + env(safe-area-inset-top, 0px));
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: var(--rpr-bg-hover-2);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.rpr-lst-sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.rpr-lst-field {
  margin-bottom: 20px;
}

.rpr-lst-field-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--rpr-text);
  margin-bottom: 8px;
}

.rpr-lst-field-label-row {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
}

.rpr-lst-field-label-row span:last-child {
  font-weight: 600;
  color: var(--rpr-text-secondary);
}

.rpr-lst-field-icon-wrap {
  position: relative;
}

.rpr-lst-field-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #9aa1ae;
  pointer-events: none;
}

.rpr-lst-field input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--rpr-border-strong);
  border-radius: var(--rpr-radius-md);
  padding: 12px 12px 12px 40px;
  font-size: 15px;
  outline: none;
}

.rpr-lst-field input[type="text"]:focus {
  border-color: var(--rpr-blue);
}

.rpr-lst-field select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--rpr-border-strong);
  border-radius: var(--rpr-radius-md);
  padding: 12px;
  font-size: 15px;
  outline: none;
  background: #fff;
  cursor: pointer;
}

.rpr-lst-field input[type="range"] {
  width: 100%;
  accent-color: var(--rpr-navy);
}

.rpr-lst-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rpr-lst-chip-radio {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.rpr-lst-sheet-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--rpr-border-faint);
}

/* ---------- Map + cards layout ---------- */

.rpr-lst-row {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
}

.rpr-lst-cards-col {
  flex: 1;
  min-width: 0;
  padding: 20px 28px 80px;
}

.rpr-lst-map-wrap {
  display: none;
  flex: 0 0 auto;
  width: 44%;
  max-width: 680px;
  background: var(--rpr-bg-selected);
  position: sticky;
  top: var(--rpr-lst-sticky-top, 150px);
  height: calc(100vh - var(--rpr-lst-sticky-top, 150px));
}

body.rpr-map-visible .rpr-lst-map-wrap {
  display: block;
}

.rpr-lst-map {
  width: 100%;
  height: 100%;
}

/* Leaflet custom pin + popup styling (matches the prototype's .rpr-pin) */
.rpr-pin {
  background: var(--rpr-blue);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 14px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(20, 30, 60, 0.3);
  border: 2px solid #fff;
  font-family: var(--rpr-font);
  /* The divIcon has no fixed iconSize (its width varies with the price
	   text, "$75" vs "$1,200"), so Leaflet positions its wrapper by this
	   element's natural top-left corner at the marker's exact geographic
	   point rather than centering it — this shifts it back over that point
	   regardless of its own size, so panTo()/setView() centering the map on
	   a marker's LatLng actually lines up with where the bubble is drawn. */
  transform: translate(-50%, -50%);
}

.rpr-pin.active {
  background: var(--rpr-blue-dark);
}

.rpr-popup .leaflet-popup-content-wrapper {
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
}

.rpr-popup .leaflet-popup-content {
  margin: 0;
  width: 220px !important;
}

.rpr-popup-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.rpr-popup-media {
  aspect-ratio: 4 / 3;
  background: var(--rpr-border-faintest);
  overflow: hidden;
}

.rpr-popup-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rpr-popup-body {
  padding: 10px 12px;
}

.rpr-popup-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--rpr-text);
  line-height: 1.3;
  margin-bottom: 4px;
}

.rpr-popup-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--rpr-blue);
}

.rpr-popup-price span {
  font-weight: 400;
  color: #6b7280;
}

/* ---------- Results grid + cards ---------- */

.rpr-lst-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
}

.rpr-lst-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--rpr-border);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  transition:
    box-shadow 0.18s,
    transform 0.18s,
    border-color 0.15s;
}

.rpr-lst-card:hover,
.rpr-lst-card.is-hovered {
  box-shadow: 0 10px 26px rgba(20, 30, 60, 0.13);
  transform: translateY(-2px);
  border-color: var(--rpr-blue);
}

.rpr-lst-card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--rpr-border-faintest);
}

.rpr-lst-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rpr-lst-card-rating {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--rpr-text);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: var(--rpr-radius-pill);
}

.rpr-lst-card-rating span {
  font-weight: 400;
  color: #6b7280;
}

.rpr-lst-card-rating span.rpr-lst-card-rating-star {
  color: #f2b60d;
  margin: 0 2px 0 3px;
}

.rpr-lst-card-rating span.rpr-lst-card-rating-count {
  margin-left: 1px;
}

.rpr-lst-card-meta {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: rgba(20, 28, 48, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--rpr-radius-pill);
}

.rpr-lst-card-body {
  padding: 13px 14px 15px;
}

.rpr-lst-card-name {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  max-height: 41px;
  overflow: hidden;
}

.rpr-lst-card-price-row {
  margin-top: 5px;
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.rpr-lst-card-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--rpr-blue);
}

.rpr-lst-card-pernight {
  font-size: 13px;
  color: #6b7280;
}

.rpr-lst-card-city {
  margin-top: 9px;
  font-size: 12px;
  color: var(--rpr-text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Empty state ---------- */

.rpr-lst-empty {
  padding: 80px 0;
  text-align: center;
  color: var(--rpr-text-tertiary);
  font-size: 15px;
}

.rpr-lst-empty-title {
  font-weight: 700;
  color: var(--rpr-text);
  font-size: 17px;
  margin-bottom: 8px;
}

.rpr-lst-empty a {
  color: var(--rpr-blue);
  font-weight: 600;
}

/* ---------- Load more ---------- */

.rpr-lst-loadmore-wrap {
  display: flex;
  justify-content: center;
  margin-top: 40px;
}

.rpr-lst-loadmore-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--rpr-blue);
  color: #fff;
  border: 0;
  border-radius: 26px;
  padding: 13px 30px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.rpr-lst-loadmore-btn:hover {
  background: var(--rpr-blue-dark);
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  .rpr-lst-filterbar-inner {
    display: none !important;
  }

  .rpr-lst-filterbar-mobile {
    display: flex !important;
  }

  /* The header's desktop inline filter row is replaced on mobile by the
	   compact bar above + this page's own filter sheet. */
  .rpr-hdr-search {
    display: none !important;
  }

  .rpr-lst-row {
    flex-direction: column !important;
  }

  .rpr-lst-cards-col {
    order: 2;
    padding: 16px 16px 60px !important;
  }

  .rpr-lst-map-wrap {
    order: 1;
  }

  body.rpr-map-visible .rpr-lst-map-wrap {
    width: 100%;
    max-width: 100%;
    height: 300px;
    position: relative;
    top: auto;
    margin-bottom: 4px;
  }

  /* The map-toggle button lives in the desktop inline filter row, hidden
	   at this width (see .rpr-hdr-search above) — with no control to hide
	   it again, the server-rendered "visible by default" class would
	   otherwise permanently plant a 300px map above every mobile visitor's
	   results with no way to dismiss it. */
  body.rpr-map-visible .rpr-lst-map-wrap {
    display: none;
  }
}

/* On tablet specifically (not phone), the map isn't hidden by default and
   sits beside the card list — not stacked above it — same side-by-side
   split as desktop, just narrower proportions. There's still no way to
   manually toggle it at this width (same reasoning as the phone-width rule
   above — the toggle lives in .rpr-hdr-search, hidden below 1024px), so
   this restores the map's actual server-rendered default (visible) instead
   of leaving it permanently hidden like phone does. Cards drop to a single
   column since the cards column is now sharing width with the map rather
   than having the full row to itself. */
@media (min-width: 681px) and (max-width: 1024px) {
  .rpr-lst-row {
    flex-direction: row !important;
  }

  .rpr-lst-cards-col {
    order: 1 !important;
  }

  .rpr-lst-grid {
    grid-template-columns: 1fr !important;
  }

  body.rpr-map-visible .rpr-lst-map-wrap {
    display: block;
    order: 2 !important;
    width: 60%;
    max-width: none;
    position: sticky;
    top: var(--rpr-header-height, 50px);
    height: calc(100vh - var(--rpr-header-height, 50px) - 16px);
    margin-bottom: 0;
  }
}
