/* ============================================================
   footprint.broker — A digital codex
   Palette:
     Charred Walnut    #1C1410
     Deep Vellum       #F0E6D0
     Burgundy Wax      #6B1528
     Tarnished Gold    #8B7D3C
     True Ink Black    #0A0806
     Candle Smoke      #2A2018
     Foxed Cream       #E8D5B0
     Venetian Night    #12090E
     Wax Highlight     #8B2040
     Wax Shadow        #4A0E1C
   ============================================================ */

:root {
    --walnut: #1C1410;
    --vellum: #F0E6D0;
    --burgundy: #6B1528;
    --gold: #8B7D3C;
    --ink: #0A0806;
    --smoke: #2A2018;
    --cream: #E8D5B0;
    --night: #12090E;
    --wax-hi: #8B2040;
    --wax-lo: #4A0E1C;

    --folio-bg: var(--walnut);
    --folio-text: var(--cream);

    --display: "Cormorant Garamond", "Lora", Georgia, serif;
    --body: "Lora", Georgia, serif;
    --caps: "EB Garamond", "Cormorant Garamond", Georgia, serif;
}

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

html {
    scroll-behavior: smooth;
}

html, body {
    height: 100%;
    width: 100%;
}

body {
    background-color: var(--folio-bg);
    color: var(--folio-text);
    font-family: var(--body);
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    line-height: 1.75;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.8s ease-in-out, color 0.8s ease-in-out;
    overflow-x: hidden;
}

/* ===== Body-wide paper grain ===== */
.paper-grain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    opacity: 0.5;
    mix-blend-mode: overlay;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(232, 213, 176, 0.04) 0, transparent 30%),
        radial-gradient(circle at 80% 70%, rgba(107, 21, 40, 0.03) 0, transparent 35%);
}
.paper-grain::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' seed='4'/><feColorMatrix values='0 0 0 0 0.10  0 0 0 0 0.07  0 0 0 0 0.05  0 0 0 0.55 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/></svg>");
    background-size: 220px 220px;
    opacity: 0.18;
    mix-blend-mode: multiply;
}

/* ===== Scroll progress vertical rule ===== */
.progress-rule {
    position: fixed;
    top: 0;
    left: 18px;
    width: 1px;
    height: 100vh;
    background: rgba(107, 21, 40, 0.18);
    z-index: 50;
    pointer-events: none;
}
.progress-rule__fill {
    display: block;
    width: 1px;
    height: 0%;
    background: var(--burgundy);
    transition: height 0.18s linear;
    box-shadow: 0 0 6px rgba(107, 21, 40, 0.45);
}
.progress-rule::before, .progress-rule::after {
    content: "";
    position: absolute;
    left: -3px;
    width: 7px;
    height: 1px;
    background: var(--burgundy);
    opacity: 0.55;
}
.progress-rule::before { top: 0; }
.progress-rule::after  { bottom: 0; }

/* ===== Codex container — scroll snap ===== */
.codex {
    position: relative;
    width: 100%;
    scroll-snap-type: y mandatory;
    overflow-y: auto;
    height: 100vh;
    z-index: 1;
}

/* Each folio = full viewport */
.folio {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1.5rem, 4vw, 4rem) clamp(2rem, 6vw, 7rem);
    transition: background-color 0.8s ease-in-out, color 0.8s ease-in-out;
    perspective: 1400px;
}

.folio--recto {
    background-color: var(--walnut);
    color: var(--cream);
}
.folio--verso {
    background-color: var(--vellum);
    color: var(--ink);
}

/* Vignette */
.vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center,
                transparent 35%,
                rgba(28, 20, 16, 0.42) 88%,
                rgba(18, 9, 14, 0.7) 100%);
    pointer-events: none;
    z-index: 2;
}
.vignette--light {
    background: radial-gradient(ellipse at center,
                transparent 40%,
                rgba(42, 32, 24, 0.18) 88%,
                rgba(42, 32, 24, 0.32) 100%);
}

/* Folio corner mark (recto/verso indicator) */
.folio-mark {
    position: absolute;
    bottom: clamp(1.2rem, 2.5vw, 2rem);
    font-family: var(--caps);
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    letter-spacing: 0.32em;
    color: var(--gold);
    opacity: 0.55;
    font-variant-caps: all-small-caps;
    font-feature-settings: 'smcp' 1, 'c2sc' 1;
    z-index: 6;
}
.folio-mark--recto { right: clamp(2rem, 4vw, 4rem); }
.folio-mark--verso { left: clamp(2rem, 4vw, 4rem); }

