/* ============================================
   mystical.quest - Fairycore Grimoire Tapestry
   ============================================ */
:root {
    --parchment-cream: #FDF6EC;
    --warm-linen: #F5ECD7;
    --gilded-honey: #D4B87A;
    --antique-brass: #C4A265;
    --pressed-petal: #E8B4B8;
    --fern-whisper: #A8C5A0;
    --twilight-ink: #4A3F35;
    --moth-wing: #C8B8D8;
    --candle-glow: #FFF8E7;
    --linen-dark: #EDE3CC;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    background: var(--parchment-cream);
    color: var(--twilight-ink);
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: 1.1rem;
    line-height: 1.75;
    overflow-x: hidden;
}

/* ==============================
   BOKEH LAYERS
   ============================== */
.bokeh-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}
.bokeh-layer--bg { z-index: 0; }
.bokeh-layer--mid { z-index: 1; }
.bokeh-circle {
    position: absolute;
    border-radius: 50%;
    display: block;
}
@keyframes bokehDrift {
    0% { transform: translate(0, 0); }
    25% { transform: translate(15px, -10px); }
    50% { transform: translate(-8px, -18px); }
    75% { transform: translate(10px, 5px); }
    100% { transform: translate(0, 0); }
}
.bokeh-drift {
    animation: bokehDrift 30s linear infinite;
}

/* ==============================
   VINE SPINE
   ============================== */
.vine-spine {
    position: fixed;
    left: 20%;
    top: 0;
    width: 40px;
    height: 100vh;
    z-index: 5;
    pointer-events: none;
    filter: drop-shadow(0 0 12px rgba(196, 162, 101, 0.35));
}
.vine-path {
    stroke-dasharray: 6000;
    stroke-dashoffset: 6000;
    transition: stroke-dashoffset 0.1s linear;
}
.vine-leaf {
    opacity: 0;
    transition: opacity 800ms ease;
}
.vine-leaf.visible {
    opacity: 1;
}

/* ==============================
   BLOOM NODES
   ============================== */
.bloom-node {
    position: absolute;
    left: 20%;
    top: 50%;
    width: 48px;
    height: 48px;
    margin-left: -24px;
    margin-top: -24px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--candle-glow), var(--pressed-petal));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transform: scale(0);
    transition: transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 16px rgba(232, 180, 184, 0.25);
}
.bloom-node.visible {
    transform: scale(1);
}
.bloom-node--final {
    width: 64px;
    height: 64px;
    margin-left: -32px;
    margin-top: -32px;
    cursor: pointer;
    pointer-events: auto;
    position: relative;
    left: auto;
    top: auto;
    margin: 0 auto 3rem;
}
.bloom-node--final:hover {
    transform: scale(1.1);
    transition: transform 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==============================
   CHAPTERS
   ============================== */
.chapter {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(3rem, 6vw, 6rem) clamp(1rem, 3vw, 3rem);
}

/* THE COVER */
.chapter--cover {
    background: var(--candle-glow);
    background-image:
        radial-gradient(circle at 30% 40%, rgba(212, 184, 122, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 70% 60%, rgba(232, 180, 184, 0.08) 0%, transparent 45%),
        radial-gradient(circle at 50% 80%, rgba(200, 184, 216, 0.06) 0%, transparent 40%);
}
.cover-content {
    position: relative;
    z-index: 3;
    text-align: center;
}
.cover-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(3rem, 7vw, 6rem);
    letter-spacing: 0.08em;
    color: var(--antique-brass);
    text-shadow: 0 1px 2px rgba(139, 115, 72, 0.2);
    opacity: 0;
    animation: titleFadeIn 1.5s ease-out 0.5s forwards;
}
@keyframes titleFadeIn {
    to { opacity: 1; }
}
.cover-subtitle {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 1.6rem;
    color: var(--twilight-ink);
    opacity: 0;
    animation: titleFadeIn 1.5s ease-out 1.5s forwards;
    margin-top: 1rem;
}
.scroll-chevron {
    margin-top: 4rem;
    animation: chevronPulse 2s ease-in-out infinite;
    opacity: 0.6;
}
@keyframes chevronPulse {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50% { transform: translateY(8px); opacity: 0.8; }
}

/* CHAPTER CONTENT PANELS */
.chapter--content {
    background: linear-gradient(180deg, var(--parchment-cream) 0%, var(--candle-glow) 100%);
}
.chapter-panel {
    position: relative;
    z-index: 3;
    max-width: 480px;
    padding: clamp(2rem, 4vw, 3rem);
    border-radius: 16px;
    background: var(--parchment-cream);
    border: 1px solid var(--gilded-honey);
    box-shadow: 0 8px 32px rgba(139, 115, 72, 0.12);
    /* Subtle crosshatch texture */
    background-image:
        repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(74, 63, 53, 0.02) 10px, rgba(74, 63, 53, 0.02) 11px),
        repeating-linear-gradient(-45deg, transparent, transparent 10px, rgba(74, 63, 53, 0.02) 10px, rgba(74, 63, 53, 0.02) 11px);
}

