/* ================================================================
   ConcurrEngine — Swiss Rationalism x Watercolor Dissolution
   ================================================================ */

:root {
    --deep-naval: #0a1628;
    --midnight-wash: #0f2440;
    --slate-depth: #162d50;
    --frosted-steel: #c8d1dc;
    --oxidized-steel: #7b8794;
    --muted-steel: #8a95a5;
    --copper-patina: #4a9e8e;
    --tarnished-copper: #2d7a6d;
    --warm-mercury: #d4a574;
    --diluted-indigo: #1a3a6b;
    --aqua-bleed: #1f5c6b;
    --copper-dissolution: #4a7e6b;
    --card-gap: 2px;
    --grid-margin: clamp(40px, 5vw, 80px);
}

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

html {
    scroll-behavior: auto;
    overflow-x: hidden;
}

body {
    background-color: var(--deep-naval);
    color: var(--frosted-steel);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* SVG Filters - Hidden */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* Grain Overlay */
.grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.03;
    filter: url(#wc-grain);
    background: var(--frosted-steel);
    mix-blend-mode: soft-light;
}

/* ================================================================
   Navigation
   ================================================================ */

.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 16px var(--grid-margin);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.nav-brand {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--frosted-steel);
    margin-bottom: 8px;
}

.nav-rule {
    width: 100%;
    height: 1px;
    background-color: var(--oxidized-steel);
    margin-bottom: 10px;
}

.nav-links {
    display: flex;
    gap: 48px;
}

.nav-token {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--oxidized-steel);
    cursor: default;
    transition: color 200ms ease-out;
}

.nav-token:hover {
    color: var(--copper-patina);
}

/* ================================================================
   Main Content & Phases
   ================================================================ */

.main {
    position: relative;
    z-index: 1;
}

.phase {
    position: relative;
}

.phase-idle {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 80px var(--grid-margin) 40px;
}

.phase-spawning {
    height: 100vh;
}

.phase-executing {
    min-height: 150vh;
    padding: 0 var(--grid-margin);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 25vh;
}

.phase-converging {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.phase-spacer {
    height: 100%;
}

/* ================================================================
   Card Grid
   ================================================================ */

.card-grid {
    position: sticky;
    top: 80px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--card-gap);
    width: 100%;
    max-width: 1200px;
    z-index: 2;
    transition: gap 1.5s ease-out;
}

.card-grid.converging {
    gap: 0px;
}

/* ================================================================
   Process Cards
   ================================================================ */

.process-card {
    position: relative;
    background-color: var(--midnight-wash);
    min-height: 160px;
    padding: 20px;
    overflow: hidden;
    transform: scale(0.97);
    opacity: 0.6;
    transition: transform 400ms cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 600ms ease-out,
                box-shadow 150ms ease-out,
                background-color 300ms ease-out;
}

.process-card:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 24px rgba(10, 22, 40, 0.6);
    z-index: 5;
}

.process-card.spawned {
    transform: scale(1.0);
    opacity: 1;
}

.process-card.converged {
    overflow: visible;
}

/* Card Watercolor Wash */
.card-wash {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    opacity: 0;
    transition: opacity 600ms ease-out;
    mix-blend-mode: soft-light;
    pointer-events: none;
}

.process-card.spawned .card-wash {
    opacity: 0.6;
}

.process-card[data-wash='a'] .card-wash {
    background:
        radial-gradient(ellipse at 15% 20%, var(--diluted-indigo) 0%, transparent 70%),
        radial-gradient(ellipse at 80% 70%, var(--aqua-bleed) 0%, transparent 60%);
}

.process-card[data-wash='b'] .card-wash {
    background:
        radial-gradient(ellipse at 50% 50%, var(--aqua-bleed) 0%, transparent 65%),
        radial-gradient(ellipse at 20% 80%, var(--copper-dissolution) 0%, transparent 55%);
}

.process-card[data-wash='c'] .card-wash {
    background:
        radial-gradient(ellipse at 70% 30%, var(--copper-dissolution) 0%, transparent 60%),
        radial-gradient(ellipse at 30% 70%, var(--diluted-indigo) 0%, transparent 70%);
}

/* Card Indicator */
.card-indicator {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 6px;
    height: 6px;
    transition: background-color 200ms ease-out;
}

.card-indicator[data-state='idle'] {
    background-color: var(--oxidized-steel);
}

.card-indicator[data-state='executing'] {
    background-color: var(--copper-patina);
}

.card-indicator[data-state='blocked'] {
    background-color: var(--warm-mercury);
}

.card-indicator[data-state='completed'] {
    background-color: var(--frosted-steel);
}

/* Card Content */
.card-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.card-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--oxidized-steel);
}

.card-id {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--muted-steel);
}

.card-status {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--copper-patina);
    transition: color 200ms ease-out, opacity 300ms ease-out;
}

.card-status.blocked {
    color: var(--warm-mercury);
}

/* ================================================================
   Idle Instruction
   ================================================================ */

.idle-instruction {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 3rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--frosted-steel);
    text-align: center;
    margin-top: 40px;
    opacity: 1;
    transition: opacity 800ms ease-out;
}

.idle-instruction.hidden {
    opacity: 0;
}

/* ================================================================
   Narrative Blocks
   ================================================================ */

.narrative-block {
    max-width: 640px;
    padding: 48px;
    background-color: rgba(15, 36, 64, 0.85);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms ease-out, transform 600ms ease-out;
}

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

.narrative-block[data-narrative='0'] {
    align-self: flex-start;
}

.narrative-block[data-narrative='1'] {
    align-self: center;
}

.narrative-block[data-narrative='2'] {
    align-self: flex-end;
}

.narrative-text {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.72;
    color: var(--frosted-steel);
}

/* ================================================================
   Converge Message
   ================================================================ */

.converge-message {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 4.5vw, 4.5rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--frosted-steel);
    text-align: center;
    opacity: 0;
    transition: opacity 1200ms ease-out;
}

.converge-message.visible {
    opacity: 1;
}

/* ================================================================
   Particle Canvas
   ================================================================ */

#particleCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 50;
    opacity: 0;
    transition: opacity 800ms ease-out;
}

#particleCanvas.active {
    opacity: 1;
}

/* ================================================================
   Responsive
   ================================================================ */

@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .nav-links {
        gap: 24px;
    }

    .narrative-block {
        padding: 32px;
    }

    .narrative-block[data-narrative='0'],
    .narrative-block[data-narrative='1'],
    .narrative-block[data-narrative='2'] {
        align-self: stretch;
    }
}

@media (max-width: 480px) {
    .card-grid {
        grid-template-columns: 1fr;
    }

    .process-card {
        min-height: 120px;
    }
}
