/* economics.day — a 1923 counting-house ledger rendered as a website. */

/* ----- Palette tokens (from DESIGN.md) -----
   #F5EAD2 aged folio paper
   #E8D7B0 foxed paper margin
   #3B2A1D iron-gall ink
   #6B2D1A oxblood / cinnabar
   #7A4A1F sepia ink
   #2A1F18 leather desktop dark
   #4A3624 leather desktop light
   #B79253 brass
   #1F4D2E banker's-lamp green glass
   #F5DBA1 tungsten light wash
   plus paper rule colours #C8A878 and #A88A55
*/

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

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background-color: #2A1F18;
    background-image:
        /* leather grain noise via repeating gradient */
        repeating-linear-gradient(
            107deg,
            rgba(74, 54, 36, 0.18) 0,
            rgba(74, 54, 36, 0.18) 1px,
            transparent 1px,
            transparent 3px
        ),
        repeating-linear-gradient(
            17deg,
            rgba(26, 15, 8, 0.10) 0,
            rgba(26, 15, 8, 0.10) 1px,
            transparent 1px,
            transparent 4px
        ),
        radial-gradient(ellipse at 25% 35%, #4A3624 0%, transparent 55%),
        radial-gradient(ellipse at 75% 75%, #4A3624 0%, transparent 60%),
        linear-gradient(135deg, #2A1F18 0%, #1A100A 100%);
    color: #3B2A1D;
    font-family: 'IM Fell English', 'Cormorant Garamond', Georgia, serif;
    font-size: 18px;
    line-height: 1.55;
    overflow-x: hidden;
    position: relative;
}

/* Single tungsten light wash from upper-right (the lamp) */
.desktop-light {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background:
        radial-gradient(ellipse 60% 70% at 88% 12%, rgba(245, 219, 161, 0.42) 0%, rgba(245, 219, 161, 0.18) 30%, transparent 65%),
        radial-gradient(ellipse 90% 90% at 10% 90%, rgba(26, 15, 8, 0.55) 0%, transparent 70%);
    transition: opacity 0.6s ease;
}

.desktop-light.dim {
    opacity: 0.25;
}

.desktop-light.flicker {
    animation: lamp-flicker 0.28s steps(3) 1;
}

@keyframes lamp-flicker {
    0%   { opacity: 1; }
    33%  { opacity: 0.55; }
    66%  { opacity: 0.85; }
    100% { opacity: 1; }
}

.desktop-noise {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.18;
    background-image:
        radial-gradient(circle at 5% 5%, rgba(0,0,0,0.4) 1px, transparent 1px),
        radial-gradient(circle at 50% 70%, rgba(0,0,0,0.3) 1px, transparent 1px),
        radial-gradient(circle at 80% 30%, rgba(0,0,0,0.25) 1px, transparent 1px);
    background-size: 7px 7px, 11px 11px, 13px 13px;
}

/* Coffee ring stain on desk (lower-right of leather, outside folio) */
.desk-stain.coffee-ring {
    position: fixed;
    width: 80px;
    height: 80px;
    right: 80px;
    bottom: 220px;
    border: 3px solid rgba(107, 45, 26, 0.32);
    border-radius: 50%;
    box-shadow: inset 0 0 14px rgba(107, 45, 26, 0.18);
    pointer-events: none;
    z-index: 1;
    transform: rotate(-12deg);
}

.desk-stain.pin-prick {
    position: fixed;
    width: 4px;
    height: 4px;
    left: 6%;
    top: 38%;
    background: #1A0F08;
    border-radius: 50%;
    box-shadow: 0 0 2px rgba(0,0,0,0.6);
    pointer-events: none;
    z-index: 1;
}

/* ----- DESK OBJECTS (peripheral, not on the folio) ----- */

.desk-object {
    position: fixed;
    z-index: 5;
    pointer-events: auto;
    border: none;
    background: transparent;
    padding: 0;
}

.desk-object svg {
    display: block;
    filter: drop-shadow(2px 6px 10px rgba(0,0,0,0.55));
}

.lamp {
    top: 0;
    right: 24px;
    width: 180px;
    height: auto;
    cursor: pointer;
    transform-origin: 50% 100%;
}
.lamp svg { width: 100%; height: auto; }

.fountain-pen {
    top: 80px;
    left: 24px;
    width: 280px;
    transform-origin: 50% 50%;
    transition: transform 0.25s ease-out;
    pointer-events: none;
}
.fountain-pen svg { width: 100%; height: auto; transform: rotate(-18deg); }

.brandy-glass {
    bottom: 120px;
    left: 32px;
    width: 110px;
    pointer-events: none;
}
.brandy-glass svg { width: 100%; height: auto; }

.abacus {
    bottom: 80px;
    right: 32px;
    width: 180px;
    cursor: pointer;
}
.abacus svg { width: 100%; height: auto; }

.letter-bundle {
    bottom: 0;
    left: 50%;
    transform: translate(-50%, 40%);
    width: 220px;
    cursor: pointer;
    background: transparent;
    border: none;
    z-index: 5;
}
.letter-bundle svg { width: 100%; height: auto; }
.letter-bundle:hover { transform: translate(-50%, 32%); transition: transform 0.4s ease-out; }

/* ----- THE FOLIO ----- */

.folio {
    position: relative;
    width: 1280px;
    max-width: calc(100vw - 32px);
    margin: 96px auto 280px auto;
    background-color: #F5EAD2;
    /* aged folio paper: noise + horizontal hairline ruling + foxed margins */
    background-image:
        /* horizontal ruling: 24-line-per-inch hairlines in faint sepia */
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent 23px,
            rgba(200, 168, 120, 0.4) 23px,
            rgba(200, 168, 120, 0.4) 23.5px
        ),
        /* paper fibre */
        repeating-linear-gradient(
            91deg,
            rgba(168, 138, 85, 0.05) 0,
            rgba(168, 138, 85, 0.05) 1px,
            transparent 1px,
            transparent 6px
        ),
        radial-gradient(ellipse at 50% 0%, rgba(245, 219, 161, 0.5) 0%, transparent 40%),
        radial-gradient(ellipse at 0% 50%, rgba(232, 215, 176, 0.6) 0%, transparent 28%),
        radial-gradient(ellipse at 100% 50%, rgba(232, 215, 176, 0.6) 0%, transparent 28%);
    box-shadow:
        0 0 0 1px rgba(120, 90, 50, 0.4),
        0 8px 30px rgba(0,0,0,0.4),
        0 30px 80px rgba(0,0,0,0.35),
        inset 0 0 60px rgba(168, 138, 85, 0.18);
    z-index: 3;
    color: #3B2A1D;
    padding: 0;
    transform: translateY(40px);
    opacity: 0;
    animation: folio-rise 1.4s ease-out 0.2s forwards;
}

@keyframes folio-rise {
    to { transform: translateY(0); opacity: 1; }
}

/* Marbled endpaper at the very top */
.endpaper {
    width: 100%;
    height: 60px;
    overflow: hidden;
    border-bottom: 1px solid #6B2D1A;
}
.endpaper svg { display: block; width: 100%; height: 100%; }

/* ----- 1. FOLIO HEAD ----- */

.folio-head {
    padding: 36px 96px 32px 96px;
    position: relative;
}

.running-head {
    position: absolute;
    top: 80px;
    font-family: 'IM Fell English', serif;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #7A4A1F;
}
.verso-head { left: 96px; }
.recto-head { right: 96px; text-align: right; }

.running-title {
    font-family: 'IM Fell English', serif;
    font-size: 12px;
    letter-spacing: 0.32em;
    text-align: center;
    text-transform: uppercase;
    color: #6B2D1A;
    margin-top: 36px;
}

.double-rule {
    margin: 20px auto 28px auto;
    height: 5px;
    border-top: 1px solid #6B2D1A;
    border-bottom: 1px solid #6B2D1A;
    width: 88%;
}

.folio-title {
    font-family: 'IM Fell English', serif;
    font-style: italic;
    font-weight: 400;
    font-size: 28px;
    line-height: 1.3;
    color: #3B2A1D;
    text-align: left;
    padding-left: 0;
    position: relative;
}

.drop-cap {
    float: left;
    width: 130px;
    height: 130px;
    margin: 4px 18px -10px -8px;
    color: #6B2D1A;
}
.drop-cap svg { width: 100%; height: 100%; }

#drop-cap-T {
    fill: #6B2D1A;
    fill-opacity: 0;
    transition: fill-opacity 0.6s ease 1.6s;
}
#drop-cap-T.drawn {
    fill-opacity: 1;
    animation: ink-spread 2s ease-out;
}
@keyframes ink-spread {
    0%   { fill-opacity: 0; }
    100% { fill-opacity: 1; }
}

