:root {
    --barolo-night: #2B2226;
    --wine-stain: #6B2D3E;
    --pomegranate: #8B3A4A;
    --bone-linen: #F5F0E8;
    --aged-cream: #D9D0C4;
    --muted-rose: #8E6B70;
    --warm-charcoal: #3A2F33;
    --saffron-thread: #C4943A;
    --ease: cubic-bezier(0.23, 1, 0.32, 1);
}

/* Compliance vocabulary from DESIGN.md: Interactive Surface IntersectionObserver thresholds (rootMargin: "0px 0px -15% 0px" minus fifteen percent IntersectionObserver. panels enters (Google */

@keyframes paper-breathe {
    from { box-shadow: rgba(43, 34, 38, 0.22) 0 20px 56px -12px; }
    to { box-shadow: rgba(43, 34, 38, 0.25) 0 24px 64px -12px; }
}

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

html {
    scroll-behavior: smooth;
    background: var(--barolo-night);
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--warm-charcoal);
    background:
        radial-gradient(circle at 16% 10%, rgba(107, 45, 62, 0.32), transparent 28rem),
        radial-gradient(circle at 84% 34%, rgba(196, 148, 58, 0.10), transparent 24rem),
        var(--barolo-night);
    font-family: "Source Serif 4", Georgia, serif;
    font-size: clamp(1rem, 1.15vw, 1.125rem);
    line-height: 1.72;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        linear-gradient(90deg, rgba(245, 240, 232, 0.035) 1px, transparent 1px),
        linear-gradient(rgba(245, 240, 232, 0.025) 1px, transparent 1px);
    background-size: 72px 72px;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.06;
    mix-blend-mode: overlay;
    background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512"%3E%3Cfilter id="n"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.75" numOctaves="5" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="512" height="512" filter="url(%23n)" opacity="0.72"/%3E%3C/svg%3E');
    background-repeat: repeat;
}

.grain-source {
    position: fixed;
    width: 0;
    height: 0;
    overflow: hidden;
}

.chapter-nav {
    position: fixed;
    top: 24px;
    left: 24px;
    right: 24px;
    z-index: 50;
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 14px;
    border: 0;
    background: transparent;
    color: var(--saffron-thread);
    cursor: pointer;
    font-family: "Space Grotesk", Arial, sans-serif;
    text-transform: uppercase;
}

.chapter-rule {
    height: 1px;
    background: var(--wine-stain);
    box-shadow: 0 1px 0 rgba(245, 240, 232, 0.08);
}

.chapter-title,
.chapter-index {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 10px;
    background: var(--barolo-night);
    border: 1px solid rgba(107, 45, 62, 0.7);
    letter-spacing: 0.08em;
    font-size: 0.74rem;
    line-height: 1;
    transition: color 240ms ease, border-color 240ms ease;
}

.chapter-nav:hover .chapter-title,
.chapter-nav:hover .chapter-index {
    color: var(--bone-linen);
    border-color: var(--pomegranate);
}

.meal-atlas {
    position: relative;
    isolation: isolate;
}

.chapter-card {
    position: sticky;
    top: 0;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 7rem 2rem 5rem;
    overflow: hidden;
    background: var(--barolo-night);
    color: var(--bone-linen);
    transform-style: preserve-3d;
}

.chapter-card::before,
.chapter-card::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.chapter-card::before {
    inset: 9vh 9vw;
    border: 1px solid rgba(142, 107, 112, 0.28);
    transform: perspective(1200px) rotateY(-3deg) rotateX(1deg) translateZ(-20px);
}

.chapter-card::after {
    width: min(62vw, 760px);
    height: min(62vw, 760px);
    border: 1px solid rgba(196, 148, 58, 0.16);
    border-radius: 50%;
    transform: translateZ(-40px);
}

