/* sim-ai.net - Neural Network Interior Visualization */
/* Palette: Deep Void #060B14, Cortex Layer #0D1B2A, Synapse Blue #00A6FF,
   Dendrite Cyan #00E5FF, Axon White #E0F0FF, Signal Pulse #4FC3F7,
   Inactive Gray #2A3A4A, Spark Gold #FFD54F */

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

html {
    font-size: 16px;
    scroll-behavior: auto;
}

body {
    background: #060B14;
    color: #E0F0FF;
    font-family: 'IBM Plex Mono', monospace;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

/* ============================================
   VIEWPORT & CANVAS (2D Panning System)
   ============================================ */

#viewport {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#canvas {
    position: absolute;
    width: 300vw;
    height: 300vh;
    will-change: transform;
    transition: transform 0.8s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* ============================================
   DENDRITIC BACKGROUND
   ============================================ */

#dendrite-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* ============================================
   CONNECTION SVG
   ============================================ */

#connections-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.connection-path {
    fill: none;
    stroke: #2A3A4A;
    stroke-width: 1.5;
    transition: stroke 0.6s ease;
}

.connection-path.active {
    stroke: #00A6FF;
    filter: url(#glow-filter);
}

.connection-path-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    fill: #4FC3F7;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.data-packet {
    fill: #FFD54F;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.data-packet.traveling {
    opacity: 1;
}

/* ============================================
   NODES (Neural Network Layers)
   ============================================ */

.node {
    position: absolute;
    width: clamp(320px, 28vw, 520px);
    border-radius: 24px;
    border: 1px solid rgba(0, 166, 255, 0.3);
    background: radial-gradient(ellipse at center, #0D1B2A 0%, #060B14 100%);
    z-index: 2;
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out, border-color 0.4s ease-out, box-shadow 0.4s ease-out;
}

.node.dormant {
    opacity: 0.35;
    border-color: rgba(42, 58, 74, 0.6);
    box-shadow: none;
}

.node.activating {
    opacity: 0.75;
    transform: scale(0.96);
    border-color: rgba(0, 166, 255, 0.5);
    box-shadow: 0 0 20px rgba(0, 166, 255, 0.15);
}

.node.active {
    opacity: 1;
    transform: scale(1);
    border-color: rgba(0, 166, 255, 0.7);
    box-shadow: 0 0 30px rgba(0, 166, 255, 0.2), 0 0 60px rgba(0, 166, 255, 0.08);
    animation: node-pulse 3s ease-in-out infinite;
}

@keyframes node-pulse {
    0%, 100% { box-shadow: 0 0 20px rgba(0, 166, 255, 0.15), 0 0 40px rgba(0, 166, 255, 0.05); }
    50% { box-shadow: 0 0 35px rgba(0, 166, 255, 0.3), 0 0 70px rgba(0, 166, 255, 0.1); }
}

.node-halo {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    border: 1px solid rgba(0, 166, 255, 0.3);
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
}

.node.active .node-halo {
    animation: halo-expand 1.5s ease-out forwards;
}

@keyframes halo-expand {
    0% { width: 0; height: 0; opacity: 0.6; }
    100% { width: 200%; height: 200%; opacity: 0; }
}

.node-inner {
    padding: clamp(24px, 3vw, 40px);
}

.node-id {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #4FC3F7;
    display: block;
    margin-bottom: 16px;
}

.node-title {
    font-family: 'Space Mono', monospace;
    font-size: clamp(1.6rem, 3.5vw, 3rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #FFFFFF;
    text-shadow: 0 0 8px rgba(0, 166, 255, 0.4);
    margin-bottom: 20px;
    line-height: 1.2;
}

.node-body {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.875rem, 1.2vw, 1.05rem);
    font-weight: 400;
    line-height: 1.75;
    color: #B8D4E3;
    max-width: 540px;
    margin-bottom: 16px;
}

.node-body.highlight {
    color: #FFFFFF;
    font-weight: 500;
}

.code-block {
    background: rgba(6, 11, 20, 0.8);
    border: 1px solid #2A3A4A;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
}

.code-block code {
    font-family: 'Fira Code', monospace;
    font-size: clamp(0.875rem, 1.2vw, 1.05rem);
    color: #00E5FF;
    display: block;
    line-height: 1.8;
    font-variant-ligatures: common-ligatures;
}

.node-data-readout {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #2A3A4A;
    padding-top: 12px;
    margin-top: 12px;
}

.readout-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #4FC3F7;
}

