/**
 * RADIAL HUD - Modern Video Game In-Game HUD
 *
 * A circular HUD system that radiates around the player ship,
 * displaying dynamic stats like armor, shields, throttle, speed, and action progress.
 * Designed to be intuitive, engaging, and easily expandable.
 */

/* ===== RADIAL HUD CONTAINER ===== */
/* CRITICAL: This must override all other transform rules */
body #radialHUD,
#radialHUD {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 600px;
    height: 600px;
    pointer-events: none;
    z-index: 50; /* Below UI panels but above game canvas */

    /* Ensure flat, straight-on view (no 3D perspective) */
    perspective: none !important;
    transform-style: flat !important;
    backface-visibility: visible !important;
}

/* Override any wildcard transform rules */
* #radialHUD {
    transform: translate(-50%, -50%) !important;
}

/* ===== RADIAL HUD CENTER ===== */
.radial-hud-center {
    display: none !important; /* Hidden - minimalist design */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(88, 166, 255, 0.1) 0%, transparent 70%);
    border: 2px solid rgba(88, 166, 255, 0.3);
    border-radius: 50%;
    box-shadow:
        inset 0 0 20px rgba(88, 166, 255, 0.2),
        0 0 30px rgba(88, 166, 255, 0.3);
    animation: centerPulse 2s ease-in-out infinite;
}

/* ===== CENTER HOVER TRIGGER ===== */
.radial-center-trigger {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 99;
    pointer-events: auto;
}

/* ===== INNER NAVIGATION RING ===== */
.radial-inner-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
    width: 200px;
    height: 200px;
    pointer-events: none;
    z-index: 100;
}

.radial-inner-ring.visible {
    pointer-events: auto;
}

/* Background blur layer - behind icons */
.radial-inner-ring::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(13, 17, 23, 0.6) 0%, rgba(13, 17, 23, 0.3) 35%, rgba(13, 17, 23, 0.05) 60%, rgba(13, 17, 23, 0) 75%);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 50%;
    mask-image: radial-gradient(circle, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 1) 40%, rgba(0, 0, 0, 0.5) 65%, rgba(0, 0, 0, 0.1) 80%, rgba(0, 0, 0, 0) 90%);
    -webkit-mask-image: radial-gradient(circle, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 1) 40%, rgba(0, 0, 0, 0.5) 65%, rgba(0, 0, 0, 0.1) 80%, rgba(0, 0, 0, 0) 90%);
    z-index: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.radial-inner-ring.visible::before {
    opacity: 1;
}