.folio--verso .folio-mark { color: var(--burgundy); opacity: 0.6; }

/* ============================================================
   FOLIO I — Colophon
   ============================================================ */
.folio--colophon { background-color: var(--walnut); }

.colophon {
    position: relative;
    width: min(900px, 92%);
    padding: clamp(3rem, 6vw, 5rem) clamp(2rem, 5vw, 4rem);
    text-align: center;
    z-index: 4;
}

.colophon__eyebrow {
    font-family: var(--caps);
    font-variant-caps: all-small-caps;
    font-feature-settings: 'smcp' 1, 'c2sc' 1;
    letter-spacing: 0.42em;
    font-size: clamp(0.7rem, 1vw, 0.88rem);
    color: var(--gold);
    margin-bottom: clamp(1.5rem, 3vw, 2.4rem);
    opacity: 0.85;
}

.colophon__title {
    font-family: var(--display);
    font-weight: 700;
    font-style: normal;
    text-transform: uppercase;
    font-size: clamp(3rem, 10vw, 7.5rem);
    line-height: 0.95;
    letter-spacing: 0.12em;
    color: var(--cream);
    font-feature-settings: 'liga' 1, 'kern' 1, 'dlig' 1;
    text-shadow: 0 0 30px rgba(232, 213, 176, 0.06);
    margin-bottom: clamp(1.6rem, 3vw, 2.4rem);
}
.colophon__title .dot {
    color: var(--burgundy);
    font-style: italic;
}

.colophon__subtitle {
    font-family: var(--body);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1rem, 1.6vw, 1.2rem);
    color: var(--cream);
    letter-spacing: 0.06em;
    margin: 1.4rem 0 1rem;
    opacity: 0.95;
}

.colophon__imprint {
    font-family: var(--caps);
    font-variant-caps: all-small-caps;
    font-feature-settings: 'smcp' 1, 'c2sc' 1;
    letter-spacing: 0.36em;
    font-size: clamp(0.65rem, 0.95vw, 0.8rem);
    color: var(--gold);
    opacity: 0.7;
    margin-top: clamp(1.5rem, 3vw, 2rem);
}

/* Corner fleurons */
.fleuron {
    position: absolute;
    width: clamp(48px, 7vw, 90px);
    height: clamp(48px, 7vw, 90px);
    z-index: 3;
}
.fleuron--tl { top: 0; left: 0; }
.fleuron--tr { top: 0; right: 0; }
.fleuron--bl { bottom: 0; left: 0; }
.fleuron--br { bottom: 0; right: 0; }

/* Stroke-draw animation */
.fleuron .draw {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.2s ease-out;
}
.folio.in-view .fleuron .draw {
    stroke-dashoffset: 0;
}
/* stagger nested paths within a fleuron */
.fleuron .draw:nth-child(2) { transition-delay: 0.18s; }
.fleuron .draw:nth-child(3) { transition-delay: 0.36s; }
.fleuron .draw:nth-child(4) { transition-delay: 0.54s; }

/* Lozenge rule */
.rule {
    width: min(60%, 480px);
    height: 20px;
    margin: 1.4rem auto;
    overflow: visible;
}
.rule--small { width: min(50%, 320px); height: 16px; margin: 1rem auto; }
.rule--seal  { width: min(70%, 540px); margin-top: 2rem; }
.rule .rule-line {
    stroke-dasharray: 320;
    stroke-dashoffset: 320;
    transition: stroke-dashoffset 1s ease-out;
}
.folio.in-view .rule .rule-line { stroke-dashoffset: 0; }
.rule .rule-line--right { transition-delay: 0.05s; }
.rule .rule-lozenge {
    transform-origin: center;
    transform: scale(0);
    transition: transform 0.5s ease-out 0.7s;
}
.folio.in-view .rule .rule-lozenge { transform: scale(1); }

/* ============================================================
   FOLIO I (Verso) — Manifest
   ============================================================ */
.folio--manifest { background-color: var(--vellum); }

.manifest {
    position: relative;
    width: min(960px, 92%);
    z-index: 4;
}

.manifest__header { text-align: center; margin-bottom: clamp(2rem, 4vw, 3.2rem); }

.manifest__eyebrow {
    font-family: var(--caps);
    font-variant-caps: all-small-caps;
    font-feature-settings: 'smcp' 1, 'c2sc' 1;
    letter-spacing: 0.4em;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    color: var(--burgundy);
    opacity: 0.85;
    margin-bottom: 1rem;
}

