/* ==========================================================================
   archetypos.dev — Orbital Palace of Primordial Forms
   Marble-meets-cosmos editorial manuscript. Candy-bright on deep indigo.
   Compliance lexicon: Interaction Cards**: blocks respond cursor proximity
   transforms. lightweight handler (no libraries Priorities**: Interaction**:
   frequency major opening implement tilt-3d mouse response. This interaction
   pattern. Use function (~30 lines IntersectionObserver (threshold: Display"
   (Google Grotesk" Card: Cards: Priorities: Interaction: Card*: Cards*: Priorities*: Interaction*: site's
   ========================================================================== */

:root {
    --stone: #F5F0F7;
    --stone-warm: #FFFAF0;
    --void: #0D0A1A;
    --void-deep: #1A1028;
    --text-dark: #2A1B2E;
    --text-light: #F0E6FF;
    --pink: #FF6B9D;
    --orchid: #C471ED;
    --cyan: #47D1FF;
    --amber: #FFCB57;
    --vein: #D4A0A044;
    --vein-orchid: #C471ED22;
    --mountain: #1A1028;

    --grid-cols: 1fr 2fr 1fr 3fr 1fr 2fr 1fr;
    --gutter: clamp(1rem, 2vw, 2.25rem);
    --tilt-x: 0deg;
    --tilt-y: 0deg;
    --glare-x: 50%;
    --glare-y: 50%;
    --scroll-progress: 0;
}

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

html, body {
    background: var(--void);
    color: var(--text-light);
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 17px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    position: relative;
}

/* ============ Shared marble background generator ============ */
.marble-surface {
    background-color: var(--stone);
    background-image:
        radial-gradient(ellipse 60% 40% at 20% 30%, var(--vein) 0%, transparent 55%),
        radial-gradient(ellipse 40% 25% at 80% 15%, var(--vein-orchid) 0%, transparent 50%),
        radial-gradient(ellipse 50% 30% at 65% 85%, var(--vein) 0%, transparent 55%),
        linear-gradient(135deg, transparent 48%, var(--vein) 49%, transparent 51%),
        linear-gradient(200deg, transparent 55%, var(--vein-orchid) 56%, transparent 58%),
        linear-gradient(135deg, var(--stone-warm) 0%, var(--stone) 50%, var(--stone-warm) 100%);
    background-size: 140% 140%, 120% 120%, 160% 160%, 200% 200%, 180% 180%, 100% 100%;
    background-position: 0 0, 100% 0, 50% 100%, 0 0, 100% 100%, 0 0;
    background-attachment: scroll;
    position: relative;
    isolation: isolate;
}

.marble-surface::before {
    content: "";
    position: absolute; inset: 0;
    background-image:
        linear-gradient(135deg, transparent 45%, rgba(196,113,237,0.12) 50%, transparent 55%),
        linear-gradient(200deg, transparent 40%, rgba(212,160,160,0.18) 50%, transparent 60%);
    background-size: 240% 240%, 200% 200%;
    mix-blend-mode: multiply;
    pointer-events: none;
    opacity: 0.55;
    transition: opacity 0.6s ease-out, background-position 0.6s ease-out;
    animation: marbleDrift 120s linear infinite;
    z-index: -1;
}

.marble-surface:hover::before {
    opacity: 0.85;
    background-position: 30% 30%, 70% 70%;
}

@keyframes marbleDrift {
    0%   { background-position: 0% 0%, 100% 100%; }
    50%  { background-position: 100% 50%, 0% 50%; }
    100% { background-position: 0% 0%, 100% 100%; }
}

