/* ==========================================================
   NeuroVision 3D - Advanced Cyber-Medical Dark Glassmorphism
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;600;800;900&family=Outfit:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;700&display=swap');

:root {
    --bg-dark: #050811;
    --bg-surface: rgba(10, 16, 31, 0.7);
    --bg-surface-elevated: rgba(15, 23, 42, 0.85);
    --border-glass: rgba(0, 217, 255, 0.2);
    --border-glow: rgba(0, 217, 255, 0.5);

    --neon-cyan: #00d9ff;
    --neon-blue: #0077ff;
    --neon-purple: #b829ff;
    --neon-pink: #ff007f;
    --neon-green: #00ff88;

    --text-primary: #f0f6fc;
    --text-secondary: #8b9bb4;
    --text-muted: #53637e;

    --font-main: 'Outfit', sans-serif;
    --font-tech: 'Space Grotesk', sans-serif;
    --font-hud: 'Orbitron', monospace;

    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-main);
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

/* Three.js Canvas Container */
#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    cursor: grab;
}

#canvas-container:active {
    cursor: grabbing;
}

/* Grid & Vignette Overlay */
.vignette-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    background: radial-gradient(circle at center, transparent 40%, rgba(5, 8, 17, 0.75) 100%);
}

/* ==========================================================
   Loading Screen
   ========================================================== */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.6s var(--ease-out-expo), visibility 0.6s;
}

#loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-spinner-wrapper {
    position: relative;
    width: 130px;
    height: 130px;
    margin-bottom: 2rem;
}

.loader-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--neon-cyan);
    animation: spin 1.8s linear infinite;
}

.loader-ring:nth-child(2) {
    inset: 12px;
    border-top-color: var(--neon-purple);
    animation: spin-reverse 1.4s linear infinite;
}

.loader-ring:nth-child(3) {
    inset: 24px;
    border-top-color: var(--neon-blue);
    animation: spin 1.0s linear infinite;
}

.loader-core {
    position: absolute;
    inset: 38px;
    background: radial-gradient(circle, var(--neon-cyan), transparent 70%);
    border-radius: 50%;
    animation: pulse-core 2s ease-in-out infinite alternate;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes spin-reverse {
    to { transform: rotate(-360deg); }
}

@keyframes pulse-core {
    from { opacity: 0.3; transform: scale(0.85); }
    to { opacity: 0.9; transform: scale(1.15); }
}

.loading-title {
    font-family: var(--font-hud);
    font-size: 1.6rem;
    letter-spacing: 4px;
    color: var(--neon-cyan);
    text-shadow: 0 0 15px rgba(0, 217, 255, 0.6);
    margin-bottom: 0.5rem;
}

.loading-bar-container {
    width: 280px;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
    position: relative;
    border: 1px solid rgba(0, 217, 255, 0.3);
}

#loading-progress-fill {
    width: 20%;
    height: 100%;
    background: linear-gradient(90deg, var(--neon-blue), var(--neon-cyan));
    border-radius: 4px;
    box-shadow: 0 0 10px var(--neon-cyan);
    transition: width 0.3s ease;
}

#loading-status-text {
    font-family: var(--font-tech);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ==========================================================
   Header HUD Navigation
   ========================================================== */
.header-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    pointer-events: none;
}

.header-left, .header-center, .header-right {
    pointer-events: auto;
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 0 8px var(--neon-cyan));
    animation: float-icon 3s ease-in-out infinite alternate;
}

@keyframes float-icon {
    from { transform: translateY(0); }
    to { transform: translateY(-4px); }
}

.brand-title {
    font-family: var(--font-hud);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.brand-title span {
    color: var(--neon-cyan);
    text-shadow: 0 0 12px var(--neon-cyan);
}

.brand-tag {
    font-size: 0.65rem;
    font-family: var(--font-tech);
    padding: 2px 6px;
    background: rgba(0, 217, 255, 0.15);
    border: 1px solid var(--border-glass);
    border-radius: 4px;
    color: var(--neon-cyan);
    letter-spacing: 1px;
}

/* Mode Switcher Tabs */
.style-switcher {
    display: flex;
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 40px;
    padding: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 0 12px rgba(0, 217, 255, 0.05);
}

.style-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-tech);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 1px;
    padding: 8px 18px;
    border-radius: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s var(--ease-out-expo);
}

.style-btn:hover {
    color: #ffffff;
}

