/* --- GLOBAL THEME --- */
:root {
    --bg-dark: #111111;
    --panel-bg: rgba(20, 20, 20, 0.9);
    --accent-cyan: #00E5FF;
    --accent-pink: #FF4081;
    --text-main: #ffffff;
    --text-dim: #aaaaaa;
}

body, html { 
    margin: 0; padding: 0; height: 100%; 
    background-color: #000; color: var(--text-main);
    font-family: 'Inter', -apple-system, sans-serif;
}

details {
    margin-bottom: 10px;
    background-color: var(--panel-bg);
    padding: 10px;
    border-radius: 8px;
}

details summary {
    cursor: pointer;
    font-weight: bold;
    padding: 5px 0;
}

details p {
    margin-top: 10px;
    padding-left: 10px;
}

#map { position: absolute; top: 0; bottom: 0; left: 0; right: 0; z-index: 1; }

/* --- FLOATING HEADER --- */
header {
    position: absolute; top: 20px; left: 20px; z-index: 1000;
    background: var(--panel-bg);
    padding: 20px; border-radius: 12px; border: 1px solid #333;
    backdrop-filter: blur(10px); max-width: 380px;
}
header h1 { margin: 0; color: var(--accent-cyan); font-size: 1.5rem; font-family: 'Merriweather', serif; }
header p { margin: 10px 0 0 0; font-size: 0.85rem; color: var(--text-dim); line-height: 1.4; }

#controls {
    position: absolute;
    top: 140px;
    left: 20px;
    z-index: 1001;
}

#intensity-explanation {
    background: var(--panel-bg);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #444;
    color: white;
    font-size: 0.8rem;
    max-width: 180px;
    backdrop-filter: blur(10px);
    box-sizing: border-box;
}

.toggle-container {
    background: rgba(20, 20, 20, 0.9);
    padding: 5px;
    border-radius: 8px;
    border: 1px solid #444;
    display: flex;
    gap: 5px;
}

.map-button {
    background: #333;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
}

/* --- SIDEBAR PANELS --- */
@media (min-width: 769px) {
    #comparison-panels {
        position: absolute; 
        top: 20px; 
        right: 20px; 
        z-index: 1000;
        width: 340px; 
        display: flex; 
        flex-direction: column; 
        gap: 15px;
    }
}

.panel {
    background: var(--panel-bg); padding: 20px; border-radius: 12px;
    border: 1px solid #333; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    backdrop-filter: blur(10px); transition: 0.3s;
}
#panel-1 { border-top: 4px solid var(--accent-cyan); }
#panel-2 { border-top: 4px solid var(--accent-pink); }

.panel h2 { margin: 0 0 15px 0; font-size: 1.2rem; text-transform: uppercase; letter-spacing: 1px; }
#panel-1 h2 { color: var(--accent-cyan); }
#panel-2 h2 { color: var(--accent-pink); }

.data-item { display: flex; justify-content: space-between; margin-bottom: 8px; border-bottom: 1px solid #222; padding-bottom: 4px; }
.data-label { color: var(--text-dim); font-size: 0.8rem; cursor: pointer; user-select: none;}
.data-value { font-weight: bold; font-family: monospace; font-size: 0.95rem; }
.placeholder { color: #555; text-align: center; font-style: italic; font-size: 0.9rem; }

/* Hoverbox styles for desktop */
.data-label-with-hover {
    position: relative;
    display: inline-block;
    cursor: pointer;
    touch-action: manipulation;
}

.hover-info-box {
    display: none;
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--panel-bg);
    border: 1px solid #444;
    border-radius: 8px;
    padding: 10px;
    min-width: 200px;
    max-width: 250px;
    z-index: 9999;
    font-size: 0.8rem;
    color: var(--text-main);
    backdrop-filter: blur(8px);
    margin-left: 10px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

@media (min-width: 769px) {
    .data-label-with-hover {
        cursor: help;
    }

    .data-label-with-hover:hover .hover-info-box {
        display: block;
        opacity: 1;
    }
}

/* --- LEGEND --- */
#legend {
    position: absolute; bottom: 30px; left: 20px; z-index: 1000;
    background: var(--panel-bg); padding: 15px; border-radius: 12px;
    border: 1px solid #333; min-width: 180px; backdrop-filter: blur(10px);
}
#legend h4 { margin: 0 0 12px 0; color: var(--accent-cyan); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; }
.legend-item { display: flex; align-items: center; margin-bottom: 6px; font-size: 0.75rem; }
.legend-color { width: 16px; height: 16px; margin-right: 12px; border-radius: 3px; }

#static-legends {
    position: absolute;
    bottom: 30px;
    left: 20px;
    z-index: 1000;
    display: flex;
    gap: 10px;
}

