/* ================================================================
   LWM World Map - Styles
   Destination: /map/assets/css/map.css
   Build: 004-map-protection-popup
   All selectors are scoped under .lwm-map-page or .map-* classes so
   nothing here affects /includes/header.php or global.css.
   ================================================================ */
.lwm-map-page {
    --map-ocean: #162638;
    --map-land: #223a52;
    --map-land-stroke: #3a6488;
    --map-gold: #c8a24e;
    --map-gold-light: #e8cc7a;
    --map-gold-dim: rgba(200,162,78,0.2);
    --map-text: #e0dcd4;
    --map-text-dim: #8a9aaa;
    --map-panel: #1a2e42;
    --map-panel-border: #264058;
    --map-card: #213548;
    --map-card-hover: #28405a;
    --map-prayer: #8f80d8;
    --map-prayer-dim: rgba(112,96,184,0.15);
    /* Persecution levels (Open Doors WWL): graduated, not one red */
    --map-level-high: #c47f2c;
    --map-level-very-high: #c25a2a;
    --map-level-extreme: #a8302f;
    --map-level-extreme-light: #e07a72;
    --map-marker-restricted: #f3e6df;
    --map-serif: 'Georgia', 'Crimson Pro', serif;
    --map-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    background: var(--map-ocean);
    color: var(--map-text);
    font-family: var(--map-sans);
    min-height: 80vh;
    position: relative;
}

/* ---- Header ---- */
.map-header { text-align: center; padding: 2rem 1rem 0.5rem; position: relative; }
.map-header h1 {
    font-family: var(--map-serif); font-weight: 700;
    font-size: clamp(1.4rem, 3.5vw, 2rem);
    color: var(--map-gold); letter-spacing: 0.02em; margin: 0;
}
.map-header p { font-size: 0.9rem; color: var(--map-text-dim); margin: 0.3rem 0 0; }

/* ---- Admin gear (missions permission only) ---- */
.map-admin-gear {
    position: absolute; top: 1rem; right: 1rem;
    background: var(--map-card); border: 1px solid var(--map-panel-border);
    color: var(--map-text-dim); width: 2.2rem; height: 2.2rem;
    border-radius: 50%; font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center;
    text-decoration: none; transition: color 0.2s, border-color 0.2s;
}
.map-admin-gear:hover, .map-admin-gear:focus-visible { color: var(--map-gold); border-color: var(--map-gold); }

/* ---- Prayer banner (global) ---- */
.map-prayer-banner {
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    background: var(--map-prayer-dim);
    border-top: 1px solid rgba(112,96,184,0.2);
    border-bottom: 1px solid rgba(112,96,184,0.2);
    padding: 0.5rem 1rem; text-decoration: none; color: var(--map-prayer);
    font-size: 0.85rem; font-weight: 500; transition: background 0.2s;
}
.map-prayer-banner:hover, .map-prayer-banner:focus-visible { background: rgba(112,96,184,0.22); }
.map-prayer-pulse {
    width: 8px; height: 8px; border-radius: 50%; background: var(--map-prayer);
    animation: mapPrayerPulse 2s ease-in-out infinite;
}
@keyframes mapPrayerPulse {
    0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(112,96,184,0.5); }
    50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(112,96,184,0); }
}

/* ---- Global stats bar ---- */
.map-global-bar {
    display: flex; justify-content: center; gap: 0.5rem 1.5rem;
    padding: 0.6rem 1rem; flex-wrap: wrap;
    background: rgba(0,0,0,0.15);
    border-bottom: 1px solid var(--map-panel-border);
    font-size: 0.78rem; color: var(--map-text-dim);
}
.map-global-stat { display: flex; align-items: center; gap: 0.3rem; }
.map-global-stat strong { color: var(--map-level-extreme-light); font-weight: 600; }
.map-global-stat em { font-style: normal; color: var(--map-text); font-weight: 600; }
.map-global-source { flex-basis: 100%; text-align: center; font-size: 0.72rem; }
.map-global-source a { color: var(--map-text-dim); }
.map-global-source a:hover, .map-global-source a:focus-visible { color: var(--map-gold); }

