/* ============================================
   CONCURRENGINE.COM - Styles
   1978 Parallel-Processing Mainframe Aesthetic
   ============================================ */

:root {
    --bg-deep: #0E0A18;
    --bg-elevated: #1A1128;
    --surface: #2A1F3D;
    --accent-amber: #F28C28;
    --accent-brass: #C4A57B;
    --text-body: #E0D4C0;
    --text-highlight: #E8D5B7;
    --accent-violet: #7B4FD4;
    --indicator-fork: #D45B3A;
    --indicator-sync: #3ABFA8;
    --font-display: 'Bebas Neue', sans-serif;
    --font-body: 'Space Grotesk', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
    --cycle: 24px;
    --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

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

html {
    scroll-behavior: smooth;
    font-size: 17px;
    background-color: var(--bg-deep);
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--text-body);
    line-height: 1.65;
    background-color: var(--bg-deep);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---- Background Plotter Lines ---- */

.plotter-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 500vh;
    pointer-events: none;
    z-index: 0;
}

.plotter-line {
    fill: none;
    stroke: var(--accent-brass);
    stroke-width: 1;
    opacity: 0.15;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 0.1s linear;
}

/* ---- Punchcard Dot Pattern ---- */

.punchcard-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image: radial-gradient(circle, var(--surface) 1px, transparent 1px);
    background-size: 12px 14px;
    opacity: 0.05;
}

/* ---- Pipeline Navigation ---- */

.pipeline-nav {
    position: fixed;
    bottom: 50%;
    right: 24px;
    transform: translateY(50%);
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 100;
}

.nav-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--accent-violet);
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    padding: 0;
}

.nav-dot.visited {
    background: var(--accent-violet);
    border-color: var(--accent-violet);
}

.nav-dot.current {
    background: var(--accent-amber);
    border-color: var(--accent-amber);
    box-shadow: 0 0 8px var(--accent-amber), 0 0 16px rgba(242, 140, 40, 0.3);
    animation: navPulse 2s ease-in-out infinite;
}

@keyframes navPulse {
    0%, 100% { box-shadow: 0 0 8px var(--accent-amber), 0 0 16px rgba(242, 140, 40, 0.3); }
    50% { box-shadow: 0 0 12px var(--accent-amber), 0 0 24px rgba(242, 140, 40, 0.5); }
}

.nav-label {
    position: absolute;
    right: 22px;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--accent-brass);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.nav-dot:hover .nav-label {
    opacity: 1;
}

/* ---- Pipeline Stages ---- */

.pipeline-stage {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1;
    padding: 96px var(--cycle);
}

.pipeline-stage.execute-stage {
    min-height: 120vh;
}

#return {
    min-height: 80vh;
}

.stage-content {
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
}

.return-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ---- Typography ---- */

h1 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(56px, 10vw, 96px);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-amber);
    line-height: 0.95;
    margin-bottom: 48px;
    text-align: center;
}

h2 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(32px, 5vw, 48px);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-highlight);
    line-height: 1;
    margin-bottom: 48px;
}

h3 {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: clamp(18px, 2.5vw, 24px);
    color: var(--accent-brass);
    margin-top: 48px;
    margin-bottom: 24px;
    text-transform: none;
}

.body-text {
    color: var(--text-body);
    margin-bottom: 24px;
    line-height: 1.65;
}

.tagline {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(18px, 2.5vw, 22px);
    color: var(--text-highlight);
    text-align: center;
    margin-bottom: 48px;
    line-height: 1.5;
}

.colophon {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 14px;
    color: #7A6E85;
    margin-top: 48px;
}

.mono-inline {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 14px;
    color: var(--accent-amber);
    background: var(--bg-elevated);
    padding: 2px 6px;
    border-radius: 2px;
}

.return-statement {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: clamp(18px, 2.5vw, 22px);
    color: var(--indicator-sync);
    text-align: center;
    max-width: 500px;
    margin-bottom: 48px;
}

/* ---- Code Blocks ---- */

.code-block {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 14px;
    color: var(--accent-amber);
    background: var(--bg-elevated);
    padding: 24px;
    border-radius: 4px;
    border-left: 3px solid var(--accent-violet);
    margin: 24px 0;
    line-height: 1.7;
    overflow-x: auto;
}

.code-comment {
    color: #7A6E85;
}

.code-keyword {
    color: var(--accent-violet);
}

.mono-block {
    display: block;
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 12px;
    color: var(--accent-amber);
    background: var(--bg-deep);
    padding: 12px;
    border-radius: 2px;
    margin-top: 12px;
    line-height: 1.8;
}

/* ---- Register Displays ---- */

.register-display {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-elevated);
    border: 1px solid var(--surface);
    border-radius: 4px;
    padding: 12px 20px;
    margin-bottom: 24px;
}

.register-display.small {
    padding: 8px 16px;
}

.register-label {
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: 10px;
    letter-spacing: 0.08em;
    color: #7A6E85;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.register-value {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 24px;
    color: var(--accent-amber);
    letter-spacing: 0.06em;
    text-shadow: 0 0 8px rgba(242, 140, 40, 0.4);
    min-width: 80px;
    text-align: center;
}

