/* ═══════════════════════════════════════
   Aether — World Radio Map (map.html only)
   Choropleth console, country panel,
   legend, search. Tokens from base.css,
   station cards styled by home.css.
   ═══════════════════════════════════════ */

/* ── Page scaffold ── */
.map-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem 120px;
}

.map-intro {
    max-width: 720px;
    margin-bottom: 1.5rem;
}

.map-intro h1 {
    font-size: var(--fs-h1);
    font-weight: 800;
    margin: 0.4rem 0 0.8rem;
}

.map-intro p {
    color: var(--text-secondary);
    line-height: 1.7;
}

/* ── Map console ── */
.map-console {
    overflow: hidden;
}

.map-toolbar {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    flex-wrap: wrap;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--line);
}

.map-status {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    white-space: nowrap;
    max-width: 100%;
}

.map-status #map-status-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

.map-search-wrap {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    /* stays on the toolbar's LEFT side — the right edge sits under the
       open country panel, which would swallow its clicks */
}

.map-search {
    font-family: var(--font-mono);
    font-size: var(--fs-data);
    color: var(--text-primary);
    background: var(--bg-inset);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.7rem;
    min-width: 220px;
}

.map-search::placeholder {
    color: var(--text-muted);
}

/* Zoom stack floats inside the viewport (bottom-left, map convention) so it
   stays reachable while the country panel overlays the page's right side. */
.map-zoom {
    position: absolute;
    left: var(--sp-2);
    bottom: var(--sp-2);
    z-index: 7; /* above the mobile tap-to-engage overlay — zoom is always allowed */
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.map-zoom button {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    width: 44px;
    height: 44px;
    background: var(--bg-overlay);
    color: var(--text-secondary);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.map-zoom button:hover {
    color: var(--signal);
    border-color: var(--line-signal);
}

/* ── Viewport / stage ── */
.map-viewport {
    position: relative;
    aspect-ratio: 784 / 459;
    max-height: 68vh;
    min-height: 300px;
    width: 100%;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 50% 42%, rgba(0, 229, 255, 0.04), transparent 68%),
        var(--bg-inset);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; /* JS relaxes to pan-y on coarse pointers until engaged */
}

.map-viewport.dragging {
    cursor: grabbing;
}

/* Zoom is rendered via the svg viewBox (vector-crisp at any scale), NOT a CSS
   transform on the stage — a transform rasterizes once and upscales blurry. */
.map-stage {
    position: absolute;
    inset: 0;
}

.map-stage svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* Fill/stroke are set on the svg root and INHERITED, never on `path` directly:
   multi-part countries are <g> groups whose inline fill must reach the child
   paths, and a direct path rule would beat that inheritance. */
.map-stage svg {
    fill: var(--bg-panel);
    stroke: rgba(150, 172, 199, 0.20);
    stroke-width: 0.5;
}

.map-stage path {
    vector-effect: non-scaling-stroke; /* hairline borders at any zoom */
}

.map-stage .map-live {
    cursor: pointer;
    transition: filter var(--t-fast) var(--ease);
}

.map-stage .map-live:hover {
    filter: brightness(1.5);
    stroke: var(--line-signal);
    stroke-width: 1;
}

.map-stage .map-live:focus {
    outline: none;
    stroke: var(--signal);
    stroke-width: 1.2;
}

.map-stage .map-selected {
    stroke: var(--signal);
    stroke-width: 1.2;
    filter: brightness(1.3);
}

.map-stage .map-empty {
    pointer-events: none;
}

/* Country currently showing its transmitter dots: pull the fill back so the
   cyan dots read as lights. Must also beat the hover/selected brightness. */
.map-stage .map-live.map-dotted,
.map-stage .map-live.map-dotted:hover {
    filter: brightness(0.35) saturate(0.7);
}

/* ── Geo dot layer (phase 5b) ── */
.geo-dots circle {
    fill: var(--signal);
    opacity: 0.85;
    stroke: rgba(0, 0, 0, 0);  /* invisible halo widens the hit target */
    stroke-width: 9px;
    vector-effect: non-scaling-stroke;
    pointer-events: all;
    cursor: pointer;
    transition: opacity var(--t-fast) var(--ease);
}

.geo-dots circle:hover {
    fill: #eafcff;
    opacity: 1;
}

.geo-dots circle.playing {
    fill: #fff;
    opacity: 1;
    animation: dot-pulse 1.6s ease-in-out infinite;
}

@keyframes dot-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
    .geo-dots circle.playing {
        animation: none;
    }
}