.nav-icon {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.radial-inner-ring.visible .nav-icon {
    opacity: 1;
}

.nav-icon {
    position: absolute;
    display: flex;
    z-index: 1;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    transform: translate(-50%, -50%) !important;
    filter: drop-shadow(0 0 6px rgba(88, 166, 255, 0.4));
}

.nav-icon:hover {
    filter: drop-shadow(0 0 12px rgba(88, 166, 255, 0.8));
    transform: translate(-50%, -50%) scale(1.2) !important;
}

.nav-icon:active {
    transform: translate(-50%, -50%) scale(0.9) !important;
}

.nav-icon-tooltip {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid rgba(88, 166, 255, 0.6);
    border-radius: 4px;
    padding: 4px 8px;
    font-family: 'Orbitron', monospace;
    font-size: 10px;
    color: #F0F6FC;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.nav-icon:hover .nav-icon-tooltip {
    opacity: 1;
}

@keyframes centerPulse {
    0%, 100% {
        box-shadow:
            inset 0 0 20px rgba(88, 166, 255, 0.2),
            0 0 30px rgba(88, 166, 255, 0.3);
    }
    50% {
        box-shadow:
            inset 0 0 30px rgba(88, 166, 255, 0.4),
            0 0 40px rgba(88, 166, 255, 0.5);
    }
}

/* ===== STAT ARC BASE ===== */
.stat-arc {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
    pointer-events: none;
}

.stat-arc svg {
    transform: rotate(-90deg) !important; /* Start from top */
}

/* Individual stat arc paths */
.stat-arc-path-bg {
    fill: none;
    stroke: rgba(88, 166, 255, 0.15);
    stroke-width: 8;
    stroke-linecap: round;
}

.stat-arc-path-fill {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.3s ease-out, stroke 0.3s ease;
}

/* ===== STAT ARC COLORS ===== */
.stat-armor .stat-arc-path-fill {
    stroke: url(#armorGradient);
}

.stat-shields .stat-arc-path-fill {
    stroke: url(#shieldsGradient);
}

.stat-throttle .stat-arc-path-fill {
    stroke: url(#throttleGradient);
}

.stat-speed .stat-arc-path-fill {
    stroke: url(#speedGradient);
}

.stat-action .stat-arc-path-fill {
    stroke: url(#actionGradient);
}

.stat-hull .stat-arc-path-fill {
    stroke: url(#hullGradient);
}

/* ===== STAT LABELS ===== */
.stat-label {
    display: none !important; /* Hidden - using only emoji icons */
}

.stat-value {
    display: none !important; /* Hidden - will use SVG text on arc instead */
}

/* SVG text that follows the arc curve */
.stat-arc-text {
    font-family: 'Orbitron', monospace;
    font-size: 11px;
    font-weight: 600;
    fill: rgba(240, 246, 252, 0.85);
    letter-spacing: 1.5px;
    pointer-events: none;
    filter: drop-shadow(0 0 4px rgba(88, 166, 255, 0.6))
            drop-shadow(0 0 8px rgba(88, 166, 255, 0.3));
}

/* ===== STAT ICON ===== */
.stat-icon {
    display: none !important; /* Hidden - using only curved text on arcs */
    position: absolute;
    font-size: 16px;
    color: #58A6FF;
    text-shadow:
        0 0 8px rgba(88, 166, 255, 0.8),
        0 0 16px rgba(88, 166, 255, 0.4);
    filter: drop-shadow(0 0 4px rgba(88, 166, 255, 0.6));
    pointer-events: none;
}

/* Icon positioning at arc start points */
.stat-speed .stat-icon {
    top: 50%;
    left: -10px;
    transform: translateY(-50%) !important;
}

.stat-throttle .stat-icon {
    top: 50%;
    left: -10px;
    transform: translateY(-50%) !important;
}

.stat-hull .stat-icon {
    top: -10px;
    left: 50%;
    transform: translateX(-50%) !important;
}

.stat-armor .stat-icon {
    top: -10px;
    left: 50%;
    transform: translateX(-50%) !important;
}

.stat-shields .stat-icon {
    top: -10px;
    left: 50%;
    transform: translateX(-50%) !important;
}

/* ===== CRITICAL STATE ANIMATIONS ===== */
.stat-critical .stat-arc-path-fill {
    animation: criticalPulse 0.8s ease-in-out infinite;
}

@keyframes criticalPulse {
    0%, 100% {
        stroke: #FF4444;
        filter: drop-shadow(0 0 5px rgba(255, 68, 68, 0.6));
    }
    50% {
        stroke: #FF8888;
        filter: drop-shadow(0 0 10px rgba(255, 68, 68, 0.9));
    }
}

.stat-critical .stat-label,
.stat-critical .stat-value {
    color: #FF4444;
    animation: textFlash 0.8s ease-in-out infinite;
}

@keyframes textFlash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ===== WARNING STATE ===== */
.stat-warning .stat-arc-path-fill {
    stroke: #FFC107;
}

.stat-warning .stat-label,
.stat-warning .stat-value {
    color: #FFC107;
}

/* ===== ACTIVE ACTION STATE ===== */
.stat-active .stat-arc-path-fill {
    animation: activeGlow 1.5s ease-in-out infinite;
}

@keyframes activeGlow {
    0%, 100% {
        filter: drop-shadow(0 0 5px rgba(88, 166, 255, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 15px rgba(88, 166, 255, 0.9));
    }
}

/* ===== STAT POSITIONING (Radial Layout) ===== */
/* These positions create a circular arrangement around the ship */

/* Hull - Top Right (Layer 3, outside speed/throttle) */
.stat-hull {
    --arc-radius: 204px;
    --arc-angle: 90deg;
}

.stat-hull .stat-label {
    top: 30px;
    right: 50px;
}

.stat-hull .stat-value {
    top: 45px;
    right: 50px;
}

.stat-hull .stat-icon {
    top: 15px;
    right: 45px;
}

/* Armor - Top Right (Layer 4, outside hull) */
.stat-armor {
    --arc-radius: 216px;
    --arc-angle: 90deg;
}

.stat-armor .stat-label {
    top: 25px;
    right: 30px;
}

.stat-armor .stat-value {
    top: 40px;
    right: 30px;
}

.stat-armor .stat-icon {
    top: 10px;
    right: 25px;
}

/* Shields - Top Right (Layer 5, outermost) */
.stat-shields {
    --arc-radius: 228px;
    --arc-angle: 90deg;
}

.stat-shields .stat-label {
    top: 20px;
    right: 10px;
}

.stat-shields .stat-value {
    top: 35px;
    right: 10px;
}

.stat-shields .stat-icon {
    top: 5px;
    right: 5px;
}

/* Throttle - Left (Layer 2, outer, paired with speed) */
.stat-throttle {
    --arc-radius: 192px;
    --arc-angle: 50deg;
}

.stat-throttle .stat-label {
    top: 50%;
    left: 20px !important;
    transform: translateY(-100%) !important;
}

.stat-throttle .stat-value {
    top: 50%;
    left: 20px !important;
    transform: translateY(-10%) !important;
}

.stat-throttle .stat-icon {
    top: 50%;
    left: 5px !important;
    transform: translateY(-50%) !important;
}

/* Speed - Left */
.stat-speed {
    --arc-radius: 180px;
    --arc-angle: 50deg;
}

.stat-speed .stat-label {
    top: 50%;
    left: 90px !important;
    transform: translateY(-100%) !important;
}

.stat-speed .stat-value {
    top: 50%;
    left: 90px !important;
    transform: translateY(-10%) !important;
}

.stat-speed .stat-icon {
    top: 50%;
    left: 15px;
    transform: translateY(-50%) !important;
}

/* Action Progress - Bottom */
.stat-action {
    --arc-radius: 210px;
    --arc-angle: 80deg;
}

.stat-action .stat-label {
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) !important;
}

.stat-action .stat-value {
    bottom: 55px;
    left: 50%;
    transform: translateX(-50%) !important;
}

.stat-action .stat-icon {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) !important;
}

/* ===== SVG GRADIENTS (defined in JS/HTML) ===== */
/* These are referenced by the stat-arc-path-fill classes above */

/* ===== RESPONSIVE SCALING ===== */
@media (max-width: 1919px) {
    #radialHUD {
        width: 500px;
        height: 500px;
    }

    .radial-hud-center {
        width: 100px;
        height: 100px;
    }

    .stat-label {
        font-size: 10px;
    }

    .stat-value {
        font-size: 12px;
    }

    .stat-icon {
        font-size: 16px;
    }

    /* Scale stat positions proportionally (500/600 = 0.833) */
    .stat-hull .stat-label { top: 25px; right: 42px; }
    .stat-hull .stat-value { top: 38px; right: 42px; }
    .stat-hull .stat-icon { top: 12px; right: 38px; }

    .stat-armor .stat-label { top: 21px; right: 25px; }
    .stat-armor .stat-value { top: 33px; right: 25px; }
    .stat-armor .stat-icon { top: 8px; right: 21px; }

    .stat-shields .stat-label { top: 17px; right: 8px; }
    .stat-shields .stat-value { top: 29px; right: 8px; }
    .stat-shields .stat-icon { top: 4px; right: 4px; }

    .stat-throttle .stat-label { left: 17px !important; }
    .stat-throttle .stat-value { left: 17px !important; }
    .stat-throttle .stat-icon { left: 4px !important; }

    .stat-speed .stat-label { left: 50px !important; }
    .stat-speed .stat-value { left: 50px !important; }
    .stat-speed .stat-icon { left: 30px !important; }

    .stat-action .stat-label { bottom: 33px; }
    .stat-action .stat-value { bottom: 46px; }
    .stat-action .stat-icon { bottom: 17px; }
}

@media (max-width: 1366px) {
    #radialHUD {
        width: 400px;
        height: 400px;
    }

    .radial-hud-center {
        width: 80px;
        height: 80px;
    }

    .stat-label {
        font-size: 9px;
    }

    .stat-value {
        font-size: 11px;
    }

    .stat-icon {
        font-size: 14px;
    }

    .stat-arc-path-bg,
    .stat-arc-path-fill {
        stroke-width: 6;
    }

    /* Scale stat positions proportionally (400/600 = 0.667) */
    .stat-hull .stat-label { top: 20px; right: 33px; }
    .stat-hull .stat-value { top: 30px; right: 33px; }
    .stat-hull .stat-icon { top: 10px; right: 30px; }

    .stat-armor .stat-label { top: 17px; right: 20px; }
    .stat-armor .stat-value { top: 27px; right: 20px; }
    .stat-armor .stat-icon { top: 7px; right: 17px; }

    .stat-shields .stat-label { top: 13px; right: 7px; }
    .stat-shields .stat-value { top: 23px; right: 7px; }
    .stat-shields .stat-icon { top: 3px; right: 3px; }

    .stat-throttle .stat-label { left: 13px !important; }
    .stat-throttle .stat-value { left: 13px !important; }
    .stat-throttle .stat-icon { left: 3px !important; }

    .stat-speed .stat-label { left: 23px; }
    .stat-speed .stat-value { left: 23px; }
    .stat-speed .stat-icon { left: 10px; }

    .stat-action .stat-label { bottom: 27px; }
    .stat-action .stat-value { bottom: 37px; }
    .stat-action .stat-icon { bottom: 13px; }
}

/* ===== HIDE/SHOW TOGGLE ===== */
.radial-hud-hidden {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.radial-hud-visible {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* ===== ZERO STATE (No value) ===== */
.stat-zero .stat-arc-path-fill {
    opacity: 0.3;
}

.stat-zero .stat-value {
    opacity: 0.5;
}

/* ===== PERFORMANCE MODE ===== */
body.performance-mode .stat-arc-path-fill {
    transition: none; /* Disable transitions for better performance */
}

body.performance-mode .stat-arc-path-bg {
    opacity: 0.5; /* Reduce background arc opacity */
}

/* ===== TOOLTIP (on hover) ===== */
.stat-tooltip {
    position: absolute;
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid #58A6FF;
    border-radius: 6px;
    padding: 8px 12px;
    font-family: 'Orbitron', monospace;
    font-size: 11px;
    color: #F0F6FC;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1000;
    box-shadow: 0 0 15px rgba(88, 166, 255, 0.4);
}

.stat-label:hover + .stat-tooltip {
    opacity: 1;
}
