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

html {
    scroll-behavior: smooth;
}

body {
    background: #0d0221;
    color: #e0d4f7;
    font-family: 'Exo 2', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    line-height: 1.65;
    overflow-x: hidden;
}

/* === SCANLINE OVERLAY === */
.scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(0,0,0,0.08) 2px,
        rgba(0,0,0,0.08) 4px
    );
    pointer-events: none;
    z-index: 9999;
    opacity: 0.35;
    transition: opacity 0.5s;
}

/* === THREAD COUNTER === */
.thread-counter {
    position: fixed;
    top: 20px;
    right: 20px;
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    color: #39ff14;
    text-shadow: 0 0 6px #39ff1488;
    z-index: 100;
    background: rgba(13, 2, 33, 0.85);
    padding: 8px 14px;
    border: 1px solid #39ff1444;
    opacity: 0;
}

.thread-counter.visible {
    opacity: 1;
}

/* === TIMELINE SPINE === */
.timeline-spine {
    position: fixed;
    left: 8vw;
    top: 0;
    width: 4px;
    height: 100%;
    background: #ff2d6b;
    box-shadow: 0 0 12px #ff2d6b, 0 0 24px #ff2d6b55;
    z-index: 50;
    transform: scaleY(0);
    transform-origin: top;
}

.timeline-spine.active {
    animation: spineIgnite 800ms ease-out forwards;
}

@keyframes spineIgnite {
    to { transform: scaleY(1); }
}

/* === GRID BACKGROUND === */
.grid-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(
            90deg,
            rgba(26, 10, 46, 0.15) 0px,
            transparent 1px,
            transparent 60px
        ),
        repeating-linear-gradient(
            0deg,
            rgba(26, 10, 46, 0.15) 0px,
            transparent 1px,
            transparent 60px
        );
    animation: gridPulse 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes gridPulse {
    0%, 100% { opacity: 0.08; }
    50% { opacity: 0.15; }
}

/* === SCENES === */
.scene {
    position: relative;
    min-height: 100vh;
    padding: 60px 20px 60px calc(8vw + 40px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* === SCENE: BOOT === */
.scene-boot {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.title-container {
    position: relative;
    z-index: 10;
    text-align: center;
    opacity: 0;
}

.title-container.visible {
    opacity: 1;
}

.main-title {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 7vw, 6rem);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #e0d4f7;
    text-shadow: 3px 3px 0 #ff2d6b, -2px -2px 0 #00e5ff;
}

.main-title span {
    display: inline-block;
    opacity: 0;
}

.main-title span.revealed {
    opacity: 1;
}

/* === SKYLINE === */
.skyline {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 320px;
    opacity: 0;
    transition: opacity 600ms ease;
}

.skyline.visible {
    opacity: 1;
}

.skyline-resume {
    position: relative;
    height: 280px;
    margin-top: 40px;
}

.building {
    position: absolute;
    bottom: 0;
    background: #1a0a2e;
}

.building .antenna {
    position: absolute;
    top: -40px;
    left: 50%;
    width: 1px;
    height: 40px;
    background: #e0d4f7;
}

.building .antenna::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -3px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ff2d6b;
    animation: antennaPulse 1.5s ease-in-out infinite;
}

@keyframes antennaPulse {
    0%, 100% { opacity: 0.3; box-shadow: 0 0 4px #ff2d6b; }
    50% { opacity: 1; box-shadow: 0 0 12px #ff2d6b; }
}

.window {
    position: absolute;
    width: 4px;
    height: 4px;
    animation: windowBlink var(--blink-dur, 3s) ease-in-out infinite;
}

.window:nth-child(odd) {
    background: #ff2d6b;
}
.window:nth-child(even) {
    background: #00e5ff;
}
.window:nth-child(3n) {
    background: #e5ff00;
}

@keyframes windowBlink {
    0%, 40%, 100% { opacity: 1; }
    50%, 90% { opacity: 0; }
}

/* === THREAD NODES === */
.thread-node {
    position: absolute;
    left: calc(8vw - 4px);
    top: 50%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #ff2d6b;
    background: transparent;
    z-index: 60;
    animation: nodePulse var(--pulse-dur, 1.2s) ease-in-out infinite;
    transition: background 0.3s, box-shadow 0.3s;
}

.thread-node.filled {
    background: #ff2d6b;
    box-shadow: 0 0 10px #ff2d6b;
}

.node-blocked {
    border-color: #ff2d6b;
}

.node-blocked.filled {
    background: #ff2d6b;
    box-shadow: 0 0 14px #ff2d6b;
}

.node-resume {
    border-color: #00e5ff;
}

.node-resume.filled {
    background: #00e5ff;
    box-shadow: 0 0 10px #00e5ff;
}

.node-final {
    position: absolute;
    left: calc(8vw - 8px);
    top: 50%;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #e0d4f7;
    background: #e0d4f7;
    z-index: 60;
    animation: finalPulse 2s ease-in-out infinite;
}

@keyframes nodePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.4); }
}

