/* ============================================================
   xanadu.wiki — styles.css
   Ted Nelson's Project Xanadu dreamt inside Coleridge's opium vision.
   Palette : #0a0612 #181432 #2b2348 #a8b4d8 #ede1c8 #d4691e #6a8cb0
   Fonts   : Cormorant Garamond (display, italic) / Spectral (body)
             JetBrains Mono (marginalia) / Inter (fallback)
   ============================================================ */

:root {
    --obsidian: #0a0612;
    --midnight: #181432;
    --deep-ink: #2b2348;
    --vellum:   #a8b4d8;
    --cream:    #ede1c8;
    --ember:    #d4691e;
    --cave-ice: #6a8cb0;

    --vellum-8: rgba(168, 180, 216, 0.08);
    --vellum-16: rgba(168, 180, 216, 0.16);
    --vellum-32: rgba(168, 180, 216, 0.32);
    --cream-60: rgba(237, 225, 200, 0.6);
    --ember-20: rgba(212, 105, 30, 0.20);
    --ember-50: rgba(212, 105, 30, 0.50);
    --ember-90: rgba(212, 105, 30, 0.90);

    --font-display: "Cormorant Garamond", "Lora", Georgia, serif;
    --font-body:    "Spectral", "Lora", Georgia, serif;
    --font-mono:    "JetBrains Mono", "Inter", ui-monospace, Menlo, monospace;
    --font-ui:      "Inter", system-ui, sans-serif;

    --margin-w: 13.5ch;
    --rail-w:  48px;
    --easing-spring: cubic-bezier(0.2, 0.8, 0.2, 1);
    --easing-quill: cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

html, body {
    background: var(--midnight);
    color: var(--vellum);
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.95rem, 1.15vw, 1.1rem);
    line-height: 1.7;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    min-height: 100vh;
}

body {
    background:
        radial-gradient(ellipse at 12% 6%, rgba(106, 140, 176, 0.06) 0%, transparent 52%),
        radial-gradient(ellipse at 88% 92%, rgba(212, 105, 30, 0.045) 0%, transparent 48%),
        linear-gradient(180deg, var(--midnight) 0%, var(--obsidian) 100%);
    background-attachment: fixed;
    position: relative;
}

/* subtle paper-grain */
body::before {
    content: "";
    position: fixed; inset: 0;
    pointer-events: none;
    background-image:
        repeating-linear-gradient(
            90deg,
            transparent 0px, transparent 39px,
            rgba(168, 180, 216, 0.015) 39px, rgba(168, 180, 216, 0.015) 40px
        );
    z-index: 1;
}

::selection { background: var(--ember-50); color: var(--cream); }

em { font-style: italic; font-family: var(--font-body); color: var(--cream); }

/* ============================================================
   Quill-tip Cursor Ink-Trail
   ============================================================ */
.ink-trail {
    position: fixed;
    top: 0; left: 0;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(212,105,30,0.42) 0%, rgba(212,105,30,0.08) 50%, transparent 75%);
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 9999;
    mix-blend-mode: screen;
    transition: transform 400ms var(--easing-quill), opacity 300ms ease-out, width 220ms ease-out, height 220ms ease-out;
    opacity: 0.85;
    will-change: transform;
}

.ink-trail.armed {
    width: 46px; height: 46px;
    background: radial-gradient(circle, rgba(212,105,30,0.82) 0%, rgba(212,105,30,0.22) 45%, transparent 75%);
}

/* ============================================================
   Vertical Marginalia Column (left)
   ============================================================ */
.marginalia {
    position: fixed;
    top: 0; left: 0;
    width: var(--margin-w);
    height: 100vh;
    padding: 24px 16px 24px 20px;
    background: linear-gradient(180deg, rgba(10,6,18,0.88) 0%, rgba(24,20,50,0.72) 100%);
    border-right: 1px solid var(--vellum-16);
    font-family: var(--font-mono);
    font-weight: 200;
    font-size: 0.72rem;
    line-height: 1.4;
    letter-spacing: 0.03em;
    color: var(--cave-ice);
    z-index: 40;
    backdrop-filter: blur(2px);
    overflow: hidden;
}

