:root {
    /* Design font references retained without network fetching: Fraunces (Google Fonts), Libre Baskerville (Google Fonts), Space Grotesk" */
    --oxblood: #4a0e1b;
    --gold: #d4a24e;
    --parchment: #f5f0e6;
    --ink: #2c1810;
    --leather: #8b6f5c;
    --claret: #7b2d3e;
    --linen: #eee8d5;
    --candle: #f4e2c0;
    --cream: #f8f0dd;
    --rose: #f0e0e4;
    --display: Fraunces, Georgia, 'Times New Roman', serif;
    --body: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
    --label: 'Space Grotesk', Inter, Arial, sans-serif;
}

@property --heading-weight {
    syntax: '<number>';
    inherits: false;
    initial-value: 700;
}

@property --heading-opsz {
    syntax: '<number>';
    inherits: false;
    initial-value: 72;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--parchment);
    font-family: var(--body);
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 20;
    opacity: 0.18;
    background-image: radial-gradient(rgba(44, 24, 16, 0.18) 0.6px, transparent 0.8px), radial-gradient(rgba(212, 162, 78, 0.14) 0.5px, transparent 0.7px);
    background-size: 7px 7px, 11px 11px;
    mix-blend-mode: multiply;
}

.spine {
    position: fixed;
    left: 0;
    top: 0;
    width: 280px;
    height: 100vh;
    overflow-y: auto;
    z-index: 15;
    padding: 34px 0 44px;
    color: var(--parchment);
    background: linear-gradient(90deg, #2b0810 0%, var(--oxblood) 48%, #66182a 100%);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.3), inset 0 -1px 1px rgba(255,255,255,0.1), 16px 0 45px rgba(44, 24, 16, 0.22);
}

.spine::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.14;
    background: repeating-linear-gradient(125deg, transparent 0 7px, rgba(255,255,255,0.08) 8px, transparent 10px), radial-gradient(circle at 30% 20%, rgba(212,162,78,0.25), transparent 28%);
}

.bookmark {
    position: absolute;
    right: 22px;
    top: 0;
    width: 24px;
    height: 132px;
    background: var(--claret);
    clip-path: polygon(0 0, 100% 0, 100% 90%, 50% 100%, 0 90%);
    box-shadow: 0 8px 22px rgba(0,0,0,0.3);
    transform-origin: top center;
}

.wax-seal {
    position: relative;
    z-index: 1;
    width: 72px;
    height: 72px;
    margin: 6px auto 18px;
    display: grid;
    place-items: center;
    border-radius: 48% 52% 43% 57% / 56% 42% 58% 44%;
    background: radial-gradient(circle at 30% 25%, #944252, var(--claret) 62%, #521322);
    color: var(--gold);
    font-family: var(--display);
    font-weight: 700;
    box-shadow: inset 0 2px 6px rgba(255,255,255,0.18), inset 0 -6px 12px rgba(0,0,0,0.28), 0 10px 24px rgba(0,0,0,0.22);
}

.spine-kicker, .eyebrow, .volume-label {
    font-family: var(--label);
    text-transform: uppercase;
    letter-spacing: 0.24em;
    font-size: 0.72rem;
    font-weight: 600;
}

.spine-kicker { position: relative; z-index: 1; text-align: center; color: var(--candle); }

.spine-title {
    position: relative;
    z-index: 1;
    margin: 10px 26px 24px;
    font-family: var(--display);
    font-size: 2.2rem;
    line-height: 0.92;
    color: var(--parchment);
    text-shadow: 0 2px 0 rgba(0,0,0,0.22);
    font-variation-settings: 'WONK' 1, 'opsz' 72;
}

.spine-rule { position: relative; z-index: 1; height: 1px; margin: 0 24px 20px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }

.nav-link {
    position: relative;
    z-index: 1;
    display: block;
    padding: 12px 24px;
    border-bottom: 2px solid transparent;
    color: var(--parchment);
    font-family: var(--label);
    font-size: clamp(0.75rem, 0.9vw, 0.875rem);
    text-decoration: none;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-link span {
    display: inline-block;
    width: 42px;
    color: var(--gold);
    font-family: var(--display);
    font-size: 1.1em;
}

.nav-link:hover, .nav-link.active {
    color: var(--gold);
    border-bottom-color: var(--gold);
    background: rgba(212, 162, 78, 0.12);
    transform: translateX(8px);
}

.mobile-menu-toggle { display: none; }

.folio { margin-left: 280px; min-height: 100vh; background: var(--parchment); }

.frontispiece {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--oxblood);
}

.window-landscape {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(rgba(74,14,27,0.36), rgba(44,24,16,0.48)),
        radial-gradient(circle at 30% 28%, rgba(244,226,192,0.8) 0 8%, transparent 22%),
        linear-gradient(90deg, transparent 48%, rgba(44,24,16,0.6) 49% 51%, transparent 52%),
        linear-gradient(0deg, rgba(44,24,16,0.9) 0 15%, transparent 16%),
        repeating-linear-gradient(90deg, rgba(245,240,230,0.08) 0 2px, transparent 2px 120px),
        repeating-linear-gradient(0deg, rgba(245,240,230,0.07) 0 2px, transparent 2px 95px),
        radial-gradient(ellipse at 62% 70%, rgba(42,83,38,0.65), transparent 28%),
        radial-gradient(ellipse at 35% 76%, rgba(139,111,92,0.8), transparent 34%),
        linear-gradient(180deg, #d8ba87, #8b6f5c 55%, #4a0e1b);
    filter: sepia(20%) saturate(0.7);
    background-blend-mode: multiply, screen, normal, normal, normal, normal, multiply, multiply, normal;
    transform: scale(1.04);
}

.frontispiece-copy {
    position: relative;
    width: min(900px, 86%);
    padding: 52px;
    text-align: center;
    border: 1px solid rgba(212,162,78,0.56);
    background: rgba(74,14,27,0.34);
    box-shadow: 0 30px 90px rgba(0,0,0,0.28), inset 0 0 80px rgba(244,226,192,0.08);
    backdrop-filter: blur(2px);
}

.frontispiece h2 {
    margin: 0;
    font-family: var(--display);
    font-size: clamp(3rem, 6vw, 7rem);
    line-height: 0.9;
    color: var(--parchment);
    text-shadow: 0 2px 12px rgba(44,24,16,0.6);
    font-variation-settings: 'WONK' 1, 'opsz' 72;
}

.volume-label { color: var(--gold); margin: 0 0 18px; }

.subtitle {
    margin: 24px auto 0;
    max-width: 720px;
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: var(--candle);
}

.scroll-indicator { position: absolute; bottom: 28px; color: var(--gold); font-size: 3rem; animation: gentle-pulse 2s ease-in-out infinite; }

.chapter {
    position: relative;
    min-height: 100vh;
    padding: 88px 80px 72px;
    overflow: hidden;
}

.chapter.linen { background: var(--linen); }
.chapter.parchment { background: var(--parchment); }
.chapter.candle { background: var(--cream); }

.roman {
    position: absolute;
    right: 7vw;
    top: 32px;
    font-family: var(--display);
    font-size: clamp(6rem, 12vw, 12rem);
    line-height: 1;
    color: var(--rose);
    opacity: 0.82;
    pointer-events: none;
}

.chapter-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 860px) minmax(140px, 180px);
    gap: clamp(34px, 5vw, 84px);
    max-width: 1220px;
    margin: 0 auto;
}

