/* concurrent.quest - Glitch Art Concurrent Execution */

:root {
    --void-black: #0D0D0D;
    --deep-graphite: #1A1A2E;
    --charcoal-slate: #16213E;
    --sync-green: #4ECCA3;
    --wait-amber: #E8D44D;
    --block-red: #E94560;
    --signal-white: #E0E0E0;
    --fog-gray: #6B7B8D;
    --cyan-tear: #00FFF5;
    --magenta-shift: #FF00E5;
}

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

body {
    background: var(--void-black);
    color: var(--signal-white);
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.72;
    overflow-x: hidden;
}

/* Scanlines */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 1px,
        rgba(0, 255, 245, 0.03) 1px,
        rgba(0, 255, 245, 0.03) 2px
    );
}

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

/* Glitch Layers */
.glitch-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    opacity: 0;
    transition: none;
}

.glitch-top {
    clip-path: inset(0 0 50% 0);
    background: rgba(0, 255, 245, 0.05);
}

.glitch-bottom {
    clip-path: inset(50% 0 0 0);
    background: rgba(255, 0, 229, 0.05);
}

.glitch-top.active {
    opacity: 1;
    transform: translateX(5px);
}

.glitch-bottom.active {
    opacity: 1;
    transform: translateX(-5px);
}

/* Scheduler Bar */
.scheduler-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: rgba(13, 13, 13, 0.92);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    border-bottom: 1px solid rgba(78, 204, 163, 0.15);
}

.scheduler-name {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: var(--sync-green);
    letter-spacing: 0.05em;
}

.thread-indicators {
    display: flex;
    gap: 10px;
    align-items: center;
}

.indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 300ms ease;
}

.indicator.visible {
    opacity: 1;
}

.ind-running {
    background: var(--sync-green);
    animation: indicatorPulse 2s ease-in-out infinite;
}

.ind-waiting {
    background: var(--wait-amber);
    animation: indicatorPulse 2.5s ease-in-out infinite;
}

.ind-blocked {
    background: var(--block-red);
    animation: indicatorPulse 1.5s ease-in-out infinite;
}

@keyframes indicatorPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Lane System */
.lanes {
    display: grid;
    grid-template-columns: 55fr 30fr 15fr;
    min-height: 100vh;
    padding-top: 48px;
    position: relative;
    z-index: 1;
}

.lane {
    position: relative;
}

.lane-0 {
    border-right: 1px dashed rgba(78, 204, 163, 0.3);
}

.lane-1 {
    background: var(--deep-graphite);
    border-right: 1px dashed rgba(78, 204, 163, 0.3);
}

.lane-2 {
    background: var(--charcoal-slate);
    position: sticky;
    top: 48px;
    height: calc(100vh - 48px);
    overflow: hidden;
}

/* Sections */
.section {
    padding: 60px 40px;
}

.section-spawn {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Spawn Screen */
.spawn-screen {
    text-align: center;
}

.cursor-container {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: var(--sync-green);
    min-height: 2em;
}

.typed-text {
    letter-spacing: 0.05em;
}

.cursor {
    animation: blink 0.8s step-end infinite;
    color: var(--sync-green);
}

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

.subtitle {
    font-family: 'Orbitron', sans-serif;
    font-weight: 500;
    font-size: clamp(0.8rem, 1.5vw, 1.1rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--wait-amber);
    margin-top: 16px;
    opacity: 0;
    transition: opacity 800ms ease;
}

.subtitle.visible {
    opacity: 1;
}

/* Section Headers */
.section-header {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    letter-spacing: -0.01em;
    margin-bottom: 20px;
    color: var(--signal-white);
}

.thread-id {
    font-weight: 500;
    color: var(--sync-green);
    font-size: 0.6em;
    display: block;
    margin-bottom: 4px;
}

.section-contention .thread-id {
    color: var(--wait-amber);
}

/* Section Content - Reveal animations */
.section-content {
    margin-bottom: 40px;
    max-width: 700px;
}

.reveal-left {
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 500ms ease-out, transform 500ms ease-out;
}

.reveal-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-right {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 500ms ease-out, transform 500ms ease-out;
}

.reveal-right.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Barrier Lines */
.barrier-line {
    width: 100%;
    height: 1px;
    margin: 40px 0;
    position: relative;
    background: repeating-linear-gradient(
        to right,
        var(--wait-amber) 0px,
        var(--wait-amber) 8px,
        transparent 8px,
        transparent 12px
    );
    opacity: 0.4;
    transition: transform 300ms ease;
}

.barrier-line.pulse {
    animation: barrierPulse 300ms ease;
}

@keyframes barrierPulse {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(1.5); }
}

