/* mang.quest - Hexagonal Network Descent */
/* Colors from DESIGN.md */
/* #0d0d2b, #1e1e3a, #9b5de5, #00f5d4, #f72585, #0a0a1a, #c4b5fd, #3a0ca3, #6b7280, #e2e8f0, #050510 */

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

:root {
    --bg-deepest: #050510;
    --bg-dark: #0a0a1a;
    --bg-mid: #0d0d2b;
    --bg-panel: #1e1e3a;
    --accent-cyan: #00f5d4;
    --accent-purple: #9b5de5;
    --accent-pink: #f72585;
    --accent-deep-purple: #3a0ca3;
    --text-light: #e2e8f0;
    --text-muted: #6b7280;
    --text-lavender: #c4b5fd;
    --hex-size: 180px;
    --hex-gap: 8px;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg-dark);
    color: var(--text-light);
    font-family: 'Space Grotesk', sans-serif;
    overflow-x: hidden;
    cursor: none;
}

/* ===== SUBSTRATE BACKGROUND ===== */
#substrate {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

#substrate-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ===== BUBBLES LAYER ===== */
#bubbles-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(0, 245, 212, 0.3), rgba(155, 93, 229, 0.1), transparent);
    border: 1px solid rgba(0, 245, 212, 0.15);
    pointer-events: none;
    animation: bubbleFloat linear infinite;
}

@keyframes bubbleFloat {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.6;
    }
    100% {
        transform: translateY(-100vh) translateX(var(--wobble, 30px));
        opacity: 0;
    }
}

/* ===== HEX CURSOR ===== */
#hex-cursor {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    pointer-events: none;
    transform: translate(-50%, -50%);
    transition: opacity 0.3s;
    opacity: 0;
    mix-blend-mode: screen;
}

body:hover #hex-cursor {
    opacity: 1;
}

/* ===== MAIN DESCENT ===== */
#descent {
    position: relative;
    z-index: 2;
}

.descent-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
    position: relative;
}

/* ===== SECTION HEADERS ===== */
.section-header {
    text-align: center;
    margin-bottom: 60px;
}

.layer-label {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent-pink);
    display: block;
    margin-bottom: 12px;
}

.section-title {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: clamp(28px, 6vw, 72px);
    letter-spacing: -0.03em;
    line-height: 1.05;
    color: var(--accent-cyan);
    text-shadow: 0 0 40px rgba(0, 245, 212, 0.3), 0 0 80px rgba(0, 245, 212, 0.1);
}

.section-desc {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 16px;
    font-weight: 300;
    color: var(--text-muted);
    margin-top: 12px;
    letter-spacing: 0.02em;
}

/* ===== SURFACE SECTION ===== */
#surface {
    min-height: 100vh;
    background: radial-gradient(ellipse at center, var(--bg-mid) 0%, var(--bg-dark) 60%, var(--bg-deepest) 100%);
}

.hex-grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(60deg, rgba(0, 245, 212, 0.03) 1px, transparent 1px),
        linear-gradient(-60deg, rgba(0, 245, 212, 0.03) 1px, transparent 1px),
        linear-gradient(0deg, rgba(0, 245, 212, 0.03) 1px, transparent 1px);
    background-size: 60px 104px;
    pointer-events: none;
    opacity: 0.5;
}

.surface-content {
    text-align: center;
    z-index: 2;
    position: relative;
}

.glyph-container {
    margin-bottom: 24px;
}

.glyph-mang {
    font-family: 'Rajdhani', sans-serif;
    font-size: clamp(80px, 20vw, 200px);
    font-weight: 700;
    color: var(--accent-cyan);
    display: block;
    line-height: 1;
    text-shadow:
        0 0 60px rgba(0, 245, 212, 0.5),
        0 0 120px rgba(0, 245, 212, 0.2),
        0 0 200px rgba(155, 93, 229, 0.15);
    animation: glyphPulse 4s ease-in-out infinite;
}

@keyframes glyphPulse {
    0%, 100% {
        text-shadow:
            0 0 60px rgba(0, 245, 212, 0.5),
            0 0 120px rgba(0, 245, 212, 0.2),
            0 0 200px rgba(155, 93, 229, 0.15);
        transform: scale(1);
    }
    50% {
        text-shadow:
            0 0 80px rgba(0, 245, 212, 0.7),
            0 0 160px rgba(0, 245, 212, 0.35),
            0 0 260px rgba(155, 93, 229, 0.25);
        transform: scale(1.02);
    }
}

