/* ncbd.dev - Decentralized Network Aesthetic */

:root {
    --void-bg: #0A0E27;
    --consensus-mid: #1A1E3F;
    --consensus-app: #0D1F2D;
    --electric-green: #00FF88;
    --cyan: #00D4FF;
    --magenta: #FF00FF;
    --neutral-light: #D0D8E8;
    --node-gold: #FFD700;
    --error-red: #FF4444;
    --mouse-x: 50%;
    --mouse-y: 50%;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'IBM Plex Sans', sans-serif;
    background: var(--void-bg);
    color: var(--neutral-light);
    overflow-x: hidden;
    line-height: 1.6;
}

/* ===================== CONSTELLATION BACKGROUND ===================== */

.constellation-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* ===================== NAVIGATION (Hex Node Selector) ===================== */

#node-selector {
    position: fixed;
    top: 50%;
    right: 2rem;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.hex-nav {
    width: 36px;
    height: 36px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--consensus-mid);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease, background 0.3s ease;
    will-change: transform;
}

.hex-nav:hover,
.hex-nav.active {
    transform: scale(1.3);
    background: var(--electric-green);
}

.hex-nav.active {
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.6);
}

.hex-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--neutral-light);
    pointer-events: none;
}

.hex-nav.active .hex-label,
.hex-nav:hover .hex-label {
    color: var(--void-bg);
}

/* ===================== TERRITORIES (Sections) ===================== */

.territory {
    position: relative;
    width: 100%;
    overflow: hidden;
    z-index: 1;
}

/* ===================== TERRITORY 1: NODE INCEPTION ===================== */

#territory-1 {
    height: 100vh;
    background: var(--void-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.node-field {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

/* ===================== NODE TYPES ===================== */

.node {
    position: absolute;
    left: var(--x);
    top: var(--y);
    transform: translate(-50%, -50%);
    will-change: transform;
    z-index: 3;
}

.validator-node {
    width: 120px;
    height: 120px;
}

.validator-node .node-core {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle at center, rgba(255, 215, 0, 0.3), transparent 70%);
    border: 2px solid var(--node-gold);
    animation: nodePulse var(--pulse-dur) ease-in-out infinite;
    will-change: transform, opacity;
}

.validator-node .node-ring {
    position: absolute;
    top: -10px;
    left: -10px;
    width: calc(100% + 20px);
    height: calc(100% + 20px);
    border-radius: 50%;
    border: 1px solid rgba(255, 215, 0, 0.2);
    animation: ringExpand var(--pulse-dur) ease-in-out infinite;
    will-change: transform, opacity;
}

.peer-node {
    width: 80px;
    height: 80px;
}

.peer-node .node-core {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle at center, rgba(0, 255, 136, 0.3), transparent 70%);
    border: 2px solid var(--electric-green);
    animation: nodePulse var(--pulse-dur) ease-in-out infinite;
    will-change: transform, opacity;
}

.peer-node .node-ring {
    position: absolute;
    top: -8px;
    left: -8px;
    width: calc(100% + 16px);
    height: calc(100% + 16px);
    border-radius: 50%;
    border: 1px solid rgba(0, 255, 136, 0.15);
    animation: ringExpand var(--pulse-dur) ease-in-out infinite;
    will-change: transform, opacity;
}

.ephemeral-node {
    width: 40px;
    height: 40px;
}

.ephemeral-node .node-core {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle at center, rgba(0, 212, 255, 0.3), transparent 70%);
    border: 1px solid var(--cyan);
    animation: ephemeralFade 3s ease-in-out infinite;
    will-change: transform, opacity;
}

.ephemeral-node .node-ring {
    position: absolute;
    top: -6px;
    left: -6px;
    width: calc(100% + 12px);
    height: calc(100% + 12px);
    border-radius: 50%;
    border: 1px solid rgba(0, 212, 255, 0.1);
    animation: ringExpand 3s ease-in-out infinite;
    will-change: transform, opacity;
}

