/* concurrent.day - Generative Theater of Parallel Execution */

:root {
    --void-black: #0D0F14;
    --scheduler-gray: #2A2D3A;
    --thread-teal: #4ECDC4;
    --contention-coral: #FF6B6B;
    --slate-comment: #7B8794;
    --sync-ivory: #E8E4DD;
    --pipeline-indigo: #5C6BC0;
    --dawn-charcoal: #1A1D26;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--void-black);
    color: var(--sync-ivory);
    font-family: 'Instrument Serif', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.75;
    overflow-x: hidden;
}

/* Generative Canvas */
#threadCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* Central Spine */
.spine {
    position: fixed;
    top: 0;
    left: 50%;
    width: 1px;
    height: 0;
    background: var(--scheduler-gray);
    transform: translateX(-50%);
    z-index: 2;
    transition: height 2s ease, background-color 800ms ease, width 300ms ease;
}

.spine.grown {
    height: 100vh;
}

.spine.contention {
    background: var(--contention-coral);
}

.spine.pipeline {
    width: 3px;
    background: var(--pipeline-indigo);
    animation: spinePulse 3s ease-in-out infinite;
}

@keyframes spinePulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Content Wrapper */
.content-wrapper {
    position: relative;
    z-index: 3;
}

/* Acts */
.act {
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Act: Spawn */
.act-spawn {
    min-height: 100vh;
}

/* Thread Dots */
.thread-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    opacity: 0;
    transition: opacity 600ms ease, transform 800ms ease;
}

.thread-dot.visible {
    opacity: 1;
}

.dot-a {
    background: var(--thread-teal);
    left: calc(50% - 20px);
    transform: translateY(-50%);
}

.dot-b {
    background: var(--contention-coral);
    left: calc(50% + 14px);
    transform: translateY(-50%);
}

/* Split Panels */
.split-panels {
    display: flex;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    gap: 60px;
    padding: 40px;
}

.panel {
    flex: 1;
    position: relative;
}

.panel-left {
    padding-right: 40px;
    text-align: right;
}

.panel-right {
    padding-left: 40px;
    text-align: left;
}

/* Thread Labels */
.thread-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    display: block;
    margin-bottom: 20px;
}

.panel-left .thread-label {
    color: var(--thread-teal);
}

.panel-right .thread-label {
    color: var(--contention-coral);
}

/* Narrative Text */
.narrative {
    color: var(--sync-ivory);
    margin-bottom: 24px;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 700ms ease, transform 700ms ease;
}

.narrative.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Timing Markers */
.timing-marker {
    width: 100%;
    height: 1px;
    background: var(--scheduler-gray);
    position: relative;
    margin: 20px 0;
    opacity: 0.4;
}

.timing-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--slate-comment);
    opacity: 0.4;
    position: absolute;
    right: 20px;
    top: -8px;
}

/* Bridge SVGs */
.bridge-svg {
    width: 80px;
    height: 4px;
    position: relative;
    z-index: 5;
    margin: 20px auto;
    display: block;
}

.bridge-line {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    transition: stroke-dashoffset 600ms ease-out;
}

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

.bridge-dot {
    opacity: 0;
    transition: opacity 400ms ease 400ms;
}

.bridge-line.drawn ~ .bridge-dot {
    opacity: 1;
}

/* Contention */
.contention-panels {
    filter: blur(0);
    transition: filter 600ms ease;
}

.contention-panels.blurred {
    filter: blur(2px);
}

/* Deadlock Knot */
.deadlock-knot {
    position: absolute;
    left: 50%;
    top: 70%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 400ms ease;
    z-index: 10;
}

.deadlock-knot.visible {
    opacity: 1;
}

/* Sync Label */
.sync-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--slate-comment);
    text-align: center;
    opacity: 0;
    transition: opacity 600ms ease;
    margin: 16px 0;
}

.sync-label.visible {
    opacity: 1;
}

/* Pipeline */
.act-pipeline {
    align-items: center;
}

.pipeline-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 40px;
    text-align: center;
    position: relative;
}

.pipeline-chevrons {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: 2px;
    height: 100%;
    pointer-events: none;
}

.pipeline-chevron {
    width: 8px;
    height: 8px;
    border-right: 1px solid var(--pipeline-indigo);
    border-bottom: 1px solid var(--pipeline-indigo);
    transform: rotate(45deg);
    position: absolute;
    left: -3px;
    opacity: 0;
    transition: opacity 400ms ease;
}

.pipeline-chevron.visible {
    opacity: 0.6;
}

.pipeline-text {
    color: var(--sync-ivory);
}

/* Join */
.act-join {
    min-height: 100vh;
    transition: background-color 1s ease;
}

.join-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 40px;
    text-align: center;
}

.join-dots {
    position: relative;
    width: 100px;
    height: 20px;
    margin: 0 auto 40px;
}

.join-dot-a {
    position: absolute;
    left: 20px;
    top: 50%;
    transition: left 1s ease, opacity 600ms ease;
}

.join-dot-b {
    position: absolute;
    left: 74px;
    top: 50%;
    transition: left 1s ease, opacity 600ms ease;
}

.join-dots.merged .join-dot-a {
    left: 47px;
}

.join-dots.merged .join-dot-b {
    left: 47px;
}

.join-text {
    color: var(--sync-ivory);
}

/* Dot Trails */
.dot-trail {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    position: fixed;
    pointer-events: none;
    z-index: 4;
    transition: opacity 300ms ease;
}

/* Responsive */
@media (max-width: 768px) {
    .split-panels {
        flex-direction: column;
        gap: 30px;
        padding: 20px;
    }

    .panel-left,
    .panel-right {
        text-align: left;
        padding: 0;
    }

    .spine {
        display: none;
    }
}
