:root {
    --vellum: #f2e8d0;
    --ink-black: #1e1a14;
    --gold-leaf: #c8a84a;
    --rubric-red: #8a2a1e;
    --verdigris: #3a6a5a;
    --lamp-black: #2a2018;
    --faded-blue: #4a6a8a;
    --rule-line: #d4c8b0;
    --code-color: #6a5a4a;
}

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

body {
    background-color: var(--vellum);
    color: var(--ink-black);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.3vw, 1.15rem);
    line-height: 1.85;
    overflow-x: hidden;
}

/* Manuscript grid */
.manuscript-grid {
    display: grid;
    grid-template-columns: 12% 50% 22%;
    gap: 0 8%;
    max-width: 1200px;
    margin: 0 auto;
}

.manuscript-grid-narrow {
    grid-template-columns: 12% 40% 30%;
    gap: 0 9%;
}

.manuscript-grid-verse {
    grid-template-columns: 12% 35% 30%;
    gap: 0 11%;
}

/* Sections */
.codex-section {
    padding: clamp(40px, 8vh, 80px) clamp(20px, 5vw, 40px);
    position: relative;
}

/* Ruled lines behind text */
.text-body {
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent calc(1.85em - 1px),
        rgba(212, 200, 176, 0.1) calc(1.85em - 1px),
        rgba(212, 200, 176, 0.1) 1.85em
    );
}

/* Inner margin */
.inner-margin {
    position: relative;
}

/* Section marks */
.section-mark {
    font-family: 'Cormorant Garamond', serif;
    font-size: 2rem;
    color: var(--rubric-red);
    display: block;
    text-align: center;
    margin-top: 20px;
}

/* Chapter headings */
.chapter-heading {
    font-family: 'UnifrakturMaguntia', cursive;
    font-weight: 400;
    font-size: clamp(2.5rem, 5vw, 4rem);
    letter-spacing: 0.04em;
    color: var(--ink-black);
    margin-bottom: 8px;
}

.chapter-heading-centered {
    text-align: center;
    margin-bottom: 40px;
}

.chapter-subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.2rem, 1.8vw, 1.5rem);
    color: var(--rubric-red);
    margin-bottom: 32px;
    letter-spacing: 0.02em;
}

/* Body text */
.body-text {
    margin-bottom: 24px;
}

.body-strong {
    font-weight: 600;
}

/* Quest prompt */
.quest-prompt {
    font-family: 'Fira Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.75rem, 0.85vw, 0.9rem);
    color: var(--code-color);
    margin-top: 32px;
}

/* Marginalia */
.outer-margin {
    padding-top: 20px;
}

.marginalia {
    font-family: 'IM Fell English', Georgia, serif;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(0.8rem, 0.95vw, 0.95rem);
    color: var(--ink-black);
    opacity: 0.7;
    line-height: 1.6;
    margin-bottom: 20px;
}

/* Historiated initial */
.historiated-initial {
    float: left;
    width: 120px;
    height: 140px;
    margin-right: 16px;
    margin-bottom: 8px;
}

.initial-svg {
    width: 100%;
    height: 100%;
}

.draw-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 2.5s ease-in-out;
}

.draw-path.drawn {
    stroke-dashoffset: 0;
}

/* Propositions */
.proposition {
    margin-bottom: 40px;
    min-height: 30vh;
}

.prop-numeral {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 2rem;
    color: var(--gold-leaf);
    display: block;
    margin-bottom: 12px;
}

/* Llull wheel */
.llull-wheel {
    margin: 20px 0;
}

.wheel-svg {
    width: 200px;
    height: 200px;
}

.wheel-ring-outer {
    transform-origin: center;
}

.wheel-ring-inner {
    transform-origin: center;
}

/* Trial section */
.section-trial {
    background-color: var(--lamp-black);
    padding: 80px 40px;
}

.section-trial .chapter-heading {
    color: var(--gold-leaf);
}

.decision-tree {
    max-width: 800px;
    margin: 0 auto;
}

.tree-svg {
    width: 100%;
    height: auto;
}

/* Verse */
.inner-margin-staff {
    position: relative;
}

.staff-svg {
    width: 20px;
    height: 100%;
    position: absolute;
    top: 0;
    right: 0;
}

.note-head {
    transform: scale(0);
    transition: transform 0.5s ease;
}

.note-head.visible {
    transform: scale(1);
}

.verse-lines {
    margin-top: 20px;
}

.verse-line {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-size: clamp(1.05rem, 1.4vw, 1.2rem);
    line-height: 2.2;
    color: var(--ink-black);
    margin-bottom: 8px;
}

/* Explicit */
.section-explicit {
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.explicit-mark {
    margin-bottom: 40px;
}

.pilcrow {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(4rem, 8vw, 6rem);
    color: var(--rubric-red);
    line-height: 1;
}

.colophon-text {
    font-family: 'IM Fell English', Georgia, serif;
    font-style: italic;
    font-size: 0.9rem;
    color: var(--ink-black);
    opacity: 0.6;
    text-align: center;
    line-height: 1.8;
}

/* Mobile */
@media (max-width: 768px) {
    .manuscript-grid,
    .manuscript-grid-narrow,
    .manuscript-grid-verse {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .inner-margin {
        display: none;
    }

    .outer-margin,
    .outer-margin-wide {
        border-top: 1px dashed var(--gold-leaf);
        padding-top: 16px;
    }

    .historiated-initial {
        float: none;
        margin: 0 auto 16px;
    }

    .proposition {
        min-height: auto;
    }

    .staff-svg {
        display: none;
    }
}
