/* =========================================================
   continua.quest — An archive of things that persist
   Dark academia / botanical herbarium / serif-revival
   ========================================================= */

:root {
    /* Backgrounds */
    --bg-deepest:   #060404;  /* Subterranean Black */
    --bg-base:      #0D0C0A;  /* Lamp Black */
    --bg-warm:      #1A0E0E;  /* Oxblood Paper */
    --bg-claret:    #2A0A14;  /* Deep Claret */
    --bg-near:      #0A0507;  /* Near Black */

    /* Text */
    --text-primary: #D4C5A9;  /* Aged Linen */
    --text-whisper: #C8B898;  /* Parchment Whisper */

    /* Accents */
    --accent-gold:    #8B7D3C;  /* Tarnished Gold */
    --accent-moss:    #4A5240;  /* Dried Moss */
    --accent-crimson: #6B1520;  /* Pressed Crimson */
    --accent-verdigris:#3A5245; /* Verdigris Tint */

    /* Live background controlled by JS */
    --bg-current: var(--bg-base);

    /* Typography */
    --font-display: "Cormorant Garamond", "EB Garamond", Georgia, serif;
    --font-body:    "EB Garamond", Georgia, "Times New Roman", serif;
    --font-anno:    "Libre Baskerville", "EB Garamond", Georgia, serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    background: var(--bg-base);
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-current);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    transition: background-color 1.2s ease;
    position: relative;
    min-height: 100vh;
}

/* Subtle paper grain across entire body */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.05;
    mix-blend-mode: overlay;
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.85  0 0 0 0 0.78  0 0 0 0 0.65  0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-size: 220px 220px;
}

/* Soft pressed-fern watermark behind everything */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.04;
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 800'><g fill='none' stroke='%238B7D3C' stroke-width='0.6'><path d='M300,780 C295,650 305,500 300,360 C295,220 305,120 300,40'/><path d='M300,720 Q230,720 180,760 M300,720 Q370,720 420,760'/><path d='M300,650 Q220,650 160,690 M300,650 Q380,650 440,690'/><path d='M300,580 Q210,580 140,620 M300,580 Q390,580 460,620'/><path d='M300,500 Q200,500 130,540 M300,500 Q400,500 470,540'/><path d='M300,420 Q210,420 150,460 M300,420 Q390,420 450,460'/><path d='M300,340 Q220,340 170,380 M300,340 Q380,340 430,380'/><path d='M300,260 Q230,260 190,300 M300,260 Q370,260 410,300'/><path d='M300,180 Q240,180 210,220 M300,180 Q360,180 390,220'/><path d='M300,120 Q250,120 230,150 M300,120 Q350,120 370,150'/></g></svg>");
    background-position: center center;
    background-repeat: no-repeat;
    background-size: 70vw auto;
}

/* ======================
   Vine Navigation
   ====================== */
.vine-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 60px;
    height: 100vh;
    z-index: 100;
    pointer-events: none;
}

.vine-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.vine-stem {
    stroke-dasharray: 2400;
    stroke-dashoffset: 2400;
    transition: stroke-dashoffset 80ms linear;
}

.vine-leaf {
    opacity: 0;
    transform-box: fill-box;
    transform-origin: 0 0;
    transform: scale(0);
    transition: opacity 600ms ease, transform 600ms cubic-bezier(0.22, 1, 0.36, 1);
}

.vine-leaf.visible {
    opacity: 1;
    transform: scale(1);
}

/* ======================
   Strata (sections)
   ====================== */
.strata {
    position: relative;
    z-index: 1;
}

.stratum {
    min-height: 100vh;
    position: relative;
    padding: 8vh 4vw 8vh 8vw;
    overflow: hidden;
}

/* Folio numerals — Roman numerals in the outer margin */
.folio-numeral {
    position: absolute;
    top: 50%;
    right: 2vw;
    transform: translateY(-50%) rotate(90deg);
    transform-origin: center center;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 0.95rem;
    letter-spacing: 0.5em;
    color: var(--text-primary);
    opacity: 0.3;
    pointer-events: none;
    text-transform: uppercase;
}

/* ======================
   STRATUM I — Cabinet
   ====================== */