.title-rest {
    /* flows around drop cap */
}

/* ----- 2. THE DAY'S STANDING ----- */

.standing {
    padding: 36px 96px 32px 96px;
    border-top: 0.5px solid #C8A878;
    border-bottom: 0.5px solid #C8A878;
    margin-top: 24px;
}

.register-label {
    font-family: 'Pinyon Script', cursive;
    font-size: 32px;
    color: #6B2D1A;
    text-align: center;
    margin-bottom: 24px;
    font-weight: 400;
}

.standing-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 32px;
}

.standing-cell {
    text-align: center;
    position: relative;
    padding: 0 8px;
}

.standing-label {
    display: block;
    font-family: 'IM Fell English', serif;
    font-style: italic;
    font-size: 13px;
    color: #7A4A1F;
    text-transform: lowercase;
    letter-spacing: 0.04em;
    margin-bottom: 12px;
}

.standing-figure {
    display: block;
    font-family: 'Cormorant Garamond', serif;
    font-feature-settings: 'onum' 1, 'liga' 1;
    font-size: 30px;
    font-style: italic;
    font-weight: 500;
    color: #3B2A1D;
    letter-spacing: 0.01em;
    min-height: 40px;
}

.hairline {
    display: block;
    margin: 12px auto 0 auto;
    height: 1px;
    width: 70%;
    background: #6B2D1A;
}

