:root {
    /* DESIGN parser tokens: IntersectionObserver` threshold. */
    --parchment: #f7f1e8;
    --aubergine: #2d2235;
    --ink: #3a2f42;
    --cream: #f2e6d9;
    --lavender: #c4a8d4;
    --sage: #a8c4b8;
    --rose: #d4a8a8;
    --blue: #b8c4d4;
    --gold: #d4c4a8;
    --ghost: rgba(182, 156, 200, 0.4);
}

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

html { scroll-behavior: smooth; }

body {
    background: var(--parchment);
    color: var(--ink);
    font-family: "Libre Baskerville", Georgia, serif;
    font-size: 17px;
    line-height: 28px;
    overflow-x: hidden;
    font-feature-settings: "liga" 1, "onum" 1;
}

.manuscript { position: relative; }

.chapter {
    min-height: 100vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    isolation: isolate;
}

.chapter-perspective {
    position: absolute;
    inset: 0;
    perspective: 1200px;
    transform-style: preserve-3d;
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    align-items: center;
    transition: transform 120ms linear;
}

.chapter-bg {
    position: absolute;
    inset: 0;
    z-index: -2;
    opacity: 0.35;
    transform: translateZ(0);
    transition: opacity 400ms ease;
}

.in-view .chapter-bg { opacity: 1; }

.dark-chapter .chapter-bg {
    background-color: var(--aubergine);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M0 0L12 12M12 0L0 12' stroke='%23d4c4a8' stroke-width='.55' opacity='.08'/%3E%3C/svg%3E");
}

.light-chapter .chapter-bg {
    background-color: var(--parchment);
    background-image: radial-gradient(circle at 8px 8px, rgba(196, 168, 212, 0.2) 1px, transparent 1.6px);
    background-size: 16px 16px;
}

.colophon-chapter .chapter-bg {
    background-color: var(--aubergine);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='12' viewBox='0 0 24 12'%3E%3Cpath d='M0 6L12 0L24 6M0 6L12 12L24 6' fill='none' stroke='%23a8c4b8' stroke-width='.8' opacity='.1'/%3E%3C/svg%3E");
}

.page-plane {
    grid-column: 5 / span 8;
    position: relative;
    z-index: 5;
    transform: translateZ(40px) translateY(30px);
    opacity: 0;
    text-align: center;
    transition: opacity 600ms ease 820ms, transform 600ms ease 820ms;
}

.in-view .page-plane { opacity: 1; transform: translateZ(40px) translateY(0); }

.cover-plane { opacity: 1; transform: translateZ(48px); }

.cover-plane::before,
.prose-plane::before,
.colophon-plane::before {
    content: "";
    position: absolute;
    inset: -34px -46px;
    z-index: -1;
    background: rgba(247, 241, 232, 0.78);
    border: 1px solid rgba(212, 196, 168, 0.72);
    box-shadow: 0 28px 70px rgba(45, 34, 53, 0.28), 12px 12px 0 rgba(196, 168, 212, 0.12), -12px -10px 0 rgba(168, 196, 184, 0.08);
    transform: rotate(-1.2deg);
}

.cover-plane::before { background: rgba(45, 34, 53, 0.2); border-color: rgba(212, 196, 168, 0.3); }

.inverse-plane::before,
.colophon-plane::before { background: rgba(45, 34, 53, 0.62); border-color: rgba(212, 196, 168, 0.35); }

.site-title,
h2 {
    font-family: "Bebas Neue", Impact, sans-serif;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-shadow: 2px 2px 0 var(--ghost);
}

.site-title {
    display: inline-block;
    color: var(--cream);
    font-size: clamp(5rem, 12vw, 11rem);
    line-height: 0.9;
    padding: 0.04em 0.1em 0;
    animation: pulse-title 3s ease-in-out infinite;
}

.site-tagline {
    color: var(--lavender);
    font-family: "Caveat", "Comic Sans MS", cursive;
    font-size: 24px;
    margin-top: 18px;
}

h2 {
    color: var(--aubergine);
    font-size: clamp(4rem, 10vw, 9rem);
    line-height: 0.9;
    margin-bottom: 28px;
}

.inverse-plane h2 { color: var(--cream); }

.prose-plane p {
    color: var(--ink);
    max-width: 680px;
    margin: 0 auto;
}

.inverse-plane p { color: var(--cream); }

.specimen-rail,
.marginalia,
.constellation {
    position: absolute;
    z-index: 3;
    transform: translateZ(20px);
    opacity: 0;
    transition: opacity 800ms ease 420ms, transform 800ms ease 420ms;
}

.in-view .specimen-rail,
.in-view .marginalia,
.in-view .constellation { opacity: 1; }

.left-rail { left: clamp(18px, 7vw, 110px); top: 50%; transform: translateY(-50%) translateZ(20px) rotate(-5deg); }
.right-rail { right: clamp(18px, 7vw, 110px); top: 50%; transform: translateY(-50%) translateZ(20px) rotate(4deg); }
.cover-fern { top: 36%; }
.cover-moth { top: 68%; }