.style-btn.active {
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.35), rgba(0, 119, 255, 0.35));
    border: 1px solid var(--neon-cyan);
    color: #ffffff;
    box-shadow: 0 0 16px rgba(0, 217, 255, 0.4);
}

/* Quick Tools Header Right */
.quick-tools {
    display: flex;
    gap: 0.5rem;
}

.hud-tool-btn {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 7px 14px;
    border-radius: 8px;
    font-family: var(--font-tech);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.hud-tool-btn:hover {
    background: rgba(0, 217, 255, 0.15);
    border-color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.25);
}

.hud-tool-btn.muted {
    color: var(--text-muted);
    border-color: rgba(255, 255, 255, 0.1);
}

/* ==========================================================
   Webcam PiP / Gesture HUD Display
   ========================================================== */
#webcam-pip {
    position: absolute;
    top: 5.5rem;
    right: 2rem;
    width: 250px;
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: 14px;
    overflow: hidden;
    z-index: 15;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 217, 255, 0.1);
    transition: all 0.35s var(--ease-out-expo);
}

#webcam-pip.minimized {
    width: 140px;
    height: 42px;
}

#webcam-pip.minimized .pip-viewport,
#webcam-pip.minimized .pip-footer {
    display: none;
}

.pip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.35);
    border-bottom: 1px solid rgba(0, 217, 255, 0.15);
}

.pip-title {
    font-family: var(--font-hud);
    font-size: 0.68rem;
    letter-spacing: 1.5px;
    color: var(--neon-cyan);
    display: flex;
    align-items: center;
    gap: 6px;
}

.pip-live-dot {
    width: 7px;
    height: 7px;
    background: var(--neon-green);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--neon-green);
    animation: live-pulse 1.4s ease-in-out infinite;
}

@keyframes live-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

.pip-header-actions {
    display: flex;
    gap: 4px;
}

.pip-action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.pip-action-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.pip-viewport {
    position: relative;
    width: 100%;
    height: 180px;
    background: #020408;
    overflow: hidden;
}

#webcam-video {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror camera */
    opacity: 0.45;
}

#hud-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 2;
}

/* Targeting crosshairs overlay on video */
.pip-crosshairs {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    border: 1px dashed rgba(0, 217, 255, 0.18);
    margin: 8px;
}

.pip-footer {
    padding: 8px 12px;
    font-size: 0.72rem;
    font-family: var(--font-tech);
    background: rgba(0, 0, 0, 0.25);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 4px;
    margin-bottom: 4px;
}

.status-badge.searching {
    color: #ffaa00;
    background: rgba(255, 170, 0, 0.12);
    border: 1px solid rgba(255, 170, 0, 0.3);
}

.status-badge.ready {
    color: var(--neon-cyan);
    background: rgba(0, 217, 255, 0.12);
    border: 1px solid var(--border-glass);
}

.status-badge.pinch {
    color: var(--neon-pink);
    background: rgba(255, 0, 127, 0.15);
    border: 1px solid rgba(255, 0, 127, 0.4);
    box-shadow: 0 0 8px rgba(255, 0, 127, 0.3);
}

.status-badge.dual {
    color: var(--neon-purple);
    background: rgba(184, 41, 255, 0.15);
    border: 1px solid rgba(184, 41, 255, 0.4);
    box-shadow: 0 0 8px rgba(184, 41, 255, 0.3);
}

.status-badge.error {
    color: #ff3366;
    background: rgba(255, 51, 102, 0.15);
    border: 1px solid rgba(255, 51, 102, 0.4);
    box-shadow: 0 0 8px rgba(255, 51, 102, 0.3);
}

.pulse-dot.error {
    background: #ff3366;
    box-shadow: 0 0 6px #ff3366;
}

.cam-retry-btn {
    display: none;
    margin-top: 8px;
    width: 100%;
    padding: 7px 12px;
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.25), rgba(0, 119, 255, 0.35));
    border: 1px solid var(--neon-cyan);
    border-radius: 6px;
    color: #ffffff;
    font-family: var(--font-tech);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.cam-retry-btn:hover {
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.45), rgba(0, 119, 255, 0.55));
    box-shadow: 0 0 12px rgba(0, 217, 255, 0.4);
    transform: translateY(-1px);
}

.pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.pulse-dot.active {
    box-shadow: 0 0 6px currentColor;
}

#gesture-detail-text {
    color: var(--text-secondary);
    line-height: 1.25;
}