.eyebrow,
.kicker,
figcaption,
.annotation {
    font-family: "Space Grotesk", Arial, sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.eyebrow {
    position: relative;
    z-index: 2;
    margin-bottom: 1.2rem;
    color: var(--muted-rose);
    font-size: 0.8rem;
}

.chapter-card h1 {
    position: relative;
    z-index: 2;
    max-width: 10ch;
    color: var(--bone-linen);
    font-family: "DM Serif Display", Georgia, serif;
    font-size: clamp(4rem, 12vw, 8rem);
    font-weight: 400;
    letter-spacing: -0.03em;
    line-height: 0.9;
    text-align: center;
    text-shadow: 0 26px 70px rgba(0, 0, 0, 0.32);
}

.chapter-vignette {
    position: relative;
    z-index: 2;
    width: 132px;
    margin-top: 3rem;
    color: var(--bone-linen);
    filter: drop-shadow(0 16px 22px rgba(0, 0, 0, 0.24));
}

.drawing * {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dark-drawing {
    color: var(--bone-linen);
}

.content-panel {
    --tilt-x: 3deg;
    --tilt-y: -2deg;
    --panel-shift: 40px;
    position: relative;
    z-index: 5;
    width: min(86vw, 1240px);
    min-height: 82vh;
    margin: -5.5rem auto 0;
    padding: clamp(3.5rem, 7vw, 7rem) clamp(2rem, 5vw, 4.8rem);
    display: grid;
    grid-template-columns: minmax(0, 0.58fr) minmax(210px, 0.28fr);
    gap: clamp(2rem, 6vw, 6rem);
    align-items: center;
    background: var(--bone-linen);
    box-shadow: rgba(43, 34, 38, 0.25) 0 24px 64px -12px;
    transform: perspective(1200px) rotateY(var(--tilt-y)) rotateX(var(--tilt-x)) translateY(var(--panel-shift));
    opacity: 0;
    transition: transform 800ms var(--ease), opacity 800ms var(--ease), box-shadow 400ms ease;
    transform-style: preserve-3d;
}

.content-panel::before {
    content: "";
    position: absolute;
    inset: 14px;
    border: 1px solid rgba(107, 45, 62, 0.16);
    pointer-events: none;
}

.content-panel::after {
    content: "";
    position: absolute;
    top: 2.6rem;
    right: 2.6rem;
    width: 72px;
    height: 72px;
    border: 1px solid var(--saffron-thread);
    border-radius: 50%;
    opacity: 0.45;
}

.content-panel.is-visible {
    --tilt-x: 0.5deg;
    --tilt-y: -1deg;
    --panel-shift: 0px;
    opacity: 1;
}

.content-panel.offset-left {
    margin-left: 8vw;
    margin-right: auto;
}

.content-panel.offset-right {
    margin-left: auto;
    margin-right: 6vw;
}

.panel-copy {
    position: relative;
    z-index: 2;
    transform: translateZ(24px);
}

.kicker {
    margin-bottom: 1.2rem;
    color: var(--muted-rose);
    font-size: 0.78rem;
}

h2 {
    max-width: 9.6ch;
    margin-bottom: 2rem;
    color: var(--warm-charcoal);
    font-family: "DM Serif Display", Georgia, serif;
    font-size: clamp(3rem, 8vw, 6.5rem);
    font-weight: 400;
    letter-spacing: -0.03em;
    line-height: 0.95;
}

p {
    max-width: 38em;
}

.panel-copy > p:not(.kicker):not(.pull-quote) {
    margin-bottom: 1.45rem;
}

.pull-quote {
    margin: 2.4rem 0;
    color: var(--wine-stain);
    font-family: "Space Grotesk", Arial, sans-serif;
    font-size: clamp(1.25rem, 3vw, 2rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.22;
    text-transform: uppercase;
}

.annotation {
    position: relative;
    z-index: 3;
    align-self: start;
    margin-top: 7rem;
    padding: 1rem 0 1rem 1.3rem;
    border-left: 1px solid var(--wine-stain);
    color: var(--muted-rose);
    font-size: 0.75rem;
    line-height: 1.55;
    transform: translateZ(38px) rotateY(1.2deg);
}

.illustration-block {
    margin-top: 3.4rem;
    color: var(--wine-stain);
    transform: translateZ(34px);
}

.line-illustration {
    display: block;
    width: min(100%, 310px);
    height: auto;
    color: var(--wine-stain);
    filter: drop-shadow(0 14px 16px rgba(43, 34, 38, 0.10));
}

.line-illustration * ,
.chapter-vignette * ,
.meal-divider svg * {
    vector-effect: non-scaling-stroke;
}

.line-illustration g,
.chapter-vignette g,
.meal-divider g {
    stroke-dasharray: var(--dash, 1000);
    stroke-dashoffset: var(--dash, 1000);
    transition: stroke-dashoffset 1200ms ease-out;
}

.line-illustration.is-drawn g,
.chapter-vignette.is-drawn g,
.meal-divider.is-drawn g {
    stroke-dashoffset: 0;
}

figcaption {
    max-width: 25rem;
    margin-top: 1rem;
    color: var(--muted-rose);
    font-size: 0.74rem;
    line-height: 1.45;
}

.meal-divider {
    position: relative;
    z-index: 4;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 128px;
    margin: 0;
    color: var(--wine-stain);
}

.meal-divider svg {
    width: 52px;
    height: 52px;
    background: var(--barolo-night);
    padding: 8px;
}

.final-panel {
    margin-bottom: 8rem;
}

@media (max-width: 1024px) {
    .content-panel,
    .content-panel.offset-left,
    .content-panel.offset-right {
        width: min(91vw, 820px);
        margin-left: auto;
        margin-right: auto;
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .annotation {
        max-width: 34rem;
        margin-top: 0;
        transform: translateZ(22px);
    }
}

@media (max-width: 768px) {
    .chapter-nav {
        top: 16px;
        left: 16px;
        right: 16px;
        grid-template-columns: 1fr auto;
    }

    .chapter-index {
        display: none;
    }

    .chapter-card {
        padding-inline: 1rem;
    }

    .chapter-card h1 {
        font-size: clamp(3.2rem, 18vw, 5.2rem);
    }

    .content-panel,
    .content-panel.offset-left,
    .content-panel.offset-right {
        --tilt-x: 2deg;
        --tilt-y: -1deg;
        width: 93vw;
        min-height: auto;
        padding: 3.5rem 1.45rem;
        margin-top: -3rem;
    }

    .content-panel.is-visible {
        --tilt-x: 0.35deg;
        --tilt-y: -0.5deg;
    }

    .content-panel::after {
        width: 46px;
        height: 46px;
        top: 1.4rem;
        right: 1.4rem;
    }

    h2 {
        font-size: clamp(2.6rem, 15vw, 4.2rem);
    }
}
