/* === Base Reset & Noise Overlay === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background: #F5E6CC;
    color: #3D1C00;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-size: 1.2rem;
    line-height: 1.85;
    overflow-x: hidden;
}

.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.05;
    mix-blend-mode: multiply;
}

/* === Opening Gate === */
.gate {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: #F5E6CC;
}

.hero-sigil {
    position: absolute;
    animation: sigilRotate 120s linear infinite;
    opacity: 0.5;
}

.hero-sigil g {
    stroke: url(#holoGrad);
}

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

.gate-title {
    font-family: 'Poiret One', cursive;
    font-size: clamp(4rem, 12vw, 10rem);
    font-weight: 400;
    letter-spacing: 0.15em;
    color: #3D1C00;
    position: relative;
    z-index: 2;
    line-height: 1;
}

.gate-subtitle {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(1.5rem, 4vw, 3rem);
    letter-spacing: 0.4em;
    color: #6B4226;
    text-transform: uppercase;
    position: relative;
    z-index: 2;
    margin-top: 0.5rem;
}

/* === Candle Particles === */
.particle {
    position: absolute;
    bottom: -10px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: radial-gradient(circle, #E8A317, transparent);
    pointer-events: none;
    z-index: 1;
    animation: particleRise var(--dur, 10s) var(--delay, 0s) infinite linear;
    opacity: 0;
}

.particle:nth-child(1)  { left: 20%; --dur: 9s;  --delay: 0s;   --drift: 15px; }
.particle:nth-child(2)  { left: 35%; --dur: 11s; --delay: 1.2s; --drift: -20px; }
.particle:nth-child(3)  { left: 50%; --dur: 8s;  --delay: 0.5s; --drift: 10px; }
.particle:nth-child(4)  { left: 65%; --dur: 12s; --delay: 2.5s; --drift: -15px; }
.particle:nth-child(5)  { left: 80%; --dur: 10s; --delay: 1s;   --drift: 18px; }
.particle:nth-child(6)  { left: 25%; --dur: 9s;  --delay: 3s;   --drift: -12px; }
.particle:nth-child(7)  { left: 45%; --dur: 11s; --delay: 4s;   --drift: 20px; }
.particle:nth-child(8)  { left: 55%; --dur: 8s;  --delay: 0.8s; --drift: -18px; }
.particle:nth-child(9)  { left: 70%; --dur: 10s; --delay: 2s;   --drift: 14px; }
.particle:nth-child(10) { left: 30%; --dur: 12s; --delay: 5s;   --drift: -10px; }
.particle:nth-child(11) { left: 40%; --dur: 9s;  --delay: 1.8s; --drift: 16px; }
.particle:nth-child(12) { left: 60%; --dur: 11s; --delay: 3.5s; --drift: -14px; }

@keyframes particleRise {
    0%   { transform: translateY(0) translateX(0); opacity: 0; }
    10%  { opacity: 0.8; }
    70%  { opacity: 0.6; }
    100% { transform: translateY(-100vh) translateX(var(--drift, 10px)); opacity: 0; }
}

/* === Art Deco Dividers === */
.deco-divider {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem 2rem;
}

.deco-divider svg {
    width: 100%;
    height: 48px;
}

/* === Chapter Sections === */
.chapter {
    max-width: 640px;
    margin: 0 auto clamp(3rem, 8vh, 6rem);
    padding: 0 1.5rem;
}

.chapter.sealed {
    max-height: 80px;
    overflow: hidden;
    opacity: 0.6;
    transition: max-height 600ms ease-out, opacity 400ms ease-out 200ms;
}

.chapter.revealed {
    max-height: 800px;
    opacity: 1;
}

.chapter-frame {
    border: 1px solid rgba(184, 134, 11, 0.35);
    padding: clamp(1.5rem, 4vw, 3rem);
    position: relative;
    text-align: center;
}

/* Corner ornaments */
.chapter-frame::before,
.chapter-frame::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-color: rgba(184, 134, 11, 0.5);
    border-style: solid;
}

.chapter-frame::before {
    top: -1px;
    left: -1px;
    border-width: 2px 0 0 2px;
}

.chapter-frame::after {
    bottom: -1px;
    right: -1px;
    border-width: 0 2px 2px 0;
}

.sigil {
    display: block;
    margin: 0 auto 1.5rem;
}

.chapter-heading {
    font-family: 'Poiret One', cursive;
    font-size: clamp(2rem, 6vw, 5rem);
    font-weight: 400;
    letter-spacing: 0.15em;
    color: #3D1C00;
    margin-bottom: 1.5rem;
    cursor: default;
    transition: color 0.3s ease;
}

.chapter-heading.holo-active {
    background: conic-gradient(from var(--holo-angle, 0deg), #B8860B, #D4AF37, #CFB53B, #E8A317, #B8860B);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.chapter-body {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.2rem;
    line-height: 1.85;
    color: #3D1C00;
    margin-bottom: 1rem;
    text-align: left;
}

.chapter-body:last-child {
    margin-bottom: 0;
}

.accent-text {
    font-weight: 600;
    font-style: italic;
    color: #6B4226;
    text-align: center;
    font-size: 1.3rem;
}

/* === Footer === */
.closing-mark {
    text-align: center;
    padding: 2rem 0 4rem;
    background: #F5E6CC;
    box-shadow: 0 -4px 24px rgba(42, 21, 6, 0.08); /* #2A1506 shadow */
}

/* Surface card color */
.chapter-frame {
    background: #EBD9B8;
}

/* === Holographic shimmer on headings hover === */
@property --holo-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

.chapter-heading:hover {
    background: conic-gradient(from var(--holo-angle, 0deg), #B8860B, #D4AF37, #CFB53B, #E8A317, #B8860B);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: holoSpin 3s linear infinite;
}

@keyframes holoSpin {
    from { --holo-angle: 0deg; }
    to { --holo-angle: 360deg; }
}

/* Hero sigil holographic overlay */
.hero-sigil {
    background: conic-gradient(from 0deg, #D4AF37, #C49B5C, #E8D5B7, #F5E6CC, #D4AF37, #8B6914, #D4AF37);
    -webkit-mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'/>");
}

/* === Responsive === */
@media (max-width: 680px) {
    .chapter {
        padding: 0 1rem;
    }

    .chapter-frame {
        padding: 1.5rem 1rem;
    }

    .deco-divider {
        padding: 0.5rem 1rem;
    }
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
    .particle {
        display: none;
    }

    .hero-sigil {
        animation: none;
    }

    .chapter-heading:hover {
        animation: none;
    }

    .chapter.sealed {
        transition: opacity 400ms ease-out;
    }
}
