/* ============================================
   completengine.com - Cyberpunk Data-Viz Dashboard
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --bg-primary: #080c18;
    --bg-secondary: #0d1424;
    --bg-tertiary: #060a14;
    --border-grid: #1a2744;
    --border-active: #2a3a5c;
    --text-primary: #e0e8f0;
    --text-secondary: #b0bec5;
    --text-tertiary: #6b7f99;
    --accent-cyan: #00e5ff;
    --accent-amber: #ff9100;
    --accent-green: #00e676;
    --accent-red: #ff1744;
    --font-display: 'Chakra Petch', sans-serif;
    --font-body: 'IBM Plex Sans', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 1.05rem;
    line-height: 1.75;
    overflow-x: hidden;
}

/* --- Event Channel Grid (background pattern) --- */
.event-channel-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        to right,
        transparent,
        transparent 63.5px,
        var(--border-grid) 63.5px,
        var(--border-grid) 64px
    );
    opacity: 0;
    pointer-events: none;
    z-index: 0;
    animation: gridFadeIn 800ms 300ms ease-out forwards;
}

.grid-faded {
    opacity: 0.25;
    animation: none;
}

@keyframes gridFadeIn {
    to { opacity: 0.6; }
}

/* --- Command Bar --- */
#command-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 48px;
    background: rgba(8, 12, 24, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-active);
    z-index: 1000;
    transform: translateY(-100%);
    animation: commandBarSlide 500ms 2800ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes commandBarSlide {
    to { transform: translateY(0); }
}

.command-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 24px;
}

.wordmark {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.15em;
    color: var(--text-primary);
}

.sim-clock {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 400;
    color: var(--accent-cyan);
    font-feature-settings: 'tnum';
    letter-spacing: 0.05em;
}

.command-bar-right {
    display: flex;
    gap: 20px;
}

.status-indicator {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-tertiary);
    letter-spacing: 0.05em;
    transition: color 0.5s ease;
}

.status-indicator.active {
    color: var(--accent-cyan);
}