/* Alternating placement */
.chapter-panel--right {
    margin-left: calc(20% + 60px);
    opacity: 0;
    transform: translateX(60px);
    transition: opacity 700ms cubic-bezier(0.34, 1.56, 0.64, 1), transform 700ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chapter-panel--right.visible {
    opacity: 1;
    transform: translateX(0);
}
.chapter-panel--left {
    margin-right: calc(80% - 480px);
    margin-left: auto;
    opacity: 0;
    transform: translateX(-60px);
    transition: opacity 700ms cubic-bezier(0.34, 1.56, 0.64, 1), transform 700ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chapter-panel--left.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Page Curl */
.page-curl {
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 40px;
    overflow: hidden;
    border-radius: 0 16px 0 0;
    pointer-events: none;
}
.page-curl::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 40px 40px 0;
    border-color: transparent var(--linen-dark) transparent transparent;
    transition: transform 300ms ease-out;
}
.chapter-panel:hover .page-curl::before {
    transform: scale(1.1);
}

/* Chapter Headings */
.chapter-heading {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(1.6rem, 3.5vw, 2.4rem);
    letter-spacing: 0.04em;
    color: var(--twilight-ink);
    text-shadow: 0 1px 2px rgba(139, 115, 72, 0.2);
    margin-bottom: 1.5rem;
    line-height: 1.2;
}
.chapter-num {
    display: inline-block;
    font-style: normal;
    font-weight: 500;
    font-size: 0.85em;
    color: var(--antique-brass);
    margin-right: 0.5em;
    opacity: 0.7;
}

/* Body Text */
.chapter-text {
    font-family: 'Nunito', sans-serif;
    font-weight: 300;
    font-size: 1.1rem;
    line-height: 1.75;
    color: var(--twilight-ink);
    margin-bottom: 1.25rem;
}
.chapter-text:last-child {
    margin-bottom: 0;
}

/* Illuminated Drop Cap */
.drop-cap {
    float: left;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-style: italic;
    font-size: 3.5em;
    line-height: 0.8;
    margin-right: 0.12em;
    margin-top: 0.08em;
    color: var(--gilded-honey);
}

/* Marginalia */
.marginalia {
    position: absolute;
    left: calc(20% - 100px);
    font-family: 'Caveat', cursive;
    font-size: 1rem;
    color: var(--antique-brass);
    opacity: 0;
    transform: rotate(-3deg);
    z-index: 6;
    white-space: nowrap;
    transition: opacity 600ms ease, transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.marginalia.visible {
    opacity: 0.6;
    transform: rotate(-2deg);
}

/* Pressed Flowers */
.pressed-flower {
    position: absolute;
    opacity: 0.12;
    z-index: 1;
    transition: transform 800ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.pressed-flower--fern {
    top: 15%;
    right: 8%;
    transform: rotate(-5deg);
}
.pressed-flower--fern.rotated {
    transform: rotate(-2deg);
}
.pressed-flower--lavender {
    bottom: 10%;
    left: 5%;
    transform: rotate(3deg);
}
.pressed-flower--lavender.rotated {
    transform: rotate(6deg);
}

/* ==============================
   SPECIMEN GRID (Chapter III)
   ============================== */
.specimen-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
}
.specimen-card {
    background: var(--candle-glow);
    border: 1px solid rgba(212, 184, 122, 0.4);
    border-radius: 12px;
    padding: 1rem 0.75rem;
    text-align: center;
    transition: transform 400ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 400ms ease;
    opacity: 0;
    transform: translateY(20px);
}
.specimen-card.visible {
    opacity: 1;
    transform: translateY(0);
}
.specimen-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(139, 115, 72, 0.15);
}
.specimen-icon {
    display: block;
    margin: 0 auto 0.75rem;
}
.specimen-name {
    display: block;
    font-family: 'Caveat', cursive;
    font-size: 1.2rem;
    color: var(--antique-brass);
    margin-bottom: 0.5rem;
}
.specimen-desc {
    display: block;
    font-family: 'Nunito', sans-serif;
    font-weight: 300;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--twilight-ink);
    opacity: 0.8;
}