.chapter-body { max-width: 860px; }

.eyebrow { margin: 0 0 10px; color: var(--leather); }

.chapter-title {
    margin: 0 0 30px;
    color: var(--oxblood);
    font-family: var(--display);
    font-size: clamp(2.7rem, 5.2vw, 5.8rem);
    line-height: 0.98;
    font-weight: 700;
    --heading-weight: 700;
    --heading-opsz: 72;
    font-variation-settings: 'wght' var(--heading-weight), 'opsz' var(--heading-opsz), 'WONK' 1;
}

.lead {
    font-size: clamp(1.22rem, 1.8vw, 1.7rem);
    line-height: 1.55;
    color: var(--claret);
}

p { margin: 0 0 1.35em; }
strong { color: var(--oxblood); }

.folio-list {
    margin: 38px 0;
    padding: 30px 34px;
    background: rgba(244, 226, 192, 0.48);
    border-left: 4px solid var(--gold);
    box-shadow: inset 0 0 0 1px rgba(212, 162, 78, 0.18);
}

.folio-list h3 {
    margin: 0 0 18px;
    font-family: var(--label);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.9rem;
    color: var(--oxblood);
}

.pull {
    margin: 42px 0;
    padding: 28px 34px;
    border-left: 5px solid var(--claret);
    color: var(--oxblood);
    background: rgba(240, 224, 228, 0.52);
    font-family: var(--display);
    font-size: clamp(1.35rem, 2vw, 2rem);
    line-height: 1.35;
}

.marginalia {
    align-self: start;
    position: sticky;
    top: 40px;
    margin-top: 146px;
    color: var(--leather);
    font-family: var(--label);
    font-size: 0.82rem;
    line-height: 1.55;
}

.marginalia span {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    margin-bottom: 12px;
    border-radius: 50%;
    color: var(--gold);
    border: 1px solid var(--gold);
    animation: marker-pulse 2.8s ease-in-out infinite;
}

.plate {
    position: relative;
    margin: 3rem 0;
    padding: 8px;
    overflow: hidden;
    border: 1px solid var(--gold);
    background: var(--parchment);
    box-shadow: 0 20px 50px rgba(44,24,16,0.12);
}

.plate::after {
    content: '';
    position: absolute;
    inset: 8px;
    background-image: radial-gradient(rgba(44,24,16,0.22) 0.5px, transparent 0.7px);
    background-size: 5px 5px;
    opacity: 0.08;
    pointer-events: none;
}

