/* =============================================
   mang.quest - Sci-Fi HUD Overlay Network Quest
   ============================================= */

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background: #080C14;
    color: #C8D6E5;
    font-family: 'Exo 2', sans-serif;
    font-weight: 400;
    font-size: 15px;
    line-height: 1.7;
    overflow-x: hidden;
    min-height: 100vh;
}

/* =============================================
   Network Canvas (Full-viewport SVG background)
   ============================================= */
#network-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    overflow: hidden;
}

#network-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.network-layer {
    transition: transform 0.1s ease-out;
}

.bg-layer circle {
    opacity: 0.2;
}

.bg-layer line {
    stroke: #5A6E82;
    stroke-opacity: 0.15;
    stroke-width: 0.5;
}

.fg-layer circle {
    opacity: 0.4;
}

.fg-layer line {
    stroke: #5A6E82;
    stroke-opacity: 0.3;
    stroke-width: 0.5;
}

/* Node styles */
.network-node {
    transition: opacity 0.3s ease, r 0.3s ease;
    cursor: pointer;
}

.network-node.active {
    opacity: 1 !important;
}

.network-node-border {
    fill: none;
    stroke-width: 1;
    stroke-opacity: 0.5;
}

/* Ripple effects */
.ripple-circle {
    fill: none;
    stroke-width: 1.5;
    pointer-events: none;
}

/* Drift animation for the network graph */
@keyframes networkDrift {
    0% { transform: translate(0, 0); }
    25% { transform: translate(-15px, -10px); }
    50% { transform: translate(10px, -20px); }
    75% { transform: translate(-5px, 15px); }
    100% { transform: translate(0, 0); }
}

#network-bg-layer {
    animation: networkDrift 60s ease-in-out infinite;
}

#network-fg-layer {
    animation: networkDrift 45s ease-in-out infinite reverse;
}

/* =============================================
   Scan Line Overlay
   ============================================= */
#scan-line-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

#scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, rgba(64, 196, 255, 0.1) 20%, rgba(64, 196, 255, 0.4) 50%, rgba(64, 196, 255, 0.1) 80%, transparent 100%);
    animation: scanLineVertical 8s linear infinite;
}

@keyframes scanLineVertical {
    0% { top: -2px; opacity: 0; }
    5% { opacity: 1; }
    95% { opacity: 1; }
    100% { top: 100vh; opacity: 0; }
}

/* =============================================
   Top HUD Bar
   ============================================= */
#top-hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 48px;
    background: rgba(8, 12, 20, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(64, 196, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    transform: translateY(-100%);
    transition: transform 0.4s ease-out;
}

#top-hud.visible {
    transform: translateY(0);
}

.hud-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    color: #5A6E82;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-right: 8px;
}

.hud-title {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 16px;
    color: #40C4FF;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hud-data {
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
    color: rgba(64, 196, 255, 0.7);
    letter-spacing: 0.06em;
}

.hud-left, .hud-center, .hud-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hud-center {
    gap: 12px;
}

/* Progress bar with radar pulse */
.progress-container {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

#radar-pulse {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
}

#radar-pulse::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1px solid rgba(64, 196, 255, 0.2);
}

#radar-pulse::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 50%;
    height: 50%;
    transform-origin: bottom left;
    background: conic-gradient(from 0deg, transparent 0deg, rgba(64, 196, 255, 0.3) 30deg, transparent 60deg);
    animation: radarSweep 3s linear infinite;
}

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

.progress-bar {
    width: 200px;
    height: 4px;
    background: rgba(64, 196, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

#progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #7C4DFF, #40C4FF);
    border-radius: 2px;
    transition: width 0.6s ease-out;
    box-shadow: 0 0 8px rgba(64, 196, 255, 0.4);
}

#progress-text {
    min-width: 32px;
    text-align: right;
}

.coord-label {
    margin-left: 16px;
}

/* =============================================
   Corner Status Panels
   ============================================= */
.corner-panel {
    position: fixed;
    width: 120px;
    height: 60px;
    background: rgba(8, 12, 20, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 90;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 8px 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.corner-panel.visible {
    opacity: 1;
}

.corner-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 9px;
    color: #5A6E82;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.corner-value {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 18px;
    color: #40C4FF;
    letter-spacing: 0.08em;
}

#corner-tl {
    top: 64px;
    left: 16px;
}

