/* ==========================================================================
   GARGANTUA — Schwarzschild Black Hole Raytracer
   Design System: Deep Space Glassmorphism & Astrometric Telemetry UI
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400&family=Syne:wght@600;700;800&display=swap');

:root {
    --bg-deep: #020408;
    --panel-bg: rgba(6, 10, 20, 0.75);
    --panel-border: rgba(0, 240, 255, 0.14);
    --panel-border-hover: rgba(0, 240, 255, 0.35);
    --accent-cyan: #00f0ff;
    --accent-blue: #2f80ed;
    --accent-amber: #ffb300;
    --accent-red: #ff3344;
    --accent-green: #00ff88;
    --text-primary: #f0f4fc;
    --text-secondary: #8da2c0;
    --text-muted: #4e6280;
    --font-mono: 'Space Mono', 'Consolas', 'Courier New', monospace;
    --font-display: 'Syne', system-ui, -apple-system, sans-serif;
    --panel-radius: 10px;
    --transition-fast: 0.18s ease;
    --transition-smooth: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-deep);
    font-family: var(--font-mono);
    color: var(--text-primary);
    font-size: 12px;
    letter-spacing: 0.02em;
}

#webgl-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: block;
    z-index: 1;
}

#ui-root {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    pointer-events: none;
}

/* Common Glass Panel */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--panel-border);
    border-radius: var(--panel-radius);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65), 0 0 1px rgba(0, 240, 255, 0.2) inset;
    pointer-events: auto;
    transition: border-color var(--transition-fast), transform var(--transition-smooth), opacity var(--transition-smooth);
}

.glass-panel:hover {
    border-color: var(--panel-border-hover);
}

/* -------------------------------------------------------------
   HEADER BAR
   ------------------------------------------------------------- */
.hud-header {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    gap: 16px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-mark {
    position: relative;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #000;
    border: 1.5px solid var(--accent-cyan);
    display: flex;
    align-items: center;
    justify-content: center;
}

.singularity-core {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #000;
    box-shadow: 0 0 12px #000;
}

.photon-ring-pulse {
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 1px dashed rgba(0, 240, 255, 0.6);
    animation: ring-rotate 16s linear infinite;
}

@keyframes ring-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.logo-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 0.18em;
    color: #fff;
    line-height: 1.1;
    text-shadow: 0 0 12px rgba(0, 240, 255, 0.6);
}

.logo-sub {
    font-size: 8.5px;
    letter-spacing: 0.12em;
    color: var(--accent-cyan);
    opacity: 0.85;
}

/* Presets & Buttons */
.preset-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.preset-label {
    font-size: 9.5px;
    color: var(--text-muted);
    font-weight: 700;
    margin-right: 4px;
}

.hud-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 6px 11px;
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
}

.hud-btn:hover {
    background: rgba(0, 240, 255, 0.12);
    border-color: var(--accent-cyan);
    color: #fff;
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.25);
}

.hud-btn.active {
    background: rgba(0, 240, 255, 0.22);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    box-shadow: 0 0 16px rgba(0, 240, 255, 0.35);
}

.btn-key {
    display: inline-block;
    padding: 1px 4px;
    font-size: 9px;
    background: rgba(0, 240, 255, 0.15);
    color: var(--accent-cyan);
    border-radius: 3px;
    font-weight: bold;
}

.orbit-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.2s ease;
}

.hud-btn.active .orbit-indicator {
    background: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan);
    animation: pulse-dot 1.2s ease infinite;
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.6; }
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quality-selector {
    display: flex;
    align-items: center;
    gap: 3px;
}

.qual-btn {
    padding: 5px 8px;
    font-size: 10px;
}

/* -------------------------------------------------------------
   LEFT HUD: TELEMETRY
   ------------------------------------------------------------- */
.hud-telemetry {
    position: absolute;
    top: 80px;
    left: 16px;
    width: 270px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.hud-telemetry.collapsed {
    transform: translateX(-310px);
    opacity: 0;
    pointer-events: none;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 8px;
}

.telemetry-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--accent-cyan);
}