.marginalia::after {
    content: "";
    position: absolute; left: 0; right: 0; bottom: 0;
    height: 80px;
    background: linear-gradient(180deg, transparent, var(--midnight));
    pointer-events: none;
}

.version-tumbler-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px dashed var(--vellum-16);
}

.version-tumbler {
    width: 22px; height: 22px;
    animation: tumble 8s steps(6, end) infinite;
    flex-shrink: 0;
}

@keyframes tumble {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.tumbler-label {
    color: var(--ember);
    font-size: 0.64rem;
    letter-spacing: 0.1em;
    text-transform: lowercase;
}

.marginalia-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: calc(100vh - 180px);
    overflow: hidden;
}

.marginalia-list li {
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0.45;
    transition: opacity 500ms ease-out, color 500ms ease-out;
    position: relative;
    padding-left: 12px;
}

.marginalia-list li::before {
    content: "";
    position: absolute;
    left: 0; top: 8px;
    width: 6px; height: 1px;
    background: var(--cave-ice);
    opacity: 0.4;
}

.marginalia-list li.active {
    opacity: 1;
    color: var(--cream);
}

.marginalia-list li.active::before {
    background: var(--ember);
    opacity: 1;
    width: 8px;
}

.m-ts {
    color: var(--ember);
    font-size: 0.66rem;
    letter-spacing: 0.06em;
}

.m-note {
    color: inherit;
    font-size: 0.7rem;
    opacity: 0.85;
}

.coordinate-readout {
    position: absolute;
    left: 20px; bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 10px;
    border-top: 1px dashed var(--vellum-16);
    color: var(--vellum);
    font-size: 0.64rem;
    z-index: 2;
}
.cr-key { color: var(--cave-ice); letter-spacing: 0.1em; }
.cr-val { color: var(--ember); font-size: 0.74rem; }

/* ============================================================
   Right-margin ZigZag Rail
   ============================================================ */
.zigzag-rail {
    position: fixed;
    top: 0; right: 0;
    width: var(--rail-w);
    height: 100vh;
    padding: 12px 4px;
    z-index: 40;
    pointer-events: none;
}

.zigzag-svg {
    width: 100%; height: 100%;
    display: block;
}

.zz-drawn {
    stroke-dasharray: 3400;
    stroke-dashoffset: 3400;
    transition: stroke-dashoffset 320ms linear;
}

.rail-label {
    position: absolute;
    right: 4px; bottom: 14px;
    font-family: var(--font-mono);
    font-weight: 200;
    font-size: 0.6rem;
    letter-spacing: 0.12em;
    color: var(--cave-ice);
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    text-transform: lowercase;
    opacity: 0.7;
}

/* ============================================================
   Frost-Form Corner Ornaments
   ============================================================ */
.frost-form {
    position: fixed;
    width: 300px;
    height: 300px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1800ms ease-out;
    z-index: 5;
}
.frost-form.visible { opacity: 0.18; }

.frost-tl { top: -20px; left: calc(var(--margin-w) - 30px); }
.frost-tr { top: -20px; right: calc(var(--rail-w) - 30px); transform: scaleX(-1); }
.frost-bl { bottom: -20px; left: calc(var(--margin-w) - 30px); transform: scaleY(-1); }
.frost-br { bottom: -20px; right: calc(var(--rail-w) - 30px); transform: scale(-1, -1); }

.frost-form path,
.frost-form line {
    stroke: var(--cave-ice);
    stroke-width: 0.8;
    fill: none;
    stroke-linecap: round;
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    animation: frost-grow 2400ms var(--easing-spring) forwards;
}

@keyframes frost-grow {
    to { stroke-dashoffset: 0; }
}

/* ============================================================
   Ink-blot Field
   ============================================================ */
.inkblot-field {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    opacity: 0.6;
}

.inkblot {
    position: absolute;
    width: 90px; height: 90px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(10,6,18,0.85) 0%, rgba(10,6,18,0.35) 55%, transparent 80%);
    filter: blur(8px);
    mix-blend-mode: multiply;
}