/* ---- Map container ----
   Visible window is the viewBox set by map-view.js (world view:
   0 10 1000 400, i.e. latitude 86.4 N to 57.6 S). Aspect 5:2 matches it. */
.map-container {
    position: relative; width: 100%; max-width: 1200px;
    margin: 0.75rem auto; aspect-ratio: 5 / 2;
}
.map-svg { width: 100%; height: 100%; display: block; }

/* Countries. non-scaling-stroke keeps borders the same screen width at any zoom. */
.map-country {
    fill: var(--map-land);
    stroke: var(--map-land-stroke);
    stroke-width: 0.6px;
    stroke-opacity: 0.55;
    vector-effect: non-scaling-stroke;
    fill-rule: evenodd;
}
.map-country.is-level-high      { fill: var(--map-level-high); }
.map-country.is-level-very_high { fill: var(--map-level-very-high); }
.map-country.is-level-extreme   { fill: var(--map-level-extreme); }
.map-country.is-restricted { cursor: pointer; stroke: #000; stroke-opacity: 0.6; }
.map-country.is-restricted:hover { filter: brightness(1.15); }

/* Cordon: hatching drawn over restricted country shapes */
.map-cordon { fill: url(#lwmCordonHatch); pointer-events: none; fill-rule: evenodd; }

/* Equator */
.map-equator { stroke: var(--map-land-stroke); stroke-width: 0.6px; vector-effect: non-scaling-stroke; stroke-dasharray: 6 5; opacity: 0.3; }

/* ---- Markers ----
   Only the dot scales on hover, around its own centre (transform-box:
   fill-box). The pulse ring ignores the pointer, so hover cannot flicker. */
.map-marker { cursor: pointer; outline: none; }
.map-marker-hit { fill: transparent; }
.map-marker-dot {
    transform-box: fill-box; transform-origin: center;
    transition: transform 0.2s ease-out;
}
.map-marker:hover .map-marker-dot,
.map-marker:focus-visible .map-marker-dot { transform: scale(1.3); }
.map-marker-focus { fill: none; stroke: var(--map-gold-light); opacity: 0; }
.map-marker:focus-visible .map-marker-focus { opacity: 1; }
.map-marker-pulse {
    pointer-events: none;
    transform-box: fill-box; transform-origin: center;
    animation: mapMarkerPulse 2.5s ease-out infinite;
}
@keyframes mapMarkerPulse {
    0%   { transform: scale(1);   opacity: 0.45; }
    100% { transform: scale(2.6); opacity: 0; }
}
.map-marker-label { pointer-events: none; font-family: var(--map-sans); font-weight: 600; }

/* ---- Legend ---- */
.map-legend {
    display: flex; justify-content: center; gap: 0.6rem 1.6rem;
    padding: 0.5rem 1rem 1.2rem; flex-wrap: wrap;
}
.map-legend-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; color: var(--map-text-dim); }
.map-legend-dot { width: 10px; height: 10px; border-radius: 50%; }
.map-legend-dot.lg-open { background: var(--map-gold); }
.map-legend-dot.lg-restricted { background: var(--map-marker-restricted); box-shadow: 0 0 0 2px var(--map-level-extreme); }
.map-legend-dot.lg-hq { background: var(--map-gold-light); box-shadow: 0 0 0 2px var(--map-ocean), 0 0 0 3px var(--map-gold); }
.map-legend-swatch { width: 14px; height: 10px; border-radius: 2px; }
.map-legend-swatch.lg-high      { background: var(--map-level-high); }
.map-legend-swatch.lg-very_high { background: var(--map-level-very-high); }
.map-legend-swatch.lg-extreme   { background: var(--map-level-extreme); }

/* ---- Load error ---- */
.map-error {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    background: var(--map-panel); border: 1px solid var(--map-panel-border);
    color: var(--map-text); padding: 0.9rem 1.2rem; border-radius: 8px;
    font-size: 0.85rem; max-width: 90%; text-align: center;
}

/* ---- Overlay + panel ---- */
.map-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 9000; opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.map-overlay.open { opacity: 1; pointer-events: auto; }
.map-panel {
    position: fixed; top: 0; right: 0;
    width: min(440px, 94vw); height: 100vh; height: 100dvh;
    background: var(--map-panel); border-left: 1px solid var(--map-panel-border);
    z-index: 9001; overflow-y: auto;
    display: flex; flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    visibility: hidden;
}
.map-panel.open { transform: translateX(0); visibility: visible; }
.map-panel-header {
    padding: 1.3rem 1.3rem 0.9rem;
    border-bottom: 1px solid var(--map-panel-border);
    display: flex; justify-content: space-between; align-items: flex-start;
    flex-shrink: 0;
}
.map-panel-header h2 {
    font-family: var(--map-serif); font-size: 1.3rem; font-weight: 700;
    color: var(--map-gold); margin: 0;
}
.map-panel-subtitle { font-size: 0.8rem; color: var(--map-text-dim); margin-top: 0.2rem; }
.map-close {
    background: none; border: 1px solid var(--map-panel-border);
    color: var(--map-text-dim); width: 2rem; height: 2rem;
    border-radius: 50%; cursor: pointer; font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: color 0.2s;
}
.map-close:hover, .map-close:focus-visible { color: var(--map-text); border-color: var(--map-text); }
.map-panel-body { padding: 1.1rem 1.3rem 2rem; flex: 1; }

/* ---- Department cards ---- */
.map-dept-card {
    display: flex; align-items: center; gap: 0.8rem;
    background: var(--map-card); border-radius: 8px;
    padding: 0.8rem 0.9rem; margin-bottom: 0.45rem;
    text-decoration: none; color: var(--map-text);
    transition: background 0.15s;
}
a.map-dept-card:hover, a.map-dept-card:focus-visible { background: var(--map-card-hover); }
.map-dept-card.is-soon { opacity: 0.6; }
.map-dept-icon {
    width: 36px; height: 36px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; flex-shrink: 0;
    background: var(--map-gold-dim); color: var(--map-gold);
}
.map-dept-icon.prayer { background: var(--map-prayer-dim); color: var(--map-prayer); }
.map-dept-info { flex: 1; min-width: 0; }
.map-dept-name { font-weight: 600; font-size: 0.88rem; }
.map-dept-desc { font-size: 0.75rem; color: var(--map-text-dim); margin-top: 0.05rem; }
.map-dept-arrow { color: var(--map-text-dim); font-size: 0.85rem; flex-shrink: 0; }
.map-dept-soon {
    font-size: 0.7rem; color: var(--map-text-dim); flex-shrink: 0;
    border: 1px solid var(--map-panel-border); border-radius: 4px; padding: 0.1rem 0.4rem;
}

/* ---- Section label ---- */
.map-section-label {
    font-size: 0.78rem; font-weight: 600; color: var(--map-text-dim);
    margin: 1.2rem 0 0.45rem; padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--map-panel-border);
}
.map-section-label:first-child { margin-top: 0; }

/* ---- Minister rows ---- */
.map-minister-row {
    display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0;
    border-bottom: 1px solid rgba(38,64,88,0.35);
}
.map-minister-row:last-child { border-bottom: none; }
.map-minister-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--map-gold-dim); color: var(--map-gold);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--map-serif); font-weight: 700; font-size: 0.8rem; flex-shrink: 0;
}
.map-minister-name { font-weight: 600; font-size: 0.88rem; }
.map-minister-role { font-size: 0.75rem; color: var(--map-text-dim); }