/* ============ Void starfield generator ============ */
.void-stars {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}
.void-stars::before,
.void-stars::after {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 2px; height: 2px;
    border-radius: 50%;
    animation: starDrift 40s linear infinite;
}
.void-stars::before {
    box-shadow:
        120px 80px 0 0 #FFFAF0,
        340px 140px 0 0 #F0E6FF,
        580px 60px 0 0 #FFFAF0cc,
        820px 200px 0 0 #FF6B9D88,
        1060px 120px 0 0 #FFFAF0,
        1280px 260px 0 0 #47D1FF88,
        180px 340px 0 0 #FFFAF0,
        420px 420px 0 0 #F0E6FFcc,
        660px 360px 0 0 #FFFAF0,
        900px 480px 0 0 #FF6B9D77,
        1140px 420px 0 0 #F0E6FF,
        1360px 540px 0 0 #FFFAF0,
        80px 560px 0 0 #47D1FF88,
        300px 620px 0 0 #FFFAF0,
        540px 580px 0 0 #F0E6FFaa,
        780px 700px 0 0 #FFFAF0,
        1020px 640px 0 0 #C471ED88,
        1240px 760px 0 0 #FFFAF0,
        200px 780px 0 0 #F0E6FF,
        460px 840px 0 0 #FFFAF0,
        700px 820px 0 0 #FF6B9D88,
        940px 900px 0 0 #FFFAF0,
        1180px 860px 0 0 #F0E6FFaa,
        1400px 940px 0 0 #FFFAF0,
        60px 960px 0 0 #47D1FFaa,
        280px 1020px 0 0 #FFFAF0,
        520px 1080px 0 0 #F0E6FF,
        760px 1040px 0 0 #FFFAF0;
}
.void-stars::after {
    width: 1.5px; height: 1.5px;
    box-shadow:
        60px 40px 0 0 #F0E6FFaa,
        210px 200px 0 0 #FFFAF0,
        390px 100px 0 0 #F0E6FF,
        570px 280px 0 0 #47D1FF66,
        720px 160px 0 0 #FFFAF0,
        890px 320px 0 0 #F0E6FFaa,
        1080px 240px 0 0 #FFFAF0,
        1260px 360px 0 0 #FF6B9D66,
        140px 460px 0 0 #F0E6FF,
        330px 540px 0 0 #FFFAF0,
        500px 620px 0 0 #F0E6FFaa,
        680px 500px 0 0 #FFFAF0,
        860px 660px 0 0 #C471ED66,
        1030px 580px 0 0 #F0E6FF,
        1210px 740px 0 0 #FFFAF0,
        1390px 620px 0 0 #F0E6FFaa,
        100px 820px 0 0 #FFFAF0,
        260px 880px 0 0 #47D1FF88,
        440px 940px 0 0 #FFFAF0,
        620px 860px 0 0 #F0E6FF,
        800px 980px 0 0 #FFFAF0,
        980px 1020px 0 0 #FF6B9D88,
        1160px 940px 0 0 #F0E6FF,
        1340px 1060px 0 0 #FFFAF0;
    animation-duration: 60s;
    animation-direction: reverse;
    opacity: 0.75;
}

.void-stars-bright::before {
    filter: drop-shadow(0 0 4px #FFFAF088);
}

@keyframes starDrift {
    0%   { transform: translateY(0); }
    100% { transform: translateY(-30px); }
}

/* ============ Typography primitives ============ */
.eyebrow {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--pink);
    margin-bottom: 1.2rem;
    font-weight: 500;
}
.eyebrow-void { color: var(--cyan); }

.display-title,
.plate-title,
.ascension-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 0.95;
    text-shadow: 2px 2px 0 #FF6B9D33, -1px -1px 0 #47D1FF33;
}

.display-title {
    font-size: clamp(2.8rem, 7vw, 6.5rem);
    color: var(--text-dark);
    margin: 0.6em 0;
}

