/* lower.quest - Goblincore Descent into the Understory */

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
    background: #1a1612;
}

body {
    background: #1a1612;
    color: #c8bfb2;
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1.05rem, 1.8vw, 1.25rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ==================== GRAIN OVERLAY ==================== */
#grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
}

#grain-overlay svg {
    width: 100%;
    height: 100%;
}

/* ==================== TYPOGRAPHY ==================== */
h1, h2, h3 {
    font-family: 'Playfair Display', Georgia, serif;
    color: #f4ede4;
    line-height: 1.05;
    letter-spacing: -0.03em;
}

h1 {
    font-weight: 900;
    font-size: clamp(4rem, 10vw, 8rem);
}

h2 {
    font-weight: 700;
    font-size: clamp(2.2rem, 5vw, 3.8rem);
    margin-bottom: 1.2rem;
}

h3 {
    font-weight: 700;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    margin-bottom: 0.8rem;
}

p {
    margin-bottom: 1.2rem;
}

p:last-child {
    margin-bottom: 0;
}

.section-label {
    display: block;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #8b9e7a;
    margin-bottom: 3rem;
}

.accent-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 600;
    font-size: clamp(1.2rem, 2.2vw, 1.5rem);
    color: #e8b88a;
    line-height: 1.55;
    font-style: italic;
}

/* ==================== STRATA SECTIONS ==================== */
.stratum {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
}

/* ==================== CANDLE GLOW SYSTEM ==================== */
.candle-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.candle-glow--hero {
    background: radial-gradient(ellipse at 50% 30%, rgba(240, 201, 122, 0.06) 0%, transparent 65%);
    animation: candleFlicker 3.5s ease-in-out infinite alternate;
}

.candle-glow--understory {
    background: radial-gradient(ellipse at 35% 40%, rgba(240, 201, 122, 0.05) 0%, transparent 60%);
    animation: candleFlicker 3.5s ease-in-out infinite alternate;
    animation-delay: 0.7s;
}

.candle-glow--litter {
    background: radial-gradient(ellipse at 60% 35%, rgba(240, 201, 122, 0.055) 0%, transparent 58%);
    animation: candleFlicker 3.5s ease-in-out infinite alternate;
    animation-delay: 1.4s;
}

.candle-glow--mycelium {
    background: radial-gradient(ellipse at 45% 50%, rgba(240, 201, 122, 0.045) 0%, transparent 55%);
    animation: candleFlicker 3.5s ease-in-out infinite alternate;
    animation-delay: 2.1s;
}

.candle-glow--bedrock {
    background: radial-gradient(ellipse at 50% 45%, rgba(240, 201, 122, 0.07) 0%, transparent 60%);
    animation: candleFlicker 3.5s ease-in-out infinite alternate;
    animation-delay: 0.9s;
}

@keyframes candleFlicker {
    0% { opacity: 0.04; transform: scale(1); }
    33% { opacity: 0.07; transform: scale(1.01); }
    66% { opacity: 0.05; transform: scale(0.99); }
    100% { opacity: 0.08; transform: scale(1.005); }
}

/* ==================== LENS FLARE ==================== */
.lens-flare {
    position: relative;
    height: 0;
    overflow: visible;
    z-index: 10;
}

.lens-flare::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -20vw;
    width: 140vw;
    height: 1.5px;
    background: linear-gradient(90deg, transparent 0%, #f0c97a 45%, #f0c97a 55%, transparent 100%);
    opacity: 0;
    transition: none;
    pointer-events: none;
}

.lens-flare::after {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: #f0c97a;
    border-radius: 50%;
    filter: blur(20px);
    opacity: 0;
    pointer-events: none;
}

.lens-flare.is-fired::before {
    animation: flareStreak 1.2s ease-out forwards;
}

.lens-flare.is-fired::after {
    animation: flareBloom 1.2s ease-out forwards;
}

@keyframes flareStreak {
    0% { opacity: 0; }
    30% { opacity: 0.2; }
    100% { opacity: 0; }
}

@keyframes flareBloom {
    0% { opacity: 0; }
    30% { opacity: 0.08; }
    100% { opacity: 0; }
}

/* ==================== SECTION 1: CANOPY GAP ==================== */
#canopy-gap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #1a1612;
    background-image: radial-gradient(ellipse at 50% 30%, rgba(244, 237, 228, 0.04) 0%, transparent 50%);
}

.canopy-gap__content {
    position: relative;
    z-index: 2;
    text-align: left;
    padding: 0 5vw;
    max-width: 90vw;
    transform: translateX(-5%);
}

.canopy-gap__title {
    color: rgba(244, 237, 228, 0.7);
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 2.5s ease-out, transform 2.5s ease-out;
}

