/* ===== CSS Custom Properties ===== */
:root {
    --bg-void: #0a0e1e;
    --bg-panel: #111833;
    --accent-green: #00ffc8;
    --accent-amber: #ffab00;
    --accent-red: #ff5252;
    --accent-purple: #7c4dff;
    --accent-blue: #00b0ff;
    --text-primary: #e0f7fa;
    --text-secondary: #b0bec5;
    --text-muted: #546e7a;
    --glow-green: #39ff85;
    --text-highlight: rgba(255, 255, 255, 0.9); /* #ffffff at 90% opacity */
    --grid-line: rgba(0, 255, 200, 0.08);
    --panel-border: rgba(0, 255, 200, 0.15);
    --panel-bg: rgba(10, 14, 30, 0.85);

    --font-display: 'Chakra Petch', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --font-accent: 'Exo 2', sans-serif;

    --spring-ease: cubic-bezier(0.34, 1.56, 0.64, 1);
    --elastic-ease: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-void);
    color: var(--text-secondary);
    overflow-x: hidden;
    min-height: 100vh;
}

/* ===== Boot Overlay ===== */
#boot-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg-void);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

#boot-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.boot-lines {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 2rem;
}

.boot-line {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-green);
    letter-spacing: 0.04em;
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.boot-line.visible {
    opacity: 1;
    transform: translateX(0);
}

/* ===== Dashboard Grid ===== */
#dashboard {
    display: grid;
    grid-template-columns: 60px 1fr 240px;
    grid-template-rows: 1fr;
    min-height: 100vh;
    width: 100%;
    position: relative;
    opacity: 0;
    transition: opacity 0.8s ease 0.3s;
}

#dashboard.visible {
    opacity: 1;
}

/* ===== Timeline Spine ===== */
#timeline-spine {
    grid-column: 1;
    background: var(--bg-panel);
    border-right: 1px solid var(--grid-line);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 10;
}

#timeline-spine::-webkit-scrollbar {
    width: 3px;
}

#timeline-spine::-webkit-scrollbar-track {
    background: transparent;
}

#timeline-spine::-webkit-scrollbar-thumb {
    background: var(--accent-green);
    border-radius: 3px;
}

.spine-header {
    padding: 12px 8px;
    text-align: center;
    border-bottom: 1px solid var(--grid-line);
}

.spine-track {
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    min-height: 400vh;
    position: relative;
}

.spine-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-green);
    position: relative;
    flex-shrink: 0;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.3s ease, transform 0.3s var(--spring-ease);
}

.spine-dot.visible {
    opacity: 1;
    transform: scale(1);
}

.spine-dot.amber { background: var(--accent-amber); }
.spine-dot.red { background: var(--accent-red); }
.spine-dot.purple { background: var(--accent-purple); }
.spine-dot.blue { background: var(--accent-blue); }

.spine-dot::after {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    width: 20px;
    height: 1px;
    background: currentColor;
    opacity: 0.3;
}

.spine-timestamp {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    color: var(--text-muted);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 0.04em;
}

/* ===== Simulation Canvas ===== */
#simulation-canvas {
    grid-column: 2;
    position: relative;
    overflow: hidden;
}

.sim-section {
    min-height: 100vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.section-content {
    width: 100%;
    height: 100%;
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sim-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* Section clip-path transition (horizontal wipe) */
.sim-section {
    clip-path: inset(0 100% 0 0);
    transition: clip-path 0.6s ease;
}

.sim-section.revealed {
    clip-path: inset(0 0 0 0);
}

.section-text {
    position: relative;
    z-index: 5;
    max-width: 600px;
    padding: 2rem;
    pointer-events: none;
}

.display-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4.5rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-primary);
    line-height: 1.15;
    margin-bottom: 0.5rem;
}

.body-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.875rem, 1.2vw, 1.125rem);
    line-height: 1.7;
    color: var(--text-secondary);
}

.scale-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    text-align: center;
}

.large-label {
    font-size: 1.2rem !important;
    color: var(--accent-green) !important;
}

.process-counter {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.counter-value {
    font-family: var(--font-mono);
    font-size: 2.5rem;
    color: var(--accent-green);
    letter-spacing: 0.04em;
}

/* ===== Shared Label Styles ===== */
.mono-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.mono-data {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-green);
    letter-spacing: 0.04em;
    display: block;
    line-height: 1.6;
}

.mono-data.large {
    font-size: 2rem;
    line-height: 1.2;
}

.text-green {
    color: var(--accent-green);
}

.text-amber {
    color: var(--accent-amber);
}

.text-red {
    color: var(--accent-red);
}

.text-highlight {
    color: #ffffff;
    opacity: 0.9;
}

/* ===== Event Tag Chips ===== */
.event-tag {
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
}

