/* === CSS Custom Properties === */
:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --surface: #1a2744;
    --border: #4a6fa5;
    --text-primary: #c8d0f0;
    --text-secondary: #8a9cc0;
    --text-dim: #5c6d8e;
    --accent-primary: #7b8cde;
    --accent-teal: #4dd0b8;
    --accent-magenta: #d64f8c;
    --chrome: #d0d8e8;
    --skeleton-a: #1a2744;
    --skeleton-b: #223352;
    --speed: 1;
    --diagonal-angle: 12deg;
}

/* === 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: 'Share Tech', sans-serif;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.8;
    letter-spacing: 0.02em;
    overflow-x: hidden;
    min-height: 100vh;
}

/* === Blueprint Grid === */
#blueprint-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.2s ease;
    background-image:
        linear-gradient(var(--surface) 1px, transparent 1px),
        linear-gradient(90deg, var(--surface) 1px, transparent 1px),
        linear-gradient(rgba(26,39,68,0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(26,39,68,0.3) 1px, transparent 1px);
    background-size:
        40px 40px,
        40px 40px,
        10px 10px,
        10px 10px;
    background-position: center center;
}

#blueprint-grid.visible {
    opacity: 0.15;
}

/* === Nav Trace === */
#nav-trace {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: 100vh;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.6s ease;
}

#nav-trace.visible {
    opacity: 1;
}

#nav-trace-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

#nav-trace-svg .trace-line {
    stroke: var(--accent-primary);
    stroke-width: 2;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    transition: stroke-dashoffset 1.2s ease;
}

#nav-trace-svg .trace-line.drawn {
    stroke-dashoffset: 0;
}

.nav-node {
    position: absolute;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1.5px solid var(--accent-primary);
    background: var(--bg-primary);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s, box-shadow 0.05s, background 0.05s;
}

.nav-node.revealed {
    opacity: 1;
}

.nav-node.active {
    background: var(--accent-primary);
    box-shadow: 0 0 12px rgba(123, 140, 222, 0.6), 0 0 24px rgba(123, 140, 222, 0.3);
}

.nav-node:hover {
    background: var(--accent-magenta);
    border-color: var(--accent-magenta);
}

.node-label {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem;
    color: var(--text-dim);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.15s;
}

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

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

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

#boot-text {
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
    color: var(--accent-teal);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: center;
    line-height: 2;
}

/* === Main Content === */
#main-content {
    position: relative;
    z-index: 1;
    padding-left: 48px;
    opacity: 0;
    transition: opacity 0.8s ease;
}

#main-content.visible {
    opacity: 1;
}

/* === Diagonal Sections === */
.diagonal-section {
    position: relative;
    padding: 120px 5vw 80px;
    min-height: 100vh;
    overflow: visible;
}

.section-odd {
    background: var(--bg-primary);
    clip-path: polygon(0 0, 100% 4vw, 100% calc(100% - 4vw), 0 100%);
}

.section-even {
    background: var(--bg-secondary);
    clip-path: polygon(0 4vw, 100% 0, 100% 100%, 0 calc(100% - 4vw));
}

.section-inner {
    max-width: 1100px;
    margin: 0 auto;
    position: relative;
}

/* === Component Bays === */
.component-bay {
    border: 1px solid var(--border);
    padding: 2rem 2.5rem;
    position: relative;
    margin-bottom: 2rem;
    background: rgba(10, 14, 26, 0.6);
    transition: border-color 0.05s, box-shadow 0.05s;
}

.component-bay:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(123, 140, 222, 0.15), 0 0 30px rgba(123, 140, 222, 0.08);
}

.bay-label {
    position: absolute;
    top: -0.6rem;
    left: 1rem;
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-teal);
    background: var(--bg-primary);
    padding: 0 0.5rem;
}

.section-even .bay-label {
    background: var(--bg-secondary);
}

.bay-content {
    position: relative;
    z-index: 1;
}

/* === Typography === */
.hero-title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(3rem, 8vw, 7rem);
    font-weight: 900;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-primary);
    text-shadow: 0 0 20px rgba(123, 140, 222, 0.6), 0 0 40px rgba(123, 140, 222, 0.3);
    line-height: 1.1;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-family: 'Share Tech', sans-serif;
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    color: var(--text-dim);
    max-width: 500px;
}

.section-heading {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-primary);
    text-shadow: 0 0 20px rgba(123, 140, 222, 0.6), 0 0 40px rgba(123, 140, 222, 0.3);
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.accent-text {
    color: var(--accent-teal);
    font-style: italic;
    font-size: 1.05rem;
}

