/* =====================================================================
   cafe-sweets.net — A Treatise on Sweets
   Dopamine Library at Midnight
   Palette: #0E1A3A #1B2B5C #2D3F7A #FF5BA8 #FFD23F #7AE8B8 #F2E8D0
   Fonts: Fredoka (display, year, footnote markers),
          Lora (body, italic Lora for footnote citations and pull-quotes.)
   ===================================================================== */

:root {
    --midnight-cobalt: #0E1A3A;
    --indigo-velvet: #1B2B5C;
    --twilight-lapis: #2D3F7A;
    --dopamine-pink: #FF5BA8;
    --dopamine-yellow: #FFD23F;
    --sugar-mint: #7AE8B8;
    --aged-vellum: #F2E8D0;

    --font-display: "Fredoka", "Comic Neue", system-ui, sans-serif;
    --font-body: "Lora", "Georgia", serif;

    --page-side-padding: clamp(20px, 5vw, 80px);
    --max-page-width: 1280px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--midnight-cobalt);
    color: var(--aged-vellum);
    font-family: var(--font-body);
    font-size: clamp(16px, 1.15vw, 19px);
    line-height: 1.78;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Subtle leather grain over the entire page ground */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    opacity: 0.06;
    background-image:
        radial-gradient(circle at 23% 17%, rgba(242, 232, 208, 0.5) 0%, transparent 1.5%),
        radial-gradient(circle at 71% 43%, rgba(242, 232, 208, 0.4) 0%, transparent 1.5%),
        radial-gradient(circle at 18% 81%, rgba(242, 232, 208, 0.45) 0%, transparent 1.5%),
        radial-gradient(circle at 87% 78%, rgba(242, 232, 208, 0.35) 0%, transparent 1.5%),
        radial-gradient(circle at 42% 62%, rgba(242, 232, 208, 0.4) 0%, transparent 1.5%),
        radial-gradient(circle at 56% 11%, rgba(242, 232, 208, 0.4) 0%, transparent 1.5%),
        repeating-linear-gradient(37deg, transparent 0 3px, rgba(242, 232, 208, 0.02) 3px 4px),
        repeating-linear-gradient(127deg, transparent 0 5px, rgba(14, 26, 58, 0.4) 5px 6px);
}

/* ----------------------------- DRIFTING SUGAR CRYSTALS (margins) ----------------------------- */
.crystal-field {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
}

.crystal-drift {
    position: absolute;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: var(--aged-vellum);
    stroke-width: 1;
    opacity: 0.12;
    animation: crystalDrift 22s linear infinite;
}

.crystal-drift.c1 { top: 8%;  left: 4%;  animation-duration: 28s; animation-delay: 0s; }
.crystal-drift.c2 { top: 22%; left: 96%; animation-duration: 32s; animation-delay: -8s; width: 14px; height: 14px; }
.crystal-drift.c3 { top: 41%; left: 3%;  animation-duration: 26s; animation-delay: -14s; width: 22px; height: 22px; }
.crystal-drift.c4 { top: 58%; left: 94%; animation-duration: 30s; animation-delay: -4s; }
.crystal-drift.c5 { top: 74%; left: 5%;  animation-duration: 34s; animation-delay: -18s; width: 12px; height: 12px; }
.crystal-drift.c6 { top: 86%; left: 92%; animation-duration: 24s; animation-delay: -10s; }
.crystal-drift.c7 { top: 12%; left: 88%; animation-duration: 36s; animation-delay: -22s; width: 20px; height: 20px; }

@keyframes crystalDrift {
    0%   { transform: translateY(0) rotate(0deg); opacity: 0.08; }
    50%  { transform: translateY(-30px) rotate(180deg); opacity: 0.18; }
    100% { transform: translateY(0) rotate(360deg); opacity: 0.08; }
}

/* ----------------------------- SECTION FRAME ----------------------------- */
.section {
    position: relative;
    padding: clamp(80px, 12vh, 160px) var(--page-side-padding);
    max-width: var(--max-page-width);
    margin: 0 auto;
    z-index: 5;
}

.section-heading {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--aged-vellum);
    letter-spacing: -0.01em;
    font-size: clamp(28px, 3.5vw, 48px);
    margin-bottom: 0.6em;
}

.folio-mark {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 12px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--dopamine-yellow);
    opacity: 0.75;
    margin-bottom: 1.6em;
}

