/* ============================================
   CONCURRENGINE.COM - Pixel Art Diorama
   Palette: Cool-grays, flat, zero gradients
   Fonts: Silkscreen, Press Start 2P, VT323
   All colors flat. Zero gradients. Zero opacity
   variations. Every pixel solid at 100%.
   ============================================ */

/* --- PALETTE ---
   Void Black:        #0F1117
   Charcoal Deep:     #18191D
   Smoke Dark:        #22232A
   Gunmetal:          #374151
   Slate Mid:         #4B5563
   Cool Gray:         #6B7280
   Silver Mist:       #9CA3AF
   Ash Light:         #D1D5DB
   Near White:        #E5E7EB
   Rebel Red:         #F87171
   Process Green:     #34D399
   Dead Channel Blue: #3B82F6
   ================================ */

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

html, body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #0F1117;
    font-family: 'Press Start 2P', monospace;
    color: #9CA3AF;
    image-rendering: pixelated;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: unset;
    font-smooth: never;
    cursor: crosshair;
}

/* --- Scanline CRT Overlay --- */
#scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 1px,
        rgba(0, 0, 0, 0.03) 1px,
        rgba(0, 0, 0, 0.03) 2px
    );
}

/* --- Boot Curtain (column-by-column reveal) --- */
#boot-curtain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0F1117;
    z-index: 8000;
    pointer-events: none;
}

#boot-curtain.revealing {
    /* Controlled by JS: clip-path strips generated dynamically */
}

#boot-curtain.done {
    display: none;
}

/* --- Depth Layers --- */
.depth-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    will-change: transform;
}

#layer-bg {
    z-index: 1;
}

#layer-mid {
    z-index: 2;
}

#layer-content {
    z-index: 3;
}

#layer-fg {
    z-index: 4;
    pointer-events: none;
}

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

/* --- Canvas Elements --- */
#bg-canvas,
#mid-canvas,
#fg-canvas,
#ripple-canvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

/* --- Process Monitor Strip (left edge, 48px wide) --- */
#process-monitor {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: 100vh;
    background: #18191D;
    border-right: 2px solid #374151;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 16px;
    gap: 8px;
    z-index: 10;
}

.process-icon {
    width: 40px;
    height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    padding: 4px 2px;
    border: 1px solid transparent;
}

.process-icon:hover {
    border-color: #4B5563;
    background: #22232A;
}

.process-icon.active {
    border-color: #6B7280;
    background: #22232A;
}

.process-icon.active .proc-status {
    background: #34D399;
}

.proc-canvas {
    width: 24px;
    height: 24px;
    image-rendering: pixelated;
}

.proc-label {
    font-family: 'VT323', monospace;
    font-size: 8px;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1;
}

.process-icon:hover .proc-label {
    color: #E5E7EB;
}

.process-icon.active .proc-label {
    color: #34D399;
}

.proc-status {
    width: 4px;
    height: 4px;
    background: #374151;
}

.status-active {
    background: #34D399;
    animation: blink-status 1000ms steps(1) infinite;
}

