/* Infrastructure Visualization Styles */

/* ============================================
   Brand Colors (from tailwind.config.js)
   ============================================ */
:root {
    --gold: #D4AF37;
    --gold-light: #E5C76B;
    --gold-dark: #C9A227;
    --dark: #0D0B09;
    --dark-surface: #1A1714;
    --dark-elevated: #252220;
    --warm-white: #FAF8F5;
    --electric-blue: #00D4FF;
    --secure-green: #00FF88;
    --discord-blue: #5865F2;
    --danger-red: #FF4444;
}

/* ============================================
   Global Fullscreen Setup
   ============================================ */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* ============================================
   Loading Screen
   ============================================ */
#loading-screen {
    background: radial-gradient(ellipse at center, var(--dark-surface) 0%, var(--dark) 100%);
    transition: opacity 0.5s ease-out;
}

.loading-spinner {
    filter: drop-shadow(0 0 10px rgba(212, 175, 55, 0.4));
}

/* ============================================
   Canvas Container
   ============================================ */
#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1; /* Explicitly below overlays */
    background: radial-gradient(ellipse at center, #1A1714 0%, #0D0B09 70%, #000000 100%);
}

#infrastructure-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none; /* Prevent browser gestures */
}

/* Label container for CSS2D labels - above canvas, below overlays */
#label-container {
    z-index: 10;
    overflow: visible;
}

/* CSS2DRenderer creates a child div that needs proper styling */
#label-container > div {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: visible !important;
}

/* Node label styling */
.node-label {
    /* DO NOT add transform - CSS2DRenderer handles positioning */
    /* Styling only */
    color: #FAF8F5 !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    padding: 4px 10px !important;
    background: rgba(13, 11, 9, 0.95) !important;
    border: 2px solid rgba(212, 175, 55, 0.8) !important;
    border-radius: 4px !important;
    white-space: nowrap !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9) !important;
    pointer-events: none !important;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.4) !important;
}

/* ============================================
   Chapter Overlay - Centered in viewport
   ============================================ */
#chapter-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 30;
    background: radial-gradient(ellipse at center, rgba(13, 11, 9, 0.8) 0%, rgba(13, 11, 9, 0) 70%);
    text-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    opacity: 0;
    transition: opacity 0.5s ease;
}

#chapter-overlay.visible {
    opacity: 1;
}

#chapter-overlay > div {
    text-align: center;
    padding: 1rem;
    max-width: 800px;
}

#chapter-title {
    font-size: 2rem;
    margin-bottom: 1rem;
    animation: fadeInUp 0.8s ease-out;
}

#chapter-subtitle {
    font-size: 1.125rem;
    color: rgba(250, 248, 245, 0.7);
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

@media (min-width: 768px) {
    #chapter-title {
        font-size: 3rem;
    }
    #chapter-subtitle {
        font-size: 1.25rem;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Tech Detail Overlay - Bottom center, above controls
   ============================================ */
#tech-overlay {
    position: fixed;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 35;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

#tech-overlay.visible {
    opacity: 1;
}

#tech-overlay > div {
    background: rgba(26, 23, 20, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 8px;
    padding: 12px 24px;
    white-space: nowrap;
}

#tech-detail {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--gold);
    letter-spacing: 0.05em;
}

@media (min-width: 768px) {
    #tech-detail {
        font-size: 1rem;
    }
}

@media (max-width: 640px) {
    #tech-overlay {
        bottom: 120px;
        left: 1rem;
        right: 1rem;
        transform: none;
    }

    #tech-overlay > div {
        white-space: normal;
        text-align: center;
    }
}

/* ============================================
   Tour Controls - Fixed bottom bar
   ============================================ */
#tour-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    transform: translateY(100%);
    transition: transform 0.5s ease;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}

#tour-controls.visible {
    transform: translateY(0);
}

#tour-controls > div {
    background: rgba(26, 23, 20, 0.95);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(212, 175, 55, 0.2);
    padding: 1rem;
}

#progress-bar {
    position: relative;
    height: 4px;
    background: var(--dark-elevated);
    border-radius: 9999px;
    overflow: visible;
    cursor: pointer;
    transition: transform 0.2s;
}

#progress-bar:hover {
    transform: scaleY(1.5);
}