@keyframes finalPulse {
    0%, 100% { box-shadow: 0 0 8px #e0d4f7; }
    50% { box-shadow: 0 0 24px #e0d4f7, 0 0 48px #e0d4f766; }
}

/* === THREAD BLOCKS === */
.thread-block {
    position: relative;
    background: rgba(26, 10, 46, 0.92);
    border-left: 3px solid #ff2d6b;
    padding: 40px 36px;
    margin: 20px 0;
    transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.thread-block:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px rgba(255, 45, 107, 0.3);
}

.block-wide {
    width: 70vw;
    max-width: 900px;
}

/* === ANIMATE IN === */
.animate-in {
    opacity: 0;
    transform: translateX(-60px);
    transition: opacity 400ms cubic-bezier(0.16, 1, 0.3, 1),
                transform 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

.animate-in[data-direction="right"] {
    transform: translateX(60px);
}

.animate-in.visible {
    opacity: 1;
    transform: translateX(0);
}

.animate-in.visible:hover {
    transform: translateY(-8px);
}

/* === SECTION TITLES === */
.section-title {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4rem);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #e0d4f7;
    text-shadow: 3px 3px 0 #ff2d6b, -2px -2px 0 #00e5ff;
    margin-bottom: 24px;
}

.title-cyan {
    text-shadow: 3px 3px 0 #00e5ff, -2px -2px 0 #e5ff00;
}

.title-yellow {
    text-shadow: 3px 3px 0 #e5ff00, -2px -2px 0 #ff2d6b;
}

.title-danger {
    text-shadow: 3px 3px 0 #ff2d6b, -2px -2px 0 #ff6b35;
    color: #ff2d6b;
}

.title-final {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4rem);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #e0d4f7;
    text-shadow: 0 0 20px #e0d4f766;
}

.section-body {
    font-family: 'Exo 2', sans-serif;
    font-weight: 400;
    color: #e0d4f7;
    margin-bottom: 16px;
    max-width: 700px;
}

.system-msg {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    color: #39ff14;
    text-shadow: 0 0 6px #39ff1488;
    margin-top: 24px;
    padding: 12px;
    border: 1px solid #39ff1444;
    background: rgba(13, 2, 33, 0.8);
}

/* === THREAD DIAGRAMS === */
.thread-diagram {
    position: absolute;
    top: 16px;
    right: 16px;
    opacity: 0.7;
}

/* === INTERRUPT STRIPS === */
.interrupt-strip {
    width: 100%;
    height: 40px;
    background: #ff6b35;
    display: flex;
    align-items: center;
    overflow: hidden;
    position: relative;
    z-index: 55;
}

.strip-alt {
    background: #e5ff00;
}

.strip-alt .interrupt-text {
    color: #0d0221;
}

.interrupt-text {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    color: #0d0221;
    white-space: nowrap;
    animation: scrollText 20s linear infinite;
}

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

/* === SCENE: EXECUTE (DUAL THREADS) === */
.scene-execute {
    padding-bottom: 80px;
}

.dual-threads {
    display: flex;
    gap: 0;
    align-items: stretch;
    position: relative;
}

.block-left {
    width: 38vw;
    max-width: 500px;
    border-left: 3px solid #00e5ff;
}

.block-left:hover {
    box-shadow: 0 12px 40px rgba(0, 229, 255, 0.3);
}

.block-right {
    width: 38vw;
    max-width: 500px;
    border-left: 3px solid #e5ff00;
}

.block-right:hover {
    box-shadow: 0 12px 40px rgba(229, 255, 0, 0.3);
}

.sync-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 0 12px 20px;
    position: relative;
}

