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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background: #0d0b0a;
    color: #a89279;
    font-family: 'Source Serif 4', serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* === SPLIT SCREEN === */
main {
    display: flex;
    min-height: 100vh;
}

.veil {
    position: fixed;
    top: 0;
    left: 0;
    width: 40vw;
    height: 100vh;
    background: #0d0b0a;
    border-right: 1px solid #2a2420;
    border-right-color: rgba(42, 36, 32, 0.4);
    overflow: hidden;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.revelation {
    margin-left: 40vw;
    width: 60vw;
    min-height: 500vh;
    background: #0d0b0a;
    position: relative;
}

/* === WORDMARK === */
.wordmark {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-family: 'Zilla Slab', serif;
    font-size: clamp(1rem, 1.5vw, 1.4rem);
    font-weight: 600;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: #5c4f42;
    right: 20px;
    position: absolute;
    writing-mode: vertical-rl;
}

/* === CANDLE === */
.candle {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.flame {
    width: 8px;
    height: 24px;
    background: #c47a2a;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    position: relative;
    box-shadow:
        0 0 15px 8px rgba(196, 122, 42, 0.3),
        0 0 40px 20px rgba(196, 122, 42, 0.1),
        0 0 80px 40px rgba(139, 94, 52, 0.05);
    animation:
        flameShape 3s cubic-bezier(0.4, 0, 0.2, 1) infinite,
        flameOpacity 2.5s ease-in-out infinite,
        flameShadow 3s ease-in-out infinite;
    --candle-intensity: 1;
}

.flame::before {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 6px;
    background: #2a2420;
}

.flame::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 4px;
    background: #1a1613;
    border-radius: 50%;
}

@keyframes flameShape {
    0%, 100% { transform: scaleY(1) skewX(0deg); }
    15% { transform: scaleY(1.1) skewX(-2deg); }
    30% { transform: scaleY(0.95) skewX(1deg); }
    50% { transform: scaleY(1.05) skewX(-1deg); }
    70% { transform: scaleY(0.98) skewX(2deg); }
    85% { transform: scaleY(1.08) skewX(-1.5deg); }
}

@keyframes flameOpacity {
    0%, 100% { opacity: 1; }
    25% { opacity: 0.88; }
    50% { opacity: 0.95; }
    75% { opacity: 0.85; }
}

@keyframes flameShadow {
    0%, 100% {
        box-shadow:
            0 0 15px 8px rgba(196, 122, 42, 0.3),
            0 0 40px 20px rgba(196, 122, 42, 0.1),
            0 0 80px 40px rgba(139, 94, 52, 0.05);
    }
    50% {
        box-shadow:
            0 0 20px 12px rgba(196, 122, 42, 0.35),
            0 0 50px 25px rgba(196, 122, 42, 0.15),
            0 0 100px 50px rgba(139, 94, 52, 0.08);
    }
}

/* === VEIL PARTICLES === */
.veil-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* === ATMOSPHERIC PARTICLES === */
.particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 100;
}

.particle {
    position: absolute;
    border-radius: 50%;
    background: #8b5e34;
    pointer-events: none;
}

@keyframes particleDrift {
    0% {
        transform: translateY(0) translateX(0);
        opacity: var(--p-opacity-start, 0.2);
    }
    25% {
        transform: translateY(-25vh) translateX(var(--p-sway, 5px));
    }
    50% {
        transform: translateY(-50vh) translateX(calc(var(--p-sway, 5px) * -1));
        opacity: var(--p-opacity-mid, 0.5);
    }
    75% {
        transform: translateY(-75vh) translateX(var(--p-sway, 5px));
    }
    100% {
        transform: translateY(-100vh) translateX(0);
        opacity: 0;
    }
}

/* === STANZAS === */
.stanza {
    contain: layout style paint;
    position: relative;
}

.stanza[data-stanza="1"] {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 0 12% 0 8%;
}

.stanza[data-stanza="2"] {
    min-height: 80vh;
    padding: 20vh 8% 20vh 8%;
    margin-top: 40vh;
}

.stanza[data-stanza="3"] {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10vh 5%;
    margin-top: 40vh;
}

.stanza[data-stanza="4"] {
    min-height: 80vh;
    padding: 20vh 8% 20vh 8%;
    margin-top: 40vh;
}

.stanza[data-stanza="5"] {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-top: 40vh;
}

/* Stanza reveal */
.stanza {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 600ms ease-out, transform 800ms cubic-bezier(0.16, 1, 0.3, 1);
}

.stanza.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* === STANZA 1: THE THRESHOLD === */
.hero-question {
    font-family: 'Zilla Slab', serif;
    font-size: clamp(2.8rem, 6vw, 5.5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: #d4c4a8;
}

.hero-question .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 300ms ease, transform 300ms ease;
}

.hero-question .char.visible {
    opacity: 1;
    transform: translateY(0);
}

.drawn-rule {
    width: 0%;
    height: 1px;
    background: #2a2420;
    margin: 3rem 0;
    transition: width 1.2s cubic-bezier(0.25, 0, 0.1, 1);
}

.stanza.revealed .drawn-rule {
    width: 60%;
}