.manifest__title {
    font-family: var(--display);
    font-weight: 700;
    font-style: italic;
    color: var(--ink);
    font-size: clamp(1.8rem, 4.5vw, 3.2rem);
    letter-spacing: 0.04em;
    line-height: 1.1;
    margin-bottom: 0.8rem;
    font-feature-settings: 'liga' 1, 'kern' 1;
}

.manifest__list {
    list-style: none;
    border-top: 0.5px solid rgba(107, 21, 40, 0.4);
}

.manifest__item {
    border-bottom: 0.5px solid rgba(107, 21, 40, 0.4);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.7s ease-out, transform 0.7s ease-out;
    transition-delay: var(--delay, 0ms);
}
.folio.in-view .manifest__item { opacity: 1; transform: translateY(0); }

.manifest__link {
    display: grid;
    grid-template-columns: minmax(80px, 1fr) minmax(180px, 2.4fr) minmax(160px, 2fr) minmax(180px, 2fr);
    gap: clamp(1rem, 2vw, 2rem);
    align-items: baseline;
    padding: clamp(0.9rem, 1.8vw, 1.3rem) clamp(0.6rem, 1.2vw, 1rem);
    text-decoration: none;
    color: var(--ink);
    transition: background-color 0.4s ease, color 0.4s ease, padding-left 0.4s ease;
    position: relative;
}

.manifest__link::before {
    content: "";
    position: absolute;
    left: 0; top: 50%;
    width: 0; height: 1px;
    background: var(--burgundy);
    transition: width 0.5s ease;
    transform: translateY(-50%);
}
.manifest__link:hover {
    background-color: var(--cream);
    padding-left: 1.6rem;
}
.manifest__link:hover::before { width: 1.2rem; }

.manifest__lot {
    font-family: var(--caps);
    font-variant-caps: all-small-caps;
    font-feature-settings: 'smcp' 1, 'c2sc' 1;
    letter-spacing: 0.22em;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    color: var(--gold);
    font-weight: 500;
}

.manifest__name {
    font-family: var(--display);
    font-weight: 700;
    font-style: italic;
    font-size: clamp(1.2rem, 2.4vw, 1.8rem);
    color: var(--ink);
    letter-spacing: 0.02em;
}

.manifest__desc {
    font-family: var(--body);
    font-style: italic;
    font-size: clamp(0.9rem, 1.3vw, 1.05rem);
    color: var(--smoke);
}

.manifest__prov {
    font-family: var(--caps);
    font-variant-caps: all-small-caps;
    font-feature-settings: 'smcp' 1, 'c2sc' 1;
    letter-spacing: 0.18em;
    font-size: clamp(0.7rem, 1vw, 0.82rem);
    color: var(--burgundy);
    text-align: right;
    opacity: 0.85;
}

.manifest__note {
    margin-top: clamp(1.5rem, 3vw, 2.2rem);
    text-align: center;
    font-family: var(--body);
    font-style: italic;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    color: var(--smoke);
    letter-spacing: 0.04em;
}
.manifest__note .manicule { color: var(--burgundy); font-style: normal; font-size: 1.2em; }

/* ============================================================
   Lots — Plate (recto) + Description (verso)
   ============================================================ */
.plate {
    position: relative;
    width: min(1200px, 100%);
    height: min(80vh, 720px);
    display: grid;
    grid-template-columns: 70% 30%;
    gap: clamp(1.5rem, 3vw, 2.4rem);
    align-items: stretch;
    z-index: 4;
}
.plate--reverse { grid-template-columns: 30% 70%; }
.plate--reverse .plate__caption { order: -1; }

.plate__image {
    width: 100%;
    height: 100%;
    display: block;
    border: 0.5px solid rgba(139, 125, 60, 0.35);
    box-shadow:
        0 1px 0 rgba(232, 213, 176, 0.04) inset,
        0 30px 60px rgba(18, 9, 14, 0.55),
        0 6px 14px rgba(18, 9, 14, 0.4);
    filter: sepia(0.18) contrast(1.05);
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 1s ease-out 0.15s, transform 1s ease-out 0.15s;
}
.folio.in-view .plate__image { opacity: 1; transform: translateY(0); }