/* --- Hero Section --- */
.hero-section {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    overflow: hidden;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.hero-headline {
    font-family: var(--font-display);
    font-size: clamp(2.8rem, 5vw, 4.5rem);
    font-weight: 700;
    letter-spacing: 0.25em;
    color: var(--text-primary);
    text-transform: uppercase;
    clip-path: polygon(50% 50%, 50% 50%, 50% 50%, 50% 50%);
    animation: headlineReveal 600ms 1500ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
    line-height: 1.2;
    max-width: 90vw;
}

@keyframes headlineReveal {
    to {
        clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
    }
}

.hero-subtitle {
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 300;
    color: var(--text-tertiary);
    margin-top: 20px;
    opacity: 0;
    animation: subtitleFadeIn 400ms 2200ms ease-out forwards;
}

@keyframes subtitleFadeIn {
    to { opacity: 1; }
}

/* --- Event Pulses --- */
.hero-pulses {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.pulse {
    position: absolute;
    height: 2px;
    border-radius: 1px;
    opacity: 0;
    animation-fill-mode: forwards;
}

.pulse-cyan { background: var(--accent-cyan); }
.pulse-amber { background: var(--accent-amber); }

.pulse-1  { top: 8%;  width: 80px;  animation: pulseSweep 3s 600ms linear infinite, pulseAppear 200ms 600ms ease-out forwards; }
.pulse-2  { top: 14%; width: 120px; animation: pulseSweep 4.5s 800ms linear infinite, pulseAppear 200ms 800ms ease-out forwards; }
.pulse-3  { top: 22%; width: 60px;  animation: pulseSweep 2.5s 900ms linear infinite, pulseAppear 200ms 900ms ease-out forwards; }
.pulse-4  { top: 28%; width: 100px; animation: pulseSweep 5s 1100ms linear infinite, pulseAppear 200ms 1100ms ease-out forwards; }
.pulse-5  { top: 35%; width: 70px;  animation: pulseSweep 3.5s 1200ms linear infinite, pulseAppear 200ms 1200ms ease-out forwards; }
.pulse-6  { top: 42%; width: 90px;  animation: pulseSweep 4s 1400ms linear infinite, pulseAppear 200ms 1400ms ease-out forwards; }
.pulse-7  { top: 48%; width: 140px; animation: pulseSweep 6s 1500ms linear infinite, pulseAppear 200ms 1500ms ease-out forwards; }
.pulse-8  { top: 55%; width: 50px;  animation: pulseSweep 2.8s 1600ms linear infinite, pulseAppear 200ms 1600ms ease-out forwards; }
.pulse-9  { top: 62%; width: 110px; animation: pulseSweep 5.5s 1800ms linear infinite, pulseAppear 200ms 1800ms ease-out forwards; }
.pulse-10 { top: 68%; width: 75px;  animation: pulseSweep 3.2s 1900ms linear infinite, pulseAppear 200ms 1900ms ease-out forwards; }
.pulse-11 { top: 75%; width: 95px;  animation: pulseSweep 4.2s 2000ms linear infinite, pulseAppear 200ms 2000ms ease-out forwards; }
.pulse-12 { top: 80%; width: 130px; animation: pulseSweep 5.8s 2100ms linear infinite, pulseAppear 200ms 2100ms ease-out forwards; }
.pulse-13 { top: 86%; width: 65px;  animation: pulseSweep 3.8s 2200ms linear infinite, pulseAppear 200ms 2200ms ease-out forwards; }
.pulse-14 { top: 18%; width: 85px;  animation: pulseSweep 4.8s 2300ms linear infinite, pulseAppear 200ms 2300ms ease-out forwards; }
.pulse-15 { top: 32%; width: 110px; animation: pulseSweep 3.6s 2400ms linear infinite, pulseAppear 200ms 2400ms ease-out forwards; }
.pulse-16 { top: 52%; width: 55px;  animation: pulseSweep 2.6s 2500ms linear infinite, pulseAppear 200ms 2500ms ease-out forwards; }
.pulse-17 { top: 72%; width: 145px; animation: pulseSweep 7s 2600ms linear infinite, pulseAppear 200ms 2600ms ease-out forwards; }
.pulse-18 { top: 90%; width: 70px;  animation: pulseSweep 3.3s 1700ms linear infinite, pulseAppear 200ms 1700ms ease-out forwards; }
.pulse-19 { top: 40%; width: 100px; animation: pulseSweep 4.4s 2000ms linear infinite, pulseAppear 200ms 2000ms ease-out forwards; }
.pulse-20 { top: 58%; width: 88px;  animation: pulseSweep 5.2s 2100ms linear infinite, pulseAppear 200ms 2100ms ease-out forwards; }

@keyframes pulseSweep {
    0%   { transform: translateX(-200px); }
    100% { transform: translateX(calc(100vw + 200px)); }
}

@keyframes pulseAppear {
    to { opacity: 0.7; }
}

/* --- Scroll Chevron --- */
.scroll-chevron {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

.chevron-arrow {
    width: 20px;
    height: 20px;
    border-bottom: 2px solid var(--text-tertiary);
    border-right: 2px solid var(--text-tertiary);
    transform: rotate(45deg);
    animation: chevronPulse 1.5s ease-in-out infinite;
}

@keyframes chevronPulse {
    0%, 100% { opacity: 0.3; }
    50%      { opacity: 1.0; }
}

/* --- Architecture Section --- */
.architecture-section {
    position: relative;
    padding: 120px 40px 80px;
    background: var(--bg-primary);
    overflow: hidden;
}

.arch-panels {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.arch-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-grid);
    padding: 32px 28px;
    position: relative;
    box-shadow: 0 4px 32px rgba(0, 229, 255, 0.04);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
}

.panel-left {
    transform: rotate(-0.5deg) translateX(-60px);
}

.panel-center {
    transform: rotate(0.3deg) translateY(40px);
}

.panel-right {
    transform: translateX(60px);
}

.arch-panel.visible {
    opacity: 1;
}

.panel-left.visible {
    transform: rotate(-0.5deg) translateX(0);
}

.panel-center.visible {
    transform: rotate(0.3deg) translateY(0);
}

.panel-right.visible {
    transform: translateX(0);
}

.panel-header {
    display: flex;
    flex-direction: column;
    margin-bottom: 24px;
}

.panel-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-tertiary);
    letter-spacing: 0.15em;
    margin-bottom: 6px;
}