.register-display.small .register-value {
    font-size: 18px;
    min-width: 60px;
}

.register-row {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 24px 0;
}

/* ---- Init Section ---- */

#init .stage-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.fork-diagram {
    max-width: 400px;
    width: 100%;
    margin: 24px auto 48px;
}

.init-svg .svg-line {
    stroke: var(--accent-violet);
    stroke-width: 2;
    fill: none;
}

.init-svg .fork-point {
    fill: var(--indicator-fork);
}

.init-svg .thread-indicator {
    fill: var(--accent-amber);
}

.init-svg .thread-indicator.running {
    animation: threadPulse 1.5s ease-in-out infinite;
}

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

.init-svg .svg-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    fill: #7A6E85;
    text-anchor: middle;
}

/* ---- Fork Section ---- */

.fork-animation-container {
    max-width: 400px;
    width: 100%;
    margin: 24px auto;
}

.fork-svg .fork-trunk {
    stroke: var(--accent-violet);
    stroke-width: 2;
    fill: none;
}

.fork-svg .fork-node {
    fill: var(--indicator-fork);
    stroke: var(--indicator-fork);
    stroke-width: 1;
}

.fork-svg .fork-branch {
    stroke: var(--accent-violet);
    stroke-width: 2;
    fill: none;
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 0.8s var(--bounce);
}

.fork-svg.active .fork-branch {
    stroke-dashoffset: 0;
}

.fork-svg .fork-endpoint {
    fill: var(--accent-amber);
    opacity: 0;
    transition: opacity 0.5s ease 0.6s;
}

.fork-svg.active .fork-endpoint {
    opacity: 1;
}

/* Thread columns */

.thread-columns {
    display: flex;
    gap: 16px;
    margin-top: 48px;
}

.thread-col {
    flex: 1;
    background: var(--bg-elevated);
    border: 1px solid var(--surface);
    border-radius: 4px;
    padding: 20px 16px;
    position: relative;
}

.thread-col-1 {
    background: rgba(26, 17, 40, 0.9);
}

.thread-col-2 {
    background: rgba(26, 17, 40, 0.7);
}

.thread-col-3 {
    background: rgba(26, 17, 40, 0.5);
}

.thread-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.thread-indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.thread-indicator-dot.running {
    background: var(--accent-amber);
    box-shadow: 0 0 6px rgba(242, 140, 40, 0.5);
    animation: threadPulse 1.5s ease-in-out infinite;
}

.thread-indicator-dot.blocked {
    background: var(--indicator-fork);
}

.thread-indicator-dot.synced {
    background: var(--indicator-sync);
}

.thread-id {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 12px;
    letter-spacing: 0.04em;
    color: var(--accent-brass);
}

.thread-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-body);
    margin-bottom: 12px;
}

/* ---- Execute Section ---- */

.tech-diagram {
    margin: 24px 0;
    max-width: 600px;
}

.exec-diagram .proc-unit {
    fill: var(--bg-elevated);
    stroke: var(--accent-violet);
    stroke-width: 1.5;
}

.exec-diagram .proc-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    fill: var(--accent-amber);
    text-anchor: middle;
    dominant-baseline: middle;
}

.exec-diagram .bus-line {
    stroke: var(--accent-amber);
    stroke-width: 2;
}

.exec-diagram .bus-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    fill: #7A6E85;
    text-anchor: middle;
}

.exec-diagram .conn-line {
    stroke: var(--accent-brass);
    stroke-width: 1;
    stroke-dasharray: 4 2;
}

.exec-diagram .mem-unit {
    fill: var(--surface);
    stroke: var(--accent-brass);
    stroke-width: 1;
}

.exec-diagram .mem-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    fill: var(--text-highlight);
    text-anchor: middle;
    dominant-baseline: middle;
}

/* ---- Duotone Image ---- */

.duotone-image {
    position: relative;
    margin: 48px 0;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--surface);
}

.duotone-image svg {
    display: block;
    width: 100%;
    height: auto;
}

.image-caption {
    display: block;
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: 12px;
    letter-spacing: 0.04em;
    color: #7A6E85;
    padding: 8px 12px;
    background: var(--bg-elevated);
}

/* ---- Sync Section ---- */

.sync-animation-container {
    max-width: 400px;
    width: 100%;
    margin: 24px auto;
}

.sync-svg .sync-branch {
    stroke: var(--accent-violet);
    stroke-width: 2;
    fill: none;
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 0.8s var(--bounce);
}

.sync-svg.active .sync-branch {
    stroke-dashoffset: 0;
}

.sync-svg .sync-node {
    fill: transparent;
    stroke: var(--indicator-sync);
    stroke-width: 2;
    transition: fill 0.4s ease 0.7s;
}

.sync-svg.active .sync-node {
    fill: var(--indicator-sync);
}

.sync-svg .sync-trunk {
    stroke: var(--indicator-sync);
    stroke-width: 2;
    fill: none;
    stroke-dasharray: 140;
    stroke-dashoffset: 140;
    transition: stroke-dashoffset 0.5s ease 0.8s;
}