p + p {
    margin-top: 1rem;
}

/* === Hero Section === */
.hero-bay {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.hero-illustration {
    position: absolute;
    right: -2rem;
    top: 50%;
    transform: translateY(-50%);
    width: 350px;
    height: 350px;
    opacity: 0.5;
}

/* === Section Illustrations === */
.section-illustration {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    width: 150px;
    height: 220px;
    opacity: 0.4;
}

/* === Component Bay Row === */
.component-bay-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.tool-bay {
    position: relative;
    padding-bottom: 4rem;
}

.tool-icon {
    position: absolute;
    bottom: 0.8rem;
    right: 0.8rem;
    width: 60px;
    height: 60px;
    opacity: 0.4;
}

/* === Waveform Bay === */
.waveform-bay {
    padding: 1rem 2rem;
}

.waveform-display {
    width: 100%;
    height: 80px;
}

/* === Hybrid Grid (Future Section) === */
.hybrid-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.hybrid-item {
    border-left: 2px solid var(--accent-teal);
    padding-left: 1rem;
}

.hybrid-label {
    display: block;
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-teal);
    margin-bottom: 0.3rem;
}

.hybrid-value {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* === Terminal / Join Section === */
.terminal-bay {
    max-width: 600px;
    margin: 0 auto;
}

.terminal-prompt {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border: 1px solid var(--accent-teal);
    background: rgba(10, 14, 26, 0.9);
    margin-top: 1.5rem;
}

.prompt-prefix {
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    color: var(--accent-teal);
    white-space: nowrap;
}

.terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    color: var(--text-primary);
    letter-spacing: 0.05em;
    caret-color: var(--accent-teal);
}

.terminal-input::placeholder {
    color: var(--text-dim);
    opacity: 0.5;
}

.terminal-hint {
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.terminal-response {
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
    color: var(--accent-teal);
    margin-top: 1rem;
    min-height: 1.5rem;
}

/* === Trace Gap === */
.trace-gap {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.trace-gap-line {
    width: 80%;
    height: 1px;
    background: var(--accent-primary);
    opacity: 0.2;
    animation: pulse-line 3s ease-in-out infinite;
}

@keyframes pulse-line {
    0%, 100% { opacity: 0.1; }
    50% { opacity: 0.35; }
}

/* === Oscilloscope === */
#oscilloscope {
    position: fixed;
    bottom: 0;
    left: 48px;
    right: 0;
    height: 40px;
    z-index: 90;
    pointer-events: none;
}

#oscilloscope-svg {
    width: 100%;
    height: 100%;
}

/* === Skeleton Loading State === */
.skeleton .component-bay {
    border-style: dashed;
    border-color: var(--surface);
}

.skeleton .bay-content > * {
    visibility: hidden;
}

.skeleton .component-bay::after {
    content: '';
    position: absolute;
    inset: 0.5rem;
    background: var(--skeleton-a);
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes skeleton-pulse {
    0%, 100% { background: var(--skeleton-a); }
    50% { background: var(--skeleton-b); }
}

/* === Kinetic Text (assembled state) === */
.kinetic-text span {
    display: inline-block;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.kinetic-text.assembled span {
    opacity: 1;
    transform: translateY(0);
}

/* === Section Reveal === */
.diagonal-section {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.diagonal-section.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* === Bay Assembly Animation === */
.component-bay {
    opacity: 0;
    transition: opacity 0.4s ease, border-color 0.05s, box-shadow 0.05s;
}

.revealed .component-bay {
    opacity: 1;
}

.revealed .component-bay:nth-child(1) { transition-delay: 0.1s; }
.revealed .component-bay:nth-child(2) { transition-delay: 0.3s; }
.revealed .component-bay-row { opacity: 0; transition: opacity 0.4s ease 0.4s; }
.revealed .component-bay-row { opacity: 1; }

/* === Responsive === */
@media (max-width: 768px) {
    #nav-trace { display: none; }
    #main-content { padding-left: 0; }
    #oscilloscope { left: 0; }

    .component-bay-row {
        grid-template-columns: 1fr;
    }

    .hero-illustration {
        position: static;
        transform: none;
        width: 200px;
        height: 200px;
        margin: 2rem auto;
        display: block;
        opacity: 0.4;
    }

    .section-illustration {
        position: static;
        margin: 1rem auto;
        display: block;
    }

    .hybrid-grid {
        grid-template-columns: 1fr;
    }

    .diagonal-section {
        padding: 80px 4vw 60px;
    }
}