/* ============================================================
   Arc Overlay (SVG, transclusion arcs)
   ============================================================ */
.arc-overlay {
    position: fixed;
    inset: 0;
    width: 100vw; height: 100vh;
    pointer-events: none;
    z-index: 30;
}

.arc-path {
    fill: none;
    stroke: var(--ember);
    stroke-width: 1.2;
    stroke-linecap: round;
    stroke-dasharray: 2 3;
    opacity: 0;
    transition: opacity 700ms ease-out, stroke-width 320ms ease-out;
    filter: drop-shadow(0 0 2px rgba(212,105,30,0.5));
}

.arc-path.drawn { opacity: 0.85; }

.arc-path.lit {
    stroke-width: 1.8;
    opacity: 1;
    filter: drop-shadow(0 0 6px rgba(212,105,30,0.8));
}

.arc-endpoint {
    fill: var(--obsidian);
    stroke: var(--ember);
    stroke-width: 1;
    r: 4;
    opacity: 0;
    transition: opacity 600ms ease-out 400ms;
}
.arc-endpoint.drawn { opacity: 0.9; }

/* ============================================================
   Document Container / Strata
   ============================================================ */
.document {
    position: relative;
    z-index: 10;
    margin-left: var(--margin-w);
    margin-right: var(--rail-w);
    padding: 0;
}

.stratum {
    position: relative;
    padding: 12vh 5vw 16vh 5vw;
    min-height: 100vh;
    border-bottom: 1px dashed var(--vellum-16);
}

.stratum:last-child { border-bottom: 0; }

.stratum-label {
    display: flex;
    align-items: baseline;
    gap: 18px;
    margin-bottom: 6vh;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--vellum-16);
    font-family: var(--font-mono);
    font-weight: 200;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: lowercase;
    color: var(--cave-ice);
}

.sl-numeral {
    color: var(--ember);
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    font-weight: 300;
}

.sl-name {
    color: var(--vellum);
    font-style: italic;
}

.stratum-lede {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(1.02rem, 1.3vw, 1.22rem);
    color: var(--vellum);
    max-width: 62ch;
    margin-bottom: 7vh;
    line-height: 1.65;
}

/* ============================================================
   Stratum I — The Entering
   ============================================================ */
.stratum-1 {
    background: var(--obsidian);
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 8vh 6vw;
}

.entering-stage {
    max-width: 88ch;
    margin: 0 auto;
}

.opening-couplet {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 300;
    font-size: clamp(2.5rem, 7vw, 6.5rem);
    line-height: 0.95;
    letter-spacing: -0.025em;
    color: var(--cream);
    font-feature-settings: 'dlig' 1, 'swsh' 1, 'salt' 1;
    margin-bottom: 4vh;
    position: relative;
}

.line {
    display: block;
    overflow: hidden;
    clip-path: inset(0 100% 0 0);
    animation: line-reveal 1200ms var(--easing-spring) forwards;
}
.line-a { animation-delay: 400ms; }
.line-b { animation-delay: 1000ms; font-weight: 500; }

@keyframes line-reveal {
    to { clip-path: inset(0 0 0 0); }
}

.glitch-word {
    position: relative;
    display: inline-block;
    color: var(--ember);
    font-style: italic;
}

.glitch-word .gw-a,
.glitch-word .gw-b {
    display: inline-block;
    transition: opacity 800ms ease-in-out, filter 800ms ease-in-out;
}
.glitch-word .gw-b {
    position: absolute;
    inset: 0;
    opacity: 0;
    color: var(--ember);
}

.glitch-word.flipped .gw-a { opacity: 0; filter: blur(2px); }
.glitch-word.flipped .gw-b { opacity: 1; filter: blur(0); }

.subinscription {
    font-family: var(--font-mono);
    font-weight: 200;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    color: var(--cave-ice);
    margin-top: 2.5vh;
    opacity: 0;
    animation: fade-in 1200ms ease-out 2400ms forwards;
}