/* ==========================================================
   Left Info Card - Current Active Mode
   ========================================================== */
#active-mode-card {
    position: absolute;
    top: 5.5rem;
    left: 2rem;
    max-width: 290px;
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 14px;
    padding: 1.1rem;
    z-index: 10;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
}

.mode-indicator-tag {
    font-family: var(--font-hud);
    font-size: 0.64rem;
    color: var(--neon-cyan);
    letter-spacing: 1.5px;
    margin-bottom: 0.35rem;
}

#active-mode-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 0.4rem;
}

#active-mode-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
    font-family: var(--font-tech);
}

/* ==========================================================
   Anatomical Lobes Drawer (Left Bottom)
   ========================================================== */
#anatomy-drawer {
    position: absolute;
    bottom: 5.5rem;
    left: 2rem;
    max-width: 320px;
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 14px;
    padding: 1rem;
    z-index: 10;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
}

.drawer-header {
    font-family: var(--font-hud);
    font-size: 0.75rem;
    color: var(--neon-cyan);
    letter-spacing: 1.5px;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.lobe-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.lobe-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lobe-card:hover, .lobe-card.selected {
    background: rgba(0, 217, 255, 0.12);
    border-color: var(--neon-cyan);
    transform: translateY(-1px);
}

.lobe-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: #ffffff;
}

.lobe-desc {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-family: var(--font-tech);
}

/* ==========================================================
   Bottom Telemetry Bar
   ========================================================== */
.footer-hud {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    background: linear-gradient(to top, rgba(5, 8, 17, 0.95), transparent);
    pointer-events: none;
}

.footer-left, .footer-center, .footer-right {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

/* Telemetry Items */
.telemetry-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.telemetry-label {
    font-family: var(--font-hud);
    font-size: 0.62rem;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.telemetry-value {
    font-family: var(--font-hud);
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--neon-cyan);
    text-shadow: 0 0 8px rgba(0, 217, 255, 0.3);
}

/* Zoom Gauge Meter */
.zoom-meter {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 160px;
}

.zoom-meter-header {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-hud);
    font-size: 0.62rem;
    color: var(--text-secondary);
}

.zoom-meter-bar {
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid rgba(0, 217, 255, 0.2);
}

#zoom-gauge-fill {
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, var(--neon-blue), var(--neon-cyan), var(--neon-pink));
    box-shadow: 0 0 8px var(--neon-cyan);
    transition: width 0.08s ease-out;
}

/* Slider for Sensitivity */
.slider-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.slider-control label {
    font-family: var(--font-hud);
    font-size: 0.62rem;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.custom-range {
    -webkit-appearance: none;
    appearance: none;
    width: 90px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    outline: none;
}

.custom-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--neon-cyan);
    cursor: pointer;
    box-shadow: 0 0 8px var(--neon-cyan);
}

#sens-value {
    font-family: var(--font-hud);
    font-size: 0.72rem;
    color: var(--neon-cyan);
    min-width: 28px;
}

/* ==========================================================
   Help Guide Modal
   ========================================================== */
#help-modal {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 17, 0.85);
    backdrop-filter: blur(20px);
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s var(--ease-out-expo);
}

#help-modal.open {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    width: 90%;
    max-width: 580px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-glass);
    border-radius: 18px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 217, 255, 0.15);
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(0, 217, 255, 0.2);
    padding-bottom: 1rem;
}

.modal-title {
    font-family: var(--font-hud);
    font-size: 1.25rem;
    color: #ffffff;
    letter-spacing: 1px;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close-btn:hover {
    color: #ffffff;
}

.guide-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.guide-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1.2rem;
    text-align: center;
}

.guide-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 0 10px var(--neon-cyan));
}

.guide-item h4 {
    font-size: 0.95rem;
    color: #ffffff;
    margin-bottom: 0.35rem;
}

.guide-item p {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
    font-family: var(--font-tech);
}

.guide-note {
    font-size: 0.75rem;
    color: var(--neon-cyan);
    font-family: var(--font-tech);
    background: rgba(0, 217, 255, 0.08);
    border: 1px dashed var(--border-glass);
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
}

/* ==========================================================
   Responsive adjustments
   ========================================================== */
@media (max-width: 900px) {
    #anatomy-drawer {
        display: none;
    }
    #active-mode-card {
        max-width: 220px;
    }
    #webcam-pip {
        width: 180px;
    }
    .style-btn {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
}