.conflicted-node {
    width: 70px;
    height: 70px;
}

.conflicted-node .node-core {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle at center, rgba(255, 0, 255, 0.25), transparent 70%);
    border: 2px solid var(--magenta);
    animation: conflictPulse 4s ease-in-out infinite;
    will-change: transform, opacity;
}

.conflicted-node .node-ring {
    position: absolute;
    top: -8px;
    left: -8px;
    width: calc(100% + 16px);
    height: calc(100% + 16px);
    border-radius: 50%;
    border: 1px solid rgba(255, 0, 255, 0.15);
    animation: ringExpand 4s ease-in-out infinite;
    will-change: transform, opacity;
}

/* Mini nodes for peer cards */
.mini-node {
    width: 24px !important;
    height: 24px !important;
    position: relative !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    flex-shrink: 0;
}

.mini-node .node-core {
    width: 100% !important;
    height: 100% !important;
}

.mini-node .node-ring {
    top: -4px !important;
    left: -4px !important;
    width: calc(100% + 8px) !important;
    height: calc(100% + 8px) !important;
}

/* ===================== NODE ANIMATIONS ===================== */

@keyframes nodePulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.08); opacity: 1; }
}

@keyframes ringExpand {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.15); opacity: 0.1; }
}

@keyframes ephemeralFade {
    0%, 100% { opacity: 0.2; transform: scale(0.9); }
    50% { opacity: 0.9; transform: scale(1.05); }
}

@keyframes conflictPulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    30% { transform: scale(1.12); opacity: 1; }
    60% { transform: scale(0.95); opacity: 0.7; }
}

/* ===================== CONNECTION LINES ===================== */

.connection-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.connection-line {
    stroke: var(--electric-green);
    stroke-width: 1;
    opacity: 0.3;
    stroke-dasharray: 8 4;
    animation: dashFlow 3s linear infinite;
}

@keyframes dashFlow {
    to { stroke-dashoffset: -24; }
}

/* ===================== DATA PACKETS ===================== */

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

.data-packet {
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--electric-green);
    box-shadow: 0 0 8px var(--electric-green), 0 0 16px rgba(0, 255, 136, 0.4);
    will-change: transform;
}

/* ===================== HERO TEXT ===================== */

.hero-text {
    position: relative;
    z-index: 5;
    text-align: center;
}

.hero-title {
    font-family: 'Space Mono', monospace;
    font-size: clamp(2.5rem, 8vw, 5rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--electric-green);
    text-shadow: 0 0 40px rgba(0, 255, 136, 0.4), 0 0 80px rgba(0, 255, 136, 0.15);
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.75rem, 1.2vw, 0.875rem);
    font-weight: 500;
    color: var(--cyan);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    opacity: 0.7;
}

/* ===================== TERRITORY 2: CONSENSUS LAYERS ===================== */

#territory-2 {
    height: 110vh;
    background: var(--void-bg);
    position: relative;
}

.consensus-layers {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.consensus-layer {
    flex: 1;
    position: relative;
    padding: 3rem 4rem;
    overflow: hidden;
    transition: background-color 0.8s ease;
}

.layer-app {
    background: var(--consensus-app);
}

.layer-consensus {
    background: var(--consensus-mid);
}

.layer-validation {
    background: var(--void-bg);
}

.layer-label {
    position: absolute;
    top: 1rem;
    left: 2rem;
    z-index: 5;
}

.layer-content {
    position: relative;
    width: 100%;
    height: 100%;
}

.floating-layer-node {
    position: absolute;
    left: var(--x);
    top: var(--y);
}

/* ===================== TYPOGRAPHY ===================== */

.territory-heading {
    font-family: 'Space Mono', monospace;
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--electric-green);
    margin-bottom: 1.5rem;
}

.body-text {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: clamp(1rem, 1.5vw, 1.125rem);
    font-weight: 400;
    line-height: 1.6;
    color: var(--neutral-light);
    max-width: 480px;
}

.code-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.75rem, 1.2vw, 0.875rem);
    font-weight: 500;
    color: var(--electric-green);
}

