/* FONTS */
@import url('https://fonts.googleapis.com/css2?family=Silkscreen&family=Press+Start+2P&family=VT323&display=swap');

/* RESET & GLOBALS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Press Start 2P', cursive;
    background-color: #1A0F0A;
    color: #E8D5B7;
    overflow-x: hidden;
    line-height: 2.0;
}

/* SECTIONS */
.section {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* PARALLAX LAYERS - Base */
.parallax-layer {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    animation: pixel-materialize 1s steps(10) forwards;
}

@keyframes pixel-materialize {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* SECTION 0: PORTAL GRID */
.portal-grid {
    background: linear-gradient(180deg, #1A0F0A 0%, #2D1B10 50%, #1A0F0A 100%);
}

.portal-grid .sky-far {
    background: linear-gradient(to bottom, #1A0F0A 0%, #3D2A1F 100%);
    animation-delay: 0ms;
}

.portal-grid .distant {
    background:
        repeating-linear-gradient(90deg, #2D1B10 0px, #2D1B10 4px, #3D2A1F 4px, #3D2A1F 8px),
        linear-gradient(180deg, transparent 0%, #2D1B10 100%);
    animation-delay: 30ms;
}

.portal-grid .mid {
    background:
        repeating-linear-gradient(90deg, #3D2A1F 0px, #3D2A1F 8px, #2D1B10 8px, #2D1B10 16px);
    animation-delay: 60ms;
}

.portal-arch {
    position: absolute;
    width: 320px;
    height: 400px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    box-shadow:
        0 0 0 8px #4A2E1A,
        0 0 0 12px #2D1B10,
        0 0 0 16px #4A2E1A,
        0 0 0 20px #C9A534,
        /* outer arch stones */
        -80px -80px 0 4px #3D2A1F,
        -80px -76px 0 4px #3D2A1F,
        -76px -80px 0 4px #3D2A1F,
        80px -80px 0 4px #3D2A1F,
        80px -76px 0 4px #3D2A1F,
        76px -80px 0 4px #3D2A1F,
        -80px 80px 0 4px #3D2A1F,
        -76px 80px 0 4px #3D2A1F,
        80px 80px 0 4px #3D2A1F,
        76px 80px 0 4px #3D2A1F,
        /* decorative squares */
        -60px -60px 0 4px #C9A534,
        60px -60px 0 4px #C9A534,
        -60px 60px 0 4px #C9A534,
        60px 60px 0 4px #C9A534;
    background: linear-gradient(135deg, #2D1B10 0%, #1A0F0A 100%);
}

.domain-title {
    position: absolute;
    font-family: 'Silkscreen', monospace;
    font-size: 48px;
    letter-spacing: 0.12em;
    color: #C9A534;
    text-align: center;
    z-index: 10;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-shadow:
        4px 4px 0 #1A0F0A,
        8px 8px 0 #4A2E1A;
    animation: title-pulse 2s steps(2) infinite;
}

@keyframes title-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.pixel-cursor {
    position: absolute;
    width: 4px;
    height: 4px;
    background-color: #C9A534;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    animation: cursor-blink 1s steps(2) infinite;
}

@keyframes cursor-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* SECTION 1: FIRST TIMELINE (AUTUMN) */
.first-timeline {
    background: linear-gradient(180deg, #2D1B10 0%, #1A0F0A 100%);
}

.first-timeline .canopy-far {
    background: repeating-linear-gradient(
        90deg,
        #4A2E1A 0px,
        #4A2E1A 4px,
        #3D2A1F 4px,
        #3D2A1F 8px
    );
    animation-delay: 0ms;
}

.first-timeline .undergrowth {
    background:
        repeating-linear-gradient(90deg,
            #2D1B10 0px, #2D1B10 4px,
            #3D2A1F 4px, #3D2A1F 4px,
            #4A2E1A 4px, #4A2E1A 8px
        );
    animation-delay: 30ms;
}

.first-timeline .trunks {
    background: repeating-linear-gradient(90deg,
        #8B3A1D 0px, #8B3A1D 8px,
        #4A2E1A 8px, #4A2E1A 16px,
        #6B2A1D 16px, #6B2A1D 24px
    );
    animation-delay: 60ms;
}

.first-timeline .canopy {
    background: repeating-linear-gradient(90deg,
        #D4772C 0px, #D4772C 4px,
        #C9A534 4px, #C9A534 8px,
        #D4772C 8px, #D4772C 12px
    );
    animation-delay: 90ms;
}

.candle-left {
    position: absolute;
    width: 16px;
    height: 48px;
    left: 60px;
    bottom: 80px;
    box-shadow:
        0 0 0 4px #4A2E1A,
        4px -8px 0 4px #D4772C,
        4px -4px 0 4px #D4772C,
        4px 0 0 4px #4A2E1A,
        8px -8px 0 4px #D4772C,
        8px -4px 0 4px #C9A534,
        8px 0 0 4px #4A2E1A,
        12px -8px 0 4px #D4772C,
        12px -4px 0 4px #D4772C,
        12px 0 0 4px #4A2E1A;
    animation: flame-flicker 0.6s steps(4) infinite;
}

.candle-right {
    position: absolute;
    width: 16px;
    height: 48px;
    right: 60px;
    bottom: 80px;
    box-shadow:
        0 0 0 4px #4A2E1A,
        4px -8px 0 4px #D4772C,
        4px -4px 0 4px #D4772C,
        4px 0 0 4px #4A2E1A,
        8px -8px 0 4px #D4772C,
        8px -4px 0 4px #C9A534,
        8px 0 0 4px #4A2E1A,
        12px -8px 0 4px #D4772C,
        12px -4px 0 4px #D4772C,
        12px 0 0 4px #4A2E1A;
    animation: flame-flicker 0.6s steps(4) infinite 0.2s;
}

@keyframes flame-flicker {
    0% {
        box-shadow:
            0 0 0 4px #4A2E1A,
            4px -8px 0 4px #D4772C,
            4px -4px 0 4px #D4772C,
            4px 0 0 4px #4A2E1A,
            8px -8px 0 4px #D4772C,
            8px -4px 0 4px #C9A534,
            8px 0 0 4px #4A2E1A,
            12px -8px 0 4px #D4772C,
            12px -4px 0 4px #D4772C,
            12px 0 0 4px #4A2E1A;
    }
    25% {
        box-shadow:
            0 0 0 4px #4A2E1A,
            4px -6px 0 4px #D4772C,
            4px -2px 0 4px #D4772C,
            4px 0 0 4px #4A2E1A,
            8px -6px 0 4px #C9A534,
            8px -2px 0 4px #D4772C,
            8px 0 0 4px #4A2E1A,
            12px -6px 0 4px #D4772C,
            12px -2px 0 4px #D4772C,
            12px 0 0 4px #4A2E1A;
    }
    50% {
        box-shadow:
            0 0 0 4px #4A2E1A,
            4px -10px 0 4px #D4772C,
            4px -6px 0 4px #C9A534,
            4px 0 0 4px #4A2E1A,
            8px -10px 0 4px #D4772C,
            8px -6px 0 4px #D4772C,
            8px 0 0 4px #4A2E1A,
            12px -10px 0 4px #D4772C,
            12px -6px 0 4px #C9A534,
            12px 0 0 4px #4A2E1A;
    }
    75% {
        box-shadow:
            0 0 0 4px #4A2E1A,
            4px -7px 0 4px #D4772C,
            4px -3px 0 4px #D4772C,
            4px 0 0 4px #4A2E1A,
            8px -7px 0 4px #D4772C,
            8px -3px 0 4px #C9A534,
            8px 0 0 4px #4A2E1A,
            12px -7px 0 4px #D4772C,
            12px -3px 0 4px #D4772C,
            12px 0 0 4px #4A2E1A;
    }
}

/* SECTION 2: SECOND TIMELINE (WINTER) */
.second-timeline {
    background: linear-gradient(180deg, #1A1A2E 0%, #0F1419 100%);
}

.second-timeline .canopy-far-winter {
    background: repeating-linear-gradient(
        90deg,
        #2E4A5C 0px,
        #2E4A5C 4px,
        #1E3A4A 4px,
        #1E3A4A 8px
    );
    animation-delay: 0ms;
}

.second-timeline .undergrowth-winter {
    background:
        repeating-linear-gradient(90deg,
            #1E3A4A 0px, #1E3A4A 4px,
            #2E4A5C 4px, #2E4A5C 4px,
            #1A2A3A 4px, #1A2A3A 8px
        );
    animation-delay: 30ms;
}

.second-timeline .trunks-winter {
    background: repeating-linear-gradient(90deg,
        #7BA3BC 0px, #7BA3BC 8px,
        #2E4A5C 8px, #2E4A5C 16px,
        #5B8ABC 16px, #5B8ABC 24px
    );
    animation-delay: 60ms;
}

.second-timeline .canopy-winter {
    background: repeating-linear-gradient(90deg,
        #5B8ABC 0px, #5B8ABC 4px,
        #7BA3BC 4px, #7BA3BC 8px,
        #5B8ABC 8px, #5B8ABC 12px
    );
    animation-delay: 90ms;
}

.candle-left-winter {
    position: absolute;
    width: 16px;
    height: 48px;
    left: 60px;
    bottom: 80px;
    box-shadow:
        0 0 0 4px #2E4A5C,
        4px -8px 0 4px #7BA3BC,
        4px -4px 0 4px #7BA3BC,
        4px 0 0 4px #2E4A5C,
        8px -8px 0 4px #7BA3BC,
        8px -4px 0 4px #5B8ABC,
        8px 0 0 4px #2E4A5C,
        12px -8px 0 4px #7BA3BC,
        12px -4px 0 4px #7BA3BC,
        12px 0 0 4px #2E4A5C;
    animation: flame-flicker-blue 0.6s steps(4) infinite;
}

.candle-right-winter {
    position: absolute;
    width: 16px;
    height: 48px;
    right: 60px;
    bottom: 80px;
    box-shadow:
        0 0 0 4px #2E4A5C,
        4px -8px 0 4px #7BA3BC,
        4px -4px 0 4px #7BA3BC,
        4px 0 0 4px #2E4A5C,
        8px -8px 0 4px #7BA3BC,
        8px -4px 0 4px #5B8ABC,
        8px 0 0 4px #2E4A5C,
        12px -8px 0 4px #7BA3BC,
        12px -4px 0 4px #7BA3BC,
        12px 0 0 4px #2E4A5C;
    animation: flame-flicker-blue 0.6s steps(4) infinite 0.2s;
}

@keyframes flame-flicker-blue {
    0% {
        box-shadow:
            0 0 0 4px #2E4A5C,
            4px -8px 0 4px #7BA3BC,
            4px -4px 0 4px #7BA3BC,
            4px 0 0 4px #2E4A5C,
            8px -8px 0 4px #7BA3BC,
            8px -4px 0 4px #5B8ABC,
            8px 0 0 4px #2E4A5C,
            12px -8px 0 4px #7BA3BC,
            12px -4px 0 4px #7BA3BC,
            12px 0 0 4px #2E4A5C;
    }
    25% {
        box-shadow:
            0 0 0 4px #2E4A5C,
            4px -6px 0 4px #7BA3BC,
            4px -2px 0 4px #7BA3BC,
            4px 0 0 4px #2E4A5C,
            8px -6px 0 4px #5B8ABC,
            8px -2px 0 4px #7BA3BC,
            8px 0 0 4px #2E4A5C,
            12px -6px 0 4px #7BA3BC,
            12px -2px 0 4px #7BA3BC,
            12px 0 0 4px #2E4A5C;
    }
    50% {
        box-shadow:
            0 0 0 4px #2E4A5C,
            4px -10px 0 4px #7BA3BC,
            4px -6px 0 4px #5B8ABC,
            4px 0 0 4px #2E4A5C,
            8px -10px 0 4px #7BA3BC,
            8px -6px 0 4px #7BA3BC,
            8px 0 0 4px #2E4A5C,
            12px -10px 0 4px #7BA3BC,
            12px -6px 0 4px #5B8ABC,
            12px 0 0 4px #2E4A5C;
    }
    75% {
        box-shadow:
            0 0 0 4px #2E4A5C,
            4px -7px 0 4px #7BA3BC,
            4px -3px 0 4px #7BA3BC,
            4px 0 0 4px #2E4A5C,
            8px -7px 0 4px #7BA3BC,
            8px -3px 0 4px #5B8ABC,
            8px 0 0 4px #2E4A5C,
            12px -7px 0 4px #7BA3BC,
            12px -3px 0 4px #7BA3BC,
            12px 0 0 4px #2E4A5C;
    }
}

/* SECTION 3: CONVERGENCE */
.convergence {
    background: linear-gradient(180deg, #2D1B10 0%, #1A1A2E 50%, #1A0F0A 100%);
}

.dither-zone {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background:
        repeating-linear-gradient(90deg,
            #D4772C 0px, #D4772C 4px,
            #2E4A5C 4px, #2E4A5C 8px
        ),
        repeating-linear-gradient(0deg,
            transparent 0px, transparent 4px,
            rgba(0,0,0,0.1) 4px, rgba(0,0,0,0.1) 8px
        );
    opacity: 0.6;
    animation: pixel-materialize 1s steps(10) forwards;
}

.candelabra {
    position: absolute;
    width: 64px;
    height: 96px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    box-shadow:
        /* base */
        0 32px 0 4px #4A2E1A,
        4px 32px 0 4px #4A2E1A,
        8px 32px 0 4px #4A2E1A,
        12px 32px 0 4px #4A2E1A,
        16px 32px 0 4px #4A2E1A,
        20px 32px 0 4px #4A2E1A,
        24px 32px 0 4px #4A2E1A,
        28px 32px 0 4px #4A2E1A,
        /* stem */
        12px 20px 0 4px #8B3A1D,
        12px 16px 0 4px #8B3A1D,
        12px 12px 0 4px #8B3A1D,
        12px 8px 0 4px #8B3A1D,
        /* left candle */
        4px 0 0 4px #C9A534,
        8px -4px 0 4px #D4772C,
        8px 0 0 4px #C9A534,
        /* center candle */
        12px -4px 0 4px #D4772C,
        16px -8px 0 4px #D4772C,
        16px -4px 0 4px #C9A534,
        16px 0 0 4px #C9A534,
        /* right candle */
        20px 0 0 4px #C9A534,
        24px -4px 0 4px #D4772C,
        24px 0 0 4px #C9A534;
    animation: candelabra-glow 1.5s steps(3) infinite;
}

@keyframes candelabra-glow {
    0%, 100% {
        text-shadow: 0 0 12px #D4772C;
        filter: drop-shadow(0 0 8px #D4772C);
    }
    50% {
        text-shadow: 0 0 16px #C9A534;
        filter: drop-shadow(0 0 12px #C9A534);
    }
}

/* SECTION 4: ARCHIVE */
.archive {
    background: linear-gradient(180deg, #1A0F0A 0%, #2D1B10 50%, #1A0F0A 100%);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 60px;
}

.bookshelf-back {
    position: absolute;
    width: 100%;
    height: 60%;
    bottom: 0;
    background: repeating-linear-gradient(
        90deg,
        #3D2A1F 0px, #3D2A1F 4px,
        #2D1B10 4px, #2D1B10 8px
    );
    opacity: 0.6;
    animation: pixel-materialize 1s steps(10) forwards;
}

.bookshelf-left,
.bookshelf-center,
.bookshelf-right {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 4px;
    margin: 0 8px;
}

.book {
    width: 24px;
    height: 4px;
    background-color: #C9A534;
    border: 2px solid #4A2E1A;
    cursor: pointer;
    transition: all 0.2s steps(2);
    opacity: 0;
    animation: pixel-materialize 0.6s steps(5) forwards;
}

.book-1 { animation-delay: 0ms; }
.book-2 { animation-delay: 50ms; background-color: #D4772C; }
.book-3 { animation-delay: 100ms; }
.book-4 { animation-delay: 150ms; background-color: #8B3A1D; }
.book-5 { animation-delay: 200ms; background-color: #C9A534; }

.book-6 { animation-delay: 50ms; background-color: #D4772C; }
.book-7 { animation-delay: 100ms; }
.book-8 { animation-delay: 150ms; background-color: #C9A534; }
.book-9 { animation-delay: 200ms; background-color: #8B3A1D; }
.book-10 { animation-delay: 250ms; background-color: #D4772C; }

.book-11 { animation-delay: 100ms; }
.book-12 { animation-delay: 150ms; background-color: #8B3A1D; }
.book-13 { animation-delay: 200ms; background-color: #D4772C; }
.book-14 { animation-delay: 250ms; background-color: #C9A534; }
.book-15 { animation-delay: 300ms; background-color: #8B3A1D; }

.book:hover {
    transform: translateX(2px) scaleX(1.1);
    background-color: #E8D5B7;
}

/* DIALOGUE BOXES */
.dialogue-box {
    position: relative;
    z-index: 5;
    background-color: rgba(26, 15, 10, 0.95);
    border: 4px solid #4A2E1A;
    padding: 20px;
    max-width: 480px;
    width: 90%;
    box-shadow:
        -4px -4px 0 #C9A534,
        4px 4px 0 #4A2E1A;
    animation: dialogue-appear 0.8s steps(4) forwards;
}

@keyframes dialogue-appear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.dialogue-box h2 {
    font-family: 'Silkscreen', monospace;
    font-size: 32px;
    letter-spacing: 0.12em;
    color: #C9A534;
    margin-bottom: 12px;
    text-transform: uppercase;
}

.dialogue-box p {
    font-family: 'VT323', monospace;
    font-size: 14px;
    line-height: 1.8;
    color: #E8D5B7;
    text-align: justify;
}

/* RESPONSIVE */
@media (max-width: 640px) {
    .domain-title {
        font-size: 32px;
    }

    .dialogue-box {
        max-width: 85vw;
        padding: 12px;
    }

    .dialogue-box h2 {
        font-size: 24px;
    }

    .dialogue-box p {
        font-size: 12px;
    }

    .candle-left, .candle-right,
    .candle-left-winter, .candle-right-winter {
        display: none;
    }
}