.plate-art {
    height: clamp(260px, 36vw, 460px);
    filter: sepia(20%) saturate(0.7);
    background-blend-mode: multiply;
}

.controller-art {
    background:
        radial-gradient(ellipse at 48% 57%, rgba(44,24,16,0.88) 0 11%, transparent 12%),
        radial-gradient(ellipse at 35% 56%, rgba(44,24,16,0.8) 0 13%, transparent 14%),
        radial-gradient(ellipse at 64% 56%, rgba(44,24,16,0.8) 0 13%, transparent 14%),
        radial-gradient(circle at 65% 50%, var(--gold) 0 2%, transparent 2.3%),
        radial-gradient(circle at 71% 56%, var(--claret) 0 2%, transparent 2.3%),
        linear-gradient(105deg, rgba(245,240,230,0.2) 0 36%, rgba(74,14,27,0.2) 37% 39%, transparent 40%),
        repeating-linear-gradient(0deg, rgba(44,24,16,0.1) 0 1px, transparent 1px 28px),
        linear-gradient(135deg, #b69569, #f4e2c0 42%, #8b6f5c);
}

.window-art {
    background:
        repeating-linear-gradient(90deg, rgba(44,24,16,0.52) 0 5px, transparent 5px 130px),
        repeating-linear-gradient(0deg, rgba(44,24,16,0.42) 0 5px, transparent 5px 92px),
        radial-gradient(circle at 28% 24%, #f8f0dd 0 10%, transparent 25%),
        radial-gradient(ellipse at 62% 76%, #536b36 0 22%, transparent 38%),
        linear-gradient(180deg, #d7b071, #eee8d5 52%, #7b2d3e);
}

.book-art {
    background:
        linear-gradient(90deg, transparent 0 9%, rgba(212,162,78,0.75) 9% 10%, transparent 10% 21%, rgba(212,162,78,0.58) 21% 22%, transparent 22% 36%, rgba(212,162,78,0.78) 36% 37%, transparent 37%),
        repeating-linear-gradient(90deg, #4a0e1b 0 78px, #7b2d3e 78px 146px, #8b6f5c 146px 214px),
        linear-gradient(180deg, #2c1810, #f4e2c0);
}

figcaption {
    position: relative;
    z-index: 1;
    margin: 10px 4px 2px;
    color: var(--leather);
    font-family: var(--label);
    font-size: 0.78rem;
}

.ornament {
    display: block;
    width: min(600px, 72%);
    height: 22px;
    margin: 76px auto 0;
    stroke: var(--gold);
    stroke-width: 1;
    fill: var(--gold);
}

.ornament line { stroke-dasharray: 260; stroke-dashoffset: 260; }

.morph { animation: morph-in 0.8s cubic-bezier(0.22, 1, 0.36, 1) both; animation-delay: calc(var(--i, 1) * 80ms); }

@supports (animation-timeline: view()) {
    .morph { animation: morph-in linear both; animation-timeline: view(); animation-range: entry 0% cover 32%; animation-delay: 0s; }
    .chapter-title { animation: heading-morph linear both; animation-timeline: view(); animation-range: entry 0% cover 50%; }
    .ornament line { animation: draw-line 1.2s ease-out forwards; animation-timeline: view(); animation-range: entry 20% entry 80%; }
}

@keyframes morph-in {
    from { opacity: 0; transform: scale(0.92) translateY(20px); filter: blur(4px); }
    to { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}

@keyframes heading-morph {
    from { --heading-weight: 300; --heading-opsz: 72; }
    to { --heading-weight: 800; --heading-opsz: 16; }
}

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

@keyframes gentle-pulse {
    0%, 100% { transform: translateY(0); opacity: 0.55; }
    50% { transform: translateY(8px); opacity: 1; }
}

@keyframes marker-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 rgba(212,162,78,0); }
    50% { transform: scale(1.08); box-shadow: 0 0 22px rgba(212,162,78,0.34); }
}

@media (max-width: 1400px) {
    .chapter-grid { grid-template-columns: minmax(0, 880px); }
    .marginalia { position: relative; top: auto; margin-top: 0; padding-left: 22px; border-left: 1px solid var(--gold); max-width: 540px; }
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: grid;
        place-items: center;
        position: fixed;
        left: 16px;
        top: 16px;
        z-index: 30;
        width: 48px;
        height: 48px;
        border: 1px solid var(--gold);
        background: var(--oxblood);
        color: var(--gold);
        font-size: 1.4rem;
    }

    .spine { transform: translateX(-100%); transition: transform 0.35s ease; }
    .spine.open { transform: translateX(0); }
    .folio { margin-left: 0; }
    .chapter { padding: 76px 26px 56px; }
    .frontispiece-copy { padding: 36px 24px; }
    .roman { right: 22px; top: 60px; opacity: 0.52; }
    .ornament { width: 92%; }
}