/* ===================== TEXT BLOCKS ===================== */

.text-block {
    position: absolute;
    left: var(--x);
    top: var(--y);
    max-width: 480px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.text-block.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===================== HEX BADGES ===================== */

.hex-badge {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: 60px;
    height: 60px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: rgba(0, 255, 136, 0.15);
    border: 1px solid rgba(0, 255, 136, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.hex-badge.rotating {
    animation: hexRotate var(--rot-dur) linear infinite;
    will-change: transform;
}

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

.hex-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--electric-green);
    animation: hexRotateReverse var(--rot-dur) linear infinite;
}

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

/* ===================== CONSENSUS FLOW SVG ===================== */

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

.flow-path {
    fill: none;
    stroke: var(--electric-green);
    stroke-width: 1.5;
    opacity: 0.2;
    stroke-dasharray: 12 6;
    animation: flowUp 5s linear infinite;
}

.flow-path-2 {
    stroke: var(--cyan);
    animation-duration: 7s;
    animation-delay: 1s;
}

.flow-path-3 {
    stroke: var(--magenta);
    opacity: 0.12;
    animation-duration: 9s;
    animation-delay: 2s;
}

@keyframes flowUp {
    to { stroke-dashoffset: -36; }
}

/* ===================== TERRITORY 3: PEER DISCOVERY ===================== */

#territory-3 {
    height: 100vh;
    background: var(--void-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem 0;
    background-image:
        radial-gradient(circle 1px at 10% 20%, rgba(0, 255, 136, 0.08) 100%, transparent 100%),
        radial-gradient(circle 1px at 30% 60%, rgba(0, 255, 136, 0.06) 100%, transparent 100%),
        radial-gradient(circle 1px at 50% 40%, rgba(0, 212, 255, 0.05) 100%, transparent 100%),
        radial-gradient(circle 1px at 70% 80%, rgba(0, 255, 136, 0.07) 100%, transparent 100%),
        radial-gradient(circle 1px at 90% 30%, rgba(0, 212, 255, 0.06) 100%, transparent 100%);
}

.peer-heading {
    text-align: center;
    padding: 0 4rem;
}

.peer-subtitle {
    text-align: center;
    margin-bottom: 3rem;
    opacity: 0.5;
}

.peer-carousel {
    width: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -ms-overflow-style: none;
    scrollbar-width: none;
    padding: 2rem 0;
}

.peer-carousel::-webkit-scrollbar {
    display: none;
}

.peer-track {
    display: flex;
    gap: 2rem;
    padding: 0 calc(50vw - 180px);
    width: max-content;
}

.peer-card {
    width: 320px;
    flex-shrink: 0;
    scroll-snap-align: center;
    background: rgba(26, 30, 63, 0.6);
    border: 1px solid rgba(0, 255, 136, 0.15);
    padding: 1.5rem;
    transition: transform 0.4s ease, border-color 0.4s ease;
    will-change: transform;
}

.peer-card:hover {
    transform: scale(1.05);
    border-color: var(--electric-green);
}

.peer-card-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.peer-graph {
    width: 100%;
    height: 120px;
    margin-bottom: 1rem;
    background: rgba(10, 14, 39, 0.5);
    border: 1px solid rgba(0, 255, 136, 0.05);
}

.peer-graph svg {
    width: 100%;
    height: 100%;
}

.peer-stats {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.peer-stats .code-label {
    font-size: 0.7rem;
    opacity: 0.6;
}

/* ===================== TERRITORY 4: PROTOCOL FLOW ===================== */

#territory-4 {
    min-height: 90vh;
    background: var(--void-bg);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6rem 4rem;
}

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

.protocol-path {
    fill: none;
    stroke: var(--electric-green);
    stroke-width: 2;
    opacity: 0.15;
    stroke-dasharray: 16 8;
    animation: protocolFlow 4s linear infinite;
}

.protocol-path-2 {
    stroke: var(--cyan);
    opacity: 0.1;
    animation-duration: 6s;
    animation-delay: 1.5s;
}

.protocol-path-3 {
    stroke: var(--magenta);
    opacity: 0.08;
    animation-duration: 8s;
    animation-delay: 3s;
}

@keyframes protocolFlow {
    to { stroke-dashoffset: -48; }
}

.protocol-content {
    position: relative;
    z-index: 5;
    width: 100%;
    max-width: 1200px;
    min-height: 400px;
}

/* ===================== HEX INFO BLOCKS ===================== */

.hex-info-block {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: 280px;
    padding: 2rem;
    clip-path: polygon(15% 0%, 85% 0%, 100% 15%, 100% 85%, 85% 100%, 15% 100%, 0% 85%, 0% 15%);
    background: rgba(26, 30, 63, 0.7);
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.hex-info-block.visible {
    opacity: 1;
    transform: scale(1);
}

.hex-title {
    font-family: 'Space Mono', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--electric-green);
    letter-spacing: 0.06em;
    margin: 0.5rem 0;
}

.hex-info-block .body-text {
    font-size: 0.875rem;
    opacity: 0.8;
}

.hex-info-block .code-label {
    font-size: 0.7rem;
    opacity: 0.5;
}

/* ===================== EXIT NODE ===================== */

.exit-node-container {
    position: relative;
    z-index: 5;
    margin-top: 4rem;
    display: flex;
    justify-content: center;
}

.exit-node {
    width: 140px;
    height: 140px;
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.exit-node-core {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle at center, var(--electric-green), transparent);
    opacity: 0.6;
    transition: opacity 0.4s ease, transform 0.4s ease;
    will-change: transform;
}

.exit-node:hover .exit-node-core {
    opacity: 1;
    transform: scale(1.3);
}

.exit-node-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1px solid rgba(0, 255, 136, 0.3);
    animation: exitRingPulse 6s ease-in-out infinite;
    will-change: transform, opacity;
}

