/* ========================================
   simulai.xyz — Candlelit Narrative
   ======================================== */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --midnight-void: #0d0d12;
    --ember-shadow: #1a1410;
    --parchment-cream: #e8e0d4;
    --candlewax-gold: #f5c842;
    --neon-magenta: #e040fb;
    --neon-amber: #ff6b2b;
    --electric-cyan: #00e5ff;
    --ash-lavender: #8a7f96;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--midnight-void);
    color: var(--parchment-cream);
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* ========================================
   Scroll Progress Indicator
   ======================================== */

#scroll-progress {
    position: fixed;
    right: 12px;
    top: 10vh;
    height: 80vh;
    width: 2px;
    background: rgba(224, 64, 251, 0.4);
    transform: scaleY(0);
    transform-origin: top;
    z-index: 100;
    pointer-events: none;
}

/* ========================================
   Fixed Candle Glow (persists entire page)
   ======================================== */

#candle-glow-fixed {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 30%, rgba(255, 107, 43, 0.12), transparent 60%);
    pointer-events: none;
    z-index: 1;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* ========================================
   Starfield
   ======================================== */

#starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    animation: starBreath 4s ease-in-out infinite alternate;
}

@keyframes starBreath {
    0% { opacity: 0.1; }
    100% { opacity: 0.4; }
}

/* ========================================
   Opening Void
   ======================================== */

.opening-void {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 2;
}

/* Candle Container */
.candle-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    animation: fadeInCandle 1200ms ease-out 1800ms forwards;
}

@keyframes fadeInCandle {
    from { opacity: 0; }
    to { opacity: 1; }
}

.candle-body {
    width: 8px;
    height: 40px;
    background: linear-gradient(to bottom, #e8e0d4, #c4b9a8);
    border-radius: 2px 2px 3px 3px;
    position: relative;
}

.candle-body::before {
    content: '';
    position: absolute;
    top: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 8px;
    background: #4a4040;
}

.candle-flame {
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
}

.flame-inner {
    width: 12px;
    height: 20px;
    background: radial-gradient(ellipse at center, #fff8e1, var(--candlewax-gold), var(--neon-amber), transparent);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    animation: flicker 3s ease-in-out infinite;
    position: relative;
    z-index: 2;
}

.flame-outer {
    width: 18px;
    height: 28px;
    background: radial-gradient(ellipse at center, rgba(245, 200, 66, 0.6), rgba(255, 107, 43, 0.3), transparent);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    animation: flickerOuter 4s ease-in-out infinite;
    z-index: 1;
}

.candle-glow {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255, 107, 43, 0.15), transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    animation: glowPulse 4s ease-in-out infinite alternate;
}

@keyframes flicker {
    0%, 100% { transform: skewX(-2deg) scaleY(1.05); }
    25% { transform: skewX(3deg) scaleY(0.95); }
    50% { transform: skewX(-1deg) scaleY(1.02); }
    75% { transform: skewX(2deg) scaleY(0.98); }
}

@keyframes flickerOuter {
    0%, 100% { transform: translateX(-50%) skewX(2deg) scaleY(0.97); }
    33% { transform: translateX(-50%) skewX(-3deg) scaleY(1.04); }
    66% { transform: translateX(-50%) skewX(1deg) scaleY(1.01); }
}

@keyframes glowPulse {
    0% { opacity: 0.7; transform: translateX(-50%) scale(0.95); }
    100% { opacity: 1; transform: translateX(-50%) scale(1.05); }
}

/* Opening Text */
.opening-text {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    color: var(--parchment-cream);
    text-align: center;
    max-width: 640px;
    padding: 0 2rem;
    margin-top: 3rem;
    opacity: 0;
    animation: fadeInText 1200ms ease-out 3000ms forwards;
}

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

/* ========================================
   Vignette Sections
   ======================================== */

.vignette {
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    max-width: 640px;
    margin: 0 auto;
    padding: 4rem 2rem;
    position: relative;
    z-index: 2;
}

.vignette-heading {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: var(--candlewax-gold);
    letter-spacing: 0.02em;
    line-height: 1.3;
    text-align: center;
    margin-bottom: 2rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 800ms ease-out, transform 800ms ease-out;
}

.vignette-body {
    color: var(--parchment-cream);
    text-align: left;
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 800ms ease-out, transform 800ms ease-out;
}

.vignette-body em {
    font-style: italic;
    font-weight: 600;
    color: var(--parchment-cream);
}

.annotation {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.75rem;
    color: rgba(224, 64, 251, 0.6);
    display: block;
    margin-top: 1.5rem;
    text-align: left;
    width: 100%;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 800ms ease-out, transform 800ms ease-out;
}

/* Revealed state */
.vignette-heading.revealed,
.vignette-body.revealed,
.annotation.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ========================================
   Field Lines
   ======================================== */

.field-lines {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 4vh 0;
    position: relative;
    z-index: 2;
}

.field-lines span {
    display: block;
    width: min(80%, 500px);
    height: 0;
    border-top: 1px dashed rgba(138, 127, 150, 0.3);
    opacity: 0;
    transition: opacity 600ms ease-out;
}

.field-lines.revealed span:nth-child(1) { transition-delay: 0ms; }
.field-lines.revealed span:nth-child(2) { transition-delay: 100ms; }
.field-lines.revealed span:nth-child(3) { transition-delay: 200ms; }
.field-lines.revealed span:nth-child(4) { transition-delay: 300ms; }
.field-lines.revealed span:nth-child(5) { transition-delay: 400ms; }

.field-lines.revealed span {
    opacity: 1;
}

/* ========================================
   Meadow Gradient Band
   ======================================== */

.meadow-band {
    width: 100%;
    max-width: 640px;
    height: 4px;
    margin: 4vh auto;
    background: linear-gradient(to right, var(--neon-amber), transparent);
    opacity: 0;
    transition: opacity 800ms ease-out;
    position: relative;
    z-index: 2;
}

.meadow-band.revealed {
    opacity: 1;
}

/* ========================================
   Breathing Space
   ======================================== */

.breathing-space {
    height: 40vh;
    position: relative;
    z-index: 2;
}

/* ========================================
   Responsive
   ======================================== */

@media (min-width: 1200px) {
    .vignette {
        margin-left: auto;
        margin-right: auto;
    }
}

@media (max-width: 600px) {
    .vignette {
        padding: 3rem 1.5rem;
    }

    .opening-text {
        padding: 0 1.5rem;
    }
}