/* ===== Status Panels ===== */
#status-panels {
    grid-column: 3;
    background: var(--bg-panel);
    border-left: 1px solid var(--grid-line);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 10;
}

.bento-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 14px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: border-color 0.3s ease;
}

.bento-panel:hover {
    border-color: rgba(0, 255, 200, 0.35);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--grid-line);
}

.panel-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
}

.panel-dot.active {
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green);
    animation: dot-pulse 2s ease-in-out infinite;
}

@keyframes dot-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.panel-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mini-chart {
    margin-top: 8px;
    height: 40px;
    overflow: hidden;
}

.mini-svg {
    width: 100%;
    height: 100%;
}

.thread-bars {
    display: flex;
    gap: 3px;
    margin-top: 8px;
    height: 30px;
    align-items: flex-end;
}

.thread-bar {
    width: 8px;
    background: var(--accent-green);
    border-radius: 2px 2px 0 0;
    transition: height 0.3s ease;
    opacity: 0.7;
}

.thread-bar.amber { background: var(--accent-amber); }
.thread-bar.blue { background: var(--accent-blue); }
.thread-bar.purple { background: var(--accent-purple); }

/* ===== Event Queue Bar ===== */
#event-queue-bar {
    position: fixed;
    bottom: 0;
    left: 60px;
    right: 240px;
    height: 48px;
    background: rgba(10, 14, 30, 0.92);
    border-top: 1px solid var(--grid-line);
    display: flex;
    align-items: center;
    z-index: 20;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.queue-label {
    padding: 0 16px;
    border-right: 1px solid var(--grid-line);
    height: 100%;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.queue-track {
    flex: 1;
    height: 100%;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 0 8px;
    gap: 6px;
}

.queue-item {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    flex-shrink: 0;
    position: relative;
    transition: transform 0.3s var(--spring-ease), opacity 0.3s ease;
}

.queue-item.dispatching {
    animation: dispatch-launch 0.4s var(--elastic-ease) forwards;
}

@keyframes dispatch-launch {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-60px) scale(0.5); opacity: 0; }
}

/* ===== Oscilloscope Background ===== */
.oscilloscope-layer {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.osc-trace {
    fill: none;
    stroke: var(--glow-green);
    stroke-width: 1;
    opacity: 0.08;
}

.osc-trace.trace-2 {
    opacity: 0.06;
    stroke-width: 1.5;
}

.osc-trace.trace-3 {
    opacity: 0.1;
    stroke-width: 0.8;
}

/* ===== SVG Simulation Elements ===== */
.sim-stream-line {
    stroke: var(--accent-green);
    stroke-width: 1.5;
    opacity: 0.6;
    fill: none;
}

.sim-event-node {
    transition: transform 0.15s ease;
    cursor: pointer;
}

.sim-event-node:hover {
    transform: scale(1.4);
}

.event-pulse {
    animation: event-pulse-anim 1.2s ease-out infinite;
}

@keyframes event-pulse-anim {
    0% { r: 4; opacity: 0.6; }
    100% { r: 20; opacity: 0; }
}

.dependency-arc {
    fill: none;
    stroke-width: 1;
    stroke-dasharray: 6 3;
    opacity: 0.6;
    transition: stroke-width 0.15s ease, opacity 0.15s ease;
}

.dependency-arc:hover {
    stroke-width: 2;
    opacity: 1;
}

.wavefront-ripple {
    fill: none;
    stroke-width: 1;
    mix-blend-mode: screen;
    animation: wavefront-expand 0.8s ease-out forwards;
}

@keyframes wavefront-expand {
    0% { r: 4; opacity: 0.6; }
    100% { r: 40; opacity: 0; }
}

/* ===== Isometric Dividers ===== */
.iso-divider {
    width: 100%;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 600px;
}

.iso-block {
    width: 100px;
    height: 20px;
    position: relative;
    transform: rotateX(55deg) rotateZ(-45deg);
    transform-style: preserve-3d;
}

.iso-layer {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 1px solid rgba(0, 255, 200, 0.2);
    border-radius: 2px;
}

/* ===== Grid Background Lines ===== */
#dashboard::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 60px 60px;
    opacity: 0.5;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    #dashboard {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    #timeline-spine {
        display: none;
    }

    #status-panels {
        position: relative;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        overflow: visible;
        border-left: none;
        border-top: 1px solid var(--grid-line);
    }

    .bento-panel {
        flex: 1 1 140px;
        min-width: 140px;
    }

    #event-queue-bar {
        left: 0;
        right: 0;
    }

    .sim-section {
        min-height: 60vh;
    }

    .display-title {
        font-size: clamp(1.5rem, 4vw, 2.5rem);
    }
}
