/* ============================================
   concurrengine.com - Styles
   Minimalist split-screen concurrency metaphor
   ============================================ */

:root {
    /* Palette */
    --fog-white: #f4f5f7;
    --obsidian-slate: #1a1d23;
    --graphite: #1f2937;
    --silver-mist: #d1d5db;
    --steel-gray: #6b7280;
    --ash: #374151;
    --signal-blue: #3b82f6;
    --deep-slate: #2d3748;
    --warm-gray: #9ca3af;

    /* Typography */
    --font-primary: 'IBM Plex Mono', monospace;
    --font-accent: 'Space Mono', monospace;

    /* Spacing */
    --baseline: 8px;
}

/* ---- Reset & Base ---- */

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

html {
    font-size: 16px;
    scroll-behavior: auto;
}

body {
    font-family: var(--font-primary);
    font-weight: 400;
    color: var(--graphite);
    background: var(--deep-slate);
    cursor: crosshair;
    overflow: hidden;
    line-height: 1.7;
}

/* ---- Entry Overlay ---- */

#entry-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: var(--deep-slate);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease;
}

#entry-overlay.split-left {
    background: linear-gradient(to right, var(--fog-white) 50%, var(--obsidian-slate) 50%);
}

#entry-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

#fork-line {
    position: absolute;
    left: 50%;
    top: 0;
    width: 1px;
    height: 100%;
    background: var(--silver-mist);
    transform: scaleY(0);
    transform-origin: top;
}

#fork-line.animate {
    animation: drawLine 800ms ease-out forwards;
}

@keyframes drawLine {
    from { transform: scaleY(0); }
    to { transform: scaleY(1); }
}

/* ---- Progress Bar ---- */

#progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

#progress-left,
#progress-right {
    height: 2px;
    background: var(--warm-gray);
    width: 0%;
    transition: width 0.1s linear;
}

#progress-left {
    opacity: 0.8;
}

#progress-right {
    opacity: 0.5;
}

/* ---- Site Label ---- */

#site-label {
    position: fixed;
    top: 24px;
    left: 24px;
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    letter-spacing: 0.06em;
    color: var(--graphite);
    z-index: 50;
    transition: opacity 0.4s ease;
}

#site-label.hidden {
    opacity: 0;
}

#site-label.visible {
    opacity: 1;
}

/* ---- Split Container ---- */

#split-container {
    display: grid;
    grid-template-columns: 1fr 1px 1fr;
    height: 100vh;
    width: 100%;
    opacity: 0;
    transition: opacity 0.4s ease;
}

#split-container.visible {
    opacity: 1;
}

/* ---- Panes ---- */

.pane-left {
    background: var(--fog-white);
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
}

.pane-left::-webkit-scrollbar {
    display: none;
}

.pane-right {
    background: var(--obsidian-slate);
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
}

.pane-right::-webkit-scrollbar {
    display: none;
}

/* ---- Divider ---- */

.divider {
    background: var(--steel-gray);
    width: 1px;
    height: 100%;
    position: relative;
    transition: opacity 0.6s ease;
}

.divider.hidden {
    opacity: 0;
}

/* ---- Sections ---- */

.left-section {
    min-height: 100vh;
    scroll-snap-align: start;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 80px 40px 80px 60px;
}

.right-section {
    min-height: 100vh;
    scroll-snap-align: start;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
}

/* ---- Content Blocks (Left Pane) ---- */

.content-block {
    max-width: 520px;
}

.section-label {
    font-family: var(--font-accent);
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--steel-gray);
    display: block;
    margin-bottom: calc(var(--baseline) * 3);
}

h1 {
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--graphite);
    margin-bottom: calc(var(--baseline) * 4);
}

h2 {
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--graphite);
    margin-bottom: calc(var(--baseline) * 3);
}

p {
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    line-height: 1.7;
    letter-spacing: 0.02em;
    color: var(--graphite);
    opacity: 0.85;
}

/* ---- Sync Sections ---- */

.sync-section {
    justify-content: center;
    text-align: center;
    transition: background-color 0.6s ease;
}

.left-section.sync-section {
    padding: 80px 40px;
}