.plate__caption {
    position: relative;
    padding: clamp(1.5rem, 3vw, 2.4rem) clamp(1.2rem, 2vw, 2rem);
    background: rgba(232, 213, 176, 0.04);
    border: 0.5px solid rgba(139, 125, 60, 0.35);
    align-self: center;
    max-height: 100%;
    overflow: visible;
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 1s ease-out 0.45s, transform 1s ease-out 0.45s;
}
.folio.in-view .plate__caption { opacity: 1; transform: translateY(0); }

.fleuron--small { width: 36px; height: 36px; }
.fleuron--cap-tl { top: -6px; left: -6px; }
.fleuron--cap-br { bottom: -6px; right: -6px; }

.plate__lot {
    font-family: var(--caps);
    font-variant-caps: all-small-caps;
    font-feature-settings: 'smcp' 1, 'c2sc' 1;
    letter-spacing: 0.32em;
    font-size: clamp(0.78rem, 1.1vw, 0.95rem);
    color: var(--gold);
    margin-bottom: 0.8rem;
}
.plate__title {
    font-family: var(--display);
    font-weight: 700;
    font-style: italic;
    font-size: clamp(1.6rem, 4vw, 3rem);
    letter-spacing: 0.04em;
    color: var(--cream);
    line-height: 1.05;
    margin-bottom: clamp(0.9rem, 1.8vw, 1.4rem);
    font-feature-settings: 'liga' 1, 'kern' 1;
}
.plate__medium, .plate__chain {
    font-family: var(--body);
    font-size: clamp(0.85rem, 1.15vw, 1rem);
    color: var(--cream);
    opacity: 0.85;
    line-height: 1.7;
    margin-bottom: clamp(0.6rem, 1.2vw, 1rem);
}
.plate__chain em {
    color: var(--gold);
    font-style: italic;
}
.plate__estimate {
    font-family: var(--caps);
    font-size: clamp(0.85rem, 1.2vw, 1.05rem);
    color: var(--gold);
    margin-top: clamp(1rem, 1.8vw, 1.4rem);
    padding-top: clamp(1rem, 1.8vw, 1.4rem);
    border-top: 0.5px solid rgba(139, 125, 60, 0.45);
    letter-spacing: 0.06em;
}
.plate__estimate .caps {
    font-variant-caps: all-small-caps;
    font-feature-settings: 'smcp' 1, 'c2sc' 1;
    letter-spacing: 0.32em;
    font-size: 0.85em;
    color: var(--burgundy);
}

/* Verso text-block */
.text-block {
    position: relative;
    max-width: 38ch;
    margin: 0 auto;
    width: 100%;
    z-index: 4;
    padding-top: clamp(2rem, 5vh, 4rem);
}

.text-block__lot {
    font-family: var(--caps);
    font-variant-caps: all-small-caps;
    font-feature-settings: 'smcp' 1, 'c2sc' 1;
    letter-spacing: 0.32em;
    font-size: clamp(0.78rem, 1vw, 0.92rem);
    color: var(--burgundy);
    text-align: center;
    margin-bottom: 0.6rem;
}
.text-block__title {
    font-family: var(--display);
    font-weight: 700;
    font-style: italic;
    color: var(--ink);
    font-size: clamp(1.6rem, 4vw, 2.6rem);
    letter-spacing: 0.04em;
    text-align: center;
    margin-bottom: 0.6rem;
    line-height: 1.1;
    font-feature-settings: 'liga' 1, 'kern' 1;
}
.text-block p {
    font-family: var(--body);
    font-size: clamp(1rem, 1.5vw, 1.15rem);
    color: var(--ink);
    line-height: 1.85;
    margin-bottom: 1.1rem;
    text-align: justify;
    hyphens: auto;
}
.text-block p em { color: var(--burgundy); }
.text-block__verse {
    font-family: var(--display);
    font-style: italic;
    color: var(--burgundy) !important;
    font-size: clamp(1.05rem, 1.6vw, 1.25rem) !important;
    text-align: center !important;
    margin: 1.6rem 0 !important;
    line-height: 1.5 !important;
    letter-spacing: 0.02em;
}

/* Marginalia */
.marginalia {
    position: absolute;
    font-family: var(--caps);
    color: var(--gold);
    font-size: clamp(0.9rem, 1.4vw, 1.1rem);
    opacity: 0;
    transition: opacity 1s ease-out;
    transition-delay: var(--delay, 0ms);
    z-index: 5;
}
.folio.in-view .marginalia { opacity: 0.42; }
.folio--verso .marginalia { color: var(--burgundy); }
.folio.in-view.folio--verso .marginalia { opacity: 0.55; }

