/* === CSS Custom Properties === */
:root {
    --bg-primary: #1A1A2E;
    --bg-secondary: #0F0F1B;
    --text-primary: #DCDCDC;
    --text-secondary: #9A8FA8;
    --accent-1: #00E5FF;
    --accent-1-shift: #00D9F5;
    --accent-2: #FF006E;
    --accent-2-shift: #E60063;
    --accent-3: #FFD700;
    --accent-3-shift: #FFC700;
    --accent-4: #8B5CF6;
    --accent-4-shift: #7C3AED;
    --glow-primary: rgba(0, 229, 255, 0.3);
    --current-accent: #00E5FF;
    --current-accent-glow: rgba(0, 229, 255, 0.3);
    --tree-opacity: 0.02;
    --scroll-progress: 0;
}

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

html {
    scroll-behavior: auto;
}

body {
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.4vw, 1.1rem);
    line-height: 1.7;
    overflow-x: hidden;
    min-height: 600vh;
}

/* === Typography === */
.node-label {
    font-family: 'Unbounded', sans-serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 3vw, 2.5rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--current-accent);
}

.kr-text {
    font-family: 'Noto Sans KR', sans-serif;
    letter-spacing: 0.04em;
}

.mono-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--text-secondary);
    opacity: 0.5;
}

.node-content p {
    font-family: 'Outfit', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.4vw, 1.1rem);
    line-height: 1.7;
    color: var(--text-primary);
    text-align: left;
}

/* === Scene Container === */
#scene-container {
    position: relative;
    width: 100%;
    min-height: 600vh;
}

/* === Layers === */
.layer-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: var(--tree-opacity);
}

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

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

.layer-nodes {
    position: relative;
    width: 100%;
    z-index: 2;
}

/* === Scroll Fields === */
.scroll-field {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#field-opening {
    height: 100vh;
    flex-direction: column;
    gap: 2rem;
}

#field-branch {
    height: 100vh;
}

#field-interconnection {
    height: 150vh;
}

#field-collision {
    height: 100vh;
}

#field-resolution {
    height: 100vh;
}

#field-closing {
    height: 50vh;
    flex-direction: column;
    gap: 3rem;
}

/* === Node Base Styles === */
.seed-node,
.branch-node,
.leaf-node,
.connector-node {
    position: absolute;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 1.5s ease, transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform, opacity;
}

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

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

.leaf-node {
    width: 28px;
    height: 28px;
}

.connector-node {
    width: 15px;
    height: 15px;
}

/* === Node Core === */
.node-core {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--current-accent);
    background: rgba(26, 26, 46, 0.85);
    z-index: 2;
    overflow: hidden;
}

.seed-node .node-core {
    border-width: 2px;
}

.connector-node .node-core {
    border-width: 1px;
    background: rgba(26, 26, 46, 0.6);
}

/* === Node Glow === */
.node-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 150%;
    height: 150%;
    border-radius: 50%;
    background: radial-gradient(circle, var(--current-accent-glow) 0%, transparent 70%);
    z-index: 1;
    pointer-events: none;
    filter: blur(8px);
    transition: filter 0.4s ease, width 0.4s ease, height 0.4s ease;
}

.seed-node .node-glow {
    width: 200%;
    height: 200%;
    filter: blur(15px);
}

/* === Node Content (hidden by default, shown on hover) === */
.node-content {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 220px;
    padding: 1rem;
    background: rgba(15, 15, 27, 0.92);
    border: 1px solid rgba(0, 229, 255, 0.15);
    border-radius: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease, transform 0.5s ease;
    transform: translateX(-50%) translateY(10px);
    z-index: 10;
    margin-top: 10px;
}

/* === Node Hover States === */
.seed-node:hover,
.branch-node:hover {
    transform: scale(1.2);
    opacity: 1 !important;
}

.seed-node:hover .node-glow,
.branch-node:hover .node-glow {
    filter: blur(20px);
    width: 220%;
    height: 220%;
}

.branch-node:hover .node-content {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

/* === Node Ripple === */
.node-ripple-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px solid var(--current-accent);
    opacity: 0.6;
    animation: ripple-expand 0.8s ease-out forwards;
    pointer-events: none;
}

@keyframes ripple-expand {
    0% {
        width: 100%;
        height: 100%;
        opacity: 0.6;
    }
    100% {
        width: 300%;
        height: 300%;
        opacity: 0;
    }
}

/* === Seed Primary Node Specific === */
#seed-primary {
    position: relative;
    opacity: 0;
}

#seed-primary .node-label {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 4vw, 3rem);
    color: var(--accent-1);
}

/* === Field Subtitle === */
.field-subtitle {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.4vw, 1.1rem);
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 2s ease;
    text-align: center;
}

/* === Connection Lines === */
#connection-lines line,
#connection-lines path {
    stroke-linecap: round;
    fill: none;
}

.connection-line {
    stroke: url(#line-gradient);
    stroke-width: 1.2;
    stroke-dasharray: 8 4;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.connection-line.visible {
    opacity: 0.6;
    animation: dash-flow 3s linear infinite;
}

@keyframes dash-flow {
    0% {
        stroke-dashoffset: 0;
    }
    100% {
        stroke-dashoffset: -24;
    }
}

/* === Glitch Effects === */
.glitch-label {
    position: relative;
}

.glitch-label::before,
.glitch-label::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch-label::before {
    color: var(--accent-2);
    clip-path: inset(0 0 60% 0);
    transform: translate(2px, -1px);
    opacity: 0.5;
}

.glitch-label::after {
    color: var(--accent-1);
    clip-path: inset(60% 0 0 0);
    transform: translate(-1px, 1px);
    opacity: 0.5;
}

@keyframes glitch-flicker {
    0%, 95%, 100% {
        opacity: 0;
    }
    96%, 99% {
        opacity: 0.5;
    }
}

/* === Closing Section === */
.closing-text {
    text-align: center;
}

.closing-thought {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 3vw, 2.2rem);
    color: var(--text-primary);
    letter-spacing: 0.04em;
    opacity: 0;
    transition: opacity 2s ease;
}

.closing-translation {
    font-family: 'Outfit', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.2vw, 1rem);
    color: var(--text-secondary);
    margin-top: 0.8rem;
    opacity: 0;
    transition: opacity 2.5s ease 0.5s;
}

.closing-domain {
    text-align: center;
}

.closing-domain .domain-name {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 2s ease 1s;
}

/* === Branching Tree SVG === */
#branching-tree line {
    stroke: var(--accent-1);
    stroke-linecap: round;
}

/* === Particle Canvas === */
#particle-canvas {
    opacity: 0;
    transition: opacity 0.5s ease;
}

#particle-canvas.active {
    opacity: 1;
}

/* === Visible state for scroll-triggered nodes === */
.node-visible {
    opacity: 0.7 !important;
}

.seed-node.node-visible {
    opacity: 0.9 !important;
}

.leaf-node.node-visible {
    opacity: 0.5 !important;
}

.connector-node.node-visible {
    opacity: 0.4 !important;
}

/* === Responsive: 768px and below === */
@media (max-width: 768px) {
    .seed-node {
        width: 138px;
        height: 138px;
    }

    .branch-node {
        width: 92px;
        height: 92px;
    }

    .leaf-node {
        width: 32px;
        height: 32px;
    }

    .node-content {
        width: 180px;
        padding: 0.75rem;
    }

    .node-content p {
        font-size: 0.85rem;
    }
}
