/* News map (MapLibre GL, tile-less): dark/light minimalist map of Russia —
   region borders from GeoJSON + proportional news bubbles with native
   clustering and collision-aware labels. Themed to the app's light/dark. */

.map-main {
    position: relative;
    /* Fill the viewport below the sticky topbar (64px); no footer on this page. */
    height: calc(100vh - 64px - env(safe-area-inset-top));
    min-height: 320px;
    /* Clip the floating overlays so a wide region <select> can't add page scroll. */
    overflow: hidden;
    /* Own stacking context: the overlays below stack in the hundreds/thousands
       and would otherwise outrank the drawers (z-index 100) sitting next to
       <main> in the body. Keep every map z-index local to this box. */
    isolation: isolate;
}

/* Halo colour for label text-shadow = the map background, so names stay legible. */
html[data-theme="dark"]  { --map-halo: #0d1219; }
html:not([data-theme="dark"]) { --map-halo: #eef2f6; }

/* Region selector — floating control at the top-right of the map, with the
   "back to all Russia" arrow beside it. */
/* `right` lives in map-panel.css — it tracks the city panel's width. */
.map-region-wrap {
    position: absolute;
    top: 12px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* The region picker is a combo (combo.js), not the bare <select> it starts as:
   a native option list is drawn by the OS and ignores the theme and the styled
   scrollbar, and 89 regions always scroll. These rules dress the combo's trigger
   as a map overlay — the admin form look it ships with is far too heavy here.
   .map-region still styles the <select> for the moment before combo.js swaps it. */
.map-region,
.map-region-wrap .combo-trigger {
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    /* 280px fits 88 of the 89 region names; the last, "Ханты-Мансийский автономный
       округ - Югра", needs ~294px and isn't worth that much of the map, so it
       clips to an ellipsis (.combo-value) with the full name in the tooltip. */
    max-width: 280px;
    padding: 7px 11px;
    font: inherit;
    font-size: 13px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}
/* The native arrow sits inside the control's padding; the combo's caret is a
   flex sibling with its own gap, so only the <select> needs room made for it. */
.map-region { padding-right: 30px; }
.map-region-wrap .combo { width: auto; }
.map-region-wrap .combo-trigger { min-height: 0; }
.map-region-wrap .combo-value { font-weight: 400; }

/* "Back to all Russia" — arrow-only button beside the region selector; shown only
   when a region is selected, clears the filter. */
.map-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 34px;
    height: 34px;
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}
.map-back:hover { border-color: var(--border-strong); }
.map-back[hidden] { display: none; }   /* hidden must win over display:inline-flex */

/* Floating stats chip over the map (cities / news counts). */
.map-stat-chip {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 500;
    background: rgba(13, 18, 25, .82);
    color: #dce6f0;
    border: 1px solid #22303f;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12.5px;
    line-height: 1;
    pointer-events: none;
    backdrop-filter: blur(4px);
}

#map {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.map-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    color: var(--text-muted, #6b7280);
    font-size: 14px;
    pointer-events: none;
}

/* Zoom control: themed; icons inverted on dark so they stay visible. */
.maplibregl-ctrl-group { background: var(--bg-elevated); border: 1px solid var(--border); }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--border); }
html[data-theme="dark"] .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) brightness(1.3); }

/* Phones: the topbar shrinks to 56px (responsive.css), so match the map height
   and make the floating overlays compact. */
@media (max-width: 640px) {
    .map-main { height: calc(100vh - 56px - env(safe-area-inset-top)); }
    .map-region-wrap { top: 8px; }   /* `right` lives in map-panel.css */
    /* 46vw left barely a dozen characters on a phone; 60vw still clears the back
       button (34px) beside it. */
    .map-region,
    .map-region-wrap .combo-trigger { font-size: 12px; padding: 6px 9px; max-width: 60vw; }
    .map-region { padding-right: 26px; }
    .map-stat-chip { left: 8px; bottom: 8px; padding: 5px 8px; font-size: 11.5px; }
}
