/* ══════════════════════════════════════════════════════════════
   DetectLab — Country dock + World Hillshade + “Exit view”
   ──────────────────────────────────────────────────────────────
   Styles for js/country-dock.js: the small control strip glued
   under the map search bar (country initials button + World
   hillshade checkbox), the slide-down country list, and the
   bottom-centre “Exit view” button that only appears once the
   locked country view is zoomed all the way out.
   See COUNTRY_SELECTION_DOCK.md.
   ══════════════════════════════════════════════════════════════ */

/* ── Dock strip: only once a country is active, never while the globe
   gate covers the map, never while the search autocomplete is open. ── */
.country-dock {
    display: none;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
    pointer-events: all;
}

body.country-selected .country-dock { display: flex; }
.country-dock.dock-suppressed { display: none !important; }
html.globe-gate-open .country-dock { display: none !important; }

.country-dock-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* ── Slide-down country button (shows the current 2-letter code) ── */
.country-dock-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(184, 216, 240, 0.22);
    background: rgba(6, 14, 30, 0.88);
    backdrop-filter: blur(16px);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
    color: #F5F0EB;
    font: 600 0.78rem/1 'Outfit', sans-serif;
    letter-spacing: .04em;
    cursor: pointer;
    transition: border-color .18s, background .18s;
}
.country-dock-btn:hover,
.country-dock-btn[aria-expanded="true"] {
    border-color: rgba(128, 211, 248, 0.5);
    background: rgba(14, 32, 58, 0.92);
}

.country-dock-globe { font-size: .82rem; opacity: .85; }

/* The current country's 2-letter code inside the chip. The initials in the
   slide-down panel use .country-dock-cell below — two different things. */
.country-dock-code {
    font-weight: 700;
    letter-spacing: .1em;
    color: #B9FF00;
}

.country-dock-caret {
    font-size: .62rem;
    opacity: .75;
    transition: transform .18s;
}
.country-dock.is-open .country-dock-btn .country-dock-caret { transform: rotate(180deg); }

/* ── Small “World hillshade” checkbox ── */
.country-dock-hs {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(184, 216, 240, 0.18);
    background: rgba(6, 14, 30, 0.88);
    backdrop-filter: blur(16px);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    color: rgba(245, 240, 235, 0.85);
    font: 500 0.74rem/1 'Outfit', sans-serif;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: border-color .18s, color .18s;
}
.country-dock-hs:hover { border-color: rgba(128, 211, 248, 0.42); color: #F5F0EB; }

.country-dock-hs input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    width: 14px;
    height: 14px;
    margin: 0;
    flex-shrink: 0;
    border-radius: 3px;
    border: 1px solid rgba(184, 216, 240, 0.45);
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.country-dock-hs input[type="checkbox"]:checked {
    background: #B9FF00;
    border-color: #B9FF00;
}
.country-dock-hs input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    inset: 0;
    color: #08111f;
    font: 700 11px/14px system-ui, sans-serif;
    text-align: center;
}
.country-dock-hs input[type="checkbox"]:focus-visible {
    outline: 2px solid rgba(185, 255, 0, 0.6);
    outline-offset: 1px;
}

/* Layer-info ⓘ for the World-hillshade overlay (the app hides Leaflet's own
   attribution control, so live layers credit their source through a popup). */