.folio-mark.light {
    color: var(--dopamine-yellow);
}

/* ============================================================
   FRONTISPIECE
   ============================================================ */
.frontispiece {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding-top: clamp(60px, 8vh, 140px);
    padding-bottom: clamp(60px, 8vh, 140px);
}

.frontispiece-inner {
    max-width: 820px;
    width: 100%;
    position: relative;
}

.frontispiece-edition {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: clamp(40px, 6vh, 80px);
    opacity: 0;
    animation: fadeUp 1.4s ease 0.2s forwards;
}

.edition-rule {
    display: inline-block;
    width: clamp(40px, 8vw, 100px);
    height: 1px;
    background: var(--dopamine-yellow);
    opacity: 0.7;
}

.edition-text {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 13px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--dopamine-yellow);
}

.treatise-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(48px, 9vw, 132px);
    line-height: 0.96;
    letter-spacing: -0.025em;
    color: var(--aged-vellum);
    margin-bottom: clamp(28px, 4vh, 56px);
}

.title-line {
    display: block;
    opacity: 0;
    filter: blur(6px);
    transform: translateY(8px);
    animation: titleReveal 1.6s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}

.title-line:nth-child(1) { animation-delay: 0.4s; }
.title-line:nth-child(2) { animation-delay: 0.7s; color: var(--dopamine-pink); }

@keyframes titleReveal {
    0%   { opacity: 0; filter: blur(6px); transform: translateY(8px); }
    100% { opacity: 1; filter: blur(0); transform: translateY(0); }
}

.subtitle-wrapper {
    position: relative;
    max-width: 640px;
    margin: 0 auto clamp(40px, 6vh, 64px);
    padding-bottom: 16px;
}

.treatise-subtitle {
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(17px, 1.6vw, 22px);
    line-height: 1.6;
    color: var(--aged-vellum);
    min-height: 1.6em;
    opacity: 0.92;
}

.treatise-subtitle .typed-word {
    display: inline-block;
    opacity: 0;
    transform: translateY(4px);
    animation: wordFade 0.5s ease forwards;
}

@keyframes wordFade {
    to { opacity: 1; transform: translateY(0); }
}

.subtitle-wave {
    display: block;
    width: 80%;
    height: 14px;
    margin: 8px auto 0;
    opacity: 0;
    animation: fadeIn 1s ease 2.6s forwards;
}

.frontispiece-byline {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 14px;
    color: var(--aged-vellum);
    opacity: 0;
    animation: fadeUp 1.2s ease 3.0s forwards;
}

.frontispiece-byline em {
    color: var(--dopamine-pink);
    font-style: italic;
}

.frontispiece-ornament {
    margin-top: clamp(36px, 5vh, 56px);
    opacity: 0;
    animation: fadeIn 1.4s ease 3.3s forwards;
}

.frontispiece-ornament svg {
    width: clamp(160px, 22vw, 240px);
    height: auto;
}

/* Corner sugar crystal */
.corner-crystal {
    position: absolute;
    bottom: clamp(40px, 6vh, 90px);
    right: clamp(30px, 5vw, 80px);
    width: clamp(70px, 8vw, 120px);
    height: clamp(70px, 8vw, 120px);
    opacity: 0;
    animation: crystalShimmer 1.2s ease 3.6s forwards;
}

.corner-crystal svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.crystal-face {
    fill: var(--dopamine-pink);
    stroke: var(--aged-vellum);
    stroke-width: 0.6;
}

