/* ===========================================================
   sister.quest — botanical herbarium long-scroll
   Palette (strict six-swatch duotone):
     #1F2A22 Foxglove Ink
     #E8DBC0 Rag Vellum
     #7A8C5B Frond
     #C7B98A Field Note
     #F6F0DF Pressed Leaf
     #3F1F0E Iron Gall
   Typography:
     EB Garamond (display + body)
     Cormorant Garamond (marginalia)
     JetBrains Mono (field codes + dates)
   =========================================================== */

:root {
    --ink: #1F2A22;
    --vellum: #E8DBC0;
    --frond: #7A8C5B;
    --field-note: #C7B98A;
    --pressed-leaf: #F6F0DF;
    --iron-gall: #3F1F0E;

    --serif: 'EB Garamond', 'Cormorant Garamond', Georgia, serif;
    --serif-margin: 'Cormorant Garamond', 'EB Garamond', Georgia, serif;
    --mono: 'JetBrains Mono', 'Courier New', monospace;
}

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

html {
    scroll-behavior: smooth;
}

html, body {
    background: var(--vellum);
    color: var(--ink);
    font-family: var(--serif);
    font-optical-sizing: auto;
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
}

body {
    overflow-x: hidden;
    cursor: none;
    background-image:
        radial-gradient(rgba(31,42,34,0.025) 1px, transparent 1px),
        radial-gradient(rgba(31,42,34,0.018) 1px, transparent 1px);
    background-size: 3px 3px, 7px 7px;
    background-position: 0 0, 1px 1px;
}

@media (pointer: coarse) {
    body { cursor: auto; }
}

/* ===========================================================
   Folio: vertical long-scroll, 12 chambers
   =========================================================== */
.folio {
    scroll-snap-type: y proximity;
    overflow-y: auto;
}

/* ===========================================================
   Chamber: 100vw × 100vh, three columns
   =========================================================== */
.chamber {
    position: relative;
    min-height: 100vh;
    width: 100vw;
    display: grid;
    grid-template-columns: 33vw 34vw 33vw;
    scroll-snap-align: start;
    border-top: 2px solid var(--frond);
    border-bottom: 2px solid var(--frond);
    background: var(--vellum);
    overflow: hidden;
}

.chamber:first-of-type {
    border-top: none;
}

.chamber:last-of-type {
    border-bottom: none;
}

/* ===========================================================
   Plate (left third): leaf photograph zone
   =========================================================== */
