/* ==========================================================================
   Map interface
   ========================================================================== */

.map-shell{
  position: relative;
  height: calc(100vh - 61px);
  display: flex;
  overflow: hidden;
}

/* ---- Filter sidebar ---- */
.filter-sidebar{
  width: 296px; flex: none; background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: margin-left .25s var(--ease);
  z-index: 30;
}
.filter-sidebar.collapsed{ margin-left: -296px; }
.filter-sidebar-head{
  padding: 16px 16px 10px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.filter-sidebar-head h2{ font-size: 15px; margin: 0; }
.filter-scroll{ flex: 1; overflow-y: auto; padding: 14px 16px 24px; }

.filter-group{ margin-bottom: 22px; }
.filter-group-title{
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--fg-muted); margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.filter-group-title button{ background: none; border: 0; color: var(--accent); font-family: var(--font-mono); font-size: 10.5px; cursor: pointer; }
.category-list{ display: flex; flex-direction: column; gap: 2px; }
.category-list label{
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13.5px; transition: background .12s var(--ease);
}
.category-list label:hover{ background: var(--bg-sunken); }
.category-list input[type="checkbox"]{ accent-color: var(--cat-color, var(--accent)); width: 15px; height: 15px; flex: none; }
.category-list .dot{ width: 9px; height: 9px; border-radius: 50%; background: var(--cat-color); flex: none; }
.category-list .cat-label{ flex: 1; }
.category-list .cat-count{ font-family: var(--font-mono); font-size: 11px; color: var(--fg-muted); }

.status-chips, .discipline-chips{ display: flex; flex-wrap: wrap; gap: 6px; }

.range-row{ display: flex; align-items: center; gap: 8px; }
.range-row input[type="date"]{ flex: 1; }

/* ---- Map container ---- */
.map-main{ position: relative; flex: 1; min-width: 0; }
/* Establishes a local stacking context so Leaflet's internal panes/controls
   (z-index up to ~1000) stay contained here and never escape to cover the
   topbar, sidebar, or detail panel siblings. */
#map{ position: absolute; inset: 0; background: var(--bg-sunken); z-index: 1; }

/* ---- Floating top bar over map ---- */
.map-topbar{
  position: absolute; top: 14px; left: 14px; right: 14px; z-index: 20;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.map-topbar > *{ pointer-events: auto; }
.map-search-row{ display: flex; gap: 10px; align-items: center; }
.map-search-row .search-bar{ flex: 1; max-width: 480px; }
.results-count{
  font-family: var(--font-mono); font-size: 11.5px; color: var(--fg-muted);
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; white-space: nowrap;
}
.quick-chip-row{
  display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px;
  scrollbar-width: none;
}
.quick-chip-row::-webkit-scrollbar{ display: none; }
.quick-chip-row .chip{ background: var(--bg-raised); box-shadow: var(--shadow-sm); flex: none; }

.map-controls-stack{
  position: absolute; right: 14px; bottom: 24px; z-index: 20;
  display: flex; flex-direction: column; gap: 8px;
}
.map-controls-stack .icon-btn{ background: var(--bg-raised); box-shadow: var(--shadow-sm); }

/* leaflet zoom control repositioning */
.leaflet-top.leaflet-right{ top: auto; bottom: 24px; }
.leaflet-control-zoom{ border: 1px solid var(--border) !important; box-shadow: var(--shadow-sm) !important; }
.leaflet-control-zoom a{
  background: var(--bg-raised) !important; color: var(--fg) !important;
  border-color: var(--border) !important;
}
.leaflet-control-attribution{
  background: rgba(255,255,255,.75) !important; font-size: 10px !important;
}
[data-theme="dark"] .leaflet-control-attribution{ background: rgba(11,30,45,.75) !important; color: var(--dk-muted) !important; }
[data-theme="dark"] .leaflet-control-attribution a{ color: var(--dk-cyan) !important; }
[data-theme="dark"] .leaflet-tile-pane{ filter: brightness(0.78) invert(1) contrast(0.92) hue-rotate(180deg) saturate(0.7); }

/* ---- Custom markers ---- */
.ic-marker{
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--m-color, var(--accent));
  border: 2px solid var(--bg-raised);
  box-shadow: var(--shadow-sm);
  display: grid; place-items: center;
  transition: transform .15s var(--ease);
}
.ic-marker svg{ width: 15px; height: 15px; transform: rotate(45deg); color: #fff; }
.ic-marker.is-favorite{ box-shadow: 0 0 0 3px rgba(232,89,12,.35); }
.leaflet-marker-icon:hover .ic-marker{ transform: rotate(-45deg) scale(1.12); }

.ic-cluster{
  background: var(--bg-raised); border: 2px solid var(--accent); color: var(--accent);
  border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-mono); font-weight: 600; box-shadow: var(--shadow-sm);
}

/* ---- Detail side panel ---- */
.detail-panel{
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 400px; max-width: 92vw;
  background: var(--bg-raised); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .28s var(--ease);
  z-index: 35; display: flex; flex-direction: column;
}
.detail-panel.open{ transform: translateX(0); }
.detail-panel-head{
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.detail-panel-head .grow{ flex: 1; min-width: 0; }
.detail-panel-body{ flex: 1; overflow-y: auto; padding: 0 0 24px; }

.detail-gallery{ position: relative; height: 190px; background: var(--bg-sunken); overflow: hidden; }
.detail-gallery img{ width: 100%; height: 100%; object-fit: cover; }
.detail-gallery-dots{
  position: absolute; bottom: 10px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 5px;
}
.detail-gallery-dots span{ width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.55); }
.detail-gallery-dots span.active{ background: #fff; }
.detail-gallery button.gnav{
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(11,30,45,.45); color: #fff; border: 0; width: 30px; height: 30px;
  border-radius: 50%; display: grid; place-items: center; cursor: pointer;
}
.detail-gallery button.gnav.prev{ left: 8px; }
.detail-gallery button.gnav.next{ right: 8px; }

.detail-content{ padding: 18px 20px; }
.detail-cat-tag{ display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; margin-bottom: 8px; }
.detail-content h2{ font-size: 20px; margin-bottom: 4px; }
.detail-address{ font-size: 13px; color: var(--fg-muted); margin-bottom: 14px; display: flex; gap: 6px; align-items: flex-start; }
.detail-address svg{ width: 14px; height: 14px; flex: none; margin-top: 2px; }

.detail-badges{ display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

.detail-progress-row{ display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--fg-muted); margin-bottom: 4px; font-family: var(--font-mono); }
.detail-progress{ margin-bottom: 18px; }

.detail-grid{
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px;
  margin-bottom: 18px; padding: 14px; background: var(--bg-sunken); border-radius: var(--radius-md);
}
.detail-grid .fk{ font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-muted); font-family: var(--font-mono); margin-bottom: 2px; }
.detail-grid .fv{ font-size: 13.5px; font-weight: 500; }

.detail-tags{ display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.detail-tags .tag{
  font-size: 11.5px; padding: 4px 9px; border-radius: 999px;
  background: var(--bg-sunken); color: var(--fg-muted); border: 1px solid var(--border);
}

.detail-actions{ display: flex; gap: 8px; padding: 0 20px 4px; flex-wrap: wrap; }

.detail-desc{ font-size: 13.5px; color: var(--fg-muted); line-height: 1.6; }

/* ---- Mobile filter drawer toggling ---- */
.mobile-filter-scrim{
  display: none; position: absolute; inset: 0; background: rgba(11,30,45,.4); z-index: 29;
}

@media (max-width: 880px){
  .filter-sidebar{
    position: absolute; top: 0; bottom: 0; left: 0; z-index: 32; width: 82vw; max-width: 320px;
    margin-left: -100%;
  }
  .filter-sidebar.open{ margin-left: 0; box-shadow: var(--shadow-lg); }
  .filter-sidebar.collapsed{ margin-left: -100%; }
  .mobile-filter-scrim.open{ display: block; }
  .detail-panel{ width: 100%; max-width: 100%; }
  .map-search-row .results-count{ display: none; }
  .map-controls-stack{ bottom: 84px; }
  .leaflet-top.leaflet-right{ bottom: 84px; }
}