.crystal-back { fill: #c93d83; opacity: 0.85; }
.crystal-mid  { fill: #FF5BA8; opacity: 0.95; }
.crystal-front { fill: #ff8cc2; opacity: 0.9; }
.crystal-glint { fill: none; stroke: var(--aged-vellum); stroke-width: 1.2; opacity: 0.85; }

@keyframes crystalShimmer {
    0%   { opacity: 0; transform: rotate(0deg) scale(0.9); }
    60%  { opacity: 1; transform: rotate(8deg) scale(1.05); }
    100% { opacity: 1; transform: rotate(0deg) scale(1); }
}

.corner-crystal.sparkle {
    animation: crystalSparkle 0.6s ease;
}

@keyframes crystalSparkle {
    0%, 100% { filter: brightness(1); }
    50%      { filter: brightness(1.6) drop-shadow(0 0 14px var(--dopamine-pink)); }
}

.scroll-cue {
    position: absolute;
    bottom: clamp(20px, 3vh, 40px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    opacity: 0;
    animation: fadeUp 1.2s ease 3.8s forwards, bobNudge 2.4s ease-in-out 4.6s infinite;
}

.scroll-cue-text {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--dopamine-yellow);
    opacity: 0.7;
}

.scroll-cue-arrow {
    color: var(--dopamine-yellow);
    font-size: 14px;
}

@keyframes bobNudge {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50%      { transform: translateX(-50%) translateY(6px); }
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    to { opacity: 1; }
}

/* ============================================================
   TABLE OF CONTENTS
   ============================================================ */
.toc {
    padding-top: clamp(60px, 10vh, 140px);
    padding-bottom: clamp(60px, 10vh, 140px);
}

.page-margins {
    max-width: 880px;
    margin: 0 auto;
}

.toc-heading {
    font-size: clamp(28px, 3.2vw, 44px);
    margin-bottom: 0.3em;
}

.toc-preamble {
    font-style: italic;
    color: var(--aged-vellum);
    opacity: 0.78;
    max-width: 640px;
    margin-bottom: clamp(36px, 5vh, 56px);
    font-size: clamp(15px, 1.05vw, 17px);
    line-height: 1.7;
}

.toc-list {
    list-style: none;
    border-top: 1px solid rgba(255, 210, 63, 0.25);
    padding-top: 22px;
}

.toc-item {
    display: grid;
    grid-template-columns: 36px 1fr 60px;
    gap: 16px;
    align-items: baseline;
    padding: 14px 0;
    border-bottom: 1px solid rgba(255, 210, 63, 0.12);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.toc-item.revealed {
    opacity: 1;
    transform: translateY(0);
}

.toc-num {
    font-family: var(--font-display);
    font-weight: 500;
    color: var(--dopamine-yellow);
    font-size: 14px;
    letter-spacing: 0.05em;
}

.toc-link {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 14px;
    align-items: baseline;
    text-decoration: none;
    color: var(--aged-vellum);
    transition: color 0.3s ease;
}

.toc-year {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--dopamine-pink);
    font-size: clamp(20px, 1.8vw, 26px);
    letter-spacing: -0.01em;
}

.toc-dot-leader {
    display: inline-block;
    height: 1px;
    background-image: radial-gradient(circle, var(--aged-vellum) 1px, transparent 1px);
    background-size: 6px 1px;
    background-repeat: repeat-x;
    opacity: 0.35;
    align-self: center;
    margin-top: 4px;
}

.toc-title {
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(15px, 1.1vw, 18px);
    color: var(--aged-vellum);
    text-align: right;
    max-width: 380px;
}

.toc-link:hover .toc-year {
    color: var(--dopamine-yellow);
    transition: color 0.3s ease;
}

.toc-link:hover .toc-title {
    color: var(--sugar-mint);
}

.toc-folio {
    font-family: var(--font-body);
    font-style: italic;
    color: var(--aged-vellum);
    opacity: 0.5;
    font-size: 12px;
    text-align: right;
}

.toc-item.peripheral-pulse .toc-year {
    animation: peripheralPulse 1.2s ease;
}

@keyframes peripheralPulse {
    0%, 100% { text-shadow: none; }
    50%      { text-shadow: 0 0 14px var(--dopamine-pink); }
}

.section-divider {
    margin: clamp(50px, 7vh, 90px) auto 0;
    width: 70%;
}

.section-divider svg {
    width: 100%;
    height: 30px;
    opacity: 0.7;
}

/* ============================================================
   TIMELINE
   ============================================================ */
.timeline {
    position: relative;
    padding-top: clamp(60px, 8vh, 100px);
    padding-bottom: clamp(80px, 10vh, 140px);
}

.spine-wrap {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 8px;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 4;
}

.spine-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.spine-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: spineDraw 2.4s ease 0.4s forwards;
}

@keyframes spineDraw {
    to { stroke-dashoffset: 0; }
}

.spine-pulse {
    opacity: 0;
}

.timeline-entry {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(40px, 6vw, 80px);
    margin-bottom: clamp(80px, 12vh, 160px);
    align-items: start;
}

.timeline-entry .entry-content {
    opacity: 0;
    filter: blur(4px);
    transform: translateY(20px);
    transition: opacity 0.7s ease, filter 0.7s ease, transform 0.7s ease;
}

.timeline-entry.visible .entry-content {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
}

.timeline-entry.left .entry-content {
    grid-column: 1;
    text-align: right;
    padding-right: clamp(20px, 3vw, 40px);
}

.timeline-entry.right .entry-content {
    grid-column: 2;
    text-align: left;
    padding-left: clamp(20px, 3vw, 40px);
}

/* Node on spine */
.entry-node {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.node-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--dopamine-pink);
    box-shadow: 0 0 0 3px var(--midnight-cobalt), 0 0 0 4px var(--dopamine-pink);
    z-index: 2;
    transition: transform 0.4s ease;
}

.node-ring {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--dopamine-yellow);
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.timeline-entry.visible .node-ring {
    opacity: 0.8;
    transform: scale(1);
}

.timeline-entry.passed .node-dot {
    background: var(--dopamine-yellow);
    box-shadow: 0 0 0 3px var(--midnight-cobalt), 0 0 0 4px var(--dopamine-yellow);
}

/* Year marker */
.entry-year {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(64px, 9vw, 132px);
    line-height: 0.9;
    letter-spacing: -0.02em;
    color: var(--dopamine-pink);
    margin-bottom: 0.2em;
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 0.6s ease, transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.timeline-entry.visible .entry-year {
    opacity: 1;
    transform: scale(1);
    transition-delay: 0.4s;
}

/* Heading */
.entry-heading {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(22px, 2.4vw, 34px);
    line-height: 1.18;
    letter-spacing: -0.01em;
    color: var(--aged-vellum);
    margin-bottom: clamp(20px, 3vh, 32px);
}

/* Body */
.entry-body p {
    margin-bottom: 1.2em;
    color: var(--aged-vellum);
    font-size: clamp(15px, 1.1vw, 17.5px);
    line-height: 1.78;
}

.entry-body em {
    color: var(--sugar-mint);
    font-style: italic;
}

/* Footnote marker */
.footnote-marker {
    font-family: var(--font-display);
    font-weight: 500;
    color: var(--dopamine-yellow);
    font-size: 11px;
    cursor: pointer;
    margin-left: 1px;
    position: relative;
    display: inline-block;
    transition: transform 0.3s ease, color 0.3s ease;
    vertical-align: super;
    line-height: 0;
}

.footnote-marker::after {
    content: "";
    position: absolute;
    left: -2px;
    right: -2px;
    bottom: -3px;
    height: 6px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 6' preserveAspectRatio='none'><path d='M0,3 C7.5,0 15,6 22.5,3 C26.25,1.5 30,4.5 30,3' stroke='%23FFD23F' stroke-width='1' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    opacity: 0;
    transform: scaleX(0);
    transform-origin: left;
    transition: opacity 0.3s ease, transform 0.4s ease;
}

.footnote-marker:hover {
    animation: markerPulse 0.6s ease infinite;
    color: var(--dopamine-pink);
}

.footnote-marker:hover::after {
    opacity: 1;
    transform: scaleX(1);
}

@keyframes markerPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.15); }
}