.canopy-gap__title.is-revealed {
    opacity: 1;
    transform: translateY(0);
}

.canopy-gap__subtitle {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.1rem;
    color: #c8bfb2;
    max-width: 520px;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 1.5s ease-out, transform 1.5s ease-out;
}

.canopy-gap__subtitle.is-revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ==================== SECTION 2: UNDERSTORY ==================== */
#understory {
    background: linear-gradient(180deg, #1a1612 0%, #2e2519 100%);
    padding: 12rem 0 10rem;
}

.understory__content {
    position: relative;
    z-index: 2;
    max-width: 85vw;
    margin: 0 auto;
    padding-left: 3vw;
}

.understory__block {
    margin-bottom: 5rem;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.understory__block.is-revealed {
    opacity: 1;
    transform: translateY(0);
}

.understory__block--left {
    max-width: 600px;
    margin-left: 2vw;
    transform: translateY(24px) rotate(-1.5deg);
    border-radius: 12px 4px 18px 6px;
    background: rgba(46, 37, 25, 0.6);
    padding: 2.5rem 3rem;
}

.understory__block--left.is-revealed {
    transform: translateY(0) rotate(-1.5deg);
}

.understory__block--right {
    max-width: 550px;
    margin-left: auto;
    margin-right: 4vw;
    transform: translateY(24px) rotate(1deg);
    border-radius: 6px 14px 4px 16px;
    background: rgba(46, 37, 25, 0.5);
    padding: 2.5rem 3rem;
}

.understory__block--right.is-revealed {
    transform: translateY(0) rotate(1deg);
}

.understory__block--center {
    max-width: 480px;
    margin-left: 12vw;
    padding: 2rem 0;
}

.understory__block--center.is-revealed {
    transform: translateY(0);
}

/* ==================== MUSHROOM CLUSTERS ==================== */
.mushroom-cluster {
    position: absolute;
    z-index: 3;
    pointer-events: none;
}

.mushroom-cluster--1 {
    right: 6vw;
    bottom: 8rem;
}

.mushroom-cluster--2 {
    left: 4vw;
    bottom: 6rem;
}

.mushroom-cap {
    position: absolute;
    background: rgba(232, 184, 138, 0.2);
    border-radius: 50% 50% 8% 8%;
}

.mushroom-cluster--1 .mushroom-cap:nth-child(1) {
    width: 45px;
    height: 28px;
    transform: rotate(-12deg);
    top: 0;
    left: 0;
}

.mushroom-cluster--1 .mushroom-cap:nth-child(2) {
    width: 32px;
    height: 20px;
    transform: rotate(8deg);
    top: 10px;
    left: 40px;
}

.mushroom-cluster--1 .mushroom-cap:nth-child(3) {
    width: 55px;
    height: 35px;
    transform: rotate(-5deg);
    top: -15px;
    left: 65px;
}

.mushroom-cluster--2 .mushroom-cap:nth-child(1) {
    width: 38px;
    height: 24px;
    transform: rotate(15deg);
    top: 0;
    left: 0;
}

.mushroom-cluster--2 .mushroom-cap:nth-child(2) {
    width: 50px;
    height: 32px;
    transform: rotate(-8deg);
    top: -10px;
    left: 35px;
}

.mushroom-cluster--2 .mushroom-cap:nth-child(3) {
    width: 28px;
    height: 18px;
    transform: rotate(20deg);
    top: 12px;
    left: 80px;
}

.mushroom-cluster--2 .mushroom-cap:nth-child(4) {
    width: 42px;
    height: 26px;
    transform: rotate(-3deg);
    top: -5px;
    left: 100px;
}

/* ==================== SECTION 3: LEAF LITTER ==================== */
#leaf-litter {
    background: #2e2519;
    padding: 10rem 0 12rem;
}

.leaf-litter__content {
    position: relative;
    z-index: 2;
    max-width: 78vw;
    margin: 0 auto;
}