.telemetry-status {
    font-size: 9px;
    color: var(--accent-green);
    background: rgba(0, 255, 136, 0.12);
    border: 1px solid rgba(0, 255, 136, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
}

.metric-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    background: rgba(0, 0, 0, 0.35);
    padding: 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.metric-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.metric-key {
    font-size: 8.5px;
    color: var(--text-muted);
    font-weight: 700;
}

.metric-val {
    font-size: 14px;
    font-weight: 700;
}

.telemetry-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.section-title {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.data-grid {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: rgba(0, 0, 0, 0.25);
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.data-pair {
    display: flex;
    justify-content: space-between;
    font-size: 10.5px;
}

.data-label {
    color: var(--text-secondary);
}

.data-value {
    font-weight: 700;
    color: #fff;
}

.doppler-scale {
    display: flex;
    justify-content: space-between;
    font-size: 8px;
    margin-bottom: 2px;
}

.doppler-bar {
    position: relative;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #00f0ff 0%, #ffffff 50%, #ff3344 100%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow: visible;
}

.doppler-indicator {
    position: absolute;
    top: -3px;
    width: 4px;
    height: 14px;
    background: #fff;
    border-radius: 2px;
    box-shadow: 0 0 6px #fff;
    transform: translateX(-50%);
    transition: left 0.1s ease-out;
}

/* -------------------------------------------------------------
   RIGHT HUD: 21-PARAMETER INSPECTOR
   ------------------------------------------------------------- */
.hud-inspector {
    position: absolute;
    top: 80px;
    right: 16px;
    bottom: 74px;
    width: 320px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hud-inspector.collapsed {
    transform: translateX(360px);
    opacity: 0;
    pointer-events: none;
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent-cyan);
    font-family: var(--font-mono);
    font-size: 10px;
    cursor: pointer;
    text-decoration: underline;
    opacity: 0.8;
}

.link-btn:hover {
    opacity: 1;
}

.category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.cat-pill {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border-radius: 4px;
    padding: 3px 7px;
    font-size: 9.5px;
    cursor: pointer;
    font-family: var(--font-mono);
    transition: all var(--transition-fast);
}

.cat-pill:hover {
    color: #fff;
    border-color: rgba(0, 240, 255, 0.4);
}

.cat-pill.active {
    background: rgba(0, 240, 255, 0.15);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.params-scroll-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Scrollbar */
.params-scroll-list::-webkit-scrollbar {
    width: 4px;
}
.params-scroll-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
.params-scroll-list::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.25);
    border-radius: 2px;
}

.param-row {
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    transition: border-color var(--transition-fast);
}

.param-row:hover {
    border-color: rgba(0, 240, 255, 0.25);
}

.param-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.param-title {
    font-size: 10.5px;
    color: var(--text-secondary);
}

.param-val-badge {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent-cyan);
    background: rgba(0, 240, 255, 0.1);
    padding: 1px 5px;
    border-radius: 3px;
}

.hud-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    cursor: pointer;
}

.hud-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan);
    cursor: pointer;
    transition: transform 0.1s ease;
}

.hud-range::-webkit-slider-thumb:hover {
    transform: scale(1.3);
}

.inspector-footer {
    padding-top: 4px;
}

.full-width {
    width: 100%;
    justify-content: center;
}

/* -------------------------------------------------------------
   BOTTOM DOCK: DEBUG VIEWS (0 - 9)
   ------------------------------------------------------------- */
.hud-debug-bar {
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
    height: 46px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}

.hud-debug-bar.collapsed {
    transform: translateY(70px);
    opacity: 0;
    pointer-events: none;
}

.debug-title {
    font-size: 9.5px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    white-space: nowrap;
}

.debug-pills {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    flex: 1;
    padding-bottom: 2px;
}

.debug-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 5px;
    padding: 5px 9px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.debug-btn:hover {
    background: rgba(0, 240, 255, 0.1);
    border-color: var(--accent-cyan);
    color: #fff;
}

.debug-btn.active {
    background: rgba(0, 240, 255, 0.2);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
}

.debug-key {
    background: rgba(0, 240, 255, 0.15);
    color: var(--accent-cyan);
    padding: 0 4px;
    border-radius: 2px;
    font-size: 9px;
    font-weight: bold;
}

/* -------------------------------------------------------------
   MODAL & TOAST
   ------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: auto;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    width: 640px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.modal-header h2 {
    font-family: var(--font-display);
    font-size: 16px;
    color: #fff;
    letter-spacing: 0.08em;
}

.info-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-card {
    background: rgba(0, 0, 0, 0.3);
    padding: 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.info-card h3 {
    font-size: 12px;
    color: var(--accent-cyan);
    margin-bottom: 6px;
}

.info-card p {
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 6px;
}

.info-card code {
    display: block;
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid rgba(0, 240, 255, 0.2);
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    margin: 6px 0;
    font-size: 11px;
}

.info-card ul {
    padding-left: 18px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.key-table {
    width: 100%;
    border-collapse: collapse;
}

.key-table td {
    padding: 5px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.key-table kbd {
    background: rgba(0, 240, 255, 0.15);
    border: 1px solid rgba(0, 240, 255, 0.3);
    color: var(--accent-cyan);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
}

.hud-toast {
    position: absolute;
    bottom: 74px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(6, 10, 20, 0.9);
    border: 1px solid var(--accent-cyan);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
    color: #fff;
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 11px;
    pointer-events: none;
    opacity: 0;
    transition: all 0.25s ease;
    z-index: 50;
    letter-spacing: 0.05em;
}

.hud-toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.webgl-error-banner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 4, 8, 0.95);
    border: 1px solid var(--accent-red);
    box-shadow: 0 0 30px rgba(255, 51, 68, 0.5);
    color: #fff;
    padding: 24px;
    border-radius: 8px;
    z-index: 999;
    text-align: center;
    max-width: 440px;
}

.webgl-error-banner h3 {
    color: var(--accent-red);
    margin-bottom: 8px;
}

/* Color utility classes */
.text-cyan { color: var(--accent-cyan) !important; }
.text-green { color: var(--accent-green) !important; }
.text-amber { color: var(--accent-amber) !important; }
.text-red { color: var(--accent-red) !important; }
.text-blue { color: var(--accent-blue) !important; }

/* Responsive Adjustments for Mobile & Tablets */
@media (max-width: 900px) {
    .hud-header {
        height: auto;
        flex-wrap: wrap;
        padding: 10px 14px;
    }
    .preset-group {
        display: none;
    }
    .hud-telemetry {
        display: none;
    }
    .hud-inspector {
        width: calc(100vw - 32px);
        left: 16px;
        right: 16px;
        top: 130px;
        bottom: 80px;
    }
    .hud-debug-bar {
        bottom: 12px;
        left: 12px;
        right: 12px;
    }
}
