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

:root {
    --bg-primary: #faf0e2;
    --bg-secondary: #e8cdb5;
    --accent-primary: #c45d3e;
    --accent-secondary: #a0422a;
    --text-primary: #3b1f14;
    --text-secondary: #5b3a29;
    --text-tertiary: #a0846e;
    --highlight: #e8a87c;
    --shadow-dark: #2a1509;
    --peach-gold: #f4d6b0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Archivo', sans-serif;
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    color: var(--text-secondary);
    background: var(--bg-primary);
    overflow-x: hidden;
    position: relative;
}

/* === SCANLINES OVERLAY === */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 3px,
        rgba(59, 31, 20, 0.03) 3px,
        rgba(59, 31, 20, 0.03) 4px
    );
    animation: scanlineShift 0.1s steps(1) infinite;
}

@keyframes scanlineShift {
    0% { background-position-y: 0; }
    100% { background-position-y: 1px; }
}

/* === ISOMETRIC GRID UNDERLAY === */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.03;
    background:
        repeating-linear-gradient(30deg, var(--text-primary) 0px, transparent 1px, transparent 60px),
        repeating-linear-gradient(150deg, var(--text-primary) 0px, transparent 1px, transparent 60px);
}

/* === SCENE 1: BOOT SEQUENCE === */
.scene-boot {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--shadow-dark);
    position: relative;
    z-index: 1;
    animation: bootFade 1.2s ease 3s forwards;
}

@keyframes bootFade {
    to { background: var(--bg-primary); }
}

.boot-title {
    display: flex;
    gap: 0.05em;
}

.letter {
    font-family: 'Righteous', cursive;
    font-size: clamp(4rem, 12vw, 9rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--peach-gold);
    opacity: 0;
    transform: rotateX(60deg) rotateZ(-45deg) scale(0.3);
    animation: letterMorph 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.letter[data-index="0"] { animation-delay: 0.4s; }
.letter[data-index="1"] { animation-delay: 0.6s; }
.letter[data-index="2"] { animation-delay: 0.8s; }
.letter[data-index="3"] { animation-delay: 1.0s; }
.letter[data-index="4"] { animation-delay: 1.2s; }

@keyframes letterMorph {
    0% {
        opacity: 0;
        transform: rotateX(60deg) rotateZ(-45deg) scale(0.3);
    }
    100% {
        opacity: 1;
        transform: rotateX(0) rotateZ(0) scale(1);
    }
}

.boot-subtitle {
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-primary);
    margin-top: 1.5rem;
    min-height: 1.5em;
}

/* === SCENE 2 & 4: TIMELINE === */
.scene-timeline {
    position: relative;
    z-index: 1;
    padding: clamp(4rem, 8vh, 7rem) 1rem;
    min-height: 400vh;
}

.scene-timeline-2 {
    min-height: 300vh;
}

.timeline-spine {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 3px;
    transform: translateX(-50%);
    background: linear-gradient(
        to bottom,
        var(--accent-primary),
        var(--highlight),
        var(--text-secondary)
    );
    opacity: 0;
    animation: spineReveal 1s ease forwards;
    animation-delay: 3.5s;
}

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

/* === TIMELINE NODES === */
.timeline-node {
    position: relative;
    margin-bottom: clamp(4rem, 8vh, 7rem);
    display: flex;
    align-items: flex-start;
}

.node-left {
    justify-content: flex-end;
    padding-right: calc(50% + 40px);
    text-align: right;
}

.node-right {
    justify-content: flex-start;
    padding-left: calc(50% + 40px);
    text-align: left;
}

.node-marker {
    position: absolute;
    left: 50%;
    top: 1rem;
    transform: translateX(-50%);
    z-index: 2;
}

.iso-cube {
    width: 40px;
    height: 40px;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(60deg) rotateZ(-45deg) scale(0);
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.iso-cube.cube-large {
    width: 50px;
    height: 50px;
}

.timeline-node.visible .iso-cube {
    transform: rotateX(60deg) rotateZ(-45deg) scale(1);
}

.cube-face {
    position: absolute;
    width: 100%;
    height: 100%;
}

.cube-top {
    background: var(--highlight);
    transform: translateY(-50%) rotateX(90deg);
    width: 100%;
    height: 100%;
    clip-path: polygon(50% 0%, 100% 25%, 50% 50%, 0% 25%);
    background: var(--highlight);
    position: absolute;
    top: -10px;
    left: 0;
}

.cube-front {
    background: var(--accent-primary);
    clip-path: polygon(0% 25%, 50% 50%, 50% 100%, 0% 75%);
    position: absolute;
    top: -10px;
    left: 0;
}

.cube-side {
    background: var(--accent-secondary);
    clip-path: polygon(50% 50%, 100% 25%, 100% 75%, 50% 100%);
    position: absolute;
    top: -10px;
    left: 0;
}

.node-connector {
    position: absolute;
    top: 1.8rem;
    width: 40px;
    height: 2px;
    background: var(--accent-primary);
    opacity: 0;
    transition: opacity 0.4s ease 0.3s;
}

.node-left .node-connector {
    right: calc(50% - 20px);
    transform-origin: right center;
}

.node-right .node-connector {
    left: calc(50% - 20px);
    transform-origin: left center;
}

.timeline-node.visible .node-connector {
    opacity: 1;
}

.node-card {
    max-width: 420px;
    padding: 2rem 2.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--bg-secondary);
    box-shadow: 8px 8px 0 rgba(42, 21, 9, 0.08);
    opacity: 0;
    transition: opacity 0.6s ease 0.4s, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.4s;
}

.node-left .node-card {
    transform: rotate(-1.2deg) translateX(-30px);
}

.node-right .node-card {
    transform: rotate(0.8deg) translateX(30px);
}