.left-section.sync-section.merged {
    background: var(--deep-slate);
}

.right-section.sync-section.merged {
    background: var(--deep-slate);
}

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

.sync-heading {
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--silver-mist);
    margin-bottom: calc(var(--baseline) * 3);
}

.sync-text {
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    line-height: 1.7;
    letter-spacing: 0.02em;
    color: var(--steel-gray);
}

.left-section.sync-section .sync-heading {
    color: var(--graphite);
    transition: color 0.6s ease;
}

.left-section.sync-section.merged .sync-heading {
    color: var(--silver-mist);
}

.left-section.sync-section .sync-text {
    color: var(--steel-gray);
}

/* ---- Right Pane Displays ---- */

.process-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(var(--baseline) * 4);
}

.annotation {
    font-family: var(--font-accent);
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--steel-gray);
}

.shape-cluster {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    position: relative;
    min-height: 120px;
}

/* ---- Process Shapes ---- */

.process-shape {
    position: relative;
    transition: border-width 0.15s ease, opacity 0.15s ease;
}

.process-shape:hover {
    border-width: 2px;
    opacity: 1;
}

.process-shape.circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 1px solid var(--steel-gray);
    background: transparent;
    animation: pulse 4s ease-in-out infinite;
}

.process-shape.circle.small {
    width: 50px;
    height: 50px;
}

.process-shape.circle.idle {
    opacity: 0.6;
}

.process-shape.circle.terminated {
    opacity: 0.2;
    border-color: var(--steel-gray);
    animation: fadeTerminate 2s ease-in-out infinite;
}

.process-shape.square {
    width: 60px;
    height: 60px;
    border-radius: 0;
    border: 1px solid var(--steel-gray);
    background: rgba(59, 130, 246, 0.15);
}

.process-shape.square.active {
    animation: rotate 12s linear infinite;
}

.process-shape.square.waiting {
    opacity: 0.4;
    animation: pulse 4s ease-in-out infinite;
}

.process-shape.square.deadlocked {
    border-color: var(--signal-blue);
    opacity: 0.7;
    animation: none;
}

/* ---- Data Lines ---- */

.data-line {
    width: 120px;
    height: 1px;
    background: var(--steel-gray);
    position: relative;
    animation: lineReveal 1.2s ease-out forwards;
}

.data-line.deadlock-line {
    background: var(--signal-blue);
    opacity: 0.5;
}

.data-line.reverse {
    transform: rotate(180deg);
    margin-top: -40px;
}

.data-line.channel-line {
    width: 160px;
}

/* ---- Data Dots ---- */

.data-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--signal-blue);
    position: absolute;
    animation: traverse 3s linear infinite;
}

.data-dot.channel-dot {
    animation: traverseChannel 2.5s linear infinite;
}

/* ---- Fork Diagram ---- */

.fork-diagram {
    flex-direction: column;
    gap: 12px;
}

.fork-branch {
    display: flex;
    align-items: center;
    gap: 12px;
}

.branch-line-top,
.branch-line-bottom {
    width: 80px;
}

/* ---- Mutex Diagram ---- */

.mutex-diagram {
    gap: 16px;
}

.mutex-lock {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lock-indicator {
    width: 8px;
    height: 8px;
    background: var(--signal-blue);
    transition: all 0.2s ease;
}

.lock-indicator.locked {
    background: var(--signal-blue);
}

.lock-indicator:hover {
    background: transparent;
    border: 1px solid var(--signal-blue);
}

/* ---- Timing Diagram ---- */

.timing-diagram {
    width: 100%;
    max-width: 400px;
    position: relative;
    padding: 20px 0;
}

.timing-track {
    margin-bottom: 32px;
    position: relative;
}

.timing-track .annotation {
    display: block;
    margin-bottom: 8px;
}

.track-line {
    height: 24px;
    background: rgba(107, 114, 128, 0.15);
    position: relative;
    border-radius: 0;
}

.exec-block {
    position: absolute;
    top: 2px;
    height: 20px;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
    opacity: 0;
    animation: blockAppear 0.6s ease-out forwards;
}

.exec-block:nth-child(1) { animation-delay: 0.2s; }
.exec-block:nth-child(2) { animation-delay: 0.6s; }
.exec-block:nth-child(3) { animation-delay: 1.0s; }

.join-block {
    background: rgba(59, 130, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.6);
}

.join-line {
    position: absolute;
    left: 50%;
    top: 0;
    width: 1px;
    height: 100%;
    border-left: 1px dashed var(--signal-blue);
    opacity: 0.4;
}

.sweep-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 100%;
    background: var(--silver-mist);
    opacity: 0.6;
    animation: sweep 8s linear infinite;
}