.marginalia--asterism { top: 18%; left: 6%; }
.marginalia--pilcrow { top: 70%; left: 4%; font-size: clamp(1.4rem, 2vw, 1.8rem); }
.marginalia--manicule { top: 30%; left: 5%; font-size: clamp(1.2rem, 2vw, 1.6rem); }
.marginalia--right { left: auto; right: 5%; }

/* ============================================================
   FOLIO V — Wax Seal
   ============================================================ */
.folio--seal {
    background-color: var(--walnut);
    flex-direction: column;
}

.seal-stage {
    position: relative;
    width: min(720px, 90%);
    text-align: center;
    z-index: 4;
}

.seal__eyebrow {
    font-family: var(--caps);
    font-variant-caps: all-small-caps;
    font-feature-settings: 'smcp' 1, 'c2sc' 1;
    letter-spacing: 0.4em;
    font-size: clamp(0.75rem, 1vw, 0.9rem);
    color: var(--gold);
    margin-bottom: clamp(2rem, 4vw, 3rem);
    opacity: 0.8;
}

.seal-wrapper {
    position: relative;
    width: clamp(180px, 28vw, 320px);
    height: clamp(180px, 28vw, 320px);
    margin: 0 auto;
    perspective: 800px;
}

.seal {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 4px 20px rgba(18, 9, 14, 0.6))
            drop-shadow(0 12px 32px rgba(18, 9, 14, 0.45));
    transform: translate3d(0,0,0);
    transition: transform 0.18s ease-out;
    will-change: transform;
}

@media (hover: none) {
    .seal { animation: seal-breathe 4s ease-in-out infinite; }
}

@keyframes seal-breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.015); }
}

.seal__caption {
    font-family: var(--display);
    font-style: italic;
    font-weight: 700;
    color: var(--cream);
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    letter-spacing: 0.06em;
    margin-top: clamp(1.5rem, 3vw, 2.2rem);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 1s ease-out 0.4s, transform 1s ease-out 0.4s;
    font-feature-settings: 'liga' 1, 'kern' 1;
}
.folio.in-view .seal__caption { opacity: 1; transform: translateY(0); }

.seal__sub {
    font-family: var(--caps);
    font-variant-caps: all-small-caps;
    font-feature-settings: 'smcp' 1, 'c2sc' 1;
    letter-spacing: 0.4em;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    color: var(--gold);
    opacity: 0;
    margin-top: 1rem;
    transition: opacity 1s ease-out 0.7s;
}
.folio.in-view .seal__sub { opacity: 0.75; }

/* ============================================================
   Page-turn diagonal clip-path (recto -> verso, folio I)
   Applied via JS class .turning to the recto folio when leaving
   ============================================================ */
.folio--colophon {
    transform-origin: right center;
    transition: clip-path 0.6s cubic-bezier(0.6, 0.04, 0.4, 1),
                transform 0.6s cubic-bezier(0.6, 0.04, 0.4, 1);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}
.folio--colophon.turning {
    clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%);
    transform: rotateY(-3deg);
}

/* ============================================================
   Responsive tweaks
   ============================================================ */
@media (max-width: 880px) {
    .plate {
        grid-template-columns: 1fr;
        grid-template-rows: 60% 40%;
        height: min(86vh, 760px);
    }
    .plate--reverse { grid-template-columns: 1fr; }
    .plate--reverse .plate__caption { order: 0; }

    .manifest__link {
        grid-template-columns: 1fr;
        gap: 0.2rem;
        padding: 1rem 0.4rem;
    }
    .manifest__prov { text-align: left; }
    .progress-rule { left: 8px; }

    .folio { padding: 1.4rem 1.2rem; }
    .colophon { padding: 2rem 1.2rem; }
    .fleuron { width: 42px; height: 42px; }

    .marginalia { display: none; }
}

@media (max-width: 520px) {
    .colophon__title { letter-spacing: 0.05em; }
    .plate__image { min-height: 280px; }
}

/* ============================================================
   Custom scrollbar for codex
   ============================================================ */
.codex::-webkit-scrollbar {
    width: 6px;
}
.codex::-webkit-scrollbar-track {
    background: rgba(28, 20, 16, 0.2);
}
.codex::-webkit-scrollbar-thumb {
    background: rgba(107, 21, 40, 0.55);
    border-radius: 0;
}
.codex::-webkit-scrollbar-thumb:hover {
    background: var(--burgundy);
}
