/* diversification.css – страница /diversification: карта нод и распределение */

.div-page {
    padding-bottom: 1rem;
}

/* ===== Сводка ===== */
.div-stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.div-stat {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.85rem 1rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(var(--blur-md));
    min-width: 0;
}

.div-stat-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.div-stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
}

/* ===== Сетка: карта + панель ===== */
.div-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 1rem;
    align-items: start;
    margin-bottom: 1rem;
}

.div-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(var(--blur-md));
    padding: 1rem 1.2rem;
    min-width: 0;
}

.div-card h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.8rem;
    letter-spacing: 0.3px;
}

.div-card h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin: 1rem 0 0.4rem;
}

.div-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.div-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.8rem;
}

.div-card-head h2 {
    margin-bottom: 0;
}

/* ===== Карта ===== */
.map-legend {
    display: flex;
    gap: 0.9rem;
    font-size: 0.72rem;
    color: var(--text-dim);
}

.map-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-2);
    display: inline-block;
}

.legend-dot.is-active {
    background: var(--accent-alt);
}

.map-frame {
    position: relative;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    background: rgba(var(--surface-rgb), 0.6);
    overflow: hidden;
}

#worldMap {
    display: block;
    width: 100%;
    height: auto;
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
    /* Пока карта не увеличена, жесты пальцем прокручивают страницу */
    touch-action: pan-x pan-y pinch-zoom;
}

#worldMap:active {
    cursor: grabbing;
}

.map-frame.is-zoomed #worldMap {
    touch-action: none;
}

.map-graticule {
    fill: none;
    stroke: rgba(var(--text-rgb), 0.06);
    stroke-width: 0.5;
    vector-effect: non-scaling-stroke;
}

.map-country {
    fill: rgba(var(--text-rgb), 0.09);
    stroke: rgba(var(--text-rgb), 0.22);
    stroke-width: 0.5;
    vector-effect: non-scaling-stroke;
}

.map-country.has-nodes {
    fill: rgba(var(--accent-rgb), 0.2);
    stroke: rgba(var(--accent-rgb), 0.45);
}

.map-marker {
    cursor: pointer;
    outline: none;
}

.marker-hit {
    fill: transparent;
}

.marker-dot {
    fill: var(--accent-2);
    stroke: var(--surface);
    transition: fill 0.2s ease;
}

.map-marker.is-active .marker-dot {
    fill: var(--accent-alt);
}

.map-marker:hover .marker-dot,
.map-marker:focus-visible .marker-dot {
    fill: var(--accent);
}

.map-marker:focus-visible .marker-hit {
    fill: rgba(var(--accent-rgb), 0.25);
}

.marker-pulse {
    fill: rgba(var(--accent-alt-rgb), 0.35);
    transform-box: fill-box;
    transform-origin: center;
    animation: marker-pulse 2.4s ease-out infinite;
    pointer-events: none;
}

@keyframes marker-pulse {
    from { transform: scale(1); opacity: 0.8; }
    to { transform: scale(2.4); opacity: 0; }
}

.marker-count {
    fill: var(--surface);
    font-family: 'Exo 2', sans-serif;
    font-weight: 700;
    text-anchor: middle;
    pointer-events: none;
}

.map-status {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 0.85rem;
    pointer-events: none;
}

.map-status[hidden] {
    display: none;
}

.map-controls {
    position: absolute;
    right: 0.6rem;
    bottom: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.map-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    background: var(--glass-bg-strong);
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease;
}

.map-btn i {
    font-size: 0.8rem;
}

.map-btn:hover {
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.12);
}

.map-hint,
.map-credit {
    margin-top: 0.6rem;
    font-size: 0.72rem;
    color: var(--text-dim);
}

.map-credit {
    margin-top: 0.2rem;
    color: var(--text-dimmer);
}

.hint-touch {
    display: none;
}

@media (hover: none) {
    .hint-desktop {
        display: none;
    }

    .hint-touch {
        display: inline;
    }
}

/* ===== Всплывающий список нод (десктоп — у маркера) ===== */
.map-popover {
    position: fixed;
    z-index: 9000;
    width: 320px;
    max-width: calc(100vw - 16px);
    max-height: min(420px, 70vh);
    display: flex;
    flex-direction: column;
    background: var(--surface-elevated);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 48px rgba(var(--black-rgb), 0.45);
    overflow: hidden;
}

.map-popover[hidden] {
    display: none;
}

.pop-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--glass-border);
}

.pop-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
}

.pop-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-dim);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.pop-close:hover {
    color: var(--text);
    background: rgba(var(--text-rgb), 0.08);
}

.pop-body {
    overflow-y: auto;
    padding: 0.5rem 0.6rem 0.7rem;
    overscroll-behavior: contain;
}