/* Pull-quote */
.pull-quote {
    margin: clamp(24px, 4vh, 40px) 0;
    padding: clamp(20px, 3vh, 32px) clamp(24px, 3vw, 40px);
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(16px, 1.2vw, 19px);
    line-height: 1.6;
    color: var(--aged-vellum);
    background: linear-gradient(180deg, rgba(122, 232, 184, 0.06), rgba(122, 232, 184, 0.02));
    border-left: 2px solid var(--sugar-mint);
    position: relative;
}

.timeline-entry.left .pull-quote {
    border-left: none;
    border-right: 2px solid var(--sugar-mint);
}

.pull-quote .quote-mark {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--sugar-mint);
    font-size: 1.5em;
    line-height: 0;
    vertical-align: -0.3em;
    margin-right: 4px;
}

.pull-quote .quote-mark.close {
    margin-left: 4px;
    margin-right: 0;
}

.pull-quote cite {
    display: block;
    margin-top: 12px;
    font-size: 13px;
    color: var(--aged-vellum);
    opacity: 0.6;
    font-style: italic;
}

/* Leather plate (figure) */
.leather-plate {
    position: relative;
    margin: clamp(28px, 4vh, 48px) 0 0;
    padding: 16px;
    background: var(--indigo-velvet);
    border: 1px solid rgba(255, 210, 63, 0.5);
    box-shadow: 0 0 0 1px rgba(14, 26, 58, 0.6), 0 12px 40px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.leather-plate::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 12% 18%, rgba(242, 232, 208, 0.06) 0%, transparent 2%),
        radial-gradient(circle at 38% 47%, rgba(242, 232, 208, 0.05) 0%, transparent 2%),
        radial-gradient(circle at 62% 28%, rgba(242, 232, 208, 0.06) 0%, transparent 2%),
        radial-gradient(circle at 87% 71%, rgba(242, 232, 208, 0.05) 0%, transparent 2%),
        radial-gradient(circle at 25% 78%, rgba(242, 232, 208, 0.06) 0%, transparent 2%),
        radial-gradient(circle at 71% 88%, rgba(242, 232, 208, 0.05) 0%, transparent 2%),
        repeating-linear-gradient(45deg, transparent 0 2px, rgba(255, 210, 63, 0.02) 2px 3px),
        repeating-linear-gradient(135deg, transparent 0 3px, rgba(14, 26, 58, 0.3) 3px 4px);
    pointer-events: none;
    opacity: 0.8;
}

