/* MapLibre browse: search → full-width map → 3-column results (Property, Services) */
.cl-map-browse {
  --cl-map-frame-radius: 0.9rem;
  --cl-map-min-h: 340px;
  --cl-map-ideal-h: min(46vh, 520px);
  --cl-map-flow-gap: clamp(1rem, 2.5vw, 1.75rem);
}

/* Rhythm after search card: map block anchors the page without feeling cramped */
.cl-explore-filters + .cl-map-browse {
  margin-top: 0.35rem;
}

.cl-map-browse__eyebrow {
  letter-spacing: 0.14em;
  font-weight: 500;
  opacity: 0.82;
  margin-bottom: 0.55rem !important;
}

/* Framed map — directly under search */
.cl-map-browse__map-stage {
  border-radius: var(--cl-map-frame-radius);
  overflow: hidden;
  background: linear-gradient(160deg, rgba(248, 250, 252, 0.98) 0%, rgba(241, 245, 249, 0.55) 100%);
  border: 1px solid rgba(15, 23, 42, 0.065);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.035),
    0 10px 36px rgba(15, 23, 42, 0.07);
  padding: 0.45rem 0.45rem 0.5rem;
  margin-bottom: var(--cl-map-flow-gap);
}

.cl-map-browse__map-stage .cl-map-browse__eyebrow {
  padding-left: 0.2rem;
  padding-right: 0.2rem;
}

.cl-map-browse__map-shell {
  border-radius: calc(var(--cl-map-frame-radius) - 3px);
  overflow: hidden;
}

.cl-map-browse__map {
  width: 100%;
  min-height: var(--cl-map-min-h);
  height: var(--cl-map-ideal-h);
  max-height: 640px;
  border-radius: calc(var(--cl-map-frame-radius) - 4px);
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.055);
}

/* Search-this-area: readable on light and dark map tiles */
.cl-map-browse__search-area {
  position: absolute;
  z-index: 6;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
}

/* Desktop: control at bottom (clear of MapLibre zoom control top-right) */
@media (min-width: 768px) {
  .cl-map-browse__search-area {
    bottom: 0.75rem;
    top: auto;
  }
}

/* Mobile: control at top so it never fights the marker bottom sheet */
@media (max-width: 767.98px) {
  .cl-map-browse__search-area {
    top: max(0.5rem, env(safe-area-inset-top));
    bottom: auto;
  }

  /* Property map: sit below the floating toolbar */
  .cl-map-browse--property .cl-map-browse__search-area {
    top: calc(max(0.45rem, env(safe-area-inset-top)) + 3.45rem);
  }
}

#cl-property-results,
#cl-property-explore-filters {
  scroll-margin-top: 1rem;
}