.pop-location + .pop-location {
    margin-top: 0.7rem;
    padding-top: 0.7rem;
    border-top: 1px solid var(--glass-border);
}

.pop-location-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
}

.pop-location-provider {
    font-size: 0.72rem;
    color: var(--text-dim);
    margin: 0.15rem 0 0.4rem;
}

/* ===== Кнопка ноды (список на карте и карточки площадок) ===== */
.loc-node {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    margin-top: 0.3rem;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: rgba(var(--surface-rgb), 0.5);
    color: var(--text);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.loc-node:hover,
.loc-node:focus-visible {
    border-color: rgba(var(--accent-rgb), 0.5);
    background: rgba(var(--accent-rgb), 0.08);
    outline: none;
}

.loc-node-status {
    flex-shrink: 0;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent-2);
}

.loc-node-status.is-active {
    background: var(--accent-alt);
    box-shadow: 0 0 6px rgba(var(--accent-alt-rgb), 0.6);
}

.loc-node-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.loc-node-name {
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.loc-node-meta {
    font-size: 0.7rem;
    color: var(--text-dim);
}

.node-declared {
    margin-left: 0.4rem;
    padding: 0 0.35rem;
    border-radius: 6px;
    background: rgba(var(--warning-rgb), 0.15);
    color: var(--warning);
    font-size: 0.65rem;
    white-space: nowrap;
}

.loc-node-arrow {
    flex-shrink: 0;
    font-size: 1.1rem;
    color: var(--text-dimmer);
}

/* ===== Концентрация и полосы распределения ===== */
.conc-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.conc-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.conc-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-dim);
}

.conc-share {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent);
}

.conc-value {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    margin: 0.1rem 0 0.35rem;
}

.conc-detail {
    font-size: 0.68rem;
    color: var(--text-dimmer);
    margin-top: 0.25rem;
}

.bar-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.bar-row {
    display: grid;
    grid-template-columns: minmax(0, 9rem) minmax(0, 1fr) 2rem;
    align-items: center;
    gap: 0.6rem;
}

.bar-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--text);
    min-width: 0;
}

.bar-label span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar-label .country-flag-img,
.loc-title .country-flag-img,
.pop-location-title .country-flag-img {
    width: 18px;
    height: auto;
    border-radius: 2px;
    flex-shrink: 0;
}

.bar-track {
    height: 6px;
    border-radius: 3px;
    background: rgba(var(--text-rgb), 0.1);
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent-2), var(--accent));
}

.bar-count {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    text-align: right;
}

/* ===== Карточки площадок ===== */
.div-locations {
    margin-bottom: 1rem;
}

.loc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.8rem;
}

.loc-card {
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    background: rgba(var(--surface-rgb), 0.35);
    min-width: 0;
}

.loc-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.loc-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-size: 0.88rem;
    min-width: 0;
}

.loc-title span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.loc-count {
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.12);
    padding: 0.1rem 0.5rem;
    border-radius: 20px;
}

.loc-provider {
    font-size: 0.72rem;
    color: var(--text-dim);
    margin: 0.2rem 0 0.3rem;
}

/* ===== Текстовый блок ===== */
.div-about p {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-dim);
    margin-bottom: 0.6rem;
    max-width: 75ch;
}

.div-about-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1.2rem;
    margin-top: 0.8rem;
}

.div-about-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
}

.div-about-links a:hover {
    text-decoration: underline;
}

/* ===== Планшеты ===== */
@media (max-width: 1024px) {
    .div-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .div-panel {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    }

    .div-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ===== Телефоны ===== */
@media (max-width: 640px) {
    .div-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
    }

    .div-stat {
        padding: 0.6rem 0.75rem;
    }

    .div-stat-value {
        font-size: 1.1rem;
    }

    .div-stat-label {
        font-size: 0.62rem;
    }

    .div-card {
        padding: 0.8rem 0.85rem;
        border-radius: var(--radius-md);
    }

    .div-panel {
        grid-template-columns: minmax(0, 1fr);
    }

    .div-card-head {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    /* Карта узкая — кнопки масштаба строкой под ней, а не поверх маркеров;
       размер удобен для пальца */
    .map-controls {
        position: static;
        flex-direction: row;
        justify-content: flex-end;
        padding: 0.4rem;
        border-top: 1px solid var(--glass-border);
    }

    .map-btn {
        width: 40px;
        height: 40px;
    }

    /* Список нод выезжает снизу экрана */
    .map-popover {
        left: 0 !important;
        right: 0;
        top: auto !important;
        bottom: 0;
        width: auto;
        max-width: none;
        max-height: 65vh;
        max-height: 65dvh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .loc-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .loc-node {
        padding: 0.6rem 0.65rem;
    }

    .bar-row {
        grid-template-columns: minmax(0, 7.5rem) minmax(0, 1fr) 1.8rem;
    }
}