.plate-corner {
    position: absolute;
    width: 22px;
    height: 22px;
    border: 1px solid var(--dopamine-yellow);
    z-index: 2;
}

.plate-corner.tl { top: 6px; left: 6px; border-right: none; border-bottom: none; }
.plate-corner.tr { top: 6px; right: 6px; border-left: none; border-bottom: none; }
.plate-corner.bl { bottom: 6px; left: 6px; border-right: none; border-top: none; }
.plate-corner.br { bottom: 6px; right: 6px; border-left: none; border-top: none; }

.plate-corner.tl::after,
.plate-corner.tr::after,
.plate-corner.bl::after,
.plate-corner.br::after {
    content: "";
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--dopamine-yellow);
}

.plate-corner.tl::after { top: -3px; left: -3px; }
.plate-corner.tr::after { top: -3px; right: -3px; }
.plate-corner.bl::after { bottom: -3px; left: -3px; }
.plate-corner.br::after { bottom: -3px; right: -3px; }

.plate-diagram {
    display: block;
    width: 100%;
    height: auto;
    position: relative;
    z-index: 1;
}

/* ============================================================
   FOOTNOTES ANNEX
   ============================================================ */
.footnotes-annex {
    background: var(--indigo-velvet);
    max-width: 100%;
    padding: clamp(80px, 12vh, 140px) var(--page-side-padding);
    position: relative;
    margin-top: clamp(60px, 8vh, 100px);
}

.footnotes-annex::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 12% 18%, rgba(242, 232, 208, 0.04) 0%, transparent 1.5%),
        radial-gradient(circle at 38% 47%, rgba(242, 232, 208, 0.04) 0%, transparent 1.5%),
        radial-gradient(circle at 62% 28%, rgba(242, 232, 208, 0.04) 0%, transparent 1.5%),
        radial-gradient(circle at 87% 71%, rgba(242, 232, 208, 0.04) 0%, transparent 1.5%),
        radial-gradient(circle at 25% 78%, rgba(242, 232, 208, 0.04) 0%, transparent 1.5%),
        radial-gradient(circle at 71% 88%, rgba(242, 232, 208, 0.04) 0%, transparent 1.5%),
        repeating-linear-gradient(45deg, transparent 0 4px, rgba(255, 210, 63, 0.015) 4px 5px),
        repeating-linear-gradient(135deg, transparent 0 5px, rgba(14, 26, 58, 0.3) 5px 6px);
    pointer-events: none;
    z-index: 0;
}