.exit-ring-2 {
    animation-delay: 3s;
    border-color: rgba(0, 212, 255, 0.2);
}

@keyframes exitRingPulse {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.4); opacity: 0; }
}

.exit-label {
    position: absolute;
    bottom: -2rem;
    white-space: nowrap;
    font-size: 0.75rem;
    opacity: 0.4;
    transition: opacity 0.3s ease;
}

.exit-node:hover .exit-label {
    opacity: 1;
}

/* ===================== TERRITORY TRANSITIONS (Scroll-triggered) ===================== */

.territory {
    opacity: 0.4;
    transition: opacity 0.8s ease;
}

.territory.in-view {
    opacity: 1;
}

.territory.in-view .node {
    animation-play-state: running;
}

/* ===================== RESPONSIVE ===================== */

@media (max-width: 768px) {
    #node-selector {
        right: 1rem;
        gap: 0.8rem;
    }

    .hex-nav {
        width: 28px;
        height: 28px;
    }

    .consensus-layer {
        padding: 2rem;
    }

    .text-block {
        position: relative;
        left: auto;
        top: auto;
        margin: 1rem 0;
    }

    .hex-badge {
        display: none;
    }

    .peer-track {
        padding: 0 2rem;
    }

    .peer-card {
        width: 260px;
    }

    .hex-info-block {
        position: relative;
        left: auto;
        top: auto;
        width: 100%;
        clip-path: none;
        margin-bottom: 2rem;
    }

    .protocol-content {
        display: flex;
        flex-direction: column;
        gap: 2rem;
        min-height: auto;
    }

    .floating-layer-node {
        display: none;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: clamp(2rem, 10vw, 3rem);
    }

    .territory-heading {
        font-size: clamp(1.5rem, 6vw, 2rem);
    }

    #territory-3 {
        padding: 3rem 0;
    }

    #territory-4 {
        padding: 4rem 1.5rem;
    }

    .peer-card {
        width: 240px;
        padding: 1rem;
    }

    .consensus-layer {
        padding: 1.5rem;
    }
}