.plate {
    position: relative;
    width: 33vw;
    height: 100vh;
    padding: 8px;
    background: var(--pressed-leaf);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.plate-substrate {
    position: absolute;
    inset: 8px;
    background:
        radial-gradient(rgba(31,42,34,0.03) 1px, transparent 1px),
        radial-gradient(rgba(31,42,34,0.02) 1px, transparent 1px),
        var(--pressed-leaf);
    background-size: 3px 3px, 5px 5px;
    opacity: 1;
    mix-blend-mode: multiply;
    pointer-events: none;
}

.plate-leaf {
    position: relative;
    width: 90%;
    height: 90%;
    display: block;
    mix-blend-mode: multiply;
    transition: opacity 1.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.plate-leaf .leaf-path {
    stroke-dasharray: 4000;
    stroke-dashoffset: 4000;
    transition: stroke-dashoffset 1.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.chamber.in-stage-1 .plate-leaf .leaf-path {
    stroke-dashoffset: 0;
}

.plate-leaf .flare {
    opacity: 0;
    transition: opacity 0.9s cubic-bezier(0.22, 1, 0.36, 1);
    filter: blur(28px);
    mix-blend-mode: screen;
}

.chamber.in-stage-2 .plate-leaf .flare {
    opacity: 1;
}

/* ===========================================================
   Centre (middle third): binomial + descriptor + anecdote
   =========================================================== */
.centre {
    position: relative;
    width: 34vw;
    height: 100vh;
    padding: 8vh 3.5vw;
    background: var(--vellum);
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 2vh;
    z-index: 2;
}

.binomial {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 400;
    font-size: clamp(36px, 4.6vw, 84px);
    letter-spacing: -0.012em;
    line-height: 1.04;
    color: var(--ink);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.9s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
    align-self: start;
}

.chamber.in-stage-2 .binomial {
    opacity: 1;
    transform: translateY(0);
}

.descriptor {
    font-family: var(--serif);
    font-weight: 400;
    font-size: 16px;
    line-height: 1.625;
    color: var(--ink);
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
    text-align-last: left;
    align-self: center;
    max-width: 32ch;
    margin: 0 auto;
    opacity: 0;
    transition: opacity 1.2s cubic-bezier(0.22, 1, 0.36, 1) 0.2s;
}

.chamber.in-stage-2 .descriptor {
    opacity: 1;
}

.anecdote {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 400;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    text-align: center;
    max-width: 30ch;
    margin: 0 auto;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 1s cubic-bezier(0.22, 1, 0.36, 1) 0.4s,
                transform 1s cubic-bezier(0.22, 1, 0.36, 1) 0.4s;
    align-self: end;
    padding-bottom: 2vh;
    border-top: 1px solid var(--frond);
    padding-top: 2.5vh;
}

.chamber.in-stage-2 .anecdote {
    opacity: 1;
    transform: translateY(0);
}

/* ===========================================================
   Marginalia (right third): stair of micro-artefacts
   =========================================================== */
.marginalia {
    position: relative;
    width: 33vw;
    height: 100vh;
    padding: 6vh 2.5vw;
    background: var(--field-note);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1.2vh;
    border-left: 1px solid var(--frond);
    background-image:
        radial-gradient(rgba(31,42,34,0.04) 1px, transparent 1px);
    background-size: 4px 4px;
}

.stair-item {
    display: grid;
    grid-template-columns: 64px 1fr;
    align-items: center;
    gap: 14px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
    padding: 0.4vh 0;
    border-bottom: 1px dotted rgba(31,42,34,0.18);
}

.stair-item:last-child {
    border-bottom: none;
}

.chamber.in-stage-3 .stair-item { opacity: 1; transform: translateY(0); }
.chamber.in-stage-3 .stair-item:nth-child(1) { transition-delay: 0ms; }
.chamber.in-stage-3 .stair-item:nth-child(2) { transition-delay: 90ms; }
.chamber.in-stage-3 .stair-item:nth-child(3) { transition-delay: 180ms; }
.chamber.in-stage-3 .stair-item:nth-child(4) { transition-delay: 270ms; }
.chamber.in-stage-3 .stair-item:nth-child(5) { transition-delay: 360ms; }
.chamber.in-stage-3 .stair-item:nth-child(6) { transition-delay: 450ms; }

.artefact {
    width: 48px;
    height: 48px;
    display: block;
}

.pantone {
    display: flex;
    gap: 2px;
    width: 56px;
    height: 24px;
}

.pantone .chip {
    flex: 1;
    height: 100%;
    display: block;
    border: 1px solid rgba(31,42,34,0.2);
}

.stamp {
    width: 56px;
    height: 56px;
    background: var(--iron-gall);
    color: var(--pressed-leaf);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: center;
    line-height: 1.1;
    box-shadow: 0 0 0 2px var(--field-note), inset 0 0 6px rgba(0,0,0,0.25);
    transform: rotate(-6deg);
    padding: 4px;
}

.field {
    font-family: var(--mono);
    font-size: 10px;
    line-height: 1.4;
    color: var(--ink);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: grid;
    grid-template-columns: auto;
    gap: 2px;
}

.field dt {
    font-weight: 400;
    color: var(--ink);
}

.field dd {
    font-family: var(--serif-margin);
    font-style: italic;
    font-size: 11px;
    color: var(--ink);
    opacity: 0.7;
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 4px;
}

.sparkline {
    width: 60px;
    height: 24px;
    display: block;
}

.fieldno {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--ink);
    background: var(--pressed-leaf);
    padding: 4px 8px;
    letter-spacing: 0.08em;
    text-align: center;
    border: 1px solid var(--frond);
    text-transform: uppercase;
}

.caption {
    font-family: var(--serif-margin);
    font-style: italic;
    font-weight: 500;
    font-size: 12px;
    line-height: 1.5;
    color: var(--ink);
    opacity: 0.85;
}

/* ===========================================================
   Index dot (fixed, top-right)
   =========================================================== */
.index-dot {
    position: fixed;
    top: 50vh;
    right: 28px;
    width: 36px;
    height: 36px;
    background: var(--frond);
    border-radius: 50%;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-50%);
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                height 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                background 0.4s ease;
    box-shadow:
        inset 0 0 6px rgba(31,42,34,0.4),
        0 0 0 1px var(--frond),
        0 2px 6px rgba(31,42,34,0.2);
    pointer-events: none;
}

.index-dot::before {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    border: 1px solid var(--vellum);
    opacity: 0.4;
}

.index-dot-num {
    font-family: var(--mono);
    font-size: 9px;
    color: var(--vellum);
    letter-spacing: 0.06em;
    z-index: 2;
    font-weight: 400;
}

/* ===========================================================
   Cursor leaf-tip
   =========================================================== */
.cursor-leaf {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 200;
    transform: translate(-50%, -50%) rotate(0deg);
    transition: opacity 0.2s ease;
    mix-blend-mode: multiply;
}

@media (pointer: coarse) {
    .cursor-leaf { display: none; }
}

.cursor-leaf.over-text {
    opacity: 0.5;
}

/* ===========================================================
   Initial states (before observer)
   =========================================================== */
.plate-leaf {
    opacity: 0.9;
}

/* ===========================================================
   Reduced motion
   =========================================================== */
@media (prefers-reduced-motion: reduce) {
    .plate-leaf .leaf-path {
        stroke-dashoffset: 0;
        transition: none;
    }
    .plate-leaf .flare {
        opacity: 1;
        transition: none;
    }
    .binomial,
    .descriptor,
    .anecdote {
        opacity: 1;
        transform: none;
        transition: none;
    }
    .index-dot {
        transition: background 0.4s ease;
    }
}

/* ===========================================================
   Responsive: mobile collapse to single column
   =========================================================== */
@media (max-width: 900px) {
    .chamber {
        grid-template-columns: 1fr;
        grid-template-rows: 50vh auto auto;
        min-height: auto;
    }
    .plate {
        width: 100vw;
        height: 50vh;
    }
    .centre {
        width: 100vw;
        height: auto;
        padding: 6vh 6vw;
        gap: 3vh;
    }
    .binomial {
        font-size: clamp(28px, 8vw, 56px);
        text-align: center;
    }
    .descriptor {
        max-width: 100%;
    }
    .marginalia {
        width: 100vw;
        height: auto;
        padding: 4vh 6vw;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        border-left: none;
        border-top: 1px solid var(--frond);
        gap: 16px;
    }
    .stair-item {
        flex: 0 0 200px;
        scroll-snap-align: start;
        border-bottom: none;
        border-right: 1px dotted rgba(31,42,34,0.2);
        padding: 0 14px 0 0;
    }
    .index-dot {
        right: 14px;
        width: 28px;
        height: 28px;
    }
}