.stratum-i {
    background-color: var(--bg-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cabinet-stage {
    position: relative;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.datura-svg {
    width: clamp(280px, 36vw, 480px);
    height: auto;
    display: block;
    filter: drop-shadow(0 0 30px rgba(139, 125, 60, 0.08));
}

.draw-path {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 3.2s cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.stratum-i.in-view .draw-path {
    stroke-dashoffset: 0;
}

/* Hero title — letters split via JS */
.hero-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(4rem, 10vw, 8rem);
    letter-spacing: 0.25em;
    line-height: 0.95;
    color: var(--text-primary);
    margin: 1.5rem 0 0.4rem;
    text-transform: uppercase;
    text-indent: 0.25em; /* compensate tracking on right edge */
}

.hero-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 900ms ease, transform 900ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.hero-title.lit .letter {
    opacity: 1;
    transform: translateY(0);
}

.hero-tagline {
    font-family: var(--font-anno);
    font-style: italic;
    font-size: clamp(0.95rem, 1.4vw, 1.2rem);
    color: var(--accent-gold);
    opacity: 0;
    margin: 0;
    letter-spacing: 0.05em;
    transition: opacity 1.6s ease 2.5s;
}

.stratum-i.in-view .hero-tagline {
    opacity: 0.75;
}

/* ======================
   STRATUM II — Herbarium
   ====================== */
.stratum-ii {
    background-color: var(--bg-warm);
    padding-right: 0;
    display: flex;
    align-items: center;
}

.herbarium-grid {
    display: grid;
    grid-template-columns: 40% 55%;
    gap: 5%;
    width: 100%;
    align-items: center;
}

.herbarium-text {
    padding-left: 0;
    padding-right: 2vw;
}

.herbarium-text h2 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    letter-spacing: 0.12em;
    font-variant: small-caps;
    color: var(--text-primary);
    margin: 0 0 1.2rem 0;
    line-height: 1.1;
}

.botanical-divider {
    width: 200px;
    height: 16px;
    margin: 0 0 1.6rem 0;
    opacity: 0.7;
    display: block;
}

.herbarium-text p {
    margin: 0 0 1.2rem 0;
    color: var(--text-primary);
    max-width: 38ch;
}

.herbarium-text p em {
    color: var(--accent-gold);
    font-style: italic;
}

.marginalia {
    font-family: var(--font-anno);
    font-style: italic;
    font-size: 0.85rem;
    color: var(--accent-gold);
    opacity: 0.75;
    transform: rotate(-1.5deg);
    margin-left: 2rem !important;
    max-width: 30ch;
}

.herbarium-plate {
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-right: 0;
    padding-right: 0;
}

.plate-frame {
    position: relative;
    width: 100%;
    max-width: 560px;
    padding: 2rem 2rem 1.4rem 2rem;
    background:
        radial-gradient(ellipse at center, rgba(212, 197, 169, 0.04) 0%, rgba(0,0,0,0) 70%),
        linear-gradient(180deg, #1F1313 0%, #160B0B 100%);
    box-shadow:
        inset 0 0 60px rgba(0, 0, 0, 0.6),
        inset 0 0 0 1px rgba(139, 125, 60, 0.18);
    /* Double rule border */
    outline: 1px solid rgba(139, 125, 60, 0.4);
    outline-offset: 6px;
    /* Sepia inner shadow effect */
}

.plate-frame::before {
    content: "";
    position: absolute;
    inset: 4px;
    pointer-events: none;
    border: 0.5px solid rgba(139, 125, 60, 0.18);
}

.fern-svg {
    width: 100%;
    height: auto;
    max-height: 60vh;
    display: block;
    mix-blend-mode: screen;
    filter: sepia(0.2);
}

.plate-caption {
    font-family: var(--font-anno);
    font-style: italic;
    font-size: 0.85rem;
    color: var(--accent-gold);
    opacity: 0.7;
    text-align: center;
    margin: 0.8rem 0 0 0;
    letter-spacing: 0.04em;
}

.plate-caption em {
    font-style: italic;
    color: var(--text-primary);
    opacity: 0.85;
}

/* Reveal-letters heading effect */
.reveal-letters .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 700ms ease, transform 700ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.reveal-letters .letter.space {
    width: 0.32em;
}

.reveal-letters.lit .letter {
    opacity: 1;
    transform: translateY(0);
}

/* ======================
   STRATUM III — Specimens
   ====================== */
.stratum-iii {
    background-color: var(--bg-claret);
    padding-top: 12vh;
    padding-bottom: 14vh;
}

.specimen-header {
    text-align: center;
    margin-bottom: 4vh;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

.specimen-header h2 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    letter-spacing: 0.12em;
    font-variant: small-caps;
    color: var(--text-primary);
    margin: 0 0 0.6rem 0;
}

.specimen-intro {
    font-family: var(--font-anno);
    font-style: italic;
    color: var(--accent-gold);
    opacity: 0.7;
    font-size: 0.95rem;
    margin: 0;
}

.specimen-cards {
    display: flex;
    flex-direction: column;
    gap: 6vh;
    max-width: 1100px;
    margin: 0 auto;
}

.specimen-card {
    aspect-ratio: 3 / 2;
    width: 70%;
    max-width: 760px;
    min-height: 260px;
    background:
        radial-gradient(ellipse at top left, rgba(212, 197, 169, 0.04), rgba(0,0,0,0) 50%),
        linear-gradient(180deg, #2E0D17 0%, #1E0710 100%);
    border: 1px solid var(--accent-gold);
    border-radius: 2px;
    box-shadow:
        inset 0 0 0 4px transparent,
        inset 0 0 0 5px rgba(139, 125, 60, 0.25),
        0 30px 60px -20px rgba(0, 0, 0, 0.6);
    padding: 2rem;
    display: grid;
    grid-template-columns: 32% 1fr;
    gap: 2rem;
    align-items: center;
    position: relative;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 800ms cubic-bezier(0.22, 1, 0.36, 1),
                transform 800ms cubic-bezier(0.22, 1, 0.36, 1);
}

.specimen-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.specimen-card.card-left {
    margin-right: auto;
    margin-left: 0;
    transform: translate(-15%, 40px);
}

.specimen-card.card-right {
    margin-left: auto;
    margin-right: 0;
    transform: translate(15%, 40px);
}

.specimen-card.card-left.visible {
    transform: translate(-15%, 0);
}

.specimen-card.card-right.visible {
    transform: translate(15%, 0);
}

.specimen-card::before {
    content: "";
    position: absolute;
    inset: 6px;
    border: 0.5px solid rgba(139, 125, 60, 0.35);
    pointer-events: none;
    border-radius: 1px;
}

.specimen-illustration {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.specimen-illustration svg {
    width: 100%;
    height: auto;
    max-height: 200px;
}

.specimen-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.4rem;
}

.specimen-folio {
    font-family: var(--font-anno);
    font-style: italic;
    font-size: 0.8rem;
    color: var(--accent-gold);
    opacity: 0.65;
    margin: 0;
    letter-spacing: 0.08em;
}

.specimen-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-variant: small-caps;
    font-size: 1.4rem;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.1;
}

.specimen-body {
    font-family: var(--font-body);
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-whisper);
    margin: 0.4rem 0 0 0;
    max-width: 38ch;
}

/* ======================
   STRATUM IV — Darkroom
   ====================== */
.stratum-iv {
    background-color: var(--bg-near);
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 18vh;
    padding-bottom: 18vh;
}

.darkroom {
    max-width: 38ch;
    margin: 0 auto;
    text-align: left;
}

.meditation {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 1.3rem;
    line-height: 2.0;
    color: var(--text-whisper);
    margin: 0 0 2.5rem 0;
    opacity: 0.25;
    transition: opacity 700ms ease;
}

.meditation em {
    font-style: italic;
    color: var(--accent-gold);
    opacity: 0.95;
}

/* ======================
   STRATUM V — Roots
   ====================== */
.stratum-v {
    background-color: var(--bg-deepest);
    padding: 0;
    overflow: visible;
    min-height: 110vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rootsystem-stage {
    width: 100%;
    height: 100vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.root-svg {
    width: 100%;
    max-width: 1100px;
    height: 100%;
    max-height: 95vh;
    display: block;
}

.root-path {
    stroke-dasharray: 1500;
    stroke-dashoffset: 1500;
    transition: stroke-dashoffset 8s cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.stratum-v.in-view .root-path {
    stroke-dashoffset: 0;
}

.root-label {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    font-variant: small-caps;
    letter-spacing: 0.25em;
    fill: var(--accent-gold);
    opacity: 0;
    transition: opacity 1.2s ease;
}

.root-label.visible {
    opacity: 0.75;
}

.domain-mark {
    position: absolute;
    bottom: 2.5vh;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-body);
    font-style: italic;
    font-size: 1rem;
    color: var(--accent-gold);
    opacity: 0.55;
    margin: 0;
    letter-spacing: 0.08em;
    text-align: center;
}

/* ======================
   Responsive
   ====================== */
@media (max-width: 880px) {
    .vine-nav {
        width: 36px;
    }

    .stratum {
        padding: 6vh 5vw 6vh 8vw;
    }

    .herbarium-grid {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    .herbarium-text {
        padding-right: 0;
    }

    .herbarium-text p {
        max-width: 60ch;
    }

    .specimen-card {
        width: 90%;
        grid-template-columns: 1fr;
        gap: 1rem;
        aspect-ratio: auto;
        padding: 1.6rem;
    }

    .specimen-card.card-left,
    .specimen-card.card-right {
        margin-left: auto;
        margin-right: auto;
        transform: translate(0, 40px);
    }

    .specimen-card.card-left.visible,
    .specimen-card.card-right.visible {
        transform: translate(0, 0);
    }

    .specimen-illustration svg {
        max-height: 160px;
    }

    .meditation {
        font-size: 1.1rem;
        line-height: 1.85;
    }

    .folio-numeral {
        right: 0.6rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 540px) {
    .hero-title {
        letter-spacing: 0.18em;
    }
    .vine-nav {
        width: 24px;
    }
    .stratum {
        padding-left: 6vw;
    }
}