#corner-tr {
    top: 64px;
    right: 16px;
    text-align: right;
    align-items: flex-end;
}

#corner-bl {
    bottom: 52px;
    left: 16px;
}

#corner-br {
    bottom: 52px;
    right: 16px;
    text-align: right;
    align-items: flex-end;
}

/* Corner brackets */
.corner-bracket {
    position: absolute;
    width: 16px;
    height: 16px;
    pointer-events: none;
}

.corner-bracket.tl {
    top: -4px;
    left: -4px;
    border-top: 2px solid rgba(64, 196, 255, 0.4);
    border-left: 2px solid rgba(64, 196, 255, 0.4);
}

.corner-bracket.tr {
    top: -4px;
    right: -4px;
    border-top: 2px solid rgba(64, 196, 255, 0.4);
    border-right: 2px solid rgba(64, 196, 255, 0.4);
}

.corner-bracket.bl {
    bottom: -4px;
    left: -4px;
    border-bottom: 2px solid rgba(64, 196, 255, 0.4);
    border-left: 2px solid rgba(64, 196, 255, 0.4);
}

.corner-bracket.br {
    bottom: -4px;
    right: -4px;
    border-bottom: 2px solid rgba(64, 196, 255, 0.4);
    border-right: 2px solid rgba(64, 196, 255, 0.4);
}

/* Additional corner bracket on opposite corners for full frame */
.corner-panel::before,
.corner-panel::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    pointer-events: none;
}

#corner-tl::before {
    bottom: -4px;
    right: -4px;
    border-bottom: 2px solid rgba(64, 196, 255, 0.2);
    border-right: 2px solid rgba(64, 196, 255, 0.2);
}

#corner-tr::before {
    bottom: -4px;
    left: -4px;
    border-bottom: 2px solid rgba(64, 196, 255, 0.2);
    border-left: 2px solid rgba(64, 196, 255, 0.2);
}

#corner-bl::before {
    top: -4px;
    right: -4px;
    border-top: 2px solid rgba(64, 196, 255, 0.2);
    border-right: 2px solid rgba(64, 196, 255, 0.2);
}

#corner-br::before {
    top: -4px;
    left: -4px;
    border-top: 2px solid rgba(64, 196, 255, 0.2);
    border-left: 2px solid rgba(64, 196, 255, 0.2);
}

/* =============================================
   Center Floating Content Panel
   ============================================= */
.floating-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    background: rgba(8, 12, 20, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(64, 196, 255, 0.3);
    border-radius: 12px;
    box-shadow: inset 0 0 30px rgba(64, 196, 255, 0.05), 0 0 40px rgba(8, 12, 20, 0.8);
    padding: 28px 32px;
    z-index: 80;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.floating-panel.visible {
    opacity: 1;
}

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

.panel-node-id {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    color: rgba(64, 196, 255, 0.6);
    letter-spacing: 0.06em;
}

.panel-category {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    color: #FFD740;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 2px 8px;
    border: 1px solid rgba(255, 215, 64, 0.3);
    border-radius: 4px;
}

.panel-title {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 22px;
    color: #40C4FF;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 12px;
    line-height: 1.3;
}

.panel-description {
    font-family: 'Exo 2', sans-serif;
    font-size: 15px;
    line-height: 1.7;
    color: #C8D6E5;
    margin-bottom: 20px;
}

.panel-meta {
    display: flex;
    gap: 20px;
    padding-top: 12px;
    border-top: 1px solid rgba(64, 196, 255, 0.1);
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.meta-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 9px;
    color: #5A6E82;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.meta-value {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: #00E676;
    letter-spacing: 0.08em;
}

/* =============================================
   Node Tooltip
   ============================================= */
.node-tooltip {
    position: fixed;
    background: rgba(8, 12, 20, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(64, 196, 255, 0.3);
    border-radius: 6px;
    padding: 10px 14px;
    width: 200px;
    z-index: 110;
    pointer-events: none;
    transition: opacity 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.node-tooltip.hidden {
    opacity: 0;
    visibility: hidden;
}

.tooltip-title {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 12px;
    color: #40C4FF;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tooltip-connections {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    color: rgba(64, 196, 255, 0.7);
    letter-spacing: 0.06em;
}

/* =============================================
   Bottom Scan Bar
   ============================================= */
#bottom-scan-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 32px;
    background: rgba(8, 12, 20, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(64, 196, 255, 0.15);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transform: translateY(100%);
    transition: transform 0.4s ease-out;
}

#bottom-scan-bar.visible {
    transform: translateY(0);
}

.scan-bar-inner {
    width: 100%;
    height: 2px;
    position: relative;
    overflow: hidden;
}

#scan-sweep {
    position: absolute;
    top: 0;
    left: 0;
    width: 120px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(64, 196, 255, 0.6), transparent);
    animation: scanSweep 4s linear infinite;
}