/* ----- 3. THE OPEN LEDGER ----- */

.ledger {
    display: grid;
    grid-template-columns: 1fr 24px 1fr;
    gap: 0;
    padding: 32px 0 24px 0;
    position: relative;
}

.ledger-page {
    padding: 0 96px;
    position: relative;
    /* vertical rule between description and figure */
    background-image:
        linear-gradient(to right, transparent calc(100% - 142px), #A88A55 calc(100% - 142px), #A88A55 calc(100% - 141px), transparent calc(100% - 141px));
}

.ledger-page.recto {
    background-image:
        linear-gradient(to right, transparent calc(100% - 142px), #A88A55 calc(100% - 142px), #A88A55 calc(100% - 141px), transparent calc(100% - 141px));
}

.ledger-head {
    font-family: 'IM Fell English', serif;
    font-size: 14px;
    letter-spacing: 0.32em;
    color: #6B2D1A;
    text-align: center;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.ledger-subhead {
    font-family: 'IM Fell English', serif;
    font-style: italic;
    font-weight: 400;
    font-size: 12px;
    color: #7A4A1F;
    text-align: center;
    margin-bottom: 18px;
}

.ledger-entries {
    list-style: none;
    counter-reset: ledger;
}

.ledger-line {
    display: grid;
    grid-template-columns: 56px 1fr 110px;
    gap: 8px;
    align-items: baseline;
    padding: 6px 0 5px 0;
    border-bottom: 0.5px solid rgba(200, 168, 120, 0.55);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
    position: relative;
}

.ledger-line.shown {
    opacity: 1;
    transform: translateY(0);
}

.ledger-line.hover-highlight ~ .ledger-line { /* ignore */ }

.entry-no {
    font-family: 'Cormorant Garamond', serif;
    font-feature-settings: 'onum' 1;
    font-style: italic;
    font-size: 14px;
    color: #7A4A1F;
    text-align: left;
}

.entry-desc {
    font-family: 'IM Fell English', serif;
    font-size: 14px;
    line-height: 1.5;
    color: #3B2A1D;
    padding-right: 8px;
}

.entry-fig {
    font-family: 'Cormorant Garamond', serif;
    font-feature-settings: 'onum' 1;
    font-size: 16px;
    font-style: italic;
    color: #3B2A1D;
    text-align: right;
    white-space: nowrap;
}

.ref {
    font-style: normal;
    font-size: 11px;
    color: #6B2D1A;
    margin-left: 4px;
}
.ref sup { font-size: 9px; }

.ledger-line.subtotal {
    margin-top: 12px;
    border-top: 1px solid #6B2D1A;
    border-bottom: none;
    padding-top: 10px;
}
.ledger-line.subtotal .entry-desc {
    font-style: italic;
    color: #6B2D1A;
}
.ledger-line.subtotal .entry-fig {
    font-weight: 500;
    color: #6B2D1A;
}

.oxblood-underline {
    border-bottom: 1.6px double #6B2D1A;
    padding-bottom: 1px;
    color: #6B2D1A;
}

/* Hover highlight on a ledger line illuminates its marginalia row */
.ledger-line:hover {
    background: linear-gradient(to right, transparent, rgba(245, 219, 161, 0.55), transparent);
    cursor: default;
}
.ledger-line:hover ~ .marginalia { /* unused, see JS */ }

/* ----- THE BINDING GUTTER (real, with stitches) ----- */

.binding-gutter {
    background:
        linear-gradient(
            to right,
            transparent 0%,
            rgba(120, 90, 50, 0.35) 12%,
            rgba(120, 90, 50, 0.55) 50%,
            rgba(120, 90, 50, 0.35) 88%,
            transparent 100%
        ),
        repeating-linear-gradient(
            to bottom,
            #E8D7B0 0,
            #E8D7B0 1px,
            #D4BE92 1px,
            #D4BE92 2px
        );
    position: relative;
    box-shadow:
        inset 4px 0 6px rgba(0,0,0,0.18),
        inset -4px 0 6px rgba(0,0,0,0.18);
}

.stitch-line {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    padding: 24px 0;
    align-items: center;
}

.stitch-line span {
    display: block;
    width: 12px;
    height: 1.5px;
    background: #3B2A1D;
    box-shadow: 0 0 1px rgba(0,0,0,0.4);
}

/* ----- 4. MARGINALIA ----- */

.marginalia {
    position: absolute;
    top: 30px;
    width: 84px;
    font-family: 'Pinyon Script', cursive;
    font-size: 13px;
    line-height: 1.45;
    pointer-events: none;
}

.verso-margin {
    left: 6px;
    transform: rotate(-1.5deg);
    text-align: right;
    padding-right: 6px;
    background:
        linear-gradient(to right, rgba(232, 215, 176, 0.65), rgba(232, 215, 176, 0.0));
}

.recto-margin {
    right: 6px;
    transform: rotate(1.5deg);
    text-align: left;
    padding-left: 6px;
    background:
        linear-gradient(to left, rgba(232, 215, 176, 0.65), rgba(232, 215, 176, 0.0));
}

.marginalia-note {
    margin-bottom: 18px;
    font-family: 'Pinyon Script', cursive;
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.recto-margin .marginalia-note { transform: translateX(8px); }

.marginalia-note.shown {
    opacity: 1;
    transform: translateX(0);
}

.marginalia-note.red {
    color: #6B2D1A;
}
.marginalia-note.sepia {
    color: #7A4A1F;
}

.marginalia-note .swsh {
    font-family: 'Pinyon Script', cursive;
    font-size: 22px;
    line-height: 0.6;
    margin-right: 1px;
    font-feature-settings: 'swsh' 1;
}

/* ----- 5. THE BLOTTER ----- */

.blotter-register {
    padding: 36px 96px;
}

.blotter {
    position: relative;
    background:
        repeating-linear-gradient(
            45deg,
            rgba(31, 77, 46, 0.25) 0,
            rgba(31, 77, 46, 0.25) 1px,
            transparent 1px,
            transparent 4px
        ),
        repeating-linear-gradient(
            -45deg,
            rgba(0, 0, 0, 0.06) 0,
            rgba(0, 0, 0, 0.06) 1px,
            transparent 1px,
            transparent 5px
        ),
        radial-gradient(ellipse at 30% 30%, #2C6A45 0%, #1F4D2E 60%, #142E1B 100%);
    border-radius: 6px;
    padding: 32px 28px 28px 28px;
    min-height: 220px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    color: #F5EAD2;
    box-shadow:
        0 6px 16px rgba(0,0,0,0.35),
        inset 0 0 30px rgba(0,0,0,0.4);
    transform: translateX(40px);
    opacity: 0;
    transition: transform 1s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.8s ease;
}
.blotter-register.shown .blotter {
    transform: translateX(0);
    opacity: 1;
}

.blotter-tooling {
    position: absolute;
    inset: 6px;
    border: 1.5px solid #B79253;
    border-radius: 4px;
    pointer-events: none;
    box-shadow: inset 0 0 8px rgba(183, 146, 83, 0.4);
}

.blotter-grain { display: none; }

.paperweight {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%) translateY(-200px);
    width: 80px;
    height: 80px;
    z-index: 4;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.blotter-register.shown .paperweight {
    transform: translateX(-50%) translateY(0);
}

.blotter-register.shown.shaken {
    animation: desk-shake 0.18s ease-out;
}

@keyframes desk-shake {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-2px, 2px); }
    50% { transform: translate(2px, -1px); }
    75% { transform: translate(-1px, 1px); }
}

.clipping {
    background: #F5EAD2;
    color: #3B2A1D;
    padding: 14px 16px;
    font-family: 'Cormorant Garamond', serif;
    font-feature-settings: 'onum' 1;
    font-size: 12px;
    line-height: 1.55;
    box-shadow:
        0 3px 6px rgba(0,0,0,0.4),
        inset 0 0 8px rgba(168, 138, 85, 0.18);
    border: 0.5px solid #C8A878;
    transform: rotate(-1deg);
}
.clipping-2 { transform: rotate(0.6deg); }
.clipping-3 { transform: rotate(-0.4deg); }

.dateline {
    font-family: 'IM Fell English', serif;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.18em;
    color: #6B2D1A;
    text-transform: uppercase;
    margin-bottom: 6px;
    border-bottom: 0.5px solid #6B2D1A;
    padding-bottom: 4px;
}

.clipping-body {
    font-family: 'IM Fell English', serif;
    font-size: 12px;
    line-height: 1.55;
    margin-bottom: 6px;
}

.signoff {
    font-family: 'IM Fell English', serif;
    font-size: 10px;
    letter-spacing: 0.22em;
    color: #7A4A1F;
    text-align: center;
    text-transform: uppercase;
}

/* ----- 6. THE FOREIGN CORRESPONDENCE ----- */

.correspondence {
    padding: 40px 96px 24px 96px;
}

.correspondence-inner {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 36px;
    align-items: start;
}

.vignette {
    text-align: center;
}
.vignette svg {
    display: block;
    width: 192px;
    height: 128px;
    margin: 0 auto;
}
.vignette-cap {
    margin-top: 6px;
    font-family: 'IM Fell English', serif;
    font-style: italic;
    font-size: 11px;
    color: #7A4A1F;
}

.letter {
    position: relative;
    background: #F5EAD2;
    padding: 28px 32px 28px 32px;
    box-shadow:
        0 2px 8px rgba(0,0,0,0.18),
        inset 0 0 30px rgba(168, 138, 85, 0.12);
    border: 0.5px solid #C8A878;
    min-height: 220px;
}

.letter-from {
    font-family: 'IM Fell English', serif;
    font-size: 11px;
    letter-spacing: 0.28em;
    color: #6B2D1A;
    text-transform: uppercase;
    margin-bottom: 14px;
    border-bottom: 0.5px solid #6B2D1A;
    padding-bottom: 6px;
}

.wax-seal {
    position: absolute;
    top: -28px;
    right: 32px;
    width: 80px;
    height: 80px;
    cursor: pointer;
    z-index: 4;
    filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.45));
}
.wax-seal svg { width: 100%; height: 100%; display: block; }

.seal-half {
    transform-origin: 60px 60px;
    transition: transform 0.9s cubic-bezier(0.4, 1.7, 0.6, 1);
}
.wax-seal[data-broken="true"] .left-half {
    transform: translate(-22px, 6px) rotate(-14deg);
}
.wax-seal[data-broken="true"] .right-half {
    transform: translate(22px, 6px) rotate(14deg);
}
.wax-seal[data-broken="true"] .crack {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.4s ease-out;
}

.letter-body {
    font-family: 'IM Fell English', serif;
    font-size: 14px;
    line-height: 1.65;
    color: #3B2A1D;
    max-height: 0;
    overflow: hidden;
    transition: max-height 1.2s ease-out, opacity 0.8s ease 0.3s;
    opacity: 0;
}

.wax-seal[data-broken="true"] ~ .letter-body,
.letter-body.unfolded {
    max-height: 600px;
    opacity: 1;
}

.dispatch-dateline {
    font-family: 'IM Fell English', serif;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.2em;
    color: #6B2D1A;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.dispatch-text {
    margin-bottom: 16px;
    font-style: normal;
    text-align: justify;
}

.signature-flourish {
    display: inline-block;
    width: 180px;
    height: 36px;
    vertical-align: middle;
    margin-left: 4px;
}
.signature-flourish svg { width: 100%; height: 100%; }
.signature-flourish path {
    transition: stroke-dashoffset 1.4s ease-out;
}
.signature-flourish.drawn path {
    stroke-dashoffset: 0 !important;
}

.dispatch-sign {
    text-align: right;
    font-family: 'Pinyon Script', cursive;
    font-size: 22px;
    color: #3B2A1D;
    margin-top: -4px;
}

/* ----- 7. FOLIO FOOT ----- */

.folio-foot {
    padding: 32px 96px 56px 96px;
    border-top: 1px solid #6B2D1A;
    border-bottom: 1px solid #6B2D1A;
    margin: 32px 24px 24px 24px;
    border-left: 0.5px solid #C8A878;
    border-right: 0.5px solid #C8A878;
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 12px 32px;
}

.footnotes {
    font-family: 'IM Fell English', serif;
    font-style: italic;
    font-size: 12px;
    color: #3B2A1D;
}
.footnotes p {
    margin-bottom: 4px;
}
.footnotes sup {
    color: #6B2D1A;
    margin-right: 3px;
}
.verso-foot { text-align: left; }
.recto-foot { text-align: right; }

.catchword-line {
    grid-column: 1 / -1;
    margin-top: 24px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 8px 0 0 0;
    border-top: 0.5px dotted #7A4A1F;
}

.catchword {
    font-family: 'Pinyon Script', cursive;
    font-size: 32px;
    color: #6B2D1A;
}

.cont {
    font-family: 'IM Fell English', serif;
    font-style: italic;
    font-size: 12px;
    color: #7A4A1F;
}

/* Dog-ear */
.dog-ear {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 32px;
    height: 32px;
    cursor: pointer;
    background: linear-gradient(135deg, transparent 50%, #E8D7B0 50%);
    transition: width 0.3s ease, height 0.3s ease;
    z-index: 6;
}
.dog-ear::after {
    content: "";
    position: absolute;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, transparent 49.5%, rgba(120, 90, 50, 0.4) 50%, transparent 51%);
}
.dog-ear:hover {
    width: 60px;
    height: 60px;
}

.dog-ear-back {
    display: none;
}

.folio.flipping {
    animation: page-turn 1.2s cubic-bezier(0.55, 0.08, 0.4, 1) forwards;
    transform-origin: right center;
    transform-style: preserve-3d;
    perspective: 1600px;
}

@keyframes page-turn {
    0% { transform: rotateY(0); }
    100% { transform: rotateY(-12deg) translateX(-30px); opacity: 0.6; filter: brightness(0.7); }
}

/* ----- REVEAL CLASSES ----- */

.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease, transform 1s ease;
}
.reveal.shown {
    opacity: 1;
    transform: translateY(0);
}