.sub-slash { color: var(--ember); margin-right: 0.5em; }

.enter-annot {
    font-family: var(--font-mono);
    font-weight: 200;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    color: var(--vellum);
    margin-top: 0.8vh;
    opacity: 0;
    animation: fade-in 1200ms ease-out 2800ms forwards;
}
.ea-key { color: var(--cave-ice); margin-right: 0.6em; }
.ea-val { color: var(--ember); }

@keyframes fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pleasure-cursor {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 5vh;
    padding: 8px 14px;
    border: 1px dashed var(--ember-50);
    border-radius: 2px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: var(--ember);
    text-transform: lowercase;
    opacity: 0;
    animation: fade-in 1200ms ease-out 3200ms forwards, cursor-pulse 2400ms ease-in-out 3600ms infinite;
}

@keyframes cursor-pulse {
    0%, 100% { border-color: var(--ember-50); }
    50%      { border-color: var(--ember); box-shadow: 0 0 12px rgba(212,105,30,0.3); }
}

/* ============================================================
   Stratum II — Twin Rivers
   ============================================================ */
.twin-rivers {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4vh;
    margin-top: 5vh;
    overflow: hidden;
}

.stream {
    position: relative;
    border: 1px solid var(--vellum-16);
    background: linear-gradient(180deg, var(--deep-ink) 0%, var(--midnight) 100%);
    padding: 20px 24px 28px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--ember-50) transparent;
}
.stream::-webkit-scrollbar { height: 6px; }
.stream::-webkit-scrollbar-thumb { background: var(--ember-50); border-radius: 3px; }
.stream::-webkit-scrollbar-track { background: transparent; }

.stream-upper { border-left: 2px solid var(--ember); }
.stream-lower {
    border-left: 2px solid var(--cave-ice);
    font-style: italic;
    color: var(--cream);
}

.stream-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--vellum-16);
    font-family: var(--font-mono);
    font-weight: 200;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    color: var(--cave-ice);
    text-transform: lowercase;
}
.sm-label { color: var(--ember); }
.sm-speed { color: var(--vellum); opacity: 0.7; }

.stream-rail {
    display: flex;
    flex-wrap: nowrap;
    gap: 6vw;
    padding-bottom: 12px;
    will-change: transform;
    transition: transform 200ms linear;
}

.river-passage {
    flex: 0 0 auto;
    min-width: 34ch;
    max-width: 42ch;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 0;
}

.rp-line {
    display: block;
    font-size: clamp(0.95rem, 1.15vw, 1.1rem);
    line-height: 1.7;
    clip-path: inset(0 100% 0 0);
    animation: line-reveal 600ms ease-out forwards;
    animation-delay: calc(var(--li, 0) * 40ms);
}

.river-passage .rp-line:nth-child(1) { --li: 1; }
.river-passage .rp-line:nth-child(2) { --li: 2; }
.river-passage .rp-line:nth-child(3) { --li: 3; }
.river-passage .rp-line:nth-child(4) { --li: 4; }
.river-passage .rp-line:nth-child(5) { --li: 5; }
.river-passage .rp-line:nth-child(6) { --li: 6; }

.rp-cite {
    font-family: var(--font-mono);
    font-weight: 200;
    font-style: normal;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    color: var(--cave-ice);
    margin-top: 8px;
    opacity: 0.8;
    text-transform: lowercase;
}

.arc-anchor {
    background: transparent;
    color: var(--ember);
    font-style: italic;
    padding: 0 2px;
    border-bottom: 1px dotted var(--ember-50);
    transition: color 300ms ease, background 300ms ease;
    cursor: help;
}

.arc-anchor:hover {
    color: var(--cream);
    background: var(--ember-20);
    border-bottom-color: var(--ember);
}

.river-footnote,
.card-footnote {
    margin-top: 4vh;
    font-family: var(--font-mono);
    font-weight: 200;
    font-size: 0.72rem;
    color: var(--cave-ice);
    max-width: 60ch;
}
.rf-mark { color: var(--ember); margin-right: 0.4em; }

