/* ============================================================
   WORLDVIEW SPATIAL INTELLIGENCE UI
   Adds circular clipping, CRT masks, and advanced data panels
   ============================================================ */

/* The signature circular spyglass cutout mask */
.worldview-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    background: radial-gradient(circle at center, transparent 35%, rgba(0, 0, 0, 0.9) 65%, #000 100%);
    display: none;
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.8);
}

/* 3D Mode Exit Bar — always visible in 3D mode, at top of map area */
.wv-exit-bar {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 12;
    display: none;
    align-items: center;
    gap: 16px;
    background: rgba(10, 14, 23, 0.92);
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: 8px;
    padding: 6px 10px 6px 14px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.wv-exit-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 2px;
    color: rgba(0, 240, 255, 0.8);
    white-space: nowrap;
}

.wv-exit-btn {
    background: rgba(255, 51, 85, 0.1);
    border: 1px solid rgba(255, 51, 85, 0.4);
    color: #ff3355;
    padding: 6px 16px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    white-space: nowrap;
}

.wv-exit-btn:hover {
    background: rgba(255, 51, 85, 0.25);
    border-color: #ff3355;
    box-shadow: 0 0 12px rgba(255, 51, 85, 0.3);
}

/* Base floating data panel */
.wv-panel {
    position: absolute;
    background: rgba(10, 14, 23, 0.85);
    border: 1px solid rgba(0, 240, 255, 0.2);
    border-radius: 8px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 10;
    padding: 0;
    color: #e2e8f0;
    font-family: 'JetBrains Mono', monospace;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    display: none;
    /* shown in WorldView mode */
    transition: width 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
}

.wv-panel-body {
    padding: 16px;
}

/* Panel close / minimize button */
.wv-panel-close {
    position: absolute;
    top: 8px;
    z-index: 2;
    width: 22px;
    height: 22px;
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: rgba(0, 240, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.2s;
}

.wv-panel-close:hover {
    background: rgba(0, 240, 255, 0.15);
    color: #00f0ff;
}

.left-panel .wv-panel-close {
    right: 8px;
}

.right-panel .wv-panel-close {
    left: 8px;
}

/* Collapsed state */
.wv-panel.collapsed .wv-panel-body {
    display: none;
}

.wv-panel.left-panel.collapsed {
    width: 36px !important;
    min-width: 36px !important;
}

.wv-panel.right-panel.collapsed {
    width: 36px !important;
    min-width: 36px !important;
}

.wv-panel::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 240, 255, 0.6), transparent);
}

.wv-panel.left-panel {
    top: 80px;
    left: 20px;
    width: 260px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.wv-panel.right-panel {
    top: 80px;
    right: 20px;
    width: 280px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.wv-panel.bottom-panel {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    border-radius: 24px;
    display: none;
    /* dynamically toggled */
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Headers and Typography */
.wv-header {
    font-size: 9px;
    color: #ffaa00;
    letter-spacing: 2px;
    margin-bottom: 12px;
}

.wv-title {
    font-size: 14px;
    font-weight: 700;
    color: #00f0ff;
    letter-spacing: 2px;
    margin-bottom: 16px;
    text-transform: uppercase;
}

/* Controls & Buttons */
.wv-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

/* 2-column grid for right panel action buttons */
.wv-grid-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 12px;
}

.wv-btn {
    background: rgba(0, 240, 255, 0.05);
    border: 1px solid rgba(0, 240, 255, 0.3);
    color: #88ddff;
    padding: 8px 8px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 9px;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1.3;
}

.wv-controls .wv-btn {
    flex: 1;
    min-width: 80px;
}

.wv-btn:hover {
    background: rgba(0, 240, 255, 0.15);
    color: #00f0ff;
}

.wv-btn.active {
    background: rgba(0, 240, 255, 0.2);
    border-color: #00f0ff;
    color: #fff;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.wv-btn.danger {
    border-color: rgba(255, 51, 85, 0.4);
    color: #ff3355;
}

.wv-btn.danger:hover,
.wv-btn.danger.active {
    background: rgba(255, 51, 85, 0.2);
    border-color: #ff3355;
    color: #fff;
    box-shadow: 0 0 10px rgba(255, 51, 85, 0.3);
}

/* Sliders */
.wv-sliders {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wv-sliders label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 9px;
    color: #88ddff;
    letter-spacing: 1px;
}

.wv-sliders input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 140px;
    height: 2px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    border-radius: 2px;
}

.wv-sliders input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 10px;
    background: #00f0ff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 8px #00f0ff;
}

/* Style Presets (Bottom Pill) */
.wv-preset-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    padding: 6px 14px;
    border-radius: 16px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s;
}

.wv-preset-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.wv-preset-btn.active {
    background: rgba(0, 240, 255, 0.15);
    color: #00f0ff;
    box-shadow: inset 0 0 10px rgba(0, 240, 255, 0.1);
}

/* Mini Cam Preview in Left Panel */
.wv-preview {
    margin-top: 16px;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

/* Environmental Anomalies / Truth Line */
.pulse-marker {
    box-sizing: border-box;
    width: 20px;
    height: 20px;
    border: 2px solid #ff3355;
    border-radius: 50%;
    position: absolute;
    animation: markerPulse 1.5s infinite ease-out;
}

@keyframes markerPulse {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

/* CRT Shader CSS fallback (if WebGL not used for UI) */
.crt-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 4px, 6px 100%;
    pointer-events: none;
    z-index: 6;
    display: none;
}

/* Panel scrollbar styling */
.wv-panel::-webkit-scrollbar {
    width: 4px;
}

.wv-panel::-webkit-scrollbar-track {
    background: transparent;
}

.wv-panel::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.2);
    border-radius: 2px;
}

.wv-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 240, 255, 0.4);
}

/* Responsive — on narrower windows, shrink panels */
@media (max-width: 1200px) {
    .wv-panel.left-panel {
        width: 220px;
        left: 10px;
    }

    .wv-panel.right-panel {
        width: 240px;
        right: 10px;
    }

    .wv-sliders input[type="range"] {
        width: 100px;
    }
}

@media (max-width: 900px) {
    .wv-panel.left-panel {
        width: 180px;
        left: 5px;
        padding: 0;
    }

    .wv-panel.right-panel {
        width: 200px;
        right: 5px;
        padding: 0;
    }

    .wv-panel-body {
        padding: 10px;
    }

    .wv-grid-controls {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .wv-panel.left-panel,
    .wv-panel.right-panel {
        width: calc(50vw - 20px);
        max-width: 200px;
    }
    .wv-panel.left-panel {
        left: 4px;
    }
    .wv-panel.right-panel {
        right: 4px;
    }
    .wv-sliders input[type="range"] {
        width: 80px;
    }
}

@media (max-width: 480px) {
    .wv-panel.left-panel,
    .wv-panel.right-panel {
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        max-height: 45vh;
        border-radius: 12px 12px 0 0;
        z-index: 9200;
    }
    .wv-panel-body {
        padding: 8px;
        max-height: 40vh;
        overflow-y: auto;
    }
    .wv-grid-controls {
        grid-template-columns: 1fr;
    }
    .wv-sliders input[type="range"] {
        width: 100%;
    }
}