/* ----- MODAL (currency cross-rates) ----- */

.modal-veil {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(26, 15, 8, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 32px;
}
.modal-veil.open {
    display: flex;
}

.modal-card {
    background: #F5EAD2;
    background-image:
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent 22px,
            rgba(200, 168, 120, 0.4) 22px,
            rgba(200, 168, 120, 0.4) 22.5px
        );
    width: min(580px, 100%);
    padding: 32px 40px;
    border: 0.5px solid #6B2D1A;
    box-shadow: 0 24px 60px rgba(0,0,0,0.55);
    position: relative;
}

.modal-close {
    position: absolute;
    top: 8px;
    right: 12px;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    font-family: 'IM Fell English', serif;
    font-size: 24px;
    color: #6B2D1A;
    cursor: pointer;
    line-height: 1;
}

.modal-card h3 {
    font-family: 'Pinyon Script', cursive;
    font-size: 28px;
    color: #6B2D1A;
    margin-bottom: 16px;
    font-weight: 400;
    text-align: center;
}

.cross-rates {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Cormorant Garamond', serif;
    font-feature-settings: 'onum' 1;
    font-size: 16px;
    color: #3B2A1D;
}

.cross-rates th, .cross-rates td {
    padding: 6px 10px;
    text-align: right;
    border-bottom: 0.5px solid #C8A878;
    font-style: italic;
}
.cross-rates thead th {
    color: #6B2D1A;
    font-weight: 600;
    border-bottom: 1px solid #6B2D1A;
}
.cross-rates tbody th {
    text-align: left;
    color: #6B2D1A;
    font-weight: 600;
}