.sync-line {
    width: 1px;
    flex: 1;
    background: repeating-linear-gradient(
        to bottom,
        #00e5ff 0px,
        #00e5ff 6px,
        transparent 6px,
        transparent 12px
    );
}

.sync-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.7rem;
    color: #00e5ff;
    text-shadow: 0 0 6px #00e5ff88;
    writing-mode: horizontal-tb;
    white-space: nowrap;
    margin-top: 8px;
}

/* === SCENE: BLOCK === */
.scene-block {
    background: linear-gradient(180deg, #0d0221, #2a0010);
}

.block-danger {
    border: 2px solid #ff2d6b;
    border-left-width: 3px;
    box-shadow: 0 0 20px rgba(255, 45, 107, 0.2);
    width: 70vw;
    max-width: 900px;
}

.block-danger.glitch-active {
    animation: blockGlitch 120ms steps(5);
}

@keyframes blockGlitch {
    0% { clip-path: inset(0 0 80% 0); transform: translateX(4px); }
    20% { clip-path: inset(20% 0 60% 0); transform: translateX(-3px); }
    40% { clip-path: inset(40% 0 40% 0); transform: translateX(6px); }
    60% { clip-path: inset(60% 0 20% 0); transform: translateX(-2px); }
    80% { clip-path: inset(80% 0 0 0); transform: translateX(5px); }
    100% { clip-path: inset(0); transform: translateX(0); }
}

.block-danger:hover {
    box-shadow: 0 12px 40px rgba(255, 45, 107, 0.4);
}

/* === SCENE: RESUME === */
.scene-resume {
    padding-bottom: 40px;
}

.block-resume {
    width: 70vw;
    max-width: 900px;
    border-left: 3px solid #00e5ff;
}

.block-resume:hover {
    box-shadow: 0 12px 40px rgba(0, 229, 255, 0.3);
}

/* === SCENE: EXIT === */
.scene-exit {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
}

.exit-content {
    position: relative;
    z-index: 10;
}

.exit-timestamp {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    color: #39ff14;
    text-shadow: 0 0 6px #39ff1488;
    margin-top: 24px;
}

/* === BLOCK SHAKE === */
@keyframes blockShake {
    0% { transform: translateX(0); }
    25% { transform: translateX(2px); }
    50% { transform: translateX(-2px); }
    75% { transform: translateX(1px); }
    100% { transform: translateX(0); }
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .dual-threads {
        flex-direction: column;
    }

    .block-left, .block-right {
        width: 80vw;
        max-width: none;
    }

    .sync-divider {
        flex-direction: row;
        padding: 12px 0;
    }

    .sync-line {
        height: 1px;
        width: 100%;
        flex: 1;
        background: repeating-linear-gradient(
            to right,
            #00e5ff 0px,
            #00e5ff 6px,
            transparent 6px,
            transparent 12px
        );
    }

    .block-wide, .block-danger, .block-resume {
        width: 80vw;
    }

    .scene {
        padding-left: calc(8vw + 24px);
        padding-right: 16px;
    }
}
