/* ============================================================
   MAP SEARCH  (/properties/map) — loaded on that page only.

   Everything a visitor touches here uses the site's own styles from
   style.css: .prop-search-form + .ja-select (the home page "Property
   Search" bar), .properties-count, .property-card (list AND the popup),
   .properties-empty.
   This file only arranges those pieces around the map.
   ============================================================ */
.mapsearch {
  --map-top: 90px;                       /* height of the site header (set by map.js) */
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--map-top));
  height: calc(100dvh - var(--map-top));
  min-height: 520px;
  border-top: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
  background: #fff;
}

/* ---- filters: the home page "Property Search" bar (.prop-search-form in style.css) ---- */
.map-filter-bar { flex: 0 0 auto; position: relative; z-index: 40; padding: 14px 20px; border-bottom: 1px solid #ccc; background: #fff; }
.map-filter-title { display: none; }                      /* shown on phones, where the search gets its own screen */
.map-search-form { margin-bottom: 0; }
.map-search-form .search-keyword { flex: 2 1 0; min-width: 0; }
.map-search-form button[type=submit],
.map-search-form .map-clear-btn { flex: 0 0 118px; }
.map-search-form .map-clear-btn {                         /* same button as SEARCH, in the site's gold */
  padding: 18px 20px;
  border: none;
  border-radius: 4px;
  background-color: #99862D;
  color: #fff;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.3s;
}
.map-search-form .map-clear-btn:hover { background-color: #7f6f24; }

/* ---- list + map ---- */
.map-layout { flex: 1 1 auto; min-height: 0; display: flex; }
.map-panel {
  flex: 0 0 700px;
  max-width: 46%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid #ccc;
  background: #fff;
}
.map-panel-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid #eee;
}
.map-panel-head .properties-count { padding-top: 0; margin-right: auto; }
/* Sort: the same slate dropdown as the search bar, a little smaller */
.map-panel-head .map-sort { flex: 0 1 215px; min-width: 0; display: flex; }
.map-sort .ja-select-btn,
.map-sort select {
  width: 100%;
  padding: 10px 32px 10px 12px;
  border: none;
  border-radius: 4px;
  background: #5F768E url(../images/search-down-icon.png) no-repeat calc(100% - 12px) center / auto 10px;
  color: #fff;
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  appearance: none;
  cursor: pointer;
}
.map-sort select option { background: #fff; color: #333; font-size: 14px; text-transform: none; }
.map-sort .ja-select.open .ja-select-btn { background-image: url(../images/search-up-icon.png); }

/* List / Map switch — the search bar's button look */
.map-view-toggle { display: inline-flex; gap: 6px; }
.map-view-toggle a,
.map-view-toggle span {
  min-width: 70px;
  padding: 10px 14px;
  border-radius: 4px;
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  line-height: 15px;
  text-align: center;
  text-transform: uppercase;
  text-decoration: none;
  color: #fff;
  background-color: #5F768E;
  transition: background 0.3s;
}
.map-view-toggle .active { background-color: #343399; }
.map-view-toggle a:hover { background-color: #2a2888; color: #fff; }

.map-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: max-content;           /* cards keep their full height inside the scrolling list */
  align-content: start;
  gap: 20px;
  padding: 15px 20px 20px;
  transition: opacity 0.15s;
}
.mapsearch.is-loading .map-list { opacity: 0.75; }
.map-list .property-card { transition: box-shadow 0.15s, border-color 0.15s; }
.map-list .property-card.active { border-color: #343399; box-shadow: 0 0 0 2px #343399; }
.map-list .properties-empty { padding: 60px 10px; }
.map-list-more {
  grid-column: 1 / -1;
  padding: 14px;
  text-align: center;
  font-size: 14px;
  color: #666;
}

.map-canvas { flex: 1 1 auto; min-width: 0; position: relative; background: #e8eaed; }
#gmap { position: absolute; inset: 0; }
.map-note {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  max-width: 90%;
  padding: 8px 16px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  font-size: 14px;
  line-height: 21px;
  text-align: center;
  color: #000;
  pointer-events: none;
}

/* ---- price pins ---- */
.map-pin {
  position: absolute;
  transform: translate(-50%, calc(-100% - 6px));
  padding: 4px 8px;
  border: 1px solid #343399;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  font-weight: 600;
  line-height: 14px;
  white-space: nowrap;
  color: #343399;
  cursor: pointer;
}
.map-pin::after {                        /* the little point under the label */
  content: '';
  position: absolute;
  left: 50%; top: 100%;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top-color: #343399;
  border-bottom-width: 0;
}
.map-pin.our { border-color: #99862D; color: #7a6b1f; }
.map-pin.our::after { border-top-color: #99862D; }
.map-pin:hover, .map-pin.hovered, .map-pin.active { background: #343399; color: #fff; z-index: 20 !important; }
.map-pin.our:hover, .map-pin.our.hovered, .map-pin.our.active { background: #99862D; color: #fff; }
.map-pin.hovered, .map-pin.active { transform: translate(-50%, calc(-100% - 6px)) scale(1.12); }

/* ---- cluster circles ---- */
.map-cluster {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 38px; height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #343399;
  box-shadow: 0 0 0 5px rgba(52, 51, 153, 0.25), 0 1px 4px rgba(0, 0, 0, 0.3);
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  z-index: 3;
}
.map-cluster.md { width: 44px; height: 44px; font-size: 13px; }
.map-cluster.lg { width: 52px; height: 52px; font-size: 14px; }
.map-cluster.xl { width: 60px; height: 60px; font-size: 15px; }
.map-cluster:hover { background: #99862D; }

/* ---- popup: the site's listing card, a little more compact ---- */
.gm-style .gm-style-iw-c { padding: 0 !important; border-radius: 0; }
.gm-style .gm-style-iw-d { overflow: hidden !important; padding: 0 !important; }
.gm-style .gm-style-iw-chr { position: absolute; top: 0; right: 0; z-index: 2; }
.gm-style .gm-style-iw-chr button { background: rgba(255, 255, 255, 0.9) !important; border-radius: 50%; margin: 4px !important; width: 30px !important; height: 30px !important; }
.gm-style .gm-style-iw-chr button span { margin: 3px !important; }
.map-popup { width: 264px; }
.map-popup .property-card { border: 0; }
.map-popup .property-card-image { aspect-ratio: 420 / 270; }
.map-popup .property-card-price { font-size: 20px; text-indent: 15px; }
.map-popup .property-card-body { padding: 12px 15px 0; }
.map-popup .property-card-stats { margin: 12px 0 14px; padding: 7px 0; }
.map-popup .property-card-footer { padding: 0 15px 15px; }
.map-popup .property-card-footer a { padding: 9px 0; }

.map-switch { display: none; }

/* ---- narrower desktops: one column of cards ---- */
@media (max-width: 1500px) {
  .map-panel { flex-basis: 380px; }
  .map-list { grid-template-columns: minmax(0, 1fr); }
  .map-panel-head { flex-wrap: wrap; }
}

/* ---- tablets + phones: Map, List or Filters — one at a time, switched at the bottom ---- */
@media (max-width: 1024px) {
  .mapsearch { position: relative; }
  .map-view-toggle { display: none; }
  .map-layout { display: block; position: relative; }
  .map-panel, .map-canvas { position: absolute; inset: 0; max-width: none; border: 0; }
  .map-panel { display: none; }
  .mapsearch[data-view="list"] .map-panel { display: flex; }
  .mapsearch[data-view="list"] .map-canvas { visibility: hidden; }
  .map-list { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-bottom: 80px; }

  /* Search: hidden until asked for, then laid out exactly like the home page bar on a phone */
  .map-filter-bar { display: none; }
  .mapsearch[data-view="filters"] .map-filter-bar {
    display: block;
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 30px 20px 90px;
    border: 0;
  }
  .mapsearch[data-view="filters"] .map-layout { display: none; }
  .map-filter-title {
    display: block;
    margin: 0 0 25px;
    font-family: 'Montserrat', sans-serif;
    font-size: 30px;
    font-weight: 400;
    text-align: center;
    text-transform: uppercase;
  }
  .map-search-form { flex-wrap: wrap; }
  .map-search-form .search-keyword { flex: 0 0 100%; }
  .map-search-form select, .map-search-form .ja-select,
  .map-search-form button[type=submit], .map-search-form .map-clear-btn { flex: 1 1 45%; }

  .map-switch {
    display: flex;
    position: absolute;
    left: 50%; bottom: 16px;
    transform: translateX(-50%);
    z-index: 60;                         /* above the search screen as well as the map */
    border-radius: 3px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  }
  .map-switch button {
    padding: 11px 18px;
    border: 0;
    background: #fff;
    font-family: 'Montserrat', sans-serif;
    font-size: 15px;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
    color: #343399;
    cursor: pointer;
  }
  .map-switch button.active { background: #343399; color: #fff; }
}
@media (max-width: 580px) {
  .map-list { grid-template-columns: minmax(0, 1fr); }
  .map-filter-title { font-size: 24px; }
  .map-switch button { padding: 11px 13px; font-size: 14px; }
}
