/* =========================================================
   MINOX MAP — FAILSAFE SMALL‑FORMAT COLD‑WAR UI THEME
   Neutral, archival, plotting‑board aesthetic
========================================================= */

/* ---------------------------------------------------------
   GLOBAL BASE
--------------------------------------------------------- */

:root {
    --failsafe-grey-0: #f2f2f2;
    --failsafe-grey-1: #e5e5e5;
    --failsafe-grey-2: #dcdcdc;
    --failsafe-grey-3: #c8c8c8;
    --failsafe-grey-4: #b5b5b5;
    --failsafe-grey-5: #9e9e9e;

    --black: #000;
    --near-black: #111;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--failsafe-grey-2);
    font-family: "Helvetica Neue", Arial, sans-serif;
    color: var(--near-black);
    letter-spacing: 0.15px;
}

/* ---------------------------------------------------------
   MAP FRAME
--------------------------------------------------------- */

#map {
    position: absolute;
    inset: 0;
    background: var(--failsafe-grey-2);
    border: 6px solid var(--black);
    box-shadow: inset 0 0 0 2px var(--failsafe-grey-3);
    z-index: 1;
}

.leaflet-container {
    background: var(--failsafe-grey-2);
    font-family: "Helvetica Neue", Arial, sans-serif;
}

.leaflet-control {
    box-shadow: none;
    border-radius: 0;
}

.leaflet-control-zoom a {
    background: var(--failsafe-grey-0);
    color: var(--black);
    border: 1px solid var(--failsafe-grey-4);
}

.leaflet-control-zoom a:hover {
    background: var(--failsafe-grey-1);
}

/* ---------------------------------------------------------
   MARKERS & CLUSTERS
--------------------------------------------------------- */

img.leaflet-marker-icon {
    width: 24px;
    height: 24px;
    image-rendering: crisp-edges;
}

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background: rgba(180, 180, 180, 0.75);
    border: 1px solid #666;
    color: #000;
    font-size: 11px;
    font-weight: 600;
}

/* ---------------------------------------------------------
   POPUPS
--------------------------------------------------------- */

.leaflet-popup-content-wrapper {
    background: var(--failsafe-grey-0);
    border-radius: 0;
    border: 1px solid var(--failsafe-grey-4);
    box-shadow: none;
    padding: 0;
}

.leaflet-popup-content {
    margin: 0;
    padding: 4px 6px;
    font-size: 11px;
    line-height: 1.3;
}

.leaflet-popup-tip {
    background: var(--failsafe-grey-0);
    border: 1px solid var(--failsafe-grey-4);
}

/* ---------------------------------------------------------
   OPERATIONAL CONTEXT PANEL
--------------------------------------------------------- */

#op-context {
    position: absolute;
    top: 0;
    right: 0;
    width: 240px;
    height: 100%;
    background: var(--failsafe-grey-1);
    border-left: 4px solid var(--black);
    padding: 14px 16px;
    box-shadow: inset 0 0 0 1px var(--failsafe-grey-3);
    z-index: 10;
}

#op-context h3 {
    margin: 0 0 10px 0;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    border-bottom: 1px solid var(--black);
    padding-bottom: 4px;
}

#op-year {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 10px;
}

#op-summary {
    font-size: 12px;
    line-height: 1.4;
}

/* ---------------------------------------------------------
   TIMELINE SLIDER
--------------------------------------------------------- */

#timeline-container {
    position: absolute;
    bottom: 16px;
    left: 16px;
    width: 220px;
    background: var(--failsafe-grey-1);
    padding: 10px 12px;
    border: 1px solid var(--black);
    box-shadow: inset 0 0 0 1px var(--failsafe-grey-3);
    z-index: 10;
}

#timeline-container label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 6px;
    color: var(--black);
}

#timeline-year {
    font-size: 15px;
    font-weight: 700;
    margin-left: 4px;
    color: var(--black);
}

#timeline {
    width: 100%;
    background: transparent;
    margin-top: 4px;
}

#timeline::-webkit-slider-runnable-track {
    height: 3px;
    background: var(--black);
}

#timeline::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--failsafe-grey-1);
    border: 2px solid var(--black);
    border-radius: 0;
    margin-top: -6px;
    cursor: pointer;
}

/* ---------------------------------------------------------
   LAYER TOGGLES
--------------------------------------------------------- */

#layer-toggles {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 160px;
    background: var(--failsafe-grey-1);
    padding: 10px 12px;
    border: 1px solid var(--black);
    box-shadow: inset 0 0 0 1px var(--failsafe-grey-3);
    z-index: 10;
}

#layer-toggles h4 {
    margin: 0 0 6px 0;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    border-bottom: 1px solid var(--black);
    padding-bottom: 3px;
}

.toggle-row {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.toggle-row input[type="checkbox"] {
    appearance: none;
    width: 12px;
    height: 12px;
    border: 2px solid var(--black);
    background: var(--failsafe-grey-1);
    margin-right: 6px;
    cursor: pointer;
}

.toggle-row input[type="checkbox"]:checked {
    background: var(--black);
}

.toggle-label {
    font-size: 11px;
    color: var(--near-black);
}

/* ---------------------------------------------------------
   LEGEND PANEL
--------------------------------------------------------- */

#legend-panel {
    position: absolute;
    bottom: 16px;
    right: 260px;
    width: 160px;
    background: var(--failsafe-grey-1);
    padding: 10px 12px;
    border: 1px solid var(--black);
    box-shadow: inset 0 0 0 1px var(--failsafe-grey-3);
    z-index: 10;
}

#legend-panel h4 {
    margin: 0 0 6px 0;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    border-bottom: 1px solid var(--black);
    padding-bottom: 3px;
}

.legend-row {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}

.legend-row img {
    width: 14px;
    height: 14px;
    margin-right: 6px;
    image-rendering: crisp-edges;
}

.legend-label {
    font-size: 11px;
    color: var(--near-black);
}
/* Enhanced failsafe rendering for OSM tiles */
.leaflet-tile {
    filter:
        grayscale(100%)
        brightness(0.85)
        contrast(0.9)
        saturate(0%)
        opacity(0.95);
}
#ops-panel {
    width: 220px;
}
#distribution-chain-overlay {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 260px;
    background: #2b2b2b;
    color: #eee;
    padding: 12px 16px;
    border: 2px solid #555;
    font-family: "IBM Plex Mono", monospace;
    z-index: 9999;
}

#distribution-chain-overlay .dist-title {
    font-weight: bold;
    margin-bottom: 6px;
    color: #9cf;
}

#distribution-chain-overlay .dist-year {
    margin-bottom: 10px;
    color: #ccc;
}

#distribution-chain-overlay .dist-active {
    background: #3a3a3a;
    padding: 8px;
    border-left: 4px solid #6cf;
}

#distribution-chain-overlay .dist-gap {
    background: #3a3a3a;
    padding: 8px;
    border-left: 4px solid #f66;
}