/* ---- Restricted / persecution ---- */
.map-restricted-badge {
    display: inline-flex; align-items: center; gap: 0.35rem;
    background: rgba(168,48,47,0.18); color: var(--map-level-extreme-light);
    font-size: 0.75rem; font-weight: 600;
    padding: 0.25rem 0.6rem; border-radius: 4px; margin-bottom: 0.7rem;
}
.map-restricted-badge svg { width: 13px; height: 13px; fill: currentColor; }
.map-restricted-notice { font-size: 0.84rem; line-height: 1.55; color: var(--map-text-dim); }

.map-persecution-card {
    background: var(--map-card); border-radius: 8px;
    padding: 0.9rem 1rem; margin-bottom: 0.6rem;
    border-left: 3px solid var(--map-level-extreme);
}
.map-persecution-card.is-level-high      { border-left-color: var(--map-level-high); }
.map-persecution-card.is-level-very_high { border-left-color: var(--map-level-very-high); }
.map-persecution-card .p-rank { font-family: var(--map-serif); font-size: 1.6rem; font-weight: 700; color: var(--map-text); }
.map-persecution-card .p-label { font-size: 0.75rem; color: var(--map-text-dim); }
.map-persecution-card .p-score { font-size: 0.85rem; margin-top: 0.3rem; }
.map-persecution-card .p-level { font-weight: 700; }
.map-stat-row {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    padding: 0.35rem 0; border-bottom: 1px solid rgba(38,64,88,0.3); font-size: 0.82rem;
}
.map-stat-row:last-child { border-bottom: none; }
.map-stat-row .s-val { font-weight: 600; color: var(--map-level-extreme-light); text-align: right; }
.map-fact-list { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.map-fact-list li {
    font-size: 0.8rem; line-height: 1.5; color: var(--map-text-dim);
    padding: 0.2rem 0 0.2rem 0.8rem; position: relative;
}
.map-fact-list li::before {
    content: ''; position: absolute; left: 0; top: 0.6rem;
    width: 4px; height: 4px; border-radius: 50%; background: var(--map-level-extreme-light); opacity: 0.6;
}
.map-source-link {
    display: inline-block; margin-top: 0.8rem; font-size: 0.75rem; color: var(--map-text-dim);
    text-decoration: none; border-bottom: 1px solid var(--map-panel-border); transition: color 0.2s;
}
.map-source-link:hover, .map-source-link:focus-visible { color: var(--map-gold); }

/* ---- Protection popup (restricted regions) - build 004 ---- */
.map-protect-scrim {
    position: fixed; inset: 0; z-index: 9100;
    background: rgba(8,16,26,0.78);
    display: none; align-items: flex-start; justify-content: center;
    padding: 2rem 16px; overflow-y: auto;
}
.map-protect-scrim.open { display: flex; }
.map-protect {
    width: 100%; max-width: 40rem;
    background: var(--map-panel); border: 1px solid var(--map-panel-border);
    border-top: 4px solid var(--map-level-extreme); border-radius: 6px;
    box-shadow: 0 18px 60px rgba(0,0,0,0.5); color: var(--map-text);
    font-size: 0.95rem; line-height: 1.55;
}
.map-protect-head { display: flex; gap: 1rem; align-items: flex-start; padding: 1.4rem 1.5rem 0.4rem; }
.map-protect-head h2 {
    flex: 1; min-width: 0; margin: 0;
    font-family: var(--map-serif); font-size: 1.45rem; font-weight: 700; line-height: 1.25;
    color: var(--map-gold);
}
.map-protect-lede { display: grid; gap: 0.7rem; padding: 0.2rem 1.5rem 1rem; }
.map-protect-lede p { margin: 0; max-width: 62ch; }
.map-protect-rank { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.map-protect-pill {
    color: #fff; background: var(--map-level-extreme);
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
    padding: 0.15rem 0.55rem; border-radius: 3px;
}
.map-protect-pill.is-level-high      { background: var(--map-level-high); }
.map-protect-pill.is-level-very_high { background: var(--map-level-very-high); }
.map-protect-sections { border-top: 1px solid var(--map-panel-border); }
.map-protect-section { border-bottom: 1px solid var(--map-panel-border); }
.map-protect-section > summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.85rem 1.5rem;
    font-family: var(--map-serif); font-size: 1.05rem; color: var(--map-text);
}
.map-protect-section > summary::-webkit-details-marker { display: none; }
.map-protect-section > summary::before {
    content: "+"; width: 1rem; flex-shrink: 0;
    font-family: var(--map-sans); font-weight: 700; color: var(--map-gold);
}
.map-protect-section[open] > summary::before { content: "\2212"; }
.map-protect-section > summary:hover,
.map-protect-section > summary:focus-visible { background: var(--map-card); outline: none; box-shadow: inset 3px 0 0 var(--map-gold); }
.map-protect-body { display: grid; gap: 0.75rem; padding: 0 1.5rem 1.1rem 3.25rem; }
.map-protect-body p { margin: 0; max-width: 62ch; }
.map-protect-body a { color: var(--map-gold-light); }
.map-protect-verse {
    margin: 0; padding: 0.15rem 0 0.15rem 0.9rem; max-width: 60ch;
    border-left: 2px solid var(--map-gold);
    font-family: var(--map-serif); font-style: italic; color: var(--map-gold-light);
}
.map-protect-verse cite {
    display: block; margin-top: 0.2rem;
    font-family: var(--map-sans); font-style: normal; font-size: 0.8rem; color: var(--map-text-dim);
}
.map-protect-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; padding: 1.1rem 1.5rem 1.3rem; }
.map-protect-btn {
    font-family: var(--map-sans); font-size: 0.92rem; font-weight: 600;
    border-radius: 4px; padding: 0.6rem 1.1rem; cursor: pointer;
    text-decoration: none; border: 1px solid transparent;
}
.map-protect-btn.is-pray { background: var(--map-prayer); color: #10131c; }
.map-protect-btn.is-pray:hover, .map-protect-btn.is-pray:focus-visible { background: #a497e4; }
.map-protect-btn.is-continue { background: transparent; color: var(--map-text); border-color: var(--map-panel-border); }
.map-protect-btn.is-continue:hover, .map-protect-btn.is-continue:focus-visible { border-color: var(--map-gold); color: var(--map-gold-light); }
.map-protect-note { margin: 0; padding: 0 1.5rem 1.1rem; font-size: 0.75rem; color: var(--map-text-dim); }

/* ---- Footer ---- */
.map-footer {
    text-align: center; padding: 0.8rem 1rem; font-size: 0.75rem; color: var(--map-text-dim);
    border-top: 1px solid var(--map-panel-border);
}
.map-footer a { color: var(--map-gold); text-decoration: none; }

/* ---- Keyboard focus (all interactive elements) ---- */
.lwm-map-page a:focus-visible, .lwm-map-page button:focus-visible {
    outline: 2px solid var(--map-gold-light); outline-offset: 2px;
}

@media (max-width: 600px) {
    .map-panel { width: 100vw; }
    .map-global-bar { gap: 0.4rem 0.8rem; font-size: 0.72rem; }
    .map-protect-scrim { padding: 1rem 12px; }
    .map-protect-head, .map-protect-lede, .map-protect-actions, .map-protect-note { padding-left: 1rem; padding-right: 1rem; }
    .map-protect-section > summary { padding-left: 1rem; padding-right: 1rem; }
    .map-protect-body { padding-left: 1rem; padding-right: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    .map-marker-pulse, .map-prayer-pulse { animation: none; }
    .map-marker-pulse { opacity: 0; }
    .map-panel, .map-overlay, .map-marker-dot { transition: none; }
}