.glyph-subtitle {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.15em;
    color: var(--text-lavender);
    display: block;
    margin-top: 8px;
}

.surface-title {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: clamp(36px, 8vw, 96px);
    letter-spacing: -0.03em;
    line-height: 1.05;
    color: var(--text-light);
    margin-bottom: 16px;
}

.surface-title .dot {
    color: var(--accent-pink);
}

.surface-tagline {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(14px, 2vw, 20px);
    font-weight: 300;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

.scroll-indicator {
    margin-top: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    animation: scrollBounce 2s ease-in-out infinite;
}

@keyframes scrollBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(10px); }
}

.scroll-hex svg {
    filter: drop-shadow(0 0 8px rgba(0, 245, 212, 0.4));
}

.scroll-text {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* ===== HEXAGONAL GRID ===== */
.hex-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 1200px;
}

.hex-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.hex-row-offset {
    margin-left: calc(var(--hex-size) / 2 + 4px);
}

.hex-cell {
    width: var(--hex-size);
    height: calc(var(--hex-size) * 1.1547);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: linear-gradient(135deg, var(--bg-panel), var(--bg-mid));
    position: relative;
    transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    cursor: none;
}

.hex-cell::before {
    content: '';
    position: absolute;
    inset: 2px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: linear-gradient(135deg, rgba(58, 12, 163, 0.3), rgba(13, 13, 43, 0.9));
    z-index: 0;
}

.hex-cell:hover {
    transform: scale(1.08);
    filter: brightness(1.3);
}

.hex-cell:hover::before {
    background: linear-gradient(135deg, rgba(0, 245, 212, 0.15), rgba(155, 93, 229, 0.2));
}

.hex-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    text-align: center;
}

.hex-icon {
    font-size: 28px;
    color: var(--accent-cyan);
    margin-bottom: 8px;
    filter: drop-shadow(0 0 6px rgba(0, 245, 212, 0.4));
}

.hex-label {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 16px;
    color: var(--text-light);
    letter-spacing: 0.02em;
}

.hex-data {
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    letter-spacing: 0.05em;
}

.hex-stat {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 24px;
    color: var(--accent-cyan);
    text-shadow: 0 0 20px rgba(0, 245, 212, 0.3);
}

/* Small hex cells */
.hex-cell-sm {
    --hex-size: 120px;
}

.hex-grid-small {
    margin-top: 60px;
}

.hex-grid-small .hex-row-offset {
    margin-left: calc(120px / 2 + 4px);
}

/* ===== DATAFLOW SECTION ===== */
#dataflow {
    background: linear-gradient(180deg, transparent 0%, rgba(58, 12, 163, 0.08) 50%, transparent 100%);
}

.flow-visualization {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.flow-stream {
    padding: 24px;
    border: 1px solid rgba(0, 245, 212, 0.1);
    border-radius: 2px;
    background: rgba(13, 13, 43, 0.6);
    clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 20px 100%, 0 calc(100% - 20px));
    transition: border-color 0.3s;
}

.flow-stream:hover {
    border-color: rgba(0, 245, 212, 0.3);
}

.stream-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.stream-name {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 18px;
    color: var(--text-lavender);
}

.stream-rate {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-cyan);
    letter-spacing: 0.05em;
}

.stream-bar {
    height: 4px;
    background: rgba(30, 30, 58, 0.8);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 12px;
}

.stream-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-deep-purple), var(--accent-purple), var(--accent-cyan));
    border-radius: 2px;
    transition: width 1.5s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 0 12px rgba(0, 245, 212, 0.3);
}

.stream-fill.animated {
    width: var(--target-width);
}

.stream-packets {
    display: flex;
    gap: 6px;
}

.packet {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(0, 245, 212, 0.6), rgba(155, 93, 229, 0.3));
    border: 1px solid rgba(0, 245, 212, 0.2);
    animation: packetPulse 2s ease-in-out infinite;
}