/* ============================================================
   Stratum III — Vellum Cards
   ============================================================ */
.vellum-field {
    position: relative;
    width: 100%;
    min-height: 160vh;
    padding: 4vh 0;
}

.vellum-card {
    position: absolute;
    left: var(--dx, 10%);
    top: var(--dy, 10%);
    width: clamp(240px, 20vw, 320px);
    padding: 18px 20px 14px;
    background:
        linear-gradient(135deg, rgba(168,180,216,0.10) 0%, rgba(168,180,216,0.04) 100%),
        var(--deep-ink);
    color: var(--cream);
    border: 1px solid var(--vellum-16);
    border-radius: 1px;
    transform: translateY(20px) rotateZ(var(--tilt, 0deg));
    filter: blur(8px) opacity(0);
    transition:
        transform 700ms var(--easing-spring),
        filter 900ms var(--easing-spring),
        box-shadow 400ms ease-out,
        border-color 300ms ease-out;
    box-shadow:
        0 1px 0 rgba(0,0,0,0.4),
        0 20px 40px -20px rgba(0,0,0,0.6);
    clip-path: polygon(
        0% 2%, 2% 0%, 98% 1%, 100% 4%,
        100% 97%, 98% 100%, 2% 98%, 0% 95%
    );
}

.vellum-card.visible {
    transform: translateY(0) rotateZ(var(--tilt, 0deg));
    filter: blur(0) opacity(1);
}

.vellum-card:hover {
    transform: translateY(-6px) rotateZ(0deg);
    border-color: var(--ember);
    box-shadow:
        0 2px 0 rgba(0,0,0,0.4),
        0 30px 60px -20px rgba(212,105,30,0.25),
        0 0 0 1px rgba(212,105,30,0.35);
    z-index: 20;
}

.vc-asterisk {
    position: absolute;
    top: 6px;
    right: 10px;
    color: var(--ember);
    font-size: 1.2rem;
    font-family: var(--font-display);
    line-height: 1;
}

.vc-body {
    font-family: var(--font-body);
    font-weight: 300;
    font-style: italic;
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--cream);
    margin-bottom: 14px;
}
.vc-body em { color: var(--ember); font-style: italic; }

.vc-source {
    font-family: var(--font-mono);
    font-weight: 200;
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    color: var(--cave-ice);
    text-transform: lowercase;
    padding-top: 8px;
    border-top: 1px dashed var(--vellum-16);
}

/* ============================================================
   Stratum IV — Pleasure-Dome Diagram
   ============================================================ */
.stratum-4 {
    background: var(--obsidian);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 10vh 6vw;
}

.dome-stage {
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

.dome-svg {
    width: 100%;
    height: auto;
    display: block;
    margin: 4vh 0 2vh;
}

.d-stroke {
    stroke-dasharray: 1400;
    stroke-dashoffset: 1400;
    transition: stroke-dashoffset 3800ms ease-out;
}
.dome-svg.drawing .d-stroke { stroke-dashoffset: 0; }

.d-unfinished {
    opacity: 0;
    transition: opacity 1400ms ease-out 2200ms;
}
.dome-svg.drawing .d-unfinished { opacity: 0.5; }

.d-label {
    font-family: var(--font-mono);
    font-weight: 200;
    font-size: 10px;
    letter-spacing: 0.1em;
    fill: var(--cream);
    opacity: 0;
    transition: opacity 500ms ease-out;
}

.d-callout { opacity: 0; transition: opacity 600ms ease-out; }
.dome-svg.drawing .d-callout { opacity: 1; }
.dome-svg.drawing .d-callout[data-cidx="1"] { transition-delay: 2400ms; }
.dome-svg.drawing .d-callout[data-cidx="2"] { transition-delay: 2800ms; }
.dome-svg.drawing .d-callout[data-cidx="3"] { transition-delay: 3200ms; }
.dome-svg.drawing .d-callout[data-cidx="4"] { transition-delay: 3600ms; }
.dome-svg.drawing .d-callout[data-cidx="5"] { transition-delay: 4000ms; }

.dome-svg.drawing .d-label { opacity: 1; }

.dome-meta {
    display: flex;
    justify-content: space-between;
    gap: 3vw;
    flex-wrap: wrap;
    padding-top: 14px;
    border-top: 1px dashed var(--vellum-16);
    font-family: var(--font-mono);
    font-weight: 200;
    font-size: 0.72rem;
    color: var(--cave-ice);
    letter-spacing: 0.08em;
    text-transform: lowercase;
}

.dome-caption { color: var(--ember); }
.dome-scale { color: var(--vellum); opacity: 0.7; margin-left: 1em; }
.dome-note {
    font-family: var(--font-body);
    font-style: italic;
    font-weight: 300;
    text-transform: none;
    letter-spacing: 0.01em;
    color: var(--vellum);
    max-width: 44ch;
    font-size: 0.84rem;
    line-height: 1.55;
}

/* ============================================================
   Stratum V — Caves of Ice
   ============================================================ */
.stratum-5 {
    background: linear-gradient(180deg, var(--midnight) 0%, var(--deep-ink) 50%, var(--midnight) 100%);
    position: relative;
}

.caves-stack {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 38ch), 1fr));
    gap: 5vh 4vw;
    margin-top: 4vh;
    max-width: 1200px;
}