.sync-svg.active .sync-trunk {
    stroke-dashoffset: 0;
}

.sync-svg .thread-indicator.synced {
    fill: var(--indicator-sync);
    animation: threadPulse 1.5s ease-in-out infinite;
}

/* Sync horizontal rules */

.sync-rules {
    display: flex;
    align-items: center;
    gap: 0;
    margin: 48px 0;
    width: 100%;
}

.sync-rule-left,
.sync-rule-right {
    flex: 1;
    height: 2px;
    background: var(--accent-violet);
    transform: scaleX(0);
    transition: transform 0.6s var(--bounce), background-color 0.4s ease 0.5s;
}

.sync-rule-left {
    transform-origin: right center;
}

.sync-rule-right {
    transform-origin: left center;
}

.sync-rules.active .sync-rule-left,
.sync-rules.active .sync-rule-right {
    transform: scaleX(1);
    background: var(--accent-amber);
}

.sync-point {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--accent-violet);
    position: relative;
    flex-shrink: 0;
    transition: border-color 0.4s ease 0.5s, background-color 0.4s ease 0.5s;
}

.sync-rules.active .sync-point {
    border-color: var(--indicator-sync);
    background: var(--indicator-sync);
    box-shadow: 0 0 12px rgba(58, 191, 168, 0.6);
}

.sync-flash {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--indicator-sync);
    opacity: 0;
}

.sync-rules.active .sync-flash {
    animation: syncFlash 0.6s ease 0.5s;
}

@keyframes syncFlash {
    0% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(3); }
}

/* ---- Return Section ---- */

.return-diagram {
    max-width: 400px;
    width: 100%;
    margin: 24px auto;
}

.return-svg .svg-line,
.return-svg .return-line {
    stroke: var(--indicator-sync);
    stroke-width: 2;
    fill: none;
}

.return-svg .return-point {
    fill: var(--indicator-sync);
}

.return-svg .result-box {
    fill: var(--bg-elevated);
    stroke: var(--indicator-sync);
    stroke-width: 1.5;
}

.return-svg .result-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    fill: var(--indicator-sync);
    text-anchor: middle;
    dominant-baseline: middle;
}

/* ---- Section Barriers ---- */

.section-barrier {
    width: 100%;
    max-width: 720px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 48px;
}

.barrier-line {
    width: 100%;
    height: 2px;
    background: var(--accent-violet);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.6s var(--bounce), background-color 0.4s ease 0.5s;
}

.barrier-line.active {
    transform: scaleX(1);
    background: var(--accent-amber);
}

/* ---- Bounce-Enter Animations ---- */

.bounce-in {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s var(--bounce);
}

.bounce-in.visible {
    opacity: 1;
    transform: translateY(0);
}

h1.bounce-in {
    transform: translateX(-40px);
}

h1.bounce-in.visible {
    transform: translateX(0);
}

h2.bounce-in {
    transform: translateX(-40px);
}

h2.bounce-in.visible {
    transform: translateX(0);
}

.tech-diagram.bounce-in,
.fork-diagram.bounce-in,
.fork-animation-container.bounce-in,
.sync-animation-container.bounce-in,
.return-diagram.bounce-in,
.duotone-image.bounce-in {
    transform: scale(0.92);
}

.tech-diagram.bounce-in.visible,
.fork-diagram.bounce-in.visible,
.fork-animation-container.bounce-in.visible,
.sync-animation-container.bounce-in.visible,
.return-diagram.bounce-in.visible,
.duotone-image.bounce-in.visible {
    transform: scale(1);
}

/* ---- Background Process Flow Lines ---- */

.pipeline-stage::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(90deg, transparent 49.5%, rgba(42, 31, 61, 0.08) 49.5%, rgba(42, 31, 61, 0.08) 50.5%, transparent 50.5%),
        linear-gradient(0deg, transparent 49.5%, rgba(42, 31, 61, 0.08) 49.5%, rgba(42, 31, 61, 0.08) 50.5%, transparent 50.5%);
    background-size: 48px 48px;
    pointer-events: none;
    z-index: -1;
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
    .thread-columns {
        flex-direction: column;
    }

    .pipeline-nav {
        right: 12px;
    }

    .register-row {
        gap: 8px;
    }

    .register-display {
        padding: 8px 12px;
    }

    .register-value {
        font-size: 18px;
    }

    .register-display.small .register-value {
        font-size: 14px;
    }

    h1 {
        margin-bottom: 24px;
    }

    h2 {
        margin-bottom: 24px;
    }

    .code-block {
        font-size: 12px;
        padding: 16px;
    }

    .pipeline-stage {
        padding: 48px 16px;
    }

    .section-barrier {
        margin-top: 24px;
    }
}

@media (max-width: 480px) {
    .nav-label {
        display: none;
    }

    .pipeline-nav {
        right: 8px;
        gap: 12px;
    }

    .nav-dot {
        width: 10px;
        height: 10px;
    }
}