.timeline-node.visible .node-card {
    opacity: 1;
}

.timeline-node.visible.node-left .node-card {
    transform: rotate(-1.2deg) translateX(0);
}

.timeline-node.visible.node-right .node-card {
    transform: rotate(0.8deg) translateX(0);
}

.node-date {
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-primary);
    display: block;
    margin-bottom: 0.75rem;
}

.node-card h3 {
    font-family: 'Righteous', cursive;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    line-height: 1.2;
}

.node-card p {
    color: var(--text-secondary);
    font-weight: 400;
}

/* === NODE ILLUSTRATIONS === */
.node-illustration {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
}

.iso-chronoscope {
    position: relative;
    width: 60px;
    height: 80px;
}

.chrono-body {
    position: absolute;
    bottom: 0;
    left: 10px;
    width: 40px;
    height: 60px;
    background: var(--accent-primary);
    transform: skewX(-5deg);
}

.chrono-dial {
    position: absolute;
    bottom: 20px;
    left: 18px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--highlight) 30%, var(--accent-secondary) 100%);
}

.chrono-top {
    position: absolute;
    top: 0;
    left: 5px;
    width: 50px;
    height: 20px;
    background: var(--accent-secondary);
    clip-path: polygon(10% 100%, 90% 100%, 80% 0%, 20% 0%);
}

.iso-platform {
    position: relative;
    width: 80px;
    height: 40px;
}

.platform-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 80px;
    height: 20px;
    background: var(--highlight);
    clip-path: polygon(20% 0%, 80% 0%, 100% 50%, 80% 100%, 20% 100%, 0% 50%);
}

.platform-front {
    position: absolute;
    top: 15px;
    left: 0;
    width: 40px;
    height: 25px;
    background: var(--accent-primary);
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 80%);
}

.platform-side {
    position: absolute;
    top: 15px;
    left: 40px;
    width: 40px;
    height: 25px;
    background: var(--accent-secondary);
    clip-path: polygon(0% 0%, 100% 0%, 100% 80%, 0% 100%);
}

/* === SCENE 3: IMPOSSIBLE STAIRCASE === */
.scene-staircase {
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-secondary);
    position: relative;
    z-index: 1;
}

.penrose-staircase {
    width: 200px;
    height: 200px;
    position: relative;
    transform-style: preserve-3d;
    animation: staircaseRotate 20s linear infinite;
}

@keyframes staircaseRotate {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(360deg); }
}

.stair-flight {
    position: absolute;
    width: 80px;
    height: 12px;
    background: var(--accent-primary);
}

.flight-1 { top: 40px; left: 60px; transform: rotate(-30deg); background: var(--accent-primary); }
.flight-2 { top: 80px; left: 100px; transform: rotate(60deg); background: var(--accent-secondary); }
.flight-3 { top: 120px; left: 60px; transform: rotate(-30deg); background: var(--highlight); }
.flight-4 { top: 80px; left: 20px; transform: rotate(60deg); background: var(--text-tertiary); }

.stair-platform {
    position: absolute;
    width: 40px;
    height: 40px;
    background: var(--accent-secondary);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.platform-1 { top: 20px; left: 80px; background: var(--highlight); }
.platform-2 { top: 60px; left: 130px; background: var(--accent-primary); }
.platform-3 { top: 120px; left: 80px; background: var(--accent-secondary); }
.platform-4 { top: 60px; left: 30px; background: var(--peach-gold); }

/* === SCENE 5: TERMINUS === */
.scene-terminus {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--bg-primary);
    position: relative;
    z-index: 1;
}

.terminus-rings {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid var(--accent-primary);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    animation: ringPulse 3s ease-out infinite;
}

.ring-1 { width: 80px; height: 80px; animation-delay: 0s; }
.ring-2 { width: 140px; height: 140px; animation-delay: 1s; }
.ring-3 { width: 200px; height: 200px; animation-delay: 2s; }

@keyframes ringPulse {
    0% { opacity: 0.4; transform: translate(-50%, -50%) scale(0.8); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
}

.terminus-hourglass {
    position: relative;
    width: 40px;
    height: 60px;
    margin-bottom: 2rem;
}

.hourglass-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-top: 30px solid var(--accent-primary);
}

.hourglass-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-bottom: 30px solid var(--accent-secondary);
}

.terminus-symbol {
    font-family: 'Righteous', cursive;
    font-size: 4rem;
    color: var(--accent-primary);
    animation: pulse 3s ease-in-out infinite;
    position: relative;
    z-index: 2;
}

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

.terminus-footer {
    margin-top: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.footer-text {
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-variant: small-caps;
}

.ouroboros {
    width: 30px;
    height: 30px;
    border: 2px solid var(--text-tertiary);
    border-radius: 50%;
    position: relative;
    animation: ouroborosSpin 4s linear infinite;
}

.ouroboros-arrow {
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 6px solid var(--text-tertiary);
}

@keyframes ouroborosSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* === MOBILE === */
@media (max-width: 768px) {
    .timeline-spine {
        left: 24px;
    }

    .timeline-node {
        padding-left: 60px !important;
        padding-right: 1rem !important;
        justify-content: flex-start !important;
        text-align: left !important;
    }

    .node-marker {
        left: 24px;
    }

    .node-connector {
        left: 44px !important;
        right: auto !important;
        width: 16px;
    }

    .node-card {
        max-width: 100%;
        padding: 1.5rem;
    }

    .node-left .node-card,
    .node-right .node-card {
        transform: none;
    }

    .timeline-node.visible.node-left .node-card,
    .timeline-node.visible.node-right .node-card {
        transform: none;
    }

    .penrose-staircase {
        width: 150px;
        height: 150px;
    }
}