#progress-fill {
    position: absolute;
    height: 100%;
    background: var(--gold);
    border-radius: 9999px;
    box-shadow: 0 0 10px var(--gold);
    transition: width 0.3s ease;
}

.speed-btn {
    border-radius: 4px;
    transition: all 0.2s;
}

.speed-btn:hover,
.speed-btn.active {
    background: rgba(212, 175, 55, 0.1);
}

/* ============================================
   Explore Mode Controls - Bottom center pill
   ============================================ */
#explore-controls {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#explore-controls.visible {
    opacity: 1;
    pointer-events: auto;
}

#explore-controls > div {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(26, 23, 20, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 9999px;
    padding: 12px 24px;
}

/* ============================================
   Info Panel - Right sidebar (desktop), Bottom sheet (mobile)
   ============================================ */
#info-panel {
    position: fixed;
    top: 56px; /* Below nav */
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 384px;
    z-index: 45;
    transform: translateX(100%);
    transition: transform 0.3s ease, visibility 0.3s;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
    visibility: hidden;
}

#info-panel.visible {
    transform: translateX(0);
    visibility: visible;
}

#info-panel > div {
    height: 100%;
    background: rgba(26, 23, 20, 0.95);
    backdrop-filter: blur(8px);
    border-left: 1px solid rgba(212, 175, 55, 0.2);
    overflow-y: auto;
    padding: 1.5rem;
}

/* Mobile: Convert to bottom sheet */
@media (max-width: 640px) {
    #info-panel {
        top: auto;
        right: 0;
        left: 0;
        bottom: 0;
        max-width: 100%;
        max-height: 50vh;
        transform: translateY(100vh);
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    }

    #info-panel.visible {
        transform: translateY(0);
        visibility: visible;
    }

    #info-panel > div {
        border-left: none;
        border-top: 1px solid rgba(212, 175, 55, 0.3);
        border-radius: 16px 16px 0 0;
        padding: 1rem 1.5rem 1.5rem;
    }

    /* Drag handle indicator */
    #info-panel > div::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: rgba(212, 175, 55, 0.4);
        border-radius: 2px;
        margin: 0 auto 1rem;
    }

    /* Make close button more prominent on mobile */
    #info-panel #close-info-btn {
        background: rgba(212, 175, 55, 0.15);
        border: 1px solid rgba(212, 175, 55, 0.3);
        border-radius: 8px;
        padding: 0.5rem;
    }

    #info-panel #close-info-btn:active {
        background: rgba(212, 175, 55, 0.3);
    }
}

#info-panel .info-section {
    padding: 1rem;
    background: rgba(37, 34, 32, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(212, 175, 55, 0.1);
}

#info-panel .info-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gold);
    margin-bottom: 0.5rem;
}

#info-panel .info-value {
    font-family: 'Inter', sans-serif;
    color: var(--warm-white);
}

#info-panel .info-code {
    font-family: monospace;
    font-size: 0.875rem;
    background: rgba(13, 11, 9, 0.5);
    padding: 0.5rem;
    border-radius: 4px;
    color: var(--gold-light);
    overflow-x: auto;
}

#info-panel .connection-list {
    list-style: none;
    padding: 0;
}

#info-panel .connection-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#info-panel .connection-list li:last-child {
    border-bottom: none;
}

#info-panel .connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ============================================
   Service Node Colors
   ============================================ */
.node-nhp-server { background: var(--gold); }
.node-nhp-ac { background: var(--electric-blue); }
.node-tracker-api { background: var(--secure-green); }
.node-cottonwood { background: #9B59B6; }
.node-trail-tales { background: #E67E22; }
.node-downloads { background: #00BCD4; }
.node-discord { background: var(--discord-blue); }
.node-blocked { background: var(--danger-red); }

/* ============================================
   3D Label Styles (CSS2DRenderer)
   Note: Main .node-label styles are defined above with !important
   DO NOT add transform here - CSS2DRenderer handles positioning
   ============================================ */
.node-label .label-title {
    font-weight: 600;
    color: var(--gold);
    margin-bottom: 2px;
}

.node-label .label-ip {
    font-family: monospace;
    font-size: 10px;
    color: rgba(250, 248, 245, 0.5);
}

/* ============================================
   Particle Trail Effect
   ============================================ */
.particle-trail {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 8px var(--gold), 0 0 16px var(--gold-light);
    pointer-events: none;
    opacity: 0;
    animation: particleFade 0.5s ease-out forwards;
}

@keyframes particleFade {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.5);
    }
}

/* ============================================
   Connection Animation Classes
   ============================================ */
.connection-pulse {
    animation: connectionPulse 2s ease-in-out infinite;
}

@keyframes connectionPulse {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 1;
    }
}