.modal-foot {
    margin-top: 16px;
    font-family: 'IM Fell English', serif;
    font-size: 12px;
    color: #7A4A1F;
    text-align: center;
}

/* ----- High-DPI ruling ----- */

@media (min-resolution: 2dppx) {
    .folio {
        background-image:
            repeating-linear-gradient(
                to bottom,
                transparent 0,
                transparent 23px,
                rgba(200, 168, 120, 0.5) 23px,
                rgba(200, 168, 120, 0.5) 23.25px
            ),
            repeating-linear-gradient(
                91deg,
                rgba(168, 138, 85, 0.05) 0,
                rgba(168, 138, 85, 0.05) 0.5px,
                transparent 0.5px,
                transparent 6px
            ),
            radial-gradient(ellipse at 50% 0%, rgba(245, 219, 161, 0.5) 0%, transparent 40%),
            radial-gradient(ellipse at 0% 50%, rgba(232, 215, 176, 0.6) 0%, transparent 28%),
            radial-gradient(ellipse at 100% 50%, rgba(232, 215, 176, 0.6) 0%, transparent 28%);
    }
}

/* ----- Responsive trim (the page is fundamentally 1280px portrait) ----- */
@media (max-width: 1320px) {
    .lamp { width: 140px; right: 4px; }
    .fountain-pen { width: 200px; left: 4px; top: 60px; }
    .brandy-glass { width: 84px; left: 6px; bottom: 80px; }
    .abacus { width: 130px; right: 6px; bottom: 60px; }
    .letter-bundle { width: 160px; }
}

@media (max-width: 900px) {
    .folio { padding: 0; }
    .folio-head { padding: 28px 24px; }
    .standing { padding: 24px; }
    .standing-row { grid-template-columns: 1fr; gap: 18px; }
    .ledger { grid-template-columns: 1fr; }
    .ledger-page { padding: 0 24px; }
    .binding-gutter { display: none; }
    .marginalia { position: relative; width: auto; left: 0; right: 0; transform: none; padding: 12px 24px; }
    .verso-margin, .recto-margin { background: transparent; text-align: left; }
    .blotter-register { padding: 24px; }
    .blotter { grid-template-columns: 1fr; }
    .correspondence { padding: 24px; }
    .correspondence-inner { grid-template-columns: 1fr; }
    .folio-foot { padding: 24px; margin: 24px; grid-template-columns: 1fr; }
    .recto-foot { text-align: left; }
    .lamp, .fountain-pen, .brandy-glass, .abacus, .letter-bundle, .desk-stain { display: none; }
    .folio-title { font-size: 22px; }
    .drop-cap { width: 80px; height: 80px; }
}