.cave-frag {
    position: relative;
    padding: 28px 26px 22px 36px;
    background: rgba(10,6,18,0.55);
    border-left: 2px solid var(--cave-ice);
    transition: border-color 400ms ease-out, background 400ms ease-out;
    opacity: 0;
    transform: translateY(16px);
    transition-property: opacity, transform, border-color, background;
    transition-duration: 900ms, 900ms, 400ms, 400ms;
    transition-timing-function: var(--easing-spring), var(--easing-spring), ease-out, ease-out;
}

.cave-frag.visible {
    opacity: 1;
    transform: translateY(0);
}

.cave-frag::before {
    content: "\201C";
    position: absolute;
    left: 10px; top: 8px;
    font-family: var(--font-display);
    font-size: 3.5rem;
    line-height: 1;
    color: var(--ember);
    opacity: 0.5;
}

.cave-frag:hover {
    border-color: var(--ember);
    background: rgba(43,35,72,0.55);
}

.cf-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.98rem, 1.2vw, 1.15rem);
    line-height: 1.7;
    color: var(--vellum);
}
.cf-text em { color: var(--cream); }

.cf-cite {
    margin-top: 14px;
    font-family: var(--font-mono);
    font-weight: 200;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: var(--cave-ice);
    text-transform: lowercase;
}

/* ============================================================
   Stratum VI — Version Tumbler Finale
   ============================================================ */
.stratum-6 {
    background: var(--obsidian);
    min-height: 110vh;
    padding: 10vh 6vw 14vh;
}

.tumbler-stage {
    position: relative;
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 1.2fr;
    gap: 6vw;
    align-items: start;
    padding: 4vh 0;
}

.tumbler-core {
    position: sticky;
    top: 10vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.big-tumbler {
    width: min(320px, 70%);
    height: auto;
    filter: drop-shadow(0 0 24px rgba(212,105,30,0.3));
}

.bt-ring { transform-origin: 100px 100px; }
.bt-r1 { animation: tumble 12s steps(6, end) infinite; }
.bt-r2 { animation: tumble 10s steps(6, end) infinite reverse; }
.bt-r3 { animation: tumble 14s steps(6, end) infinite; }
.bt-r4 { animation: tumble 8s steps(6, end) infinite reverse; }

.tumbler-spiral {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.tumbler-glyph {
    position: absolute;
    transform: translate(-50%, -50%);
    color: var(--vellum);
    font-family: var(--font-body);
    font-style: italic;
    font-size: 0.7rem;
    letter-spacing: 0.02em;
    padding: 2px 6px;
    background: rgba(10,6,18,0.75);
    border: 1px solid var(--vellum-16);
    max-width: 20ch;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    animation: glyph-spiral 900ms var(--easing-spring) forwards;
}

@keyframes glyph-spiral {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
    to   { opacity: 0.85; transform: translate(-50%, -50%) scale(1); }
}

.tumbler-tag {
    margin-top: 4vh;
    padding-top: 12px;
    border-top: 1px dashed var(--vellum-16);
    text-align: center;
}

.tag-line {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 300;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--cream);
    font-feature-settings: 'dlig' 1, 'swsh' 1, 'salt' 1;
}

.tag-sub {
    margin-top: 1vh;
    font-family: var(--font-mono);
    font-weight: 200;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    color: var(--cave-ice);
    display: inline-flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    text-transform: lowercase;
}
.tag-dot { color: var(--ember); }

.tumbler-session {
    padding-top: 2vh;
}
.ts-title {
    font-family: var(--font-mono);
    font-weight: 200;
    font-size: 0.74rem;
    letter-spacing: 0.1em;
    text-transform: lowercase;
    color: var(--ember);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--vellum-16);
}