.country-dock-info {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(184, 216, 240, 0.2);
    background: rgba(6, 14, 30, 0.88);
    backdrop-filter: blur(16px);
    color: rgba(184, 216, 240, 0.7);
    font: 600 0.72rem/1 'Outfit', sans-serif;
    cursor: pointer;
    transition: color .18s, border-color .18s;
}
.country-dock-info:hover { color: #F5F0EB; border-color: rgba(128, 211, 248, 0.5); }

/* ── Slide-down panel with the country initials ── */
.country-dock-panel {
    background: rgba(6, 14, 30, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(184, 216, 240, 0.18);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    padding: 10px;
    transform-origin: top center;
    animation: countryDockDrop .18s ease-out;
}
.country-dock-panel[hidden] { display: none !important; }

@keyframes countryDockDrop {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: none; }
}

.country-dock-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    color: rgba(184, 216, 240, 0.75);
    font: 600 0.68rem/1 'Outfit', sans-serif;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.country-dock-x {
    background: none;
    border: none;
    padding: 0 2px;
    color: rgba(184, 216, 240, 0.55);
    font-size: .78rem;
    cursor: pointer;
}
.country-dock-x:hover { color: #F5F0EB; }

.country-dock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    gap: 4px;
    max-height: 190px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.country-dock-cell {
    padding: 6px 0;
    border-radius: 6px;
    border: 1px solid rgba(184, 216, 240, 0.14);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(245, 240, 235, 0.9);
    font: 600 0.72rem/1 'Outfit', sans-serif;
    letter-spacing: .06em;
    text-align: center;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.country-dock-cell:hover,
.country-dock-cell:focus-visible {
    background: rgba(185, 255, 0, 0.16);
    border-color: rgba(185, 255, 0, 0.55);
    color: #EAFFD0;
    outline: none;
}
.country-dock-cell.is-current {
    background: rgba(185, 255, 0, 0.22);
    border-color: #B9FF00;
    color: #F2FFD8;
}

/* Full name of the hovered / focused code. */
.country-dock-name {
    margin-top: 8px;
    min-height: 1.1em;
    font: 600 0.8rem/1.25 'Outfit', sans-serif;
    color: #EAFFD0;
    opacity: 0;
    transition: opacity .12s;
}
.country-dock-name.show { opacity: 1; }

.country-dock-hint {
    margin: 6px 0 0;
    font: 400 0.68rem/1.4 'Outfit', sans-serif;
    color: rgba(184, 216, 240, 0.55);
}

/* Switching country loads the (cached) geometry — dim the grid while it does. */
.country-dock.is-busy { opacity: .72; }
.country-dock.is-busy .country-dock-grid { pointer-events: none; }

/* ── “Exit view” — middle of the lower edge, only reachable when the
   locked country view sits at its zoom floor. ── */
.country-exit-view {
    position: absolute;
    left: 50%;
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 950;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid rgba(185, 255, 0, 0.55);
    background: rgba(8, 10, 22, 0.86);
    backdrop-filter: blur(10px);
    color: #ddffb0;
    font: 600 0.82rem/1 'Outfit', sans-serif;
    letter-spacing: .04em;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}
.country-exit-view[hidden] { display: none !important; }
.country-exit-view.show { display: inline-flex; animation: countryExitIn .22s ease-out; }
.country-exit-view:hover { background: rgba(185, 255, 0, 0.18); }

@keyframes countryExitIn {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to   { opacity: 1; transform: translateX(-50%); }
}

html.globe-gate-open .country-exit-view { display: none !important; }

/* Installed PWA: bottom-right stack (live location + account) and the home
   indicator live down there, so lift the pill a little. */
body.is-pwa .country-exit-view {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 60px);
}

/* …and because of that lift the pill lands exactly where the 2D/3D switch
   sits (66px up on the website, 58px on phones, 64px + the same safe-area
   inset in the PWA 3D view). The switch is centred too and paints later, so
   it covered the pill's middle and took its taps. While the pill is on screen
   — js/country-dock.js sets this class from the very same show/hide decision
   that reveals the button — the bottom-centre column gets one more slot:
   css/map3d-terrain.css steps the switch (and the 3D bar stacked on top of
   it) up by this constant. 46px = the pill's own height (32px on phones,
   35px on desktop) plus a 10px gap.

   Scoped to body.is-pwa on purpose: on the website the pill sits 18px from
   the edge, below the 58/66px switch, so lifting anything there would just
   move a control that is already clear. */
body.is-pwa.country-exit-open {
    --country-exit-lift: 46px;
}

@media (max-width: 480px) {
    .country-dock-hs { font-size: 0.7rem; padding: 6px 8px; }
    .country-dock-grid { grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); max-height: 44vh; }
    .country-exit-view { font-size: 0.78rem; padding: 9px 15px; }
}