.packet:nth-child(2) { animation-delay: 0.3s; }
.packet:nth-child(3) { animation-delay: 0.6s; }
.packet:nth-child(4) { animation-delay: 0.9s; }
.packet:nth-child(5) { animation-delay: 1.2s; }
.packet:nth-child(6) { animation-delay: 1.5s; }

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

/* ===== DEEP NETWORK SECTION ===== */
#deep-net {
    position: relative;
    overflow: hidden;
    background: radial-gradient(ellipse at center, rgba(58, 12, 163, 0.1) 0%, transparent 70%);
}

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

.deep-grid {
    display: flex;
    gap: 80px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.node-cluster {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.cluster-label {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 18px;
    color: var(--text-lavender);
    letter-spacing: 0.05em;
}

.cluster-ring {
    width: 160px;
    height: 160px;
    position: relative;
    border: 1px solid rgba(155, 93, 229, 0.2);
    border-radius: 50%;
}

.node-point {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--bg-panel);
    border: 2px solid var(--accent-purple);
    transition: all 0.3s;
}

.node-point.active {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(0, 245, 212, 0.5), 0 0 24px rgba(0, 245, 212, 0.2);
    animation: nodePing 3s ease-in-out infinite;
}

@keyframes nodePing {
    0%, 100% { box-shadow: 0 0 12px rgba(0, 245, 212, 0.5), 0 0 24px rgba(0, 245, 212, 0.2); }
    50% { box-shadow: 0 0 20px rgba(0, 245, 212, 0.8), 0 0 40px rgba(0, 245, 212, 0.4); }
}

.node-point:nth-child(1) { top: 0; left: 50%; transform: translate(-50%, -50%); }
.node-point:nth-child(2) { top: 25%; right: 0; transform: translate(50%, -50%); }
.node-point:nth-child(3) { top: 75%; right: 0; transform: translate(50%, -50%); }
.node-point:nth-child(4) { bottom: 0; left: 50%; transform: translate(-50%, 50%); }
.node-point:nth-child(5) { top: 75%; left: 0; transform: translate(-50%, -50%); }
.node-point:nth-child(6) { top: 25%; left: 0; transform: translate(-50%, -50%); }

/* ===== ABYSS SECTION ===== */
#abyss {
    background: radial-gradient(ellipse at center bottom, rgba(247, 37, 133, 0.08) 0%, var(--bg-deepest) 70%);
    min-height: 120vh;
}

.abyss-content {
    text-align: center;
    max-width: 700px;
}

.glyph-abyss {
    margin-bottom: 48px;
}

.glyph-mang-deep {
    font-size: clamp(120px, 25vw, 300px);
    color: var(--accent-pink);
    text-shadow:
        0 0 80px rgba(247, 37, 133, 0.6),
        0 0 160px rgba(247, 37, 133, 0.3),
        0 0 300px rgba(155, 93, 229, 0.2);
    animation: abyssPulse 6s ease-in-out infinite;
}

@keyframes abyssPulse {
    0%, 100% {
        text-shadow:
            0 0 80px rgba(247, 37, 133, 0.6),
            0 0 160px rgba(247, 37, 133, 0.3),
            0 0 300px rgba(155, 93, 229, 0.2);
        opacity: 0.8;
    }
    50% {
        text-shadow:
            0 0 120px rgba(247, 37, 133, 0.9),
            0 0 240px rgba(247, 37, 133, 0.5),
            0 0 400px rgba(155, 93, 229, 0.35);
        opacity: 1;
    }
}

.abyss-stats {
    display: flex;
    gap: 48px;
    justify-content: center;
    margin-bottom: 48px;
    flex-wrap: wrap;
}

.abyss-stat-item {
    text-align: center;
}

.abyss-stat-value {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: clamp(28px, 5vw, 48px);
    color: var(--accent-cyan);
    display: block;
    text-shadow: 0 0 20px rgba(0, 245, 212, 0.3);
}

.abyss-stat-label {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

.abyss-message {
    padding: 32px;
    border: 1px solid rgba(247, 37, 133, 0.15);
    background: rgba(5, 5, 16, 0.6);
    clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
}

.abyss-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 16px;
    font-weight: 300;
    line-height: 1.7;
    color: var(--text-lavender);
}