.readout-value {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.875rem, 1.1vw, 1rem);
    color: #00E5FF;
    font-weight: 700;
}

.node-footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #2A3A4A;
    text-align: center;
}

.footer-label {
    font-family: 'Space Mono', monospace;
    font-size: clamp(1rem, 1.5vw, 1.2rem);
    font-weight: 700;
    color: #FFFFFF;
    text-shadow: 0 0 8px rgba(0, 166, 255, 0.4);
    letter-spacing: 0.08em;
    display: block;
    margin-bottom: 4px;
}

.footer-sub {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #4FC3F7;
    display: block;
}

.node-output {
    border-color: rgba(0, 229, 255, 0.4);
}

.node-output.active {
    border-color: rgba(0, 229, 255, 0.7);
    box-shadow: 0 0 40px rgba(0, 229, 255, 0.25), 0 0 80px rgba(0, 229, 255, 0.1);
}

/* ============================================
   NODE POSITIONS (on 300vw x 300vh canvas)
   ============================================ */

#node-0 { left: 130vw; top: 20vh; }
#node-1 { left: 60vw;  top: 70vh; }
#node-2 { left: 190vw; top: 65vh; }
#node-3 { left: 120vw; top: 120vh; }
#node-4 { left: 50vw;  top: 170vh; }
#node-5 { left: 185vw; top: 168vh; }
#node-6 { left: 120vw; top: 230vh; }

/* ============================================
   MINIMAP
   ============================================ */

#minimap {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 120px;
    height: 120px;
    background: rgba(6, 11, 20, 0.7);
    border: 1px solid #2A3A4A;
    border-radius: 8px;
    opacity: 0.15;
    transition: opacity 0.3s ease;
    z-index: 100;
    cursor: pointer;
    overflow: hidden;
}

#minimap:hover {
    opacity: 0.5;
}

#minimap-svg {
    width: 100%;
    height: 100%;
    animation: minimap-rotate 120s linear infinite;
}

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

.minimap-node {
    transition: fill 0.3s ease, r 0.3s ease;
}

.minimap-connection {
    stroke: #2A3A4A;
    stroke-width: 0.5;
    fill: none;
}

.minimap-connection.active {
    stroke: #00A6FF;
}

/* ============================================
   RADIAL NAVIGATION
   ============================================ */

#nav-trigger {
    position: fixed;
    top: 24px;
    left: 24px;
    width: 48px;
    height: 48px;
    background: rgba(6, 11, 20, 0.8);
    border: 1px solid #2A3A4A;
    border-radius: 50%;
    cursor: pointer;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#nav-trigger:hover {
    border-color: #00A6FF;
    box-shadow: 0 0 12px rgba(0, 166, 255, 0.3);
}

#radial-nav {
    position: fixed;
    top: 24px;
    left: 24px;
    width: 280px;
    height: 280px;
    z-index: 190;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#radial-nav.hidden {
    opacity: 0;
}

#radial-nav:not(.hidden) {
    pointer-events: auto;
}

.radial-item {
    position: absolute;
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #4FC3F7;
    cursor: pointer;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: 4px;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    white-space: nowrap;
}

.radial-item:hover {
    color: #00E5FF;
    border-color: rgba(0, 229, 255, 0.3);
    background: rgba(0, 229, 255, 0.05);
}

.radial-item.current {
    color: #00E5FF;
    border-color: rgba(0, 229, 255, 0.5);
}

/* Position radial items in a circle */
.radial-item[data-node="0"] { top: 10px;  left: 100px; }
.radial-item[data-node="1"] { top: 40px;  left: 180px; }
.radial-item[data-node="2"] { top: 100px; left: 210px; }
.radial-item[data-node="3"] { top: 160px; left: 180px; }
.radial-item[data-node="4"] { top: 200px; left: 100px; }
.radial-item[data-node="5"] { top: 160px; left: 20px;  }
.radial-item[data-node="6"] { top: 100px; left: 10px;  }