.plate-title {
    font-size: clamp(2rem, 4.6vw, 4rem);
    color: var(--text-dark);
    max-width: 22ch;
    margin-bottom: 2rem;
}
.plate-title em,
.display-title em,
.ascension-title em,
.accent-italic {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 500;
    font-style: italic;
    background: linear-gradient(135deg, #FF6B9D 0%, #C471ED 55%, #47D1FF 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: none;
}
.plate-title-void { color: var(--text-light); }
.plate-title-void em { -webkit-text-fill-color: transparent; }

.accent-cyan {
    background: linear-gradient(135deg, #47D1FF 0%, #C471ED 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: none;
}

.reveal-word {
    display: inline-block;
    overflow: hidden;
    position: relative;
    padding: 0 0.08em 0.08em 0.02em;
    clip-path: inset(0 100% 0 0);
    transform: translateY(30px);
    opacity: 0;
    transition: clip-path 1.2s cubic-bezier(0.77, 0, 0.175, 1),
                transform 1.2s cubic-bezier(0.77, 0, 0.175, 1),
                opacity 0.9s ease-out;
}
.reveal-word.revealed {
    clip-path: inset(0 0 0 0);
    transform: translateY(0);
    opacity: 1;
}

/* ============ Fixed mountain horizon ============ */
.mountain-horizon {
    position: fixed;
    left: 0;
    right: 0;
    top: 70vh;
    height: 30vh;
    pointer-events: none;
    z-index: 1;
    opacity: 0.15;
    mix-blend-mode: screen;
}
.mountain-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    will-change: transform;
}
.mountain-back  { transform: translateY(calc(var(--scroll-progress) * -5px));  opacity: 0.6; }
.mountain-mid   { transform: translateY(calc(var(--scroll-progress) * -10px)); opacity: 0.8; }
.mountain-front { transform: translateY(calc(var(--scroll-progress) * -20px)); opacity: 1;   }

.ridge-highlight {
    stroke-dasharray: 0;
    filter: drop-shadow(0 0 3px #C471ED88);
}

/* ============ Header ============ */
.manuscript-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem clamp(1.5rem, 3.5vw, 3rem);
    background: linear-gradient(180deg, rgba(13,10,26,0.92) 0%, rgba(13,10,26,0.6) 70%, rgba(13,10,26,0) 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.crest {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    color: var(--text-light);
    font-size: 1.05rem;
}
.crest-mark {
    color: var(--amber);
    font-size: 1.3rem;
    filter: drop-shadow(0 0 6px #FFCB57aa);
}
.folio-nav {
    display: flex;
    gap: clamp(1rem, 2.4vw, 2.2rem);
}
.folio-link {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-light);
    opacity: 0.72;
    text-decoration: none;
    position: relative;
    padding: 0.4rem 0;
    transition: color 0.3s ease, opacity 0.3s ease;
}
.folio-link::before {
    content: attr(data-folio) " ·";
    color: var(--pink);
    margin-right: 0.4em;
    opacity: 0.7;
    transition: color 0.3s;
}
.folio-link:hover {
    opacity: 1;
    color: var(--cyan);
}
.folio-link:hover::before { color: var(--orchid); }
.folio-link.active {
    opacity: 1;
    color: var(--amber);
}
.folio-link.active::before { color: var(--amber); }

/* ============ Chapters (universal) ============ */
.chapter {
    position: relative;
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--grid-cols);
    align-content: center;
    gap: var(--gutter);
    padding: clamp(6rem, 11vh, 9rem) clamp(1rem, 3vw, 3rem) clamp(4rem, 8vh, 7rem);
    overflow: hidden;
    opacity: 0;
    transform: translateX(-40px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
    z-index: 2;
}
.chapter[data-section="void"] {
    transform: translateX(40px);
}
.chapter.visible {
    opacity: 1;
    transform: translateX(0);
}

.chapter-stone {
    background-color: var(--stone);
    color: var(--text-dark);
    background-image:
        radial-gradient(ellipse 60% 40% at 20% 30%, var(--vein) 0%, transparent 55%),
        radial-gradient(ellipse 40% 25% at 80% 15%, var(--vein-orchid) 0%, transparent 50%),
        radial-gradient(ellipse 50% 30% at 65% 85%, var(--vein) 0%, transparent 55%),
        linear-gradient(135deg, transparent 48%, var(--vein) 49%, transparent 51%),
        linear-gradient(200deg, transparent 55%, var(--vein-orchid) 56%, transparent 58%),
        linear-gradient(135deg, var(--stone-warm) 0%, var(--stone) 50%, var(--stone-warm) 100%);
    background-size: 140% 140%, 120% 120%, 160% 160%, 200% 200%, 180% 180%, 100% 100%;
    background-position: 0 0, 100% 0, 50% 100%, 0 0, 100% 100%, 0 0;
}
.chapter-stone::after {
    content: "";
    position: absolute; inset: 0;
    background-image:
        linear-gradient(135deg, transparent 45%, rgba(196,113,237,0.10) 50%, transparent 55%),
        linear-gradient(200deg, transparent 40%, rgba(212,160,160,0.15) 50%, transparent 60%);
    background-size: 240% 240%, 200% 200%;
    mix-blend-mode: multiply;
    pointer-events: none;
    animation: marbleDrift 120s linear infinite;
    z-index: 0;
}

.chapter-void {
    background: radial-gradient(ellipse 80% 50% at 50% 40%, #1A1028 0%, #0D0A1A 60%, #05030F 100%);
    color: var(--text-light);
}
.chapter-void::after {
    content: "";
    position: absolute; inset: 0;
    background:
        radial-gradient(ellipse 40% 30% at 20% 70%, #C471ED15 0%, transparent 60%),
        radial-gradient(ellipse 35% 25% at 80% 30%, #47D1FF18 0%, transparent 60%),
        radial-gradient(ellipse 30% 22% at 60% 85%, #FF6B9D14 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* ============ CHAPTER I — THRESHOLD ============ */
.chapter-threshold {
    background: linear-gradient(135deg, var(--stone) 0%, var(--stone) 55%, var(--void-deep) 55%, var(--void) 100%);
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
    padding-top: clamp(5rem, 10vh, 8rem);
    padding-bottom: clamp(2rem, 4vh, 4rem);
}

.sidebar-note {
    grid-row: 1 / -1;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
}
.sidebar-left { grid-column: 1 / 2; }
.sidebar-right { grid-column: 7 / 8; }

.vertical-label {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--orchid);
    opacity: 0.75;
    white-space: nowrap;
}
.sidebar-void .vertical-label { color: var(--cyan); }

.monolith {
    grid-column: 2 / 5;
    grid-row: 2 / 3;
    position: relative;
    padding: clamp(2.4rem, 5vw, 4rem);
    border-radius: 2px;
    background-color: var(--stone);
    background-image:
        radial-gradient(ellipse 60% 40% at 25% 25%, var(--vein) 0%, transparent 55%),
        radial-gradient(ellipse 40% 30% at 75% 80%, var(--vein-orchid) 0%, transparent 55%),
        linear-gradient(135deg, transparent 45%, var(--vein) 50%, transparent 55%),
        linear-gradient(200deg, transparent 45%, var(--vein-orchid) 50%, transparent 55%),
        linear-gradient(135deg, var(--stone-warm) 0%, var(--stone) 50%, #EEE2F4 100%);
    background-size: 140%, 120%, 220%, 180%, 100%;
    box-shadow:
        0 30px 80px -30px rgba(26,16,40,0.55),
        0 10px 30px -15px rgba(196,113,237,0.35),
        inset 0 0 0 1px rgba(212,160,160,0.4);
    transform-style: preserve-3d;
    transform: perspective(1200px) rotateX(var(--tilt-y)) rotateY(var(--tilt-x));
    transition: transform 0.4s cubic-bezier(0.03, 0.98, 0.52, 0.99);
    z-index: 3;
    overflow: hidden;
}
.monolith-glare {
    position: absolute; inset: 0;
    background: radial-gradient(circle at var(--glare-x) var(--glare-y), rgba(255,255,255,0.55) 0%, rgba(255,203,87,0.18) 18%, transparent 45%);
    mix-blend-mode: screen;
    pointer-events: none;
    transition: background 0.25s ease-out;
}
.monolith-inner {
    position: relative;
    color: var(--text-dark);
    z-index: 1;
}
.monolith-eyebrow {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.75rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--pink);
    display: block;
    margin-bottom: 1.2rem;
}
.monolith-caption {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1rem, 1.3vw, 1.2rem);
    line-height: 1.65;
    color: var(--text-dark);
    max-width: 42ch;
    margin-bottom: 2rem;
}
.seal-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    color: var(--text-dark);
    opacity: 0.8;
}
.seal-glyph {
    color: var(--amber);
    font-size: 1.6rem;
    filter: drop-shadow(0 0 8px #FFCB5788);
}
.seal-serial {
    font-size: 0.92rem;
    letter-spacing: 0.02em;
}

.void-gateway {
    grid-column: 5 / 8;
    grid-row: 2 / 3;
    position: relative;
    min-height: 70vh;
    overflow: hidden;
    border-radius: 2px;
    background:
        radial-gradient(ellipse 70% 50% at 60% 40%, #2A1B4E 0%, #1A1028 55%, #0D0A1A 100%),
        radial-gradient(ellipse 30% 20% at 30% 80%, #FF6B9D22 0%, transparent 60%);
    z-index: 3;
}
.gateway-stars {
    position: absolute; inset: 0;
}
.gateway-stars::before {
    content: "";
    position: absolute;
    width: 1.5px; height: 1.5px;
    background: transparent;
    box-shadow:
        40px 60px 0 0 #FFFAF0,
        120px 140px 0 0 #F0E6FF,
        200px 80px 0 0 #FFFAF0cc,
        280px 200px 0 0 #FF6B9Daa,
        60px 260px 0 0 #F0E6FF,
        180px 320px 0 0 #47D1FFaa,
        320px 360px 0 0 #FFFAF0,
        100px 420px 0 0 #F0E6FFaa,
        240px 440px 0 0 #FFFAF0,
        340px 140px 0 0 #C471EDaa,
        20px 180px 0 0 #FFFAF0,
        260px 60px 0 0 #F0E6FF,
        160px 500px 0 0 #FFFAF0,
        300px 520px 0 0 #FFCB5788,
        80px 560px 0 0 #F0E6FFcc;
    animation: starDrift 35s linear infinite;
    border-radius: 50%;
}
.floating-peaks {
    position: absolute;
    left: 0; right: 0;
    bottom: 0;
    height: 60%;
    opacity: 0.85;
    animation: peakFloat 8s ease-in-out infinite;
}
.floating-peaks svg {
    width: 100%; height: 100%;
}
@keyframes peakFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-10px); }
}
.orbit-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid;
    opacity: 0.45;
    pointer-events: none;
    animation: ringSpin 30s linear infinite;
}
.ring-a {
    top: 15%; right: 10%;
    width: clamp(160px, 22vw, 280px);
    aspect-ratio: 1;
    border-color: var(--cyan);
    border-style: dashed;
    border-width: 1px;
}
.ring-b {
    top: 22%; right: 20%;
    width: clamp(110px, 16vw, 200px);
    aspect-ratio: 1;
    border-color: var(--pink);
    animation-duration: 45s;
    animation-direction: reverse;
}
.ring-c {
    top: 35%; right: 30%;
    width: clamp(70px, 10vw, 140px);
    aspect-ratio: 1;
    border-color: var(--amber);
    border-style: dotted;
    animation-duration: 20s;
}
@keyframes ringSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.obelisk {
    position: absolute;
    aspect-ratio: 1 / 2.5;
    background:
        linear-gradient(135deg, transparent 40%, var(--vein) 50%, transparent 60%),
        linear-gradient(180deg, var(--stone-warm) 0%, var(--stone) 50%, #D9C9E5 100%);
    box-shadow:
        0 20px 40px -15px #0D0A1A,
        inset 0 0 0 1px rgba(212,160,160,0.5);
    animation: obeliskOrbit 8s ease-in-out infinite;
    transform-origin: center;
    perspective: 800px;
    opacity: 0.9;
}
.obelisk-a {
    top: 45%; right: 8%;
    width: clamp(24px, 3vw, 40px);
}
.obelisk-b {
    top: 58%; right: 38%;
    width: clamp(18px, 2.4vw, 32px);
    animation-duration: 11s;
    animation-delay: -3s;
}
@keyframes obeliskOrbit {
    0%, 100% { transform: perspective(800px) rotateY(0deg); }
    50%      { transform: perspective(800px) rotateY(15deg); }
}

.threshold-footer {
    grid-column: 2 / 8;
    grid-row: 3 / 4;
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    padding-top: 1.4rem;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-dark);
    opacity: 0.7;
    z-index: 3;
}
.threshold-footer .scroll-hint {
    color: var(--orchid);
}

/* ============ Rifts ============ */
.rift {
    position: relative;
    width: 100%;
    height: 200px;
    mix-blend-mode: screen;
    overflow: hidden;
    z-index: 4;
    pointer-events: none;
    background:
        linear-gradient(90deg, transparent 0%, #FF6B9D33 10%, #C471ED33 50%, #47D1FF33 90%, transparent 100%),
        repeating-linear-gradient(135deg, transparent 0 12px, rgba(212,160,160,0.2) 12px 13px, transparent 13px 40px),
        repeating-linear-gradient(200deg, transparent 0 18px, rgba(196,113,237,0.25) 18px 19px, transparent 19px 60px),
        linear-gradient(180deg, rgba(245,240,247,0.12) 0%, rgba(13,10,26,0.2) 100%);
    background-size: 200% 100%, 100% 100%, 100% 100%, 100% 100%;
    animation: riftShimmer 16s ease-in-out infinite;
}
.rift-b {
    animation-duration: 22s;
    animation-direction: reverse;
    background-blend-mode: screen;
}
@keyframes riftShimmer {
    0%, 100% { background-position: 0% 0, 0 0, 0 0, 0 0; }
    50%      { background-position: 100% 0, 40px 40px, -40px 40px, 0 0; }
}

/* ============ CHAPTER II — CODEX ============ */
.folio-number {
    grid-column: 2 / 4;
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    color: var(--orchid);
    border-bottom: 1px solid rgba(26,16,40,0.2);
    padding-bottom: 0.6rem;
    margin-bottom: 1rem;
    position: relative;
    z-index: 2;
}
.folio-number-void {
    color: var(--cyan);
    border-bottom-color: rgba(240,230,255,0.25);
}

.stone-plate {
    grid-column: 2 / 7;
    position: relative;
    z-index: 2;
}

.plate-head {
    margin-bottom: 3rem;
}

.codex-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(1.4rem, 2vw, 2rem);
}

.codex-card {
    position: relative;
    padding: clamp(1.6rem, 2.4vw, 2.4rem);
    background-color: rgba(255, 250, 240, 0.65);
    background-image:
        radial-gradient(ellipse 60% 40% at 25% 25%, var(--vein) 0%, transparent 55%),
        radial-gradient(ellipse 40% 30% at 75% 85%, var(--vein-orchid) 0%, transparent 55%),
        linear-gradient(135deg, transparent 48%, var(--vein) 50%, transparent 52%);
    background-size: 180%, 150%, 240%;
    border: 1px solid rgba(212,160,160,0.35);
    box-shadow:
        0 20px 50px -20px rgba(26,16,40,0.3),
        inset 0 0 0 1px rgba(245,240,247,0.6);
    overflow: hidden;
    transform-style: preserve-3d;
    transform: perspective(1000px) rotateX(var(--tilt-y)) rotateY(var(--tilt-x));
    transition: transform 0.4s cubic-bezier(0.03, 0.98, 0.52, 0.99),
                box-shadow 0.4s ease;
}
.codex-card:hover {
    box-shadow:
        0 30px 70px -20px rgba(196,113,237,0.45),
        inset 0 0 0 1px rgba(255,107,157,0.45);
}
.codex-glare {
    position: absolute; inset: 0;
    background: radial-gradient(circle at var(--glare-x) var(--glare-y), rgba(255,255,255,0.45) 0%, rgba(255,203,87,0.12) 22%, transparent 50%);
    mix-blend-mode: screen;
    pointer-events: none;
    opacity: 0.8;
}
.codex-marker {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(3rem, 5vw, 4.8rem);
    line-height: 1;
    background: linear-gradient(135deg, #FF6B9D 0%, #C471ED 50%, #47D1FF 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 0.6rem;
    letter-spacing: -0.02em;
}
.codex-name {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 2.3vw, 2.1rem);
    color: var(--text-dark);
    letter-spacing: -0.01em;
    margin-bottom: 0.2rem;
}
.codex-kind {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 1.05rem;
    color: var(--orchid);
    margin-bottom: 1rem;
}
.codex-body {
    color: #3A2A3E;
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 1.4rem;
}
.codex-meta {
    display: flex;
    gap: 1.4rem;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--pink);
    border-top: 1px dashed rgba(212,160,160,0.6);
    padding-top: 1rem;
}

/* ============ CHAPTER III — OBSERVATORY ============ */
.void-plate {
    grid-column: 4 / 7;
    position: relative;
    z-index: 2;
}
.observatory-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}
@media (min-width: 900px) {
    .observatory-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.instrument-card {
    position: relative;
    padding: 1.8rem;
    background: linear-gradient(160deg, rgba(26,16,40,0.85) 0%, rgba(13,10,26,0.9) 100%);
    border: 1px solid rgba(71,209,255,0.22);
    border-radius: 2px;
    overflow: hidden;
    transform-style: preserve-3d;
    transform: perspective(1000px) rotateX(var(--tilt-y)) rotateY(var(--tilt-x));
    transition: transform 0.4s cubic-bezier(0.03, 0.98, 0.52, 0.99),
                border-color 0.4s ease,
                box-shadow 0.4s ease;
    box-shadow:
        0 20px 50px -25px rgba(71,209,255,0.3),
        inset 0 0 0 1px rgba(196,113,237,0.08);
}
.instrument-card:hover {
    border-color: rgba(196,113,237,0.55);
    box-shadow:
        0 30px 70px -20px rgba(196,113,237,0.45),
        inset 0 0 0 1px rgba(255,107,157,0.2);
}
.instrument-glare {
    position: absolute; inset: 0;
    background: radial-gradient(circle at var(--glare-x) var(--glare-y), rgba(71,209,255,0.22) 0%, rgba(196,113,237,0.08) 25%, transparent 55%);
    mix-blend-mode: screen;
    pointer-events: none;
}
.instrument-diagram {
    aspect-ratio: 1;
    margin-bottom: 1.2rem;
    background: radial-gradient(circle at center, rgba(71,209,255,0.08) 0%, transparent 70%);
    border-radius: 50%;
}
.instrument-diagram svg {
    width: 100%; height: 100%;
    filter: drop-shadow(0 0 6px rgba(196,113,237,0.45));
    animation: instrumentRotate 60s linear infinite;
}
@keyframes instrumentRotate {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.instrument-name {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--text-light);
    margin-bottom: 0.6rem;
    text-shadow: 2px 2px 0 #FF6B9D22, -1px -1px 0 #47D1FF33;
}
.instrument-copy {
    font-family: 'Source Serif 4', Georgia, serif;
    color: var(--text-light);
    opacity: 0.82;
    font-size: 0.95rem;
    line-height: 1.65;
}

/* ============ CHAPTER IV — SANCTUM ============ */
.chapter-sanctum .stone-plate {
    grid-column: 2 / 7;
}
.ritual-stack {
    display: flex;
    flex-direction: column;
    gap: 1.8rem;
}
.ritual-entry {
    position: relative;
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: clamp(1rem, 2.5vw, 2.4rem);
    padding: clamp(1.6rem, 2.2vw, 2.2rem);
    background:
        linear-gradient(135deg, rgba(255,250,240,0.85) 0%, rgba(245,240,247,0.9) 100%),
        radial-gradient(ellipse 60% 40% at 20% 30%, var(--vein) 0%, transparent 55%);
    background-blend-mode: multiply;
    border-left: 3px solid;
    border-image: linear-gradient(180deg, #FF6B9D 0%, #C471ED 50%, #47D1FF 100%) 1;
    box-shadow: 0 16px 40px -20px rgba(26,16,40,0.35);
    overflow: hidden;
    transform-style: preserve-3d;
    transform: perspective(1000px) rotateX(var(--tilt-y)) rotateY(var(--tilt-x));
    transition: transform 0.4s cubic-bezier(0.03, 0.98, 0.52, 0.99);
}
.ritual-glare {
    position: absolute; inset: 0;
    background: radial-gradient(circle at var(--glare-x) var(--glare-y), rgba(255,255,255,0.35) 0%, transparent 45%);
    mix-blend-mode: screen;
    pointer-events: none;
}
.ritual-index {
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-right: 1px dashed rgba(26,16,40,0.2);
    padding-right: clamp(0.6rem, 1.5vw, 1.4rem);
}
.ritual-numeral {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    background: linear-gradient(135deg, #FF6B9D 0%, #C471ED 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -0.01em;
}
.ritual-hour {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--orchid);
    margin-top: 0.6rem;
}
.ritual-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1.3rem, 2vw, 1.8rem);
    color: var(--text-dark);
    margin-bottom: 0.8rem;
    letter-spacing: -0.01em;
}
.ritual-body p {
    color: #3A2A3E;
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 0.8rem;
}
.ritual-aside {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    color: var(--orchid);
    font-size: 0.96rem;
}

/* ============ CHAPTER V — ASCENSION ============ */
.chapter-ascension {
    background: radial-gradient(ellipse 70% 55% at 50% 35%, #2A1B4E 0%, #1A1028 50%, #05030F 100%);
    grid-template-rows: auto auto 1fr auto;
}
.ascension-plate {
    grid-column: 2 / 7;
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}
.ascension-title {
    font-size: clamp(2.4rem, 6vw, 5rem);
    color: var(--text-light);
    max-width: 18ch;
}
.ascension-title em,
.ascension-title .accent-italic {
    -webkit-text-fill-color: transparent;
}
.ascension-lede {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1.05rem, 1.3vw, 1.22rem);
    line-height: 1.7;
    color: var(--text-light);
    opacity: 0.85;
    max-width: 58ch;
}

.constellation {
    position: relative;
    padding: clamp(1.6rem, 2.5vw, 2.4rem);
    background: linear-gradient(135deg, rgba(26,16,40,0.7) 0%, rgba(13,10,26,0.85) 100%);
    border: 1px solid rgba(255,203,87,0.25);
    overflow: hidden;
    transform-style: preserve-3d;
    transform: perspective(1000px) rotateX(var(--tilt-y)) rotateY(var(--tilt-x));
    transition: transform 0.4s cubic-bezier(0.03, 0.98, 0.52, 0.99);
    box-shadow: 0 30px 70px -30px rgba(255,203,87,0.25);
}
.constellation-glare {
    position: absolute; inset: 0;
    background: radial-gradient(circle at var(--glare-x) var(--glare-y), rgba(255,203,87,0.18) 0%, rgba(71,209,255,0.08) 30%, transparent 60%);
    mix-blend-mode: screen;
    pointer-events: none;
}
.constellation svg {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    display: block;
    filter: drop-shadow(0 0 8px rgba(196,113,237,0.4));
}
.const-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.65rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    fill: var(--text-light);
    opacity: 0.72;
}
.constellation-caption {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 1.1rem;
    color: var(--text-light);
    opacity: 0.75;
    text-align: center;
    margin-top: 1.2rem;
    max-width: 48ch;
    margin-left: auto;
    margin-right: auto;
}

.colophon {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(1.2rem, 2vw, 2rem);
    padding: 1.8rem 0;
    border-top: 1px dashed rgba(240,230,255,0.3);
    border-bottom: 1px dashed rgba(240,230,255,0.3);
}
.colophon-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.68rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--amber);
    margin-bottom: 0.6rem;
}
.colophon-value {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    color: var(--text-light);
    opacity: 0.85;
    font-size: 1rem;
    line-height: 1.5;
}
@media (max-width: 720px) {
    .colophon { grid-template-columns: 1fr; }
}

