/* ========================================
   ATLAS MAP — карта, фильтры, поиск, легенда
   (ТЗ Атлас v1.0 §7.3, Блок C)
   ======================================== */

/* ── Панель фильтров над картой ── */
.atl-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 10px 12px;
    background: var(--atl-panel-bg);
    border: 1px solid var(--atl-border);
    border-radius: 12px;
    box-shadow: var(--atl-shadow);
}

.atl-search-wrap {
    position: relative;
    flex: 1 1 220px;
    min-width: 180px;
}

.atl-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    border: 1.5px solid var(--atl-border);
    border-radius: 8px;
    background: var(--atl-bg-elevated);
    color: var(--atl-text);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s ease;
}
.atl-search-input:focus { border-color: var(--atl-accent); }
.atl-search-input::placeholder { color: var(--atl-text-muted); }

.atl-search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    inset-inline-start: 0;
    width: min(420px, 92vw);
    max-height: 320px;
    overflow-y: auto;
    background: var(--atl-panel-bg);
    border: 1px solid var(--atl-border);
    border-radius: 10px;
    box-shadow: var(--atl-shadow-elev);
    z-index: 60;
    display: flex;
    flex-direction: column;
}
.atl-search-dropdown[hidden] { display: none !important; }

.atl-search-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px;
    border: none;
    border-bottom: 1px solid var(--atl-border);
    background: transparent;
    color: var(--atl-text);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    text-align: start;
    cursor: pointer;
}
.atl-search-item:last-child { border-bottom: none; }
.atl-search-item:hover { background: var(--atl-accent-bg); }

.atl-search-item-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    color: var(--atl-text-muted);
}
.atl-search-item-ar { font-family: 'Amiri', serif; font-size: 14px; }
.atl-search-empty {
    padding: 10px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: var(--atl-text-muted);
}

.atl-filter-select {
    padding: 8px 10px;
    border: 1.5px solid var(--atl-border);
    border-radius: 8px;
    background: var(--atl-bg-elevated);
    color: var(--atl-text);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    outline: none;
    max-width: 170px;
    cursor: pointer;
}
.atl-filter-select:focus { border-color: var(--atl-accent); }

.atl-reset-btn {
    padding: 8px 14px;
    border: 1.5px solid var(--atl-border);
    border-radius: 8px;
    background: transparent;
    color: var(--atl-text-muted);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.atl-reset-btn:hover { color: var(--atl-text); border-color: var(--atl-accent); }

/* ── Контейнер карты ── */
.atl-map-wrap { position: relative; }

/* Изолирующий stacking context: внутренние z-index Leaflet (панели 200-650,
   контролы 1000) не конкурируют с оверлеями страницы — дропдаун поиска (60),
   легенда (50) и .atl-panel (40) остаются ПОВЕРХ карты */
.atl-map {
    position: relative;
    z-index: 0;
    isolation: isolate;
}

.atl-map .leaflet-container,
.atl-map.leaflet-container {
    background: var(--atl-sea);
    font-family: 'Inter', sans-serif;
    border-radius: 12px;
}

/* Глобальный reset платформы (svg { max-width: 100% }) зажимает SVG-рендереры
   Leaflet в нулевых по размеру panes: leaflet.css защищает max-width:none
   только .leaflet-overlay-pane — распространяем на все panes (суша в
   tilePane, сетка/регионы в кастомных panes иначе схлопываются в 0px) */
.atl-map .leaflet-pane svg {
    max-width: none !important;
    max-height: none !important;
}

/* маркер активной личности — плавные переходы */
.atl-map path.leaflet-interactive { transition: fill-opacity 0.2s ease, stroke-opacity 0.2s ease; }

/* ── Тултипы городов и личностей (DOM, не canvas — ТЗ §7.3) ── */
.atl-city-tt, .atl-person-tt {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    pointer-events: none;
}
.atl-city-tt::before, .atl-person-tt::before { display: none; }

.atl-city-tt {
    color: var(--atl-city-label);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.01em;
    text-shadow: 0 0 3px var(--atl-land), 0 0 3px var(--atl-land);
}
.atl-person-tt {
    color: var(--atl-text);
    font-size: 11.5px;
    font-weight: 600;
    text-shadow: 0 0 3px var(--atl-land), 0 0 4px var(--atl-land);
}
.atl-person-tt .atl-bio-honorific { font-size: 11px; }

/* подписи городов/личностей появляются с зумом (классы ставит atlas-map.js на zoomend) */
.atl-map:not(.atl-show-city-labels) .atl-city-tt { display: none; }
.atl-map:not(.atl-show-person-labels) .atl-person-tt { display: none; }

/* ── Режим силсилы: приглушение остального (ТЗ §7.3) ── */
.atl-map.atl-silsila-mode .atl-city-tt { opacity: 0.25; }
.atl-map.atl-silsila-mode .atl-person-tt.atl-dimmed { opacity: 0.25; }

/* ── Легенда: сворачиваемая, левый нижний угол (ТЗ §7.3) ── */
.atl-legend {
    position: absolute;
    bottom: 14px;
    inset-inline-start: 14px;
    z-index: 50;
    background: var(--atl-panel-bg);
    border: 1px solid var(--atl-border);
    border-radius: 10px;
    box-shadow: var(--atl-shadow);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: var(--atl-text);
    min-width: 150px;
    overflow: hidden;
}

.atl-legend-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    border: none;
    background: transparent;
    color: var(--atl-text);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.atl-legend-chevron { color: var(--atl-text-muted); transition: transform 0.15s ease; }
.atl-legend-toggle[aria-expanded="false"] .atl-legend-chevron { transform: rotate(-90deg); }

.atl-legend-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 2px 10px 9px;
}
.atl-legend-body.collapsed { display: none; }

.atl-legend-row { display: flex; align-items: center; gap: 7px; }
.atl-legend-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}
.atl-legend-line {
    width: 14px; height: 2.5px;
    border-radius: 2px;
    flex-shrink: 0;
}
.atl-legend-sep { height: 1px; background: var(--atl-border); margin: 4px 0; }

/* ── Leaflet zoom-контролы в токенах темы ── */
.atl-map .leaflet-control-zoom a {
    background: var(--atl-panel-bg);
    color: var(--atl-text);
    border-color: var(--atl-border);
}
.atl-map .leaflet-control-zoom a:hover { background: var(--atl-accent-bg); }

/* ── Мобильная адаптация ── */
@media (max-width: 767px) {
    .atl-filter-select { max-width: 46%; flex: 1 1 40%; }
    .atl-legend { bottom: 10px; inset-inline-start: 10px; font-size: 11px; }
}