/* ---- Scheduler Diagram ---- */

.scheduler-diagram {
    gap: 12px;
}

/* ---- Deadlock Diagram ---- */

.deadlock-diagram {
    flex-wrap: nowrap;
    gap: 16px;
}

/* ---- Fade Reveal ---- */

.fade-reveal {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.fade-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

.fade-delay {
    transition-delay: 150ms;
}

/* ---- Shape Tooltip ---- */

.shape-tooltip {
    position: fixed;
    padding: 4px 10px;
    font-family: var(--font-accent);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--silver-mist);
    background: var(--ash);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 200;
    white-space: nowrap;
}

.shape-tooltip.visible {
    opacity: 1;
}

/* ---- Animations ---- */

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

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

@keyframes traverse {
    0% { left: 0; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { left: calc(100% - 4px); opacity: 0; }
}

@keyframes traverseChannel {
    0% { left: 0; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { left: calc(100% - 4px); opacity: 0; }
}

@keyframes lineReveal {
    0% { clip-path: inset(0 50%); }
    100% { clip-path: inset(0 0%); }
}

@keyframes blockAppear {
    from { opacity: 0; transform: scaleX(0); }
    to { opacity: 1; transform: scaleX(1); }
}

@keyframes sweep {
    from { left: 0; }
    to { left: 100%; }
}

@keyframes fadeTerminate {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 0.3; }
}

/* ---- Responsive (below 768px) ---- */

@media (max-width: 768px) {
    body {
        overflow-y: auto;
    }

    #split-container {
        display: flex;
        flex-direction: column;
        height: auto;
    }

    .pane-left,
    .pane-right {
        overflow-y: visible;
        scroll-snap-type: none;
    }

    .pane-left {
        order: 0;
    }

    .pane-right {
        order: 1;
    }

    .divider {
        width: 100%;
        height: 1px;
        order: 0;
    }

    .left-section,
    .right-section {
        min-height: 100vh;
        scroll-snap-align: none;
    }

    .left-section {
        padding: 60px 24px;
    }

    .right-section {
        padding: 60px 24px;
    }

    #site-label {
        top: 16px;
        left: 16px;
    }

    .content-block {
        max-width: 100%;
    }

    /* Interleave sections via ordering */
    .pane-left .left-section[data-section="1"] { order: 1; }
    .pane-right .right-section[data-section="1"] { order: 2; }
    .pane-left .left-section[data-section="2"] { order: 3; }
    .pane-right .right-section[data-section="2"] { order: 4; }
    .pane-left .left-section[data-section="3"] { order: 5; }
    .pane-right .right-section[data-section="3"] { order: 6; }
    .pane-left .left-section[data-section="4"] { order: 7; }
    .pane-right .right-section[data-section="4"] { order: 8; }
    .pane-left .left-section[data-section="5"] { order: 9; }
    .pane-right .right-section[data-section="5"] { order: 10; }
    .pane-left .left-section[data-section="6"] { order: 11; }
    .pane-right .right-section[data-section="6"] { order: 12; }
    .pane-left .left-section[data-section="7"] { order: 13; }
    .pane-right .right-section[data-section="7"] { order: 14; }
    .pane-left .left-section[data-section="8"] { order: 15; }
    .pane-right .right-section[data-section="8"] { order: 16; }
    .pane-left .left-section[data-section="9"] { order: 17; }
    .pane-right .right-section[data-section="9"] { order: 18; }

    .right-section {
        background: var(--obsidian-slate);
    }

    .left-section {
        background: var(--fog-white);
    }

    .sync-section.merged {
        background: var(--deep-slate) !important;
    }
}