.specimen { width: clamp(108px, 13vw, 190px); overflow: visible; }
.specimen path,
.specimen circle,
.constellation line,
.constellation circle {
    fill: none;
    stroke: var(--lavender);
    stroke-width: 1.5px;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.pod path { stroke: var(--rose); }
.flower path { stroke: var(--blue); }
.quills path { stroke: var(--sage); }
.wax-seal path:first-child { fill: var(--rose); stroke: none; }
.wax-seal circle { fill: none; stroke: var(--lavender); stroke-width: 2; opacity: 0.48; }
.wax-seal path:not(:first-child) { fill: none; stroke: var(--cream); stroke-width: 1.5; opacity: 0.72; }

.specimen-label {
    color: var(--lavender);
    font-family: "Caveat", "Comic Sans MS", cursive;
    font-size: 20px;
    margin-top: 8px;
    text-align: center;
    transform: rotate(-2deg);
}
.rose-label { color: var(--rose); }
.blue-label { color: var(--blue); }

.marginalia {
    width: min(220px, 18vw);
    color: var(--lavender);
    font-family: "Caveat", "Comic Sans MS", cursive;
    font-size: clamp(20px, 2vw, 24px);
    line-height: 1.05;
    background-image: radial-gradient(circle at 8px 8px, rgba(196, 168, 212, 0.22) 1px, transparent 1.5px);
    background-size: 16px 16px;
    padding: 18px;
}

.left-note { left: clamp(20px, 6vw, 96px); top: 24%; transform: translateZ(20px) rotate(-4deg); }
.right-note { right: clamp(20px, 6vw, 96px); top: 22%; transform: translateZ(20px) rotate(3deg); color: var(--sage); }
.stacked-notes p + p { color: var(--rose); margin-top: 18px; transform: rotate(4deg); }

.constellation-one { left: 68%; top: 18%; width: 180px; }
.constellation svg { width: 100%; }
.constellation line,
.constellation circle { stroke: var(--gold); opacity: 0.7; }
.constellation circle { fill: var(--gold); }

.index-tab {
    position: fixed;
    right: -214px;
    top: 50%;
    z-index: 50;
    width: 260px;
    min-height: 246px;
    transform: translateY(-50%);
    background-color: var(--parchment);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='12' viewBox='0 0 24 12'%3E%3Cpath d='M0 6L12 0L24 6M0 6L12 12L24 6' fill='none' stroke='%23a8c4b8' stroke-width='.8' opacity='.16'/%3E%3C/svg%3E");
    border: 1px solid var(--gold);
    box-shadow: -10px 12px 30px rgba(45, 34, 53, 0.2);
    transition: right 360ms ease, box-shadow 360ms ease;
}

.index-tab:hover,
.index-tab.open { right: 0; box-shadow: -16px 18px 44px rgba(45, 34, 53, 0.26); }

.index-fold {
    position: absolute;
    left: 0;
    top: 0;
    border-style: solid;
    border-width: 0 0 30px 30px;
    border-color: transparent transparent rgba(212, 196, 168, 0.72) transparent;
}

.index-handle {
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%) rotate(-90deg);
    transform-origin: center;
    color: var(--aubergine);
    font-family: "Bebas Neue", Impact, sans-serif;
    font-size: 22px;
    letter-spacing: 0.12em;
}

.index-list { list-style: none; padding: 28px 22px 22px 58px; }
.index-list li { margin-bottom: 16px; }
.index-list a {
    display: flex;
    gap: 10px;
    color: var(--ink);
    text-decoration: none;
    font-family: "Caveat", "Comic Sans MS", cursive;
    font-size: 21px;
    transition: color 220ms ease, transform 220ms ease;
}
.index-list a:hover { color: var(--lavender); transform: translateX(-3px); }
.index-list span { flex: 1; border-bottom: 1px dotted var(--gold); }
.index-list b { color: var(--lavender); font-weight: 700; }

.wax-seal {
    width: 128px;
    height: 128px;
    margin: 0 auto 32px;
    filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.22));
}
.in-view .wax-seal { animation: seal-pulse 2s ease-in-out 1 both; }

.colophon-copy {
    color: var(--cream);
    font-family: "Caveat", "Comic Sans MS", cursive;
    font-size: 22px;
    line-height: 1.45;
}
.colophon-copy p { margin-bottom: 12px; }
.copyright { color: var(--gold); font-size: 18px; }

@keyframes pulse-title {
    0%, 100% { box-shadow: 0 0 0 0 rgba(196, 168, 212, 0.3); transform: scale(1); }
    50% { box-shadow: 0 0 40px 16px rgba(196, 168, 212, 0); transform: scale(1.02); }
}

@keyframes pulse-attention {
    0%, 100% { box-shadow: 0 0 0 0 rgba(196, 168, 212, 0.3); transform: scale(1); }
    50% { box-shadow: 0 0 20px 10px rgba(196, 168, 212, 0); transform: scale(1.02); }
}

@keyframes seal-pulse {
    0% { opacity: 0.8; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 0.8; transform: scale(1); }
}

.draw path,
.draw circle,
.draw line { animation: draw-line 1.6s ease forwards; }

@keyframes draw-line { to { stroke-dashoffset: 0; } }

@media (max-width: 900px) {
    .chapter-perspective { grid-template-columns: 24px repeat(8, 1fr) 24px; }
    .page-plane { grid-column: 2 / span 8; padding: 0 22px; }
    .specimen-rail, .marginalia, .constellation { opacity: 0.38; transform: translateZ(10px) scale(0.82); }
    .left-rail, .left-note { left: -34px; }
    .right-rail, .right-note { right: -34px; }
    h2 { font-size: clamp(3.3rem, 14vw, 6rem); }
}

@media (max-width: 580px) {
    body { font-size: 16px; line-height: 26px; }
    .site-title { font-size: clamp(4.1rem, 22vw, 6.2rem); }
    .site-tagline { font-size: 21px; }
    .page-plane::before { inset: -24px -18px; }
    .specimen-rail, .marginalia, .constellation { display: none; }
    .index-tab { right: -224px; transform: translateY(-50%) scale(0.9); transform-origin: right center; }
}