.annex-inner {
    max-width: var(--max-page-width);
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.footnote-heading {
    color: var(--aged-vellum);
    font-size: clamp(26px, 3vw, 40px);
    margin-bottom: 0.4em;
}

.footnote-preamble {
    font-style: italic;
    color: var(--aged-vellum);
    opacity: 0.78;
    max-width: 640px;
    margin-bottom: clamp(32px, 5vh, 48px);
    font-size: clamp(14px, 1vw, 16px);
}

.footnote-ornament-rule {
    margin-bottom: clamp(28px, 4vh, 40px);
}

.footnote-ornament-rule svg {
    width: 100%;
    height: 24px;
    max-width: 600px;
    margin: 0 auto;
    display: block;
    opacity: 0.85;
}

.footnote-list {
    columns: 2;
    column-gap: clamp(30px, 5vw, 80px);
    list-style: none;
    counter-reset: fn;
}

.footnote-item {
    break-inside: avoid;
    margin-bottom: 18px;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 8px;
    border-radius: 2px;
    transition: background 0.3s ease;
    font-size: 13px;
    line-height: 1.6;
    color: var(--aged-vellum);
}

.footnote-item.active {
    background: rgba(255, 210, 63, 0.08);
    box-shadow: inset 0 0 0 1px rgba(255, 210, 63, 0.25);
}

.fn-num {
    font-family: var(--font-display);
    font-weight: 500;
    color: var(--dopamine-yellow);
    font-size: 14px;
}

.fn-text em {
    font-style: italic;
    color: var(--sugar-mint);
    opacity: 0.92;
}

@media (max-width: 720px) {
    .footnote-list { columns: 1; }
}

/* ============================================================
   COLOPHON
   ============================================================ */
.colophon {
    max-width: 760px;
    margin: 0 auto;
    text-align: center;
    padding-top: clamp(80px, 12vh, 140px);
    padding-bottom: clamp(80px, 12vh, 160px);
}

.colophon-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(24px, 4vh, 40px);
}

.printers-mark {
    width: clamp(80px, 10vw, 120px);
    height: clamp(80px, 10vw, 120px);
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 1s ease, transform 1s ease;
}

.colophon.revealed .printers-mark {
    opacity: 1;
    transform: scale(1);
    transition-delay: 0.5s;
}

.signature-block {
    width: 100%;
    max-width: 360px;
}

.signature-svg {
    width: 100%;
    height: 80px;
    display: block;
}

#signaturePath {
    stroke-dasharray: 700;
    stroke-dashoffset: 700;
}

.colophon.revealed #signaturePath {
    animation: signatureDraw 1.8s ease 0.2s forwards;
}

@keyframes signatureDraw {
    to { stroke-dashoffset: 0; }
}

#signatureUnderline {
    stroke-dasharray: 280;
    stroke-dashoffset: 280;
}

.colophon.revealed #signatureUnderline {
    animation: signatureDraw 1.2s ease 1.4s forwards;
}

.signature-name {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 14px;
    color: var(--aged-vellum);
    opacity: 0;
    margin-top: 8px;
    transition: opacity 0.8s ease;
}

.colophon.revealed .signature-name {
    opacity: 0.7;
    transition-delay: 1.6s;
}

.colophon-meta {
    opacity: 0;
    transition: opacity 0.8s ease;
}

.colophon.revealed .colophon-meta {
    opacity: 1;
    transition-delay: 2s;
}

.colophon-line {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 13px;
    color: var(--aged-vellum);
    opacity: 0.75;
    line-height: 1.7;
}

.colophon-line em {
    color: var(--dopamine-yellow);
    font-style: italic;
}

.colophon-date {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--dopamine-pink);
    margin-top: 20px;
}

.end-fleuron {
    width: 80px;
    height: 40px;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.colophon.revealed .end-fleuron {
    opacity: 1;
    transition-delay: 2.4s;
}

.end-fleuron svg {
    width: 100%;
    height: 100%;
}

/* ============================================================
   FOOTNOTE CONNECTOR OVERLAY
   ============================================================ */
.footnote-line-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 90;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 860px) {
    .timeline-entry {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .spine-wrap { left: 20px; transform: none; }

    .timeline-entry.left .entry-content,
    .timeline-entry.right .entry-content {
        grid-column: 1;
        text-align: left;
        padding-left: 50px;
        padding-right: 0;
    }

    .timeline-entry.left .pull-quote {
        border-right: none;
        border-left: 2px solid var(--sugar-mint);
    }

    .entry-node {
        left: 20px;
        transform: translateX(-50%);
    }

    .toc-item {
        grid-template-columns: 32px 1fr;
    }

    .toc-folio { display: none; }

    .toc-title { text-align: left; max-width: 100%; }

    .toc-link {
        grid-template-columns: auto 1fr;
        gap: 12px;
    }

    .toc-dot-leader { display: none; }
}

@media (max-width: 480px) {
    .corner-crystal { width: 60px; height: 60px; bottom: 24px; right: 18px; }
    .frontispiece-edition { gap: 8px; }
    .edition-rule { width: 30px; }
    .edition-text { font-size: 10px; letter-spacing: 0.16em; }
}