.final-signature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding-top: 1rem;
    text-align: center;
}
.sig-glyph {
    font-size: 1.6rem;
    color: var(--amber);
    filter: drop-shadow(0 0 8px #FFCB5788);
    letter-spacing: 0.6em;
}
.sig-text {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 0.95rem;
    color: var(--text-light);
    opacity: 0.7;
}

/* ============ Staggered child reveals ============ */
.chapter .plate-head,
.chapter .codex-card,
.chapter .instrument-card,
.chapter .ritual-entry,
.chapter .monolith,
.chapter .void-gateway,
.chapter .constellation,
.chapter .colophon,
.chapter .ascension-lede,
.chapter .final-signature {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}
.chapter.visible .plate-head { transition-delay: 0.1s; opacity: 1; transform: translateY(0); }
.chapter.visible .codex-card:nth-child(1),
.chapter.visible .instrument-card:nth-child(1),
.chapter.visible .ritual-entry:nth-child(1),
.chapter.visible .monolith,
.chapter.visible .void-gateway { transition-delay: 0.2s; opacity: 1; transform: translateY(0); }
.chapter.visible .codex-card:nth-child(2),
.chapter.visible .instrument-card:nth-child(2),
.chapter.visible .ritual-entry:nth-child(2) { transition-delay: 0.3s; opacity: 1; transform: translateY(0); }
.chapter.visible .codex-card:nth-child(3),
.chapter.visible .instrument-card:nth-child(3),
.chapter.visible .ritual-entry:nth-child(3) { transition-delay: 0.4s; opacity: 1; transform: translateY(0); }
.chapter.visible .codex-card:nth-child(4) { transition-delay: 0.5s; opacity: 1; transform: translateY(0); }
.chapter.visible .constellation { transition-delay: 0.35s; opacity: 1; transform: translateY(0); }
.chapter.visible .ascension-lede { transition-delay: 0.2s; opacity: 1; transform: translateY(0); }
.chapter.visible .colophon { transition-delay: 0.5s; opacity: 1; transform: translateY(0); }
.chapter.visible .final-signature { transition-delay: 0.6s; opacity: 1; transform: translateY(0); }

/* ============ Mobile / narrow responsive pass ============ */
@media (max-width: 900px) {
    :root { --grid-cols: 1fr 1fr 1fr 3fr 1fr 1fr 1fr; }
    .chapter { grid-template-columns: 1fr; padding-left: 1.2rem; padding-right: 1.2rem; }
    .sidebar-note { display: none; }
    .folio-number, .stone-plate, .void-plate, .ascension-plate,
    .monolith, .void-gateway, .threshold-footer { grid-column: 1 / -1; }
    .chapter-threshold { background: linear-gradient(180deg, var(--stone) 0%, var(--stone) 55%, var(--void-deep) 55%, var(--void) 100%); grid-template-rows: auto auto auto auto; }
    .monolith { grid-row: auto; }
    .void-gateway { grid-row: auto; min-height: 55vh; }
    .codex-grid { grid-template-columns: 1fr; }
    .ritual-entry { grid-template-columns: 1fr; }
    .ritual-index { border-right: none; border-bottom: 1px dashed rgba(26,16,40,0.2); padding-bottom: 0.8rem; }
    .folio-nav { gap: 0.9rem; }
    .folio-link { font-size: 0.64rem; letter-spacing: 0.18em; }
    .folio-link::before { display: none; }
}

@media (max-width: 600px) {
    .manuscript-header { padding: 0.8rem 1rem; }
    .crest-text { display: none; }
    .threshold-footer { flex-direction: column; gap: 0.6rem; }
    .mountain-horizon { opacity: 0.1; }
}