/* === STANZA 2: THE WHISPER === */
.whisper {
    color: #3d3630;
    max-width: 540px;
    margin-bottom: 4rem;
    transition: color 800ms ease;
    font-weight: 300;
    line-height: 1.85;
}

.whisper-1 { margin-left: 0; }
.whisper-2 { margin-left: 5%; }
.whisper-3 { margin-left: 3%; }

.stanza.revealed .whisper {
    color: #a89279;
}

/* === STANZA 3: THE ARTIFACT === */
.glitch-composition {
    width: 80%;
    aspect-ratio: 16 / 10;
    position: relative;
    overflow: hidden;
    background: #1a1613;
}

.glitch-base {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1a1613;
    filter: url(#noise);
    opacity: 0.4;
}

.glitch-channel {
    position: absolute;
    top: 10%;
    left: 10%;
    width: 80%;
    height: 80%;
    mix-blend-mode: screen;
    opacity: 0;
    transition: opacity 800ms ease 200ms, transform 1200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.glitch-channel-1 {
    background: rgba(196, 122, 42, 0.6);
    transform: translate(0, 0);
}

.glitch-channel-2 {
    background: rgba(107, 58, 42, 0.6);
    transform: translate(0, 0);
}

.glitch-channel-3 {
    background: rgba(92, 79, 66, 0.6);
    transform: translate(0, 0);
}

.stanza.revealed .glitch-channel-1 {
    opacity: 0.6;
    transform: translate(5px, -3px);
}

.stanza.revealed .glitch-channel-2 {
    opacity: 0.6;
    transform: translate(-4px, 6px);
}

.stanza.revealed .glitch-channel-3 {
    opacity: 0.6;
    transform: translate(8px, 3px);
}

.glitch-scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(13, 11, 10, 0.3) 2px,
        rgba(13, 11, 10, 0.3) 4px
    );
    opacity: 0;
    transition: opacity 600ms ease 500ms;
}

.stanza.revealed .glitch-scanlines {
    opacity: 1;
}

.glitch-tear {
    position: absolute;
    left: 0;
    height: 6px;
    background: #0d0b0a;
    transition: transform 1200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.glitch-tear-1 { top: 18%; width: 45%; transform: translateX(0); }
.glitch-tear-2 { top: 35%; width: 55%; transform: translateX(0); }
.glitch-tear-3 { top: 52%; width: 35%; transform: translateX(0); }
.glitch-tear-4 { top: 71%; width: 60%; transform: translateX(0); }
.glitch-tear-5 { top: 88%; width: 40%; transform: translateX(0); }

.stanza.revealed .glitch-tear-1 { transform: translateX(12px); }
.stanza.revealed .glitch-tear-2 { transform: translateX(-8px); }
.stanza.revealed .glitch-tear-3 { transform: translateX(15px); }
.stanza.revealed .glitch-tear-4 { transform: translateX(-10px); }
.stanza.revealed .glitch-tear-5 { transform: translateX(7px); }

/* === STANZA 4: THE ECHO === */
.echo {
    font-family: 'Zilla Slab', serif;
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    font-weight: 600;
    color: #5c4f42;
    margin-bottom: 3rem;
    line-height: 1.4;
}

.echo-text {
    display: inline-block;
}

.echo-1 { margin-left: 2%; }
.echo-2 { margin-left: 8%; }
.echo-3 { margin-left: 0; }
.echo-4 { margin-left: 5%; }

.echo-1 .echo-text { color: #8b5e34; }
.echo-3 .echo-text { color: #6b3a2a; }

/* Glitch displacement on echo chars */
.echo .glitch-char {
    display: inline-block;
    transition: transform 0.1s;
}

/* === STANZA 5: THE SILENCE === */
.heartbeat-line {
    width: 60%;
    height: 1px;
    background: #2a2420;
    animation: heartbeat 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes heartbeat {
    0%, 100% { opacity: 0.08; }
    50% { opacity: 0.25; }
}

.silence-text {
    position: absolute;
    bottom: 5vh;
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.65rem, 0.8vw, 0.75rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #5c4f42;
    opacity: 0.4;
}

/* === HOVER EFFECTS === */
.stanza p:hover {
    text-shadow: 0 0 20px rgba(196, 122, 42, 0.15);
    transition: text-shadow 0.4s ease;
}

/* === EMBER PARTICLES === */
.ember {
    position: fixed;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #c47a2a;
    pointer-events: none;
    z-index: 200;
    animation: emberBurst 1.5s ease-out forwards;
}

@keyframes emberBurst {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--ember-x, 30px), var(--ember-y, -80px)) scale(0.3);
    }
}

/* === CURSOR === */
.revelation {
    cursor: none;
}

.cursor-follower {
    position: fixed;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(196, 122, 42, 0.25);
    pointer-events: none;
    z-index: 150;
    transform: translate(-50%, -50%);
    animation: cursorPulse 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    display: none;
}

.cursor-follower.active {
    display: block;
}

@keyframes cursorPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.25; }
    50% { transform: translate(-50%, -50%) scale(1.4); opacity: 0.15; }
}