.leaf-panel {
    position: relative;
    padding: 2.5rem 3rem;
    margin-bottom: 3rem;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.leaf-panel.is-revealed {
    opacity: 1;
    transform: translateY(0);
}

.leaf-panel--1 {
    background: rgba(46, 37, 25, 0.7);
    border-radius: 14px 6px 20px 8px;
    max-width: 650px;
    margin-left: 2vw;
    z-index: 4;
}

.leaf-panel--2 {
    background: rgba(139, 158, 122, 0.1);
    border-radius: 8px 16px 6px 14px;
    max-width: 520px;
    margin-left: auto;
    margin-right: 3vw;
    margin-top: -4rem;
    z-index: 3;
}

.leaf-panel--3 {
    background: rgba(232, 184, 138, 0.08);
    border-radius: 18px 4px 12px 10px;
    max-width: 480px;
    margin-left: 8vw;
    margin-top: -2rem;
    z-index: 5;
}

.leaf-panel--4 {
    background: rgba(184, 169, 200, 0.08);
    border-radius: 6px 12px 16px 4px;
    max-width: 560px;
    margin-left: auto;
    margin-right: 6vw;
    margin-top: -3rem;
    z-index: 2;
}

/* ==================== SECTION 4: MYCELIUM NETWORK ==================== */
#mycelium {
    background: linear-gradient(180deg, #2e2519 0%, #1a1612 100%);
    padding: 10rem 0 14rem;
    min-height: 120vh;
}

.mycelium-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.mycelium-line {
    fill: none;
    stroke: #8b9e7a;
    stroke-width: 0.5;
    opacity: 0.35;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 4s ease-out;
}

.mycelium-line.is-growing {
    stroke-dashoffset: 0;
}

.mycelium__content {
    position: relative;
    z-index: 2;
    max-width: 72vw;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 4rem;
    align-items: flex-start;
}

.mycelium__content .section-label {
    width: 100%;
}

.mycelium-node {
    background: rgba(26, 22, 18, 0.85);
    border: 1px solid rgba(139, 158, 122, 0.15);
    border-radius: 50% 50% 45% 55% / 45% 55% 50% 50%;
    padding: 2.5rem;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.mycelium-node.is-revealed {
    opacity: 1;
    transform: translateY(0);
}

.mycelium-node--1 {
    max-width: 420px;
    margin-left: 3vw;
    transform: translateY(24px) translate(2px, -3px);
}

.mycelium-node--1.is-revealed {
    transform: translate(2px, -3px);
}

.mycelium-node--2 {
    max-width: 380px;
    margin-left: auto;
    transform: translateY(24px) translate(-4px, 5px);
}

.mycelium-node--2.is-revealed {
    transform: translate(-4px, 5px);
}

.mycelium-node--3 {
    max-width: 350px;
    margin-left: 10vw;
    transform: translateY(24px) translate(1px, -2px);
}

.mycelium-node--3.is-revealed {
    transform: translate(1px, -2px);
}

.mycelium-node--4 {
    max-width: 400px;
    margin-left: auto;
    margin-right: 5vw;
    transform: translateY(24px) translate(-3px, 4px);
}

.mycelium-node--4.is-revealed {
    transform: translate(-3px, 4px);
}

/* ==================== SECTION 5: BEDROCK ==================== */
#bedrock {
    background: #1a1612;
    padding: 12rem 0 8rem;
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.bedrock__content {
    position: relative;
    z-index: 2;
    max-width: 60vw;
    margin: 0 auto;
    padding: 4rem;
    background: rgba(46, 37, 25, 0.4);
    border-radius: 4px;
}

.bedrock__title {
    font-size: clamp(2.8rem, 7vw, 5.2rem);
    margin-bottom: 2.5rem;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.bedrock__title.is-revealed {
    opacity: 1;
    transform: translateY(0);
}

.bedrock__text {
    font-size: clamp(1.1rem, 2vw, 1.3rem);
    line-height: 1.8;
    margin-bottom: 2rem;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.bedrock__text.is-revealed {
    opacity: 1;
    transform: translateY(0);
}

.bedrock__text--final {
    color: #e8b88a;
    font-weight: 600;
    font-size: clamp(1.3rem, 2.5vw, 1.6rem);
}

.bedrock__sigil {
    text-align: center;
    margin-top: 4rem;
    opacity: 0;
    transition: opacity 1.5s ease-out;
}

.bedrock__sigil.is-revealed {
    opacity: 1;
}

.sigil-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #b8a9c8;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(184, 169, 200, 0.4);
}

/* ==================== REVEAL ANIMATION BASE ==================== */
[data-reveal] {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

[data-reveal].is-revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .understory__content {
        max-width: 92vw;
        padding-left: 0;
    }

    .understory__block--left,
    .understory__block--right {
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
        padding: 2rem;
    }

    .understory__block--center {
        margin-left: 0;
    }

    .leaf-litter__content {
        max-width: 92vw;
    }

    .leaf-panel {
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-top: 2rem !important;
        padding: 2rem;
    }

    .mycelium__content {
        max-width: 92vw;
    }

    .mycelium-node {
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 20px;
        padding: 2rem;
    }

    .bedrock__content {
        max-width: 92vw;
        padding: 2.5rem;
    }

    .mushroom-cluster {
        display: none;
    }

    .canopy-gap__content {
        transform: none;
    }
}

/* ==================== REDUCED MOTION ==================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    [data-reveal] {
        opacity: 1;
        transform: none;
    }

    .mycelium-line {
        stroke-dashoffset: 0;
    }
}