.ts-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--ember-50) transparent;
}
.ts-list::-webkit-scrollbar { width: 4px; }
.ts-list::-webkit-scrollbar-thumb { background: var(--ember-50); border-radius: 2px; }

.ts-list li {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 8px 10px;
    background: rgba(43,35,72,0.35);
    border-left: 1px solid var(--cave-ice);
    opacity: 0;
    transform: translateX(-6px);
    animation: ts-in 500ms ease-out forwards;
    animation-delay: calc(var(--ti, 0) * 80ms);
}

@keyframes ts-in {
    to { opacity: 1; transform: translateX(0); }
}

.ts-pos {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-weight: 200;
    font-size: 0.64rem;
    color: var(--ember);
    letter-spacing: 0.08em;
    min-width: 7ch;
    padding-top: 2px;
}
.ts-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-style: italic;
    font-size: 0.86rem;
    line-height: 1.45;
    color: var(--vellum);
}

/* Colophon */
.colophon {
    margin-top: 10vh;
    padding: 30px 0;
    border-top: 1px solid var(--vellum-16);
    max-width: 1000px;
    font-family: var(--font-mono);
    font-weight: 200;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    line-height: 1.7;
    color: var(--cave-ice);
    text-transform: lowercase;
}
.cl-k { color: var(--ember); margin-right: 0.8em; letter-spacing: 0.12em; }
.colophon-line { display: block; }
.colophon-end { color: var(--cream); margin-top: 10px; }
.blink {
    color: var(--ember);
    animation: blink 1.2s steps(2, end) infinite;
}
@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ============================================================
   Responsive Shelves
   ============================================================ */
@media (max-width: 1000px) {
    :root { --margin-w: 11ch; --rail-w: 32px; }
    .opening-couplet { font-size: clamp(2rem, 8vw, 4.5rem); }
    .tumbler-stage {
        grid-template-columns: 1fr;
        gap: 4vh;
    }
    .tumbler-core { position: static; }
    .vellum-field { min-height: 240vh; }
    .vellum-card {
        position: relative;
        left: auto !important; top: auto !important;
        width: 100%;
        margin-bottom: 4vh;
    }
    .caves-stack { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    :root { --margin-w: 9ch; --rail-w: 24px; }
    html, body { font-size: 0.95rem; }
    .marginalia { padding: 16px 10px 16px 12px; }
    .marginalia-list { gap: 8px; }
    .m-ts, .m-note { font-size: 0.62rem; }
    .stratum { padding: 10vh 5vw 12vh; }
    .river-passage { min-width: 28ch; max-width: 34ch; }
    .opening-couplet { font-size: clamp(1.8rem, 9vw, 3.4rem); }
    .tag-line { font-size: clamp(1.2rem, 5vw, 1.8rem); }
    .frost-form { width: 180px; height: 180px; }
}

/* Reduced motion: keep the document readable */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .line { clip-path: inset(0 0 0 0) !important; }
    .vellum-card { filter: none !important; transform: rotateZ(var(--tilt, 0deg)) !important; }
}