.panel-title {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    font-weight: 700;
    letter-spacing: 0.25em;
    color: var(--text-primary);
    text-transform: uppercase;
}

.panel-diagram {
    margin-bottom: 20px;
}

.diagram-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 16px;
}

.diagram-cell {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-grid);
    padding: 8px 4px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-tertiary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.diagram-cell.cell-active {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.1);
}

.diagram-arrow {
    width: 100%;
    height: 12px;
    position: relative;
    margin: 8px 0 16px;
}

.diagram-arrow.arrow-right::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 10%;
    width: 80%;
    height: 1px;
    background: var(--border-active);
}

.diagram-arrow.arrow-right::before {
    content: '';
    position: absolute;
    top: 50%;
    right: 10%;
    transform: translateY(-50%) rotate(45deg);
    width: 6px;
    height: 6px;
    border-top: 1px solid var(--accent-cyan);
    border-right: 1px solid var(--accent-cyan);
}

.panel-desc {
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 300;
    color: var(--text-secondary);
    line-height: 1.6;
}

.panel-stats {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-grid);
}

.stat {
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.stat-label {
    color: var(--text-tertiary);
    letter-spacing: 0.05em;
}

.stat-value {
    font-weight: 600;
}

.stat-cyan  { color: var(--accent-cyan); }
.stat-green { color: var(--accent-green); }
.stat-amber { color: var(--accent-amber); }
.stat-red   { color: var(--accent-red); }

/* Causality Arrows */
.causality-arrows {
    display: block;
    max-width: 1200px;
    margin: 24px auto 0;
    width: 100%;
    height: 50px;
    position: relative;
    z-index: 2;
}

.causality-path {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 1s ease;
}

.causality-path.drawn {
    stroke-dashoffset: 0;
}

/* --- Section Title (shared) --- */
.section-title {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    font-weight: 700;
    letter-spacing: 0.25em;
    color: var(--text-primary);
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 48px;
}

/* --- Event Timeline Strip --- */
.timeline-section {
    padding: 80px 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-grid);
    border-bottom: 1px solid var(--border-grid);
    overflow: hidden;
}

.timeline-container {
    width: 100%;
    overflow: hidden;
}

.timeline-strip {
    display: flex;
    gap: 2px;
    animation: timelineScroll 30s linear infinite;
    width: max-content;
}

.timeline-strip:hover {
    animation-play-state: paused;
}

@keyframes timelineScroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.event-block {
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
    cursor: default;
    transition: transform 0.2s ease;
}

.event-block:hover {
    transform: scale(1.05);
}

.event-scheduled { background: var(--accent-cyan); }
.event-conflict  { background: var(--accent-amber); }
.event-completed { background: var(--accent-green); }
.event-error     { background: var(--accent-red); }

.event-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--bg-primary);
    font-weight: 600;
    letter-spacing: 0.03em;
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.event-block:hover .event-label {
    opacity: 1;
}

/* Notch marks between blocks */
.event-block::after {
    content: '';
    position: absolute;
    right: -2px;
    top: 0;
    width: 2px;
    height: 100%;
    background: var(--border-grid);
    z-index: 1;
}

/* --- Execution Model Deep-Dive --- */
.deep-dive-section {
    position: relative;
    padding: 120px 24px;
    background: var(--bg-primary);
}

.deep-dive-content {
    max-width: 680px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.deep-dive-content p {
    margin-bottom: 24px;
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.75;
    font-weight: 300;
}

.term-highlight {
    color: var(--accent-cyan);
    border-bottom: 1px solid rgba(0, 229, 255, 0.3);
}

.code-callout {
    background: #0a1020;
    border-left: 3px solid var(--accent-amber);
    padding: 20px 24px;
    margin: 32px 0;
    position: relative;
}

.code-callout .callout-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--accent-amber);
    letter-spacing: 0.15em;
    margin-bottom: 12px;
    text-transform: uppercase;
}

