/* completengine.com - Scandinavian Editorial Design */
/* Palette: #FAF4EB (cream), #2C0E16 (dark), #3E0F18 (text), #6B1D2A (burgundy), #D4C5A9 (linen), #A3433B (terracotta), #8A7E6B (warm gray), #E8D5B7 (wheat) */
/* Fonts: Rokkitt 700 (display), Lato 300/400/700 (body/ui) */
/* Constraints: No shadows, no gradients, no uppercase, no ARIA/focus styles */

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: #FAF4EB;
    color: #3E0F18;
    font-family: 'Lato', sans-serif;
    font-weight: 400;
    font-size: 18px;
    line-height: 1.72;
    /* Linen paper grain texture - tiny tiling pattern at 3% opacity */
    background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAEklEQVQYV2M4c+bMfwYkwAAADsQH/YBnXkIAAAAASUVORK5CYII=");
    overflow-x: hidden;
}

/* ===== Opening Section ===== */
/* 100vh cream, title at ~45% vertical height */
.opening {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #FAF4EB;
    position: relative;
}

.opening-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 0;
    margin-top: -5vh;
}

.quill-svg {
    width: 80px;
    height: 100px;
    margin-bottom: 40px;
}

.quill-svg .draw-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.site-title {
    font-family: 'Rokkitt', serif;
    font-weight: 700;
    font-size: 56px;
    color: #3E0F18;
    letter-spacing: 0.01em;
    line-height: 1.15;
    text-transform: none;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.site-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.tagline {
    font-family: 'Lato', sans-serif;
    font-weight: 300;
    font-size: 16px;
    color: #8A7E6B;
    margin-top: 12px;
    text-transform: none;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.tagline.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Chapter Sections ===== */
/* 120px min vertical breathing space between sections */
.chapter {
    position: relative;
    padding: 120px 24px;
}

.chapter-light {
    background-color: #FAF4EB;
    color: #3E0F18;
}

/* Dark sections: hard cut transition, like turning to a dark endpaper */
.chapter-dark {
    background-color: #2C0E16;
    color: #FAF4EB;
}

.chapter-dark h2 {
    color: #D4C5A9;
}

/* Single-axis reading flow: centered column, max 680px */
.chapter-content {
    max-width: 680px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.chapter-content h2 {
    font-family: 'Rokkitt', serif;
    font-weight: 700;
    font-size: 36px;
    color: #3E0F18;
    letter-spacing: 0.01em;
    line-height: 1.15;
    text-transform: none;
    margin-bottom: 40px;
}

.chapter-dark .chapter-content h2 {
    color: #D4C5A9;
}

.chapter-content p {
    margin-bottom: 1.4em;
    font-size: 18px;
    line-height: 1.72;
}

.chapter-dark .chapter-content p {
    color: #FAF4EB;
}

/* Bold for inline emphasis instead of italic */
.chapter-content p strong {
    font-weight: 700;
}

/* ===== Chapter Dividers ===== */
/* Decorative SVG dividers with path-draw animation */
.chapter-divider {
    text-align: center;
    margin-bottom: 60px;
}

.divider-svg {
    width: 300px;
    max-width: 80%;
    height: auto;
}

.divider-svg .draw-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 0.05s linear;
}

/* ===== Pull Quotes ===== */
/* Large typographic pull-quotes floating in isolation */
/* Centered, Rokkitt 42px, #6B1D2A, thin 1px rule above/below in #D4C5A9 */
.pull-quote {
    text-align: center;
    padding: 40px 0;
    margin: 40px 0;
    position: relative;
}

.pull-quote::before,
.pull-quote::after {
    content: '';
    display: block;
    width: 80px;
    height: 1px;
    background-color: #D4C5A9;
    margin: 0 auto;
}

.pull-quote::before {
    margin-bottom: 30px;
}

.pull-quote::after {
    margin-top: 30px;
}

.pull-quote p {
    font-family: 'Rokkitt', serif;
    font-weight: 700;
    font-size: 28px;
    color: #6B1D2A;
    line-height: 1.3;
    text-transform: none;
    margin-bottom: 0;
}

/* Dark section pull quotes */
.pull-quote-dark p {
    color: #D4C5A9;
}

.pull-quote-dark::before,
.pull-quote-dark::after {
    background-color: #8A7E6B;
}

/* ===== Margin Annotations ===== */
/* Lato 13px, italic, #8A7E6B -- like marginalia in an old textbook */
.annotation {
    font-family: 'Lato', sans-serif;
    font-weight: 300;
    font-style: italic;
    font-size: 13px;
    color: #8A7E6B;
    line-height: 1.5;
    text-transform: none;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}

.annotation.visible {
    opacity: 1;
    transform: translateX(0);
}

.annotation-dark {
    color: #8A7E6B;
}

/* Desktop (>1200px): annotations in left margin gutter, 200px left of main column */
@media (min-width: 1201px) {
    .annotation {
        position: absolute;
        left: -220px;
        width: 180px;
        text-align: right;
    }

    .annotation[data-annotation="1"] { top: 0; }
    .annotation[data-annotation="2"] { top: 280px; }
    .annotation[data-annotation="3"] { top: 0; }
    .annotation[data-annotation="4"] { top: 260px; }
    .annotation[data-annotation="5"] { top: 0; }
    .annotation[data-annotation="6"] { top: 260px; }
    .annotation[data-annotation="7"] { top: 0; }
    .annotation[data-annotation="8"] { top: 0; }
}

/* Mobile (<1200px): annotations collapse into inline parenthetical notes */
@media (max-width: 1200px) {
    .annotation {
        display: block;
        font-style: italic;
        font-weight: 400;
        font-size: 16px;
        color: #8A7E6B;
        margin-bottom: 1.4em;
        padding-left: 16px;
        border-left: 2px solid #D4C5A9;
        transform: translateX(0);
    }

    .annotation.visible {
        transform: translateX(0);
    }
}

/* ===== Organic Blob Backgrounds ===== */
/* Soft organic blob shapes: SVG paths filled with #E8D5B7 at 40% opacity */
/* Large (60-80% viewport width), partially off-screen, static (no animation) */
.organic-blob {
    position: absolute;
    z-index: 0;
    pointer-events: none;
}

.blob-1 {
    width: 65vw;
    top: -50px;
    right: -15vw;
}

.blob-2 {
    width: 60vw;
    top: 100px;
    left: -20vw;
}

.blob-3 {
    width: 70vw;
    top: 60px;
    right: -10vw;
}

/* ===== Margin Vine ===== */
/* Botanical vine along left margin, draws as user scrolls */
.margin-vine {
    position: fixed;
    left: 20px;
    top: 0;
    width: 30px;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    display: none;
}

@media (min-width: 1201px) {
    .margin-vine {
        display: block;
    }
}

/* ===== Contents Pill Navigation ===== */
/* Small pill fixed to bottom-right corner */
.contents-pill {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #6B1D2A;
    color: #FAF4EB;
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    font-family: 'Lato', sans-serif;
    font-weight: 400;
    font-size: 14px;
    text-transform: none;
    cursor: pointer;
    z-index: 100;
    transition: background-color 0.2s ease;
}

.contents-pill:hover {
    background-color: #A3433B;
}

/* Chapter list overlay panel */
.contents-panel {
    position: fixed;
    right: 20px;
    bottom: 70px;
    width: 240px;
    background-color: #2C0E16;
    border-radius: 12px;
    padding: 24px;
    z-index: 99;
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.contents-panel.open {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.chapter-link {
    font-family: 'Lato', sans-serif;
    font-weight: 400;
    font-size: 15px;
    color: #D4C5A9;
    text-decoration: none;
    text-transform: none;
    transition: color 0.15s ease;
    display: block;
}

.chapter-link:hover {
    color: #FAF4EB;
}

/* Current chapter highlighted in terracotta */
.chapter-link.active {
    color: #A3433B;
}

/* ===== Footer Spines ===== */
/* Row of book spines as footer element */
.footer-spines {
    text-align: center;
    margin-top: 80px;
    padding-bottom: 40px;
}

.footer-svg {
    width: 400px;
    max-width: 90%;
    height: auto;
}

.footer-svg .draw-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 0.05s linear;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .site-title {
        font-size: 38px;
    }

    .chapter-content h2 {
        font-size: 28px;
    }

    .pull-quote p {
        font-size: 22px;
    }

    .chapter {
        padding: 80px 20px;
    }

    .divider-svg {
        width: 240px;
    }

    .quill-svg {
        width: 60px;
        height: 75px;
    }
}

@media (max-width: 480px) {
    .site-title {
        font-size: 30px;
    }

    .chapter-content h2 {
        font-size: 24px;
    }

    .pull-quote p {
        font-size: 20px;
    }

    .contents-panel {
        width: 200px;
        right: 12px;
        bottom: 60px;
    }
}

/* ===== Path draw animation keyframes for opening quill ===== */
@keyframes drawPath {
    to {
        stroke-dashoffset: 0;
    }
}

.quill-svg.animate .draw-path {
    animation: drawPath 2.2s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}