/*
 * In de buurt (nearby_leads#index) — UX overhaul phase 6a.
 *
 * Desktop (> 900px): the Startpunt card and the numbered result cards on the
 * left, the map sticky on the right. Phone/tablet (<= 900px): the controls
 * collapse into one <details>, then the map at ~45% of the viewport, then the
 * results. The 900px breakpoint is mirrored by WIDE in nearby_map_controller.js
 * (it opens the controls on desktop).
 *
 * Pins and popups are injected by Leaflet from nearby_map_controller.js;
 * Leaflet's own `.leaflet-container a` colour is overridden here so popup
 * buttons stay navy. Classes only (CSP). Phone rules at the bottom.
 */

.gp-nearby-header { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }

.gp-nearby {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(0, 1.6fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "controls map" "list map";
  gap: 16px 22px;
  align-items: start;
}

/* ── Controls ── */
.gp-nearby-controls { grid-area: controls; min-width: 0; margin: 0; padding: 0; border: 0; }
.gp-nearby-controls > summary {
  display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap;
  min-height: 44px; margin: 0; padding: 10px 14px;
  background: #fff; border: 1px solid var(--gp-line); border-radius: 12px;
  color: var(--gp-navy); font-weight: 700; cursor: pointer;
}
.gp-nearby-controls > summary::after { margin-left: auto; }
.gp-nearby-controls[open] > summary { margin-bottom: 10px; }
.gp-nearby-summary-detail { color: var(--gp-body); font-weight: 400; font-size: 0.85rem; overflow-wrap: anywhere; }

.gp-nearby-start input[type="search"],
.gp-nearby-start input[type="text"] { margin-bottom: 0; }
.gp-nearby-address { margin: 0; }
.gp-nearby-address > summary { color: var(--gp-navy); }

.gp-nearby-filters { display: flex; flex-direction: column; gap: 12px; margin: 0; }
.gp-nearby-filter-row { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.gp-nearby-filter-label { min-width: 3.25rem; color: var(--gp-body); font-size: 0.85rem; }

/* Segmented radios: the checked segment is navy. `:has` follows the click
   straight away (the form auto-submits); focus shows on the segment. */
.gp-nearby-seg > label { display: inline-flex; align-items: center; cursor: pointer; }
.gp-nearby-seg > label:has(input:checked) { background: var(--gp-navy); color: #fff; }
.gp-nearby-seg > label:has(input:focus-visible) { outline: 2px solid var(--gp-navy); outline-offset: 1px; }
.gp-nearby-followed { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 0.85rem; }

/* ── Map ── */
.gp-nearby-map-wrap { grid-area: map; position: sticky; top: 1rem; min-width: 0; }
#nearby-map.gp-nearby-map {
  height: calc(100vh - 2rem); min-height: 560px;
  border: 1px solid var(--gp-line); border-radius: 14px;
}

/* Numbered pins: navy with white digits; a followed company is green with navy
   digits. The hovered/focused card's pin grows and gets a green ring. */
.gp-nearby-pin-wrap { background: transparent; border: 0; }
.gp-nearby-pin {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 999px; border: 2px solid #fff;
  background: var(--gp-navy); color: #fff;
  font-family: var(--gp-font-heading); font-weight: 700; font-size: 0.75rem; line-height: 1;
  box-shadow: 0 1px 4px rgba(11, 46, 71, 0.45);
  transition: transform 0.15s;
}
.gp-nearby-pin-followed { background: var(--gp-green); color: var(--gp-navy); }
.gp-nearby-pin-wrap.is-active .gp-nearby-pin {
  transform: scale(1.3);
  box-shadow: 0 0 0 3px var(--gp-green), 0 2px 6px rgba(11, 46, 71, 0.5);
}
.gp-nearby .nearby-origin-dot { background: var(--gp-green); }

.gp-nearby-popup {
  display: flex; flex-direction: column; gap: 10px; min-width: 200px;
  font-family: var(--gp-font-body); font-size: 0.85rem; color: var(--gp-ink);
}
.gp-nearby-popup-head { display: flex; align-items: center; gap: 10px; }
.gp-nearby-popup-text { display: flex; flex-direction: column; min-width: 0; }
.gp-nearby-popup-name { color: var(--gp-navy); font-size: 0.95rem; overflow-wrap: anywhere; }
.gp-nearby-popup-meta { color: var(--gp-body); font-size: 0.8rem; }
.gp-nearby-popup-actions { display: flex; gap: 8px; }
.gp-nearby-popup-actions .gp-btn { flex: 1 1 0; min-height: 40px; }
.gp-nearby-popup .gp-btn,
.gp-nearby-popup .gp-btn:hover { color: var(--gp-navy); }

/* ── Results ── */
.gp-nearby-list { grid-area: list; min-width: 0; }
.gp-nearby-list-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--gp-line);
}
.gp-nearby-list-sort { color: var(--gp-body); font-size: 0.8rem; }
.gp-nearby-results > li { margin: 0; }
.gp-nearby-result { align-items: center; gap: 12px; padding: 12px 16px; }
.gp-nearby-result:hover,
.gp-nearby-result:focus-within,
.gp-nearby-result.is-active { background: var(--gp-surface); box-shadow: inset 3px 0 0 var(--gp-navy); }
.gp-nearby-title { display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; }
.gp-nearby-name { color: var(--gp-navy); font-weight: 700; text-decoration: none; overflow-wrap: anywhere; }
.gp-nearby-name:hover { color: var(--gp-navy-raised); text-decoration: underline; }
.gp-nearby-meta { margin: 2px 0 0; color: var(--gp-body); font-size: 0.85rem; overflow-wrap: anywhere; }
.gp-nearby-num {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.75rem; height: 1.75rem; padding: 0 4px; border-radius: 999px;
  background: var(--gp-navy); color: #fff;
  font-family: var(--gp-font-heading); font-weight: 700; font-size: 0.8rem;
}
.gp-nearby-empty {
  margin: 0; padding: 16px 18px; background: #fff;
  border: 1px dashed var(--gp-line); border-radius: 14px; color: var(--gp-body);
}

/* ── Desktop: the controls are always open, so the toggle is redundant ── */
@media (min-width: 901px) {
  .gp-nearby-controls[open] > summary { display: none; }
}

/* ── Phone and tablet (kept last) ── */
@media (max-width: 900px) {
  .gp-nearby {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "controls" "map" "list";
    gap: 12px;
  }
  .gp-nearby-map-wrap { position: static; }
  #nearby-map.gp-nearby-map { height: 45vh; height: 45dvh; min-height: 240px; }
  /* gp-components wraps list items at 768px; a card keeps score, text and
     number on one line. */
  .gp-nearby-result { flex-wrap: nowrap; padding: 10px 14px; }
  .gp-nearby-result > .gp-grow { flex-basis: 0; }
  .gp-nearby-name { display: inline-flex; align-items: center; min-height: 40px; }
  .gp-nearby-seg > label { min-height: 40px; }
  .gp-nearby-followed { min-height: 40px; }
}