/* ===== TERMINAL SECTION ===== */
#terminal {
    min-height: 80vh;
    padding-bottom: 120px;
}

.terminal-window {
    width: 100%;
    max-width: 700px;
    background: var(--bg-deepest);
    border: 1px solid rgba(0, 245, 212, 0.15);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 0 40px rgba(0, 245, 212, 0.05), 0 20px 60px rgba(0, 0, 0, 0.5);
}

.terminal-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-panel);
    border-bottom: 1px solid rgba(0, 245, 212, 0.1);
}

.terminal-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot-red { background: #ff5f56; }
.dot-yellow { background: #ffbd2e; }
.dot-green { background: #27c93f; }

.terminal-title {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 8px;
}

.terminal-body {
    padding: 24px;
    font-family: 'Space Grotesk', monospace;
    font-size: 13px;
    line-height: 1.8;
}

.terminal-line {
    opacity: 0;
    transform: translateY(8px);
    animation: terminalReveal 0.4s ease forwards;
}

.terminal-line:nth-child(1) { animation-delay: 0.2s; }
.terminal-line:nth-child(2) { animation-delay: 0.6s; }
.terminal-line:nth-child(3) { animation-delay: 1.0s; }
.terminal-line:nth-child(4) { animation-delay: 1.4s; }
.terminal-line:nth-child(5) { animation-delay: 1.8s; }
.terminal-line:nth-child(6) { animation-delay: 2.2s; }
.terminal-line:nth-child(7) { animation-delay: 2.6s; }
.terminal-line:nth-child(8) { animation-delay: 3.2s; }
.terminal-line:nth-child(9) { animation-delay: 3.6s; }
.terminal-line:nth-child(10) { animation-delay: 4.0s; }
.terminal-line:nth-child(11) { animation-delay: 4.4s; }
.terminal-line:nth-child(12) { animation-delay: 4.8s; }

@keyframes terminalReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.prompt {
    color: var(--accent-cyan);
    font-weight: 600;
}

.cmd {
    color: var(--text-light);
}

.dim {
    color: var(--text-muted);
}

.hop {
    color: var(--accent-purple);
    font-weight: 500;
}

.latency {
    color: var(--accent-pink);
}

.cursor-blink {
    animation: blink 1s step-end infinite;
    color: var(--accent-cyan);
}

@keyframes blink {
    50% { opacity: 0; }
}

.terminal-footer {
    text-align: center;
    margin-top: 48px;
}

.footer-text {
    font-family: 'Rajdhani', sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.1em;
}

/* ===== SCROLL-DRIVEN REVEALS ===== */
.descent-section .section-header,
.descent-section .hex-grid,
.descent-section .flow-visualization,
.descent-section .deep-grid,
.descent-section .abyss-content,
.descent-section .terminal-window {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.descent-section.visible .section-header,
.descent-section.visible .hex-grid,
.descent-section.visible .flow-visualization,
.descent-section.visible .deep-grid,
.descent-section.visible .abyss-content,
.descent-section.visible .terminal-window {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger children */
.descent-section.visible .hex-grid {
    transition-delay: 0.2s;
}

.descent-section.visible .flow-visualization {
    transition-delay: 0.2s;
}

.descent-section.visible .deep-grid {
    transition-delay: 0.2s;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    :root {
        --hex-size: 120px;
    }

    .descent-section {
        padding: 60px 20px;
    }

    .hex-row-offset {
        margin-left: calc(var(--hex-size) / 2 + 4px);
    }

    .hex-grid-small .hex-row-offset {
        margin-left: calc(80px / 2 + 4px);
    }

    .hex-cell-sm {
        --hex-size: 80px;
    }

    .deep-grid {
        gap: 40px;
    }

    .abyss-stats {
        gap: 24px;
    }

    .flow-stream {
        padding: 16px;
    }

    .terminal-window {
        max-width: 100%;
    }

    #hex-cursor {
        display: none;
    }
}

@media (max-width: 480px) {
    :root {
        --hex-size: 100px;
    }

    .hex-row {
        gap: 4px;
    }

    .hex-row-offset {
        margin-left: calc(var(--hex-size) / 2 + 2px);
    }

    .cluster-ring {
        width: 120px;
        height: 120px;
    }
}