/* ==============================
   STAR FIELD MINI (Chapter IV)
   ============================== */
.star-field-mini {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    border-radius: 16px;
    overflow: hidden;
}
.star-point {
    position: absolute;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: var(--candle-glow);
    animation: twinkle 3s ease-in-out infinite;
}
@keyframes twinkle {
    0%, 100% { opacity: 0.03; }
    50% { opacity: 0.08; }
}

/* ==============================
   CHAPTER V - FINAL
   ============================== */
.chapter--final {
    flex-direction: column;
    background: linear-gradient(180deg, var(--candle-glow) 0%, var(--parchment-cream) 100%);
}
.root-system {
    width: 100%;
    max-width: 600px;
    margin-bottom: 2rem;
    opacity: 0.4;
}
.roots-svg {
    width: 100%;
    height: auto;
}
.final-content {
    text-align: center;
    position: relative;
    z-index: 3;
    max-width: 600px;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 800ms cubic-bezier(0.34, 1.56, 0.64, 1), transform 800ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.final-content.visible {
    opacity: 1;
    transform: translateY(0);
}
.final-heading {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(1.6rem, 4vw, 2.8rem);
    letter-spacing: 0.04em;
    line-height: 1.3;
    color: var(--twilight-ink);
    text-shadow: 0 1px 2px rgba(139, 115, 72, 0.15);
    margin-bottom: 2rem;
}
.final-colophon {
    font-family: 'Caveat', cursive;
    font-size: 1.4rem;
    color: var(--antique-brass);
    opacity: 0.6;
}

/* ==============================
   REVEAL ANIMATION (generic)
   ============================== */
[data-reveal="up"] {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 700ms cubic-bezier(0.34, 1.56, 0.64, 1), transform 700ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
[data-reveal="up"].visible {
    opacity: 1;
    transform: translateY(0);
}

/* ==============================
   RESPONSIVE
   ============================== */
@media (max-width: 768px) {
    .vine-spine {
        left: 50%;
        margin-left: -20px;
    }
    .bloom-node {
        left: 50%;
    }
    .chapter-panel--right,
    .chapter-panel--left {
        margin-left: 0;
        margin-right: 0;
        max-width: 100%;
    }
    .marginalia {
        left: auto;
        right: 1rem;
        font-size: 0.85rem;
    }
    .specimen-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    .chapter {
        padding: clamp(2rem, 4vw, 4rem) clamp(1rem, 4vw, 2rem);
    }
}