@keyframes blink-status {
    0%, 100% { background: #34D399; }
    50% { background: #0F1117; }
}

/* --- Scenes --- */
.scene {
    position: absolute;
    top: 0;
    left: 48px;
    width: calc(100vw - 48px);
    height: 100vh;
    display: none;
    align-items: center;
    padding: 40px 60px;
}

.scene.active {
    display: flex;
}

/* Pixel dissolve animation classes - steps(1) for instant on/off per design mandate */
.scene.dissolving-out {
    display: flex;
    animation: pixelDissolveOut 300ms steps(1) forwards;
}

.scene.dissolving-in {
    display: flex;
    animation: pixelDissolveIn 300ms steps(1) forwards;
}

@keyframes pixelDissolveOut {
    0% { visibility: visible; }
    99% { visibility: visible; }
    100% { visibility: hidden; }
}

@keyframes pixelDissolveIn {
    0% { visibility: hidden; }
    1% { visibility: visible; }
    100% { visibility: visible; }
}

/* --- Content Blocks --- */
.content-block {
    position: relative;
    max-width: 66%;
}

.content-asymmetric {
    margin-right: auto;
    margin-left: 20px;
}

/* --- Terminal Window (pixel-art bordered blocks w/ custom chrome) --- */
.terminal-window {
    position: relative;
    border: 2px solid #4B5563;
    background: #18191D;
    max-width: 720px;
}

/* Dithering border effect (Floyd-Steinberg-style 4px band) */
.terminal-window::before {
    content: '';
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    z-index: -1;
    pointer-events: none;
    background-image:
        repeating-linear-gradient(
            to right,
            #374151 0px, #374151 2px,
            transparent 2px, transparent 4px
        ),
        repeating-linear-gradient(
            to right,
            transparent 0px, transparent 2px,
            #374151 2px, #374151 4px
        );
    background-size: 4px 2px, 4px 2px;
    background-position: 0 0, 2px 2px;
    background-repeat: repeat;
    -webkit-mask-image:
        linear-gradient(to right, black 6px, transparent 6px, transparent calc(100% - 6px), black calc(100% - 6px)),
        linear-gradient(to bottom, black 6px, transparent 6px, transparent calc(100% - 6px), black calc(100% - 6px));
    -webkit-mask-composite: source-over;
    mask-image:
        linear-gradient(to right, black 6px, transparent 6px, transparent calc(100% - 6px), black calc(100% - 6px)),
        linear-gradient(to bottom, black 6px, transparent 6px, transparent calc(100% - 6px), black calc(100% - 6px));
    mask-composite: add;
}

.terminal-chrome {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 24px;
    background: #22232A;
    border-bottom: 2px solid #4B5563;
    padding: 0 8px;
}

.chrome-notch {
    width: 8px;
    height: 8px;
    background: #374151;
}

.chrome-notch.left {
    clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.chrome-notch.right {
    clip-path: polygon(0 0, 100% 0, 0 100%);
}

.chrome-title {
    font-family: 'VT323', monospace;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    color: #6B7280;
    text-transform: uppercase;
}

.terminal-body {
    padding: 24px 28px;
}

/* --- Typography --- */

/* Primary Display: Silkscreen */
.pixel-title {
    font-family: 'Silkscreen', sans-serif;
    font-size: clamp(3rem, 8vw, 7rem);
    color: #D1D5DB;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.1;
    margin-bottom: 16px;
    -webkit-font-smoothing: none;
    font-smooth: never;
}

.title-letter {
    display: inline-block;
    visibility: hidden;
    color: #D1D5DB;
}

.title-letter.visible {
    visibility: visible;
    animation: letterFlash 200ms steps(1);
}

@keyframes letterFlash {
    0% { color: #F87171; }
    50% { color: #F87171; }
    100% { color: #D1D5DB; }
}

/* Section headings: Silkscreen */
.pixel-heading {
    font-family: 'Silkscreen', sans-serif;
    font-size: clamp(1.8rem, 5vw, 4rem);
    color: #D1D5DB;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
    margin-bottom: 24px;
    -webkit-font-smoothing: none;
    font-smooth: never;
}

.accent-red {
    color: #F87171;
}

/* Secondary Body: Press Start 2P */
.pixel-body {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(0.65rem, 1.5vw, 0.85rem);
    color: #9CA3AF;
    line-height: 2.2;
    margin-bottom: 2rem;
    -webkit-font-smoothing: none;
    font-smooth: never;
}

/* Tertiary Code: VT323 */
.pixel-code {
    font-family: 'VT323', monospace;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    color: #6B7280;
    -webkit-font-smoothing: none;
    font-smooth: never;
}

.subtitle {
    font-size: clamp(0.55rem, 1.2vw, 0.75rem);
    color: #6B7280;
    margin-bottom: 24px;
    visibility: hidden;
}

.subtitle.visible {
    visibility: visible;
}

/* --- BOOT Scene --- */
.boot-sequence {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.boot-line {
    display: block;
    visibility: hidden;
    color: #6B7280;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    line-height: 1.8;
}

.boot-line.visible {
    visibility: visible;
}

.boot-line.active-line {
    color: #34D399;
}

/* --- FORK Scene --- */
#fork-canvas {
    width: 256px;
    height: 128px;
    image-rendering: pixelated;
    margin-bottom: 20px;
}

.process-flow-divider canvas {
    width: 320px;
    height: 32px;
    image-rendering: pixelated;
    margin-top: 16px;
}

/* --- RACE Scene --- */
.race-tracks {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.race-track {
    display: flex;
    align-items: center;
    gap: 12px;
}

.track-label {
    width: 90px;
    flex-shrink: 0;
    color: #34D399;
    font-size: clamp(0.65rem, 1vw, 0.8rem);
}

.track-bar {
    width: 200px;
    height: 12px;
    background: #22232A;
    border: 1px solid #4B5563;
    position: relative;
    flex-shrink: 0;
}

.track-runner {
    position: absolute;
    top: 0;
    left: 0;
    width: 12px;
    height: 100%;
    background: #F87171;
}

.track-feature {
    font-size: clamp(0.5rem, 1vw, 0.7rem);
    color: #6B7280;
    margin-bottom: 0;
}

.race-note {
    font-size: clamp(0.5rem, 1vw, 0.65rem);
    color: #F87171;
    font-style: normal;
}

.race-diagram canvas {
    width: 320px;
    height: 64px;
    image-rendering: pixelated;
    margin-top: 12px;
}

/* --- MERGE Scene --- */
#merge-canvas {
    width: 256px;
    height: 128px;
    image-rendering: pixelated;
    margin-bottom: 20px;
}

.kamon-bloom canvas {
    width: 128px;
    height: 128px;
    image-rendering: pixelated;
    margin-top: 16px;
}

/* --- HALT Scene --- */
.halt-contact {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.contact-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.contact-label {
    color: #34D399;
    font-size: clamp(0.65rem, 1vw, 0.8rem);
}

.contact-link {
    color: #3B82F6;
    text-decoration: none;
    font-size: clamp(0.55rem, 1vw, 0.7rem);
    margin-bottom: 0;
}

.contact-link:hover {
    color: #E5E7EB;
}

.halt-machine canvas {
    width: 160px;
    height: 80px;
    image-rendering: pixelated;
    margin-bottom: 12px;
}

.blinking-cursor {
    font-family: 'Silkscreen', sans-serif;
    font-size: clamp(1.5rem, 4vw, 3rem);
    color: #F87171;
    animation: cursor-blink 800ms steps(1) infinite;
    margin-top: 20px;
}

@keyframes cursor-blink {
    0%, 100% { visibility: visible; }
    50% { visibility: hidden; }
}

/* --- Kamon Watermarks --- */
.kamon-watermark {
    position: absolute;
    right: -100px;
    top: 50%;
    transform: translateY(-50%);
}

.kamon-watermark canvas {
    width: 128px;
    height: 128px;
    image-rendering: pixelated;
}

/* --- Pixel Art Global --- */
canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* --- No border-radius, no box-shadow anywhere --- */
* {
    border-radius: 0 !important;
    box-shadow: none !important;
}

/* --- Selection Style --- */
::selection {
    background: #F87171;
    color: #0F1117;
}

/* --- Responsive adjustments --- */
@media (max-width: 768px) {
    .scene {
        padding: 20px 20px 20px 10px;
    }

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

    .content-asymmetric {
        margin-left: 10px;
    }

    .race-track {
        flex-wrap: wrap;
        gap: 6px;
    }

    .track-bar {
        width: 140px;
    }

    .kamon-watermark {
        display: none;
    }

    .terminal-body {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    #process-monitor {
        width: 36px;
    }

    .scene {
        left: 36px;
        width: calc(100vw - 36px);
    }

    .proc-label {
        font-size: 6px;
    }

    .pixel-title {
        font-size: clamp(1.5rem, 10vw, 3rem);
    }
}