.cl-map-browse__search-area .btn {
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94) !important;
  border-color: rgba(15, 23, 42, 0.12) !important;
  color: var(--cl-navy, #0b1f3a) !important;
  font-weight: 600;
  font-size: 0.78rem;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.cl-map-browse__search-area button:disabled {
  opacity: 0.72;
  cursor: not-allowed;
}

.cl-map-browse__search-area [data-cl-search-area-btn][data-cl-loading="1"] {
  opacity: 0.65;
  pointer-events: none;
}

.cl-map-browse__search-area [data-cl-search-area-btn]:not(:disabled) {
  font-weight: 600;
}

/* Results block: breathing room before toolbar + grid */
.cl-map-browse__results {
  padding-top: 0.15rem;
}

.cl-page .cl-map-browse .cl-results-bar {
  margin-top: 0;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 15px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

@media (min-width: 768px) {
  .cl-page .cl-map-browse .cl-results-bar {
    margin-bottom: 1.15rem;
    padding: 0.8rem 1.1rem;
  }
}

.cl-map-browse__card-grid {
  margin-top: 0.15rem;
  --bs-gutter-x: 1.15rem;
  --bs-gutter-y: 1.15rem;
}

@media (min-width: 768px) {
  .cl-map-browse__card-grid {
    --bs-gutter-x: 1.35rem;
    --bs-gutter-y: 1.35rem;
  }
}

@media (min-width: 1200px) {
  .cl-map-browse__card-grid {
    --bs-gutter-x: 1.5rem;
    --bs-gutter-y: 1.5rem;
  }
}

/* Browse cards: alignment + focus (keyboard) without fighting map click-to-fly */
.cl-map-browse .cl-result-card {
  height: 100%;
}

.cl-map-browse .cl-result-card:focus-within {
  outline: 2px solid rgba(13, 110, 253, 0.45);
  outline-offset: 2px;
}

.cl-map-browse .cl-result-card .card-body {
  padding: 1rem 1.05rem 1.1rem;
}

@media (min-width: 768px) {
  .cl-map-browse .cl-result-card .card-body {
    padding: 1.05rem 1.15rem 1.15rem;
  }
}

.cl-result-card.cl-browse-card--active {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

.cl-map-browse__map-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  background: #f4f6f9;
  color: #5c6c7c;
  font-size: 0.9rem;
  padding: 1rem;
  text-align: center;
  border-radius: calc(var(--cl-map-frame-radius) - 4px);
}

@media (min-width: 992px) {
  .cl-map-browse {
    --cl-map-min-h: 380px;
    --cl-map-ideal-h: min(44vh, 560px);
  }

  .cl-map-browse__map-stage {
    padding: 0.55rem 0.55rem 0.6rem;
  }
}

@media (max-width: 767.98px) {
  .cl-map-browse {
    --cl-map-min-h: 300px;
    --cl-map-ideal-h: min(42vh, 440px);
  }

  .cl-map-browse--property {
    --cl-map-min-h: min(56svh, 560px);
    --cl-map-ideal-h: min(62svh, 640px);
  }

  .cl-map-browse--property .cl-map-browse__eyebrow {
    display: none;
  }

  .cl-map-browse__map-stage {
    margin-bottom: clamp(0.85rem, 3vw, 1.25rem);
  }

  .cl-map-browse--property .cl-map-browse__map-stage {
    padding-top: 0.35rem;
    margin-bottom: clamp(1rem, 3.5vw, 1.35rem);
  }

  .cl-map-browse--property .cl-map-browse__map-shell--property {
    min-height: min(72svh, 720px);
    border-radius: calc(var(--cl-map-frame-radius) - 3px);
  }

  .cl-map-browse--property .cl-map-browse__map-canvas {
    min-height: min(58svh, 620px);
    height: min(64svh, 680px);
  }

  .cl-map-browse--property .cl-map-browse__map {
    min-height: min(58svh, 620px);
    height: 100%;
    max-height: none;
  }

  .cl-map-mobile-toolbar {
    position: absolute;
    top: max(0.45rem, env(safe-area-inset-top));
    left: max(0.45rem, env(safe-area-inset-left));
    right: max(0.45rem, env(safe-area-inset-right));
    display: flex;
    align-items: center;
    gap: 0.35rem;
    z-index: 7;
    padding: 0.35rem 0.45rem;
    border-radius: 0.85rem;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow:
      0 2px 8px rgba(15, 23, 42, 0.06),
      0 12px 32px rgba(15, 23, 42, 0.08);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    pointer-events: auto;
  }

  .cl-map-mobile-toolbar__btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 0.55rem;
    border-radius: 0.65rem;
    border: 1px solid rgba(15, 23, 42, 0.1);
    background: rgba(248, 250, 252, 0.95);
    color: var(--cl-navy, #0b1f3a);
    font-weight: 600;
    font-size: 0.8rem;
    text-decoration: none;
    line-height: 1.2;
    -webkit-tap-highlight-color: transparent;
  }

  .cl-map-mobile-toolbar__btn--text {
    padding-left: 0.65rem;
    padding-right: 0.65rem;
  }

  .cl-map-mobile-toolbar__btn:focus-visible {
    outline: 2px solid rgba(13, 110, 253, 0.45);
    outline-offset: 2px;
  }

  .cl-map-mobile-toolbar__btn:active {
    background: rgba(241, 245, 249, 1);
  }

  .cl-map-mobile-toolbar__summary {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    padding: 0.35rem 0.65rem;
    border-radius: 0.65rem;
    border: 1px solid rgba(15, 23, 42, 0.1);
    background: rgba(255, 255, 255, 0.98);
    color: var(--cl-navy, #0b1f3a);
    font-weight: 600;
    font-size: 0.78rem;
    line-height: 1.25;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-tap-highlight-color: transparent;
  }

  .cl-map-mobile-toolbar__summary:focus-visible {
    outline: 2px solid rgba(13, 110, 253, 0.45);
    outline-offset: 2px;
  }

  .cl-map-mobile-toolbar__svg {
    display: block;
    flex-shrink: 0;
  }

  /* Marker detail: bottom sheet (desktop keeps MapLibre popup only) */
  .cl-map-browse__sheet-backdrop {
    position: absolute;
    inset: 0;
    z-index: 4;
    background: rgba(15, 23, 42, 0.28);
    border-radius: inherit;
    -webkit-tap-highlight-color: transparent;
  }

  .cl-map-browse__sheet-backdrop[hidden] {
    display: none !important;
  }

  .cl-map-browse__sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    max-height: min(46vh, 320px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 1rem 1rem 0 0;
    box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.18);
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-bottom: none;
  }

  .cl-map-browse__sheet[hidden] {
    display: none !important;
  }

  .cl-map-marker-sheet__inner {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: min(46vh, 320px);
  }

  .cl-map-marker-sheet__close {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    z-index: 2;
    width: 2.75rem;
    min-width: 44px;
    height: 2.75rem;
    min-height: 44px;
    padding: 0;
    border: none;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.95);
    color: #334155;
    font-size: 1.35rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
    cursor: pointer;
  }

  .cl-map-marker-sheet__close:focus-visible {
    outline: 2px solid var(--bs-primary, #0d6efd);
    outline-offset: 2px;
  }

  .cl-map-marker-sheet__scroll {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.65rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom));
    padding-top: 2.5rem;
  }

  .cl-map-marker-sheet__media {
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 120px;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #f1f5f9;
    margin-bottom: 0.5rem;
  }

  .cl-map-marker-sheet__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .cl-map-marker-sheet__title {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--cl-navy, #0b1f3a);
    margin: 0 0 0.35rem;
    padding-right: 2rem;
  }

  .cl-map-marker-sheet__loc {
    font-size: 0.8rem;
    color: var(--cl-text-muted, #475569);
    margin: 0 0 0.35rem;
  }

  .cl-map-marker-sheet__price {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--cl-navy, #0b1f3a);
    margin: 0 0 0.65rem;
  }

  .cl-map-marker-sheet__cta {
    margin-top: auto;
  }
}

/* Desktop: never show mobile sheet nodes (JS should not open them) */
@media (min-width: 768px) {
  .cl-map-browse__sheet,
  .cl-map-browse__sheet-backdrop {
    display: none !important;
    visibility: hidden;
    pointer-events: none;
  }
}
