/* ==========================================================================
   Public map search view (/map.html)
   Full-height split: results list beside the map, filters across the top.
   ========================================================================== */

/* The map fills the viewport below the header, so the page itself must not
   scroll; only the results list does. */
.map-page,
.map-page body { height: 100%; }
.map-page { overflow: hidden; }

.map-shell {
  display: flex;
  flex-direction: column;
  /* Header is sticky and about 70px; fill whatever is left. */
  height: calc(100vh - 70px);
  min-height: 420px;
}

/* ---- Filters ------------------------------------------------------------ */

.map-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  flex: none;
}
.map-filters input[type="search"],
.map-filters input[type="number"],
.map-filters select {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.88rem;
  background: var(--color-bg);
  color: var(--color-text);
}
.map-filters input[type="search"] { flex: 1 1 190px; min-width: 150px; }
.map-filters input[type="number"] { width: 108px; }
.map-filters select { flex: 0 1 auto; }

.map-search-move {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  cursor: pointer;
}
.map-search-move input { accent-color: var(--color-primary); }

.map-view-toggle { display: none; margin-left: auto; }
.map-view-toggle button {
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
}
.map-view-toggle button:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.map-view-toggle button:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: none; }
.map-view-toggle button.is-active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ---- Split body --------------------------------------------------------- */

.map-body {
  display: grid;
  grid-template-columns: 380px 1fr;
  flex: 1;
  min-height: 0; /* lets the children own the scrolling */
}

.map-list {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-border);
  background: var(--color-bg-alt);
  min-height: 0;
}
.map-list-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  flex: none;
}
.map-list-head select {
  margin-left: auto;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.82rem;
  background: var(--color-bg);
  color: var(--color-text);
}
.map-list-scroll {
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
}

.map-canvas-wrap { position: relative; min-height: 0; }
#map-canvas { position: absolute; inset: 0; }

.map-redo {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}
.map-cap-note {
  position: absolute;
  bottom: 0.6rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  margin: 0;
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-pill);
  background: rgba(26, 34, 51, 0.85);
  color: #fff;
  font-size: 0.76rem;
  white-space: nowrap;
}

/* ---- Result cards ------------------------------------------------------- */

.map-card {
  display: flex;
  gap: 0.7rem;
  padding: 0.6rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  scroll-margin: 0.75rem;
}
.map-card:hover,
.map-card.is-active {
  border-color: var(--color-primary);
  box-shadow: 0 4px 16px rgba(43, 86, 224, 0.16);
  text-decoration: none;
}
.map-card.is-active { transform: translateY(-1px); }
.map-card img {
  width: 104px;
  height: 82px;
  flex: none;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--color-bg-alt);
}
.map-card-body { min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.map-card-price {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-primary);
}
.map-card-price .per { font-size: 0.75rem; font-weight: 500; color: var(--color-text-muted); }
.map-card-title {
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.map-card-addr {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.map-card-specs {
  display: flex;
  gap: 0.6rem;
  font-size: 0.76rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}
.map-card-badge {
  align-self: flex-start;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.12rem 0.4rem;
  border-radius: 3px;
  color: #fff;
  margin-top: 0.2rem;
}

.map-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

/* ---- Markers ------------------------------------------------------------ */

/* Leaflet divIcons: strip the default white box so only our pill shows. */
.map-price-icon, .map-pin-icon { background: none; border: none; }

.map-price-pin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  padding: 0 0.55rem;
  border-radius: var(--radius-pill);
  background: var(--color-primary);
  color: #fff;
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.12s ease;
}
.map-price-pin:hover { transform: scale(1.08); }
/* Visited-style dimming so a buyer can tell which pins they already opened. */
.map-price-pin.is-seen { background: #7d8aa8; }
.map-price-pin.is-active {
  background: var(--color-dark);
  transform: scale(1.14);
  z-index: 1000;
}

/* Cluster bubble */
.map-cluster-icon { background: none; border: none; }
.map-cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(43, 86, 224, 0.9);
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.85rem;
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
  cursor: pointer;
}

/* Popup */
.leaflet-popup-content { margin: 0; width: 232px !important; }
.leaflet-popup-content-wrapper { padding: 0; border-radius: var(--radius-md); overflow: hidden; }
.map-popup { display: block; text-decoration: none; color: inherit; }
.map-popup:hover { text-decoration: none; }
.map-popup img { width: 100%; height: 122px; object-fit: cover; display: block; background: var(--color-bg-alt); }
.map-popup-body { padding: 0.6rem 0.75rem 0.75rem; }
.map-popup-price { font-family: var(--font-heading); font-weight: 700; color: var(--color-primary); }
.map-popup-title { font-size: 0.86rem; font-weight: 600; margin: 0.1rem 0; }
.map-popup-addr { font-size: 0.76rem; color: var(--color-text-muted); }
.map-popup-specs { font-size: 0.76rem; color: var(--color-text-muted); margin-top: 0.3rem; }

/* ---- Mobile ------------------------------------------------------------- */

@media (max-width: 860px) {
  .map-body { grid-template-columns: 1fr; }
  .map-view-toggle { display: inline-flex; }
  /* One pane at a time on a phone; the toggle swaps which. */
  .map-list { border-right: none; }
  .map-body[data-view="map"] .map-list { display: none; }
  .map-body[data-view="list"] .map-canvas-wrap { display: none; }
  .map-filters input[type="number"] { width: 92px; }
}

/* A map card for a listing offered both ways: the headline is the sale price,
   this is the monthly rent shown under it so the second offer is not invisible
   in the narrow card. */
.map-card-alt {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-top: 0.1rem;
}