.code-callout code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.7;
    font-weight: 400;
    letter-spacing: 0.05em;
}

/* --- State Machine Visualizer --- */
.state-machine-section {
    padding: 120px 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-grid);
}

.state-diagram {
    position: relative;
    max-width: 600px;
    height: 500px;
    margin: 0 auto;
}

.state-arrows {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.state-path {
    stroke-dasharray: 200;
    stroke-dashoffset: 0;
    transition: stroke 0.3s ease, stroke-dashoffset 0.6s ease;
}

.state-path.animating {
    stroke: var(--accent-cyan);
    stroke-dashoffset: 200;
    animation: strokeFlow 1s linear forwards;
}

@keyframes strokeFlow {
    0%   { stroke-dashoffset: 200; }
    100% { stroke-dashoffset: 0; }
}

.state-node {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid var(--border-active);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    cursor: pointer;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.state-node:hover {
    box-shadow: 0 0 24px rgba(0, 229, 255, 0.4);
    border-color: var(--accent-cyan);
}

.state-label {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    color: var(--text-primary);
    letter-spacing: 0.08em;
    text-align: center;
    text-transform: uppercase;
    user-select: none;
}

.state-center-zone {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    border-radius: 50%;
    z-index: 1;
    cursor: pointer;
}

/* --- Footer Console --- */
.footer-console {
    background: var(--bg-tertiary);
    padding: 48px 24px;
    border-top: 1px solid var(--border-grid);
}

.console-content {
    max-width: 680px;
    margin: 0 auto;
}

.console-line {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-tertiary);
    line-height: 2;
    letter-spacing: 0.05em;
    opacity: 0;
}

.console-line.typed {
    opacity: 1;
}

.cursor {
    color: var(--text-primary);
    animation: cursorBlink 0.8s step-end infinite;
    opacity: 0;
}

.cursor.active {
    opacity: 1;
}

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

/* --- Circuit Trace Decorations --- */
.circuit-trace {
    position: fixed;
    left: 24px;
    top: 120px;
    width: 1px;
    height: calc(100vh - 240px);
    background: var(--border-grid);
    z-index: 0;
    pointer-events: none;
}

.circuit-trace::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 1px;
    background: var(--border-grid);
}

.circuit-trace::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 24px;
    height: 1px;
    background: var(--border-active);
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .arch-panels {
        grid-template-columns: 1fr;
        gap: 24px;
        padding: 0 16px;
    }

    .panel-left,
    .panel-center,
    .panel-right {
        transform: none;
    }

    .panel-left.visible,
    .panel-center.visible,
    .panel-right.visible {
        transform: none;
    }

    .command-bar-right {
        display: none;
    }

    .hero-headline {
        letter-spacing: 0.1em;
    }

    .event-channel-grid {
        background: repeating-linear-gradient(
            to right,
            transparent,
            transparent 47.5px,
            var(--border-grid) 47.5px,
            var(--border-grid) 48px
        );
    }

    .state-diagram {
        transform: scale(0.75);
        transform-origin: top center;
        height: 380px;
    }

    .circuit-trace {
        display: none;
    }

    .causality-arrows {
        display: none;
    }
}

@media (max-width: 600px) {
    .architecture-section {
        padding: 80px 16px 60px;
    }

    .deep-dive-section {
        padding: 80px 16px;
    }

    .panel-stats {
        flex-direction: column;
        gap: 8px;
    }

    .hero-headline {
        font-size: clamp(1.6rem, 8vw, 2.8rem);
        letter-spacing: 0.08em;
    }
}

/* --- Prefers Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        animation-delay: 0ms !important;
        transition-duration: 0.01ms !important;
    }

    .hero-headline {
        clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
    }

    .hero-subtitle {
        opacity: 1;
    }

    #command-bar {
        transform: translateY(0);
    }

    .event-channel-grid {
        opacity: 0.6;
    }

    .pulse {
        opacity: 0.7;
    }

    .arch-panel {
        opacity: 1;
    }

    .console-line {
        opacity: 1;
    }
}