/* ============================================
   Keyboard Help
   ============================================ */
#keyboard-help {
    max-width: 200px;
}

#keyboard-help .kbd {
    min-width: 24px;
    text-align: center;
}

/* ============================================
   Touch Hint Animation
   ============================================ */
#touch-hint {
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(-5px);
    }
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 640px) {
    #chapter-title {
        font-size: 1.75rem;
    }

    #chapter-subtitle {
        font-size: 1rem;
    }

    #tech-overlay {
        bottom: 40%;
        left: 1rem;
        right: 1rem;
        transform: none;
    }

    #tech-overlay > div {
        text-align: center;
    }

    .node-label {
        font-size: 10px;
        padding: 4px 8px;
    }

    #info-panel {
        top: 0;
    }
}

/* ============================================
   Dark Mode Scrollbar
   ============================================ */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 55, 0.3) transparent;
}

*::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.3);
    border-radius: 3px;
}

*::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 175, 55, 0.5);
}

/* ============================================
   Focus States for Accessibility
   ============================================ */
button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    #chapter-title,
    #chapter-subtitle {
        animation: none;
    }

    #touch-hint {
        animation: none;
    }

    .particle-trail {
        animation: none;
        display: none;
    }

    .connection-pulse {
        animation: none;
    }

    #progress-fill {
        transition: none;
    }
}

/* ============================================
   Flight Mode HUD
   ============================================ */
#flight-hud {
    font-family: 'Inter', sans-serif;
}

#flight-hud.visible {
    opacity: 1;
}

#flight-hud .kbd-sm {
    display: inline-block;
    min-width: 18px;
    padding: 2px 4px;
    font-family: monospace;
    font-size: 10px;
    text-align: center;
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 3px;
    color: var(--gold);
}

#flight-speed {
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

/* Fly Ship button styling */
#fly-ship-btn {
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 6px;
    padding: 6px 12px;
}

#fly-ship-btn:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--gold);
}

/* Mobile adjustments for flight HUD */
@media (max-width: 640px) {
    #flight-hud > div:first-child > div {
        /* Top bar */
        padding: 0.5rem 1rem;
        gap: 0.5rem;
    }

    #flight-hud > div:nth-child(2) {
        /* Speed indicator - move to top left */
        left: 0.5rem;
        top: auto;
        bottom: 5rem;
        transform: none;
    }

    #flight-hud > div:nth-child(2) > div {
        width: 60px;
        padding: 0.5rem;
    }

    #flight-hud > div:nth-child(2) #flight-speed {
        font-size: 1.5rem;
    }

    #flight-hud > div:nth-child(3) {
        /* Controls hint - hide on mobile, use touch */
        display: none;
    }
}

/* ============================================
   Mobile Flight Controls
   ============================================ */
#mobile-flight-controls {
    font-family: 'Inter', sans-serif;
}

#mobile-flight-controls.visible {
    opacity: 1 !important;
}

/* Thrust button styling */
#mobile-thrust-btn {
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.2),
                inset 0 0 20px rgba(212, 175, 55, 0.1);
    backdrop-filter: blur(8px);
}

#mobile-thrust-btn:active {
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.5),
                inset 0 0 30px rgba(212, 175, 55, 0.3);
    transform: scale(0.95);
}

/* D-pad button styling */
#mobile-pitch-up,
#mobile-pitch-down,
#mobile-roll-left,
#mobile-roll-right {
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.1);
    backdrop-filter: blur(8px);
}

#mobile-pitch-up:active,
#mobile-pitch-down:active,
#mobile-roll-left:active,
#mobile-roll-right:active {
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
    transform: scale(0.9);
}

/* Ensure touch events work properly */
#mobile-flight-controls button {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

/* Hide on desktop (sm breakpoint and up) */
@media (min-width: 640px) {
    #mobile-flight-controls {
        display: none !important;
    }
}