.legend-dots {
    color: var(--signal);
}

.legend-dots[hidden] {
    display: none;
}

/* ── Tooltip ── */
.map-tooltip {
    position: absolute;
    z-index: 5;
    pointer-events: none;
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-primary);
    background: var(--bg-overlay);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    white-space: nowrap;
}

.map-tooltip .t-count {
    color: var(--signal);
}

/* [hidden] must win over the display values below (UA rule loses to them) */
.map-engage[hidden],
.map-release[hidden],
.map-tooltip[hidden],
.map-fallback[hidden] {
    display: none;
}

/* ── Tap-to-engage (coarse pointers) ── */
.map-engage {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    background: rgba(2, 4, 10, 0.45);
    border: 0;
    cursor: pointer;
    touch-action: pan-y; /* vertical swipes still scroll the page */
}

.map-engage span {
    color: var(--text-primary);
    background: var(--bg-overlay);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
}

.map-release {
    position: absolute;
    top: var(--sp-2);
    right: var(--sp-2);
    z-index: 6;
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    background: var(--bg-overlay);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0 var(--sp-3);
    cursor: pointer;
}

/* ── Legend ── */
.map-legend {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex-wrap: wrap;
    padding: var(--sp-3) var(--sp-4);
    border-top: 1px solid var(--line);
}

.legend-bar {
    height: 8px;
    flex: 0 1 220px;
    min-width: 120px;
    border: 1px solid var(--line);
    border-radius: 2px;
    background: linear-gradient(90deg, #12222f, #00e5ff);
}

.legend-note {
    margin-left: auto;
}

/* ── Progressive fallback (SVG failed) ── */
.map-fallback {
    margin-top: var(--sp-5);
}

.map-fallback-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin-top: var(--sp-3);
}

.map-fallback-list button {
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0 0.7rem;
    cursor: pointer;
}

.map-fallback-list button:hover {
    color: var(--signal);
    border-color: var(--line-signal);
}

.map-fallback-list button span {
    color: var(--signal);
}

/* ── Country panel ──
   Non-modal by design: no backdrop, so the map stays bright and fully
   interactive (pan/zoom/dots/other countries) while the panel is open. */
.country-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1200;
    width: min(430px, 100vw);
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border-left: 1px solid var(--line-strong);
    box-shadow: -20px 0 50px rgba(0, 0, 0, 0.55);
    transform: translateX(102%);
    visibility: hidden;
    transition: transform var(--t-med) var(--ease), visibility 0s linear var(--t-med);
}

.country-panel.open {
    transform: none;
    visibility: visible;
    transition: transform var(--t-med) var(--ease);
}

.country-panel:focus {
    outline: none;
}

.cp-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-4);
    border-bottom: 1px solid var(--line);
}

.cp-head h2 {
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.3;
    margin: 0.3rem 0 0.5rem;
}

.cp-btns {
    display: flex;
    gap: var(--sp-1);
    flex-shrink: 0;
}

.cp-close,
.cp-focus {
    font-family: var(--font-mono);
    font-size: 1rem;
    width: 48px;
    min-height: 40px;
    flex-shrink: 0;
    background: var(--bg-inset);
    color: var(--text-secondary);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.cp-close:hover {
    color: var(--err);
    border-color: var(--err);
}

.cp-focus:hover {
    color: var(--signal);
    border-color: var(--line-signal);
}

.cp-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-4);
}

.cp-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr); /* long station names must shrink, not blow out the column */
    gap: var(--sp-3);
}

.cp-grid .btn-play {
    text-align: center;
    text-decoration: none;
    line-height: 2.4;
}

/* ── SEO copy below the console ── */
.map-copy {
    max-width: 760px;
    margin-top: var(--sp-7);
}

.map-copy h2 {
    font-size: var(--fs-h2);
    margin: 0.4rem 0 0.8rem;
}

.map-copy p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 0.9rem;
}

/* ── Footer credit ── */
.map-credit a {
    color: var(--text-muted);
    text-decoration: underline;
}

.map-credit a:hover {
    color: var(--signal);
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .map-toolbar {
        gap: var(--sp-2);
    }

    .map-search-wrap {
        margin-left: 0;
        width: 100%;
    }

    .map-search {
        flex: 1;
        min-width: 0;
    }

    .map-viewport {
        aspect-ratio: auto;
        height: 52vh;
        min-height: 260px;
    }
}