.legend-explanation {
    background: var(--panel-bg);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #444;
    color: white;
    font-size: 0.8rem;
    max-width: 180px;
    backdrop-filter: blur(10px);
    box-sizing: border-box;
}

.legend-explanation p {
    margin: 0;
}

/* --- PULSING CIRCLES --- */
.pulsing-circle {
    background: var(--accent-pink);
    border-radius: 50%;
    box-shadow: 0 0 15px var(--accent-pink);
    animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes pulse-ring {
    0% { transform: scale(.33); opacity: 1; }
    80%, 100% { transform: scale(1.2); opacity: 0; }
}

/* Tooltip fixes */
.lga-tooltip { background: #000 !important; color: #fff !important; border: 1px solid #444 !important; font-weight: bold; }

/* --- MOBILE RESPONSIVE --- */
@media (max-width: 768px) {
    /* Mobile comparison panels - anchor to bottom */
    #comparison-panels {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        z-index: 1000;
        display: flex;
        flex-direction: row;
        gap: 8px;
        padding: 8px;
        box-sizing: border-box;
        background: var(--panel-bg);
        border-top: 1px solid #333;
        max-height: 35vh;
        overflow-y: auto;
    }

    .panel {
        flex: 1;
        padding: 12px;
        font-size: 0.75rem;
        text-align: left;
        min-width: 0;
    }
    
    .panel h2 {
        font-size: 0.85rem;
        margin-bottom: 8px;
    }
    
    .data-item {
        font-size: 0.7rem;
        margin-bottom: 6px;
    }
    
    .data-label { font-size: 0.65rem; }
    .data-value { font-size: 0.75rem; }

    /* Mobile hoverbox - position ABOVE label */
    .data-label-with-hover:hover .hover-info-box {
        display: none;
    }
    
    .data-label-with-hover.is-active .hover-info-box {
        display: block;
        opacity: 1;
        pointer-events: auto;
        /* Position fixed relative to viewport instead of absolute */
        position: fixed;
        left: 50% !important;
        transform: translateX(-50%) !important;
        top: auto !important;
        bottom: auto !important;
        /* Calculate position to be centered and above the comparison panels */
        top: 50% !important;
        margin-top: -100px; /* Offset upward */
        margin-left: 0 !important;
        width: 260px;
        max-width: calc(100vw - 30px);
        box-shadow: 0 4px 12px rgba(0,0,0,0.7);
        /* Make it more prominent */
        border: 2px solid var(--accent-cyan);
    }
    
    /* Arrow pointing down to the label - remove on mobile since position is fixed */
    .data-label-with-hover.is-active .hover-info-box::after {
        display: none;
    }

    /* Move legend to TOP on mobile */
    #legend {
        bottom: auto;
        top: 140px;
        left: 10px;
        z-index: 1001;
        font-size: 0.7rem;
        padding: 10px;
        min-width: 140px;
    }
    
    #legend h4 {
        font-size: 0.65rem;
        margin-bottom: 8px;
    }
    
    .legend-item {
        margin-bottom: 4px;
        font-size: 0.65rem;
    }
    
    .legend-color {
        width: 12px;
        height: 12px;
        margin-right: 8px;
    }
    
    #static-legends {
        bottom: auto;
        top: 300px;
        left: 10px;
        z-index: 1001;
        flex-direction: column;
        gap: 8px;
    }
    
    .legend-explanation {
        font-size: 0.7rem;
        padding: 8px;
        max-width: 160px;
    }
}