/* Deadlock Zone */
.deadlock-zone {
    margin: 60px 0;
    text-align: center;
}

.deadlock-card {
    display: inline-block;
    background: var(--deep-graphite);
    border: 1px solid var(--block-red);
    padding: 20px 30px;
    margin: 10px;
    cursor: pointer;
    transition: border-color 500ms ease, background 300ms ease;
    max-width: 280px;
    vertical-align: top;
}

.deadlock-card.resolved {
    border-color: var(--sync-green);
}

.deadlock-state {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: var(--block-red);
    display: block;
    margin-bottom: 8px;
    transition: color 500ms ease;
}

.deadlock-card.resolved .deadlock-state {
    color: var(--sync-green);
}

.deadlock-card p {
    font-size: 0.85rem;
    color: var(--fog-gray);
}

.deadlock-arrows {
    display: block;
    width: 300px;
    height: 120px;
    margin: 0 auto;
}

.deadlock-path {
    stroke-dasharray: 400;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 500ms ease;
}

.deadlock-path.breaking {
    stroke-dashoffset: 400;
}

.deadlock-hint {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: var(--fog-gray);
    margin-top: 12px;
    opacity: 0.5;
}

/* Sync Banner */
.sync-banner {
    background: var(--deep-graphite);
    padding: 40px 20px;
    text-align: center;
    margin: 40px -40px;
    border-top: 1px solid rgba(232, 212, 77, 0.3);
    border-bottom: 1px solid rgba(232, 212, 77, 0.3);
}

.sync-banner span {
    font-family: 'Orbitron', sans-serif;
    font-weight: 500;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--wait-amber);
}

/* Complete Section */
.complete-header {
    text-align: center;
    font-size: clamp(2rem, 5vw, 4rem);
}

.complete-header .thread-id {
    color: var(--sync-green);
}

.final-cursor {
    text-align: center;
    margin-top: 40px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.5rem;
    color: var(--sync-green);
}

/* Lane 1 - Annotations */
.lane-content {
    padding: 60px 20px;
    will-change: transform;
}

.annotation {
    margin-bottom: 60px;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 500ms ease-out, transform 500ms ease-out;
}

.annotation.visible {
    opacity: 1;
    transform: translateX(0);
}

.anno-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--fog-gray);
    display: block;
    margin-bottom: 8px;
}

.anno-code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.55;
    color: var(--sync-green);
    background: rgba(13, 13, 13, 0.5);
    padding: 12px;
    border-left: 2px solid rgba(78, 204, 163, 0.3);
    white-space: pre;
    overflow-x: auto;
}

/* Lane 2 - Timeline */
.timeline-header {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    color: var(--fog-gray);
    padding: 12px 8px;
    text-align: center;
    border-bottom: 1px solid rgba(78, 204, 163, 0.15);
}

.timeline-bars {
    padding: 8px 4px;
    height: calc(100% - 40px);
    overflow: hidden;
}

.timeline-bar {
    height: 4px;
    margin-bottom: 6px;
    border-radius: 1px;
    opacity: 0.7;
    transition: width 400ms ease;
    will-change: transform;
}

.timeline-bar.bar-green {
    background: var(--sync-green);
}

.timeline-bar.bar-amber {
    background: var(--wait-amber);
}

.timeline-bar.bar-red {
    background: var(--block-red);
}

/* Responsive */
@media (max-width: 768px) {
    .lanes {
        grid-template-columns: 1fr;
    }

    .lane-0 {
        border-right: none;
        border-left: 4px solid var(--sync-green);
    }

    .lane-1 {
        border-right: none;
        border-left: 4px solid var(--wait-amber);
    }

    .lane-2 {
        position: relative;
        top: 0;
        height: auto;
        min-height: 200px;
        border-left: 4px solid var(--block-red);
    }

    .section {
        padding: 40px 20px;
    }

    .sync-banner {
        margin: 40px -20px;
    }
}