/* ============================================
   SCROLL PROGRESS
   ============================================ */

#scroll-progress {
    position: fixed;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 200px;
    background: #2A3A4A;
    border-radius: 2px;
    z-index: 100;
    opacity: 0.4;
}

#scroll-bar {
    width: 100%;
    height: 0%;
    background: #00A6FF;
    border-radius: 2px;
    transition: height 0.3s ease;
    box-shadow: 0 0 6px rgba(0, 166, 255, 0.5);
}

/* ============================================
   CURSOR TRAIL
   ============================================ */

#cursor-trail {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 300;
}

.trail-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(0, 229, 255, 0.6);
    pointer-events: none;
    transition: none;
    will-change: transform, opacity;
}

/* ============================================
   MOBILE LAYOUT (< 768px)
   ============================================ */

#mobile-layout {
    display: none;
}

@media (max-width: 767px) {
    body {
        overflow-y: auto;
        overflow-x: hidden;
        height: auto;
    }

    #viewport {
        display: none;
    }

    #mobile-layout {
        display: block;
        padding: 60px 20px 40px;
        min-height: 100vh;
    }

    #mobile-nav-trigger {
        position: fixed;
        top: 16px;
        right: 16px;
        width: 40px;
        height: 40px;
        background: rgba(6, 11, 20, 0.9);
        border: 1px solid #2A3A4A;
        border-radius: 8px;
        cursor: pointer;
        z-index: 200;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #mobile-nav {
        position: fixed;
        top: 0;
        right: 0;
        width: 240px;
        height: 100vh;
        background: rgba(6, 11, 20, 0.95);
        border-left: 1px solid #2A3A4A;
        z-index: 190;
        padding: 70px 20px 20px;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }

    #mobile-nav.hidden {
        transform: translateX(100%);
        opacity: 0;
        pointer-events: none;
    }

    .mobile-nav-item {
        font-family: 'Share Tech Mono', monospace;
        font-size: 12px;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        color: #4FC3F7;
        padding: 12px 8px;
        border-bottom: 1px solid #2A3A4A;
        cursor: pointer;
        transition: color 0.2s ease;
    }

    .mobile-nav-item:hover {
        color: #00E5FF;
    }

    .mobile-node {
        position: relative;
        margin-bottom: 20px;
    }

    .mobile-connection-line {
        position: absolute;
        top: -40px;
        left: 50%;
        transform: translateX(-50%);
        width: 2px;
        height: 40px;
        background: repeating-linear-gradient(
            to bottom,
            #2A3A4A 0px,
            #2A3A4A 4px,
            transparent 4px,
            transparent 12px
        );
    }

    .mobile-node:first-of-type .mobile-connection-line {
        display: none;
    }

    .mobile-node-inner {
        background: radial-gradient(ellipse at center, #0D1B2A 0%, #060B14 100%);
        border: 1px solid rgba(0, 166, 255, 0.3);
        border-radius: 16px;
        padding: 24px;
        animation: mobile-pulse 3s ease-in-out infinite;
    }

    @keyframes mobile-pulse {
        0%, 100% { box-shadow: 0 0 15px rgba(0, 166, 255, 0.1); }
        50% { box-shadow: 0 0 25px rgba(0, 166, 255, 0.2); }
    }

    .mobile-node .node-title {
        font-size: clamp(1.2rem, 5vw, 1.6rem);
    }

    .mobile-node .node-body {
        font-size: 0.875rem;
    }

    .mobile-node .code-block code {
        font-size: 0.8rem;
    }

    #minimap {
        display: none;
    }

    #scroll-progress {
        display: none;
    }

    #nav-trigger {
        display: none;
    }

    #radial-nav {
        display: none;
    }
}

/* ============================================
   SYNAPSE GAP TRANSITION
   ============================================ */

@keyframes synapse-spark {
    0% { opacity: 0; transform: scale(0); }
    50% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.5); }
}

.synapse-spark {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #FFD54F;
    pointer-events: none;
    animation: synapse-spark 0.6s ease-out forwards;
}
