/* Map view — full-bleed canvas + floating filter sidebar */

body.map-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

.map-header { flex: 0 0 auto; }
.map-header .header-inner { max-width: none; padding: 0 20px; }

.map-layout { flex: 1 1 auto; display: flex; min-height: 0; position: relative; }

.map-sidebar {
    width: 340px; flex: 0 0 340px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 1000;
}
.map-filters { padding: 16px; border-bottom: 1px solid var(--border); }
.map-filters .filter-row { display: flex; flex-direction: column; gap: 10px; margin-bottom: 0; }
.map-filters .chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.map-filters .select { width: 100%; }
.map-count { font-size: 13px; color: var(--text-2); padding-top: 4px; font-variant-numeric: tabular-nums; }
.map-count strong { color: var(--text); }

.map-results { flex: 1 1 auto; overflow-y: auto; padding: 8px; }
.map-result {
    display: flex; gap: 12px; padding: 10px; border-radius: var(--radius-sm);
    cursor: pointer; transition: background .12s;
    border: 1px solid transparent;
}
.map-result:hover { background: var(--bg); }
.map-result.active { background: var(--accent-soft); border-color: var(--accent); }
.map-result img { width: 64px; height: 64px; border-radius: 6px; object-fit: cover; flex: 0 0 64px; background: var(--bg2); border: 1px solid var(--border); }
.map-result .mr-body { min-width: 0; }
.map-result .mr-date { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; font-variant-numeric: tabular-nums; }
.map-result .mr-name { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.3; margin: 2px 0; }
.map-result .mr-loc { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.map-canvas { flex: 1 1 auto; position: relative; }
#map { position: absolute; inset: 0; background: #e8ecef; }

/* Leaflet tweaks */
.leaflet-container { font-family: 'Inter', sans-serif; }
.leaflet-popup-content-wrapper { border-radius: var(--radius); box-shadow: var(--shadow-pop); border: 1px solid var(--border); }
.leaflet-popup-content { margin: 12px 14px; font-family: 'Inter', sans-serif; }

/* Custom markers */
.ev-marker { background: transparent; border: none; }
.ev-marker-pin {
    width: 22px; height: 22px; border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    background: var(--accent); border: 2px solid #fff;
    box-shadow: 0 2px 5px rgba(23,25,29,.28);
}
.ev-marker-pin.live { background: var(--live); }
.ev-marker-pin.long { background: var(--amber); }

/* Clusters */
.marker-cluster { background: transparent; }
.marker-cluster div {
    width: 34px !important; height: 34px !important;
    border-radius: 50% !important;
    font-family: 'Inter', sans-serif; font-weight: 700; font-size: 13px;
    color: #fff !important;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 3px 9px rgba(23,25,29,.22);
    border: 3px solid rgba(255,255,255,.9);
    font-variant-numeric: tabular-nums;
}
.marker-cluster-small div { background: #3e6b4f; }
.marker-cluster-medium div { background: #1f5738; }
.marker-cluster-large div { background: var(--accent-hover); }

/* Empty state in sidebar */
.map-empty { padding: 30px 16px; text-align: center; color: var(--text-2); font-size: 14px; }

/* Popups */
.pp { display: flex; gap: 10px; min-width: 220px; }
.pp-img { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; flex: 0 0 72px; background: var(--bg2); }
.pp-img-fallback { background: linear-gradient(135deg, var(--accent-soft), var(--bg2)); }
.pp-body { min-width: 0; }
.pp-date { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; font-variant-numeric: tabular-nums; }
.pp-name { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.3; display: block; margin: 2px 0; text-decoration: none; }
.pp-name:hover { color: var(--accent); }
.pp-loc { font-size: 12.5px; color: var(--text-2); }
.pp-live { display: inline-block; margin-top: 4px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--live); }

/* Loading state */
.map-loading { padding: 30px 16px; text-align: center; color: var(--text-2); font-size: 14px; }

/* Mobile: map on top, filter+results as a bottom sheet */
@media (max-width: 900px) {
    .map-layout { flex-direction: column-reverse; }
    .map-sidebar {
        width: 100%; flex: 0 0 auto;
        height: 45vh; max-height: none;
        border-right: none; border-top: 1px solid var(--border);
        border-radius: 16px 16px 0 0;
        box-shadow: var(--shadow-sheet);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .map-filters { padding: 14px 16px 10px; }
    .map-filters .chip-group {
        flex-wrap: nowrap; overflow-x: auto;
        margin: 0 -16px; padding: 0 16px 2px;
        scrollbar-width: none;
    }
    .map-filters .chip-group::-webkit-scrollbar { display: none; }
    .map-filters .chip { flex: 0 0 auto; padding: 10px 16px; }
    .map-filters .filter-row { flex-direction: row; gap: 8px; }
    .map-filters .select { flex: 1 1 45%; min-width: 0; padding: 11px 10px; font-size: 14px; }
    .map-count { padding-top: 6px; }
    .map-canvas { min-height: 55vh; flex: 1 1 auto; }
    .map-results { padding: 8px 12px; }

    /* iOS bounce: keep sheet content scrolling internally */
    .map-results { -webkit-overflow-scrolling: touch; }

    /* Leaflet controls clear of the sheet */
    .leaflet-bottom.leaflet-right { bottom: 6px; }
}

/* Small phones: tighter sheet */
@media (max-width: 380px) {
    .map-sidebar { height: 48vh; }
    .map-filters .filter-row { flex-direction: column; }
    .map-filters .select { flex: 1 1 auto; }
}

/* Larger Leaflet zoom controls for touch */
.leaflet-control-zoom a {
    width: 40px !important; height: 40px !important;
    line-height: 40px !important; font-size: 20px !important;
}