@keyframes scanSweep {
    0% { transform: translateX(-120px); }
    100% { transform: translateX(calc(100vw + 120px)); }
}

.scan-bar-labels {
    display: flex;
    justify-content: space-between;
    padding: 0 24px;
    margin-top: 2px;
}

.scan-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 9px;
    color: #5A6E82;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* =============================================
   Scroll Container (invisible triggers)
   ============================================= */
#scroll-container {
    position: relative;
    z-index: 10;
    pointer-events: none;
}

.scroll-section {
    height: 100vh;
    width: 100%;
}

/* =============================================
   Initialization Animations
   ============================================= */
.node-init {
    transform: scale(0);
    opacity: 0;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.6s ease;
}

.node-init.revealed {
    transform: scale(1);
    opacity: 1;
}

/* Node pulse for active nodes */
@keyframes nodePulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

.network-node.active {
    animation: nodePulse 2s ease-in-out infinite;
}

/* Ripple animation */
@keyframes rippleExpand {
    0% {
        r: 5;
        opacity: 0.3;
    }
    100% {
        r: 40;
        opacity: 0;
    }
}

.ripple-circle {
    animation: rippleExpand 0.6s ease-out forwards;
}

/* Panel morph transition */
.floating-panel.morphing .panel-title,
.floating-panel.morphing .panel-description,
.floating-panel.morphing .panel-header,
.floating-panel.morphing .panel-meta {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.floating-panel.morphed .panel-title,
.floating-panel.morphed .panel-description,
.floating-panel.morphed .panel-header,
.floating-panel.morphed .panel-meta {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease 0.1s, transform 0.3s ease 0.1s;
}

/* Connector line */
.connector-line {
    stroke: rgba(64, 196, 255, 0.5);
    stroke-width: 1;
    fill: none;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 0.3s ease;
}

.connector-line.drawn {
    stroke-dashoffset: 0;
}

/* =============================================
   Blur-focus effect for node hover
   ============================================= */
#network-svg.node-focused .network-node {
    opacity: 0.08 !important;
    transition: opacity 0.3s ease;
}

#network-svg.node-focused .network-node.highlight {
    opacity: 1 !important;
}

#network-svg.node-focused line {
    stroke-opacity: 0.05;
    transition: stroke-opacity 0.3s ease;
}

#network-svg.node-focused line.highlight {
    stroke-opacity: 0.5;
    stroke: #40C4FF;
}

/* =============================================
   Responsive adjustments
   ============================================= */
@media (max-width: 768px) {
    #top-hud {
        padding: 0 12px;
        font-size: 10px;
    }

    .hud-title {
        font-size: 12px;
    }

    .progress-bar {
        width: 100px;
    }

    .coord-label, #coordinates {
        display: none;
    }

    .corner-panel {
        width: 100px;
        height: 50px;
        padding: 6px 10px;
    }

    .corner-value {
        font-size: 14px;
    }

    .floating-panel {
        padding: 20px 24px;
    }

    .panel-title {
        font-size: 18px;
    }

    .panel-meta {
        gap: 12px;
    }

    #radar-pulse {
        display: none;
    }
}

@media (max-width: 480px) {
    .hud-center .hud-label {
        display: none;
    }

    .corner-panel {
        width: 80px;
        height: 44px;
    }

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

    .corner-label {
        font-size: 8px;
    }

    .floating-panel {
        width: 95%;
        padding: 16px 18px;
    }

    .panel-title {
        font-size: 16px;
    }

    .panel-description {
        font-size: 14px;
    }
}
