/* The bookcase and its books: old, worn and each one different. */
:root {
    --tex-leather: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='f' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='3' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.08  0 0 0 0 0.04  0 0 0 0 0.02  1.5 0 0 0 -0.58'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
    --tex-scuff: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='f' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.16' numOctaves='3' seed='9' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 0.93  0 0 0 0 0.8  1.5 0 0 0 -0.85'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
    --tex-paper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='f' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='3' seed='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.35  0 0 0 0 0.24  0 0 0 0 0.1  0.9 0 0 0 -0.38'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
    --tex-stain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='f' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012' numOctaves='4' seed='6' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45  0 0 0 0 0.27  0 0 0 0 0.08  1.3 0 0 0 -0.62'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
    --tex-woodv: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='f' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.28 .006' numOctaves='3' seed='5' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.05  0 0 0 0 0.02  0 0 0 0 0.0  2.2 0 0 0 -0.9'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
    --tex-woodh: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='f' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.006 .3' numOctaves='3' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.05  0 0 0 0 0.02  0 0 0 0 0.0  2.2 0 0 0 -0.9'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
    --tex-marble: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='f' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='turbulence' baseFrequency='.009 .02' numOctaves='4' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0.6 0.6 0.6 0 0  0.6 0.6 0.6 0 0  0.6 0.6 0.6 0 0  0 0 0 0 1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");}

/* ===== The bookcase ===== */

.case {
    --scale: 1;
    background:
        var(--tex-woodv),
        linear-gradient(180deg, #4d2f19, #2d190c);
    border-radius: 12px 12px 4px 4px;
    box-shadow:
        0 0 0 2px #1a0e05,
        inset 0 2px 0 rgba(255, 220, 170, 0.18),
        0 30px 40px -22px rgba(30, 12, 0, 0.7);
    padding: 16px 16px 0;
    position: relative;
}

.shelf-row {
    align-items: flex-end;
    background:
        radial-gradient(ellipse 70% 90% at 22% 0%, rgba(255, 196, 120, 0.3), transparent 62%),
        linear-gradient(180deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.12) 42%, rgba(0, 0, 0, 0.4)),
        var(--tex-woodv),
        #3a2312;
    box-shadow:
        inset 0 16px 24px -8px rgba(0, 0, 0, 0.75),
        inset 14px 0 18px -10px rgba(0, 0, 0, 0.7),
        inset -14px 0 18px -10px rgba(0, 0, 0, 0.7);
    display: flex;
    gap: 1px;
    overflow-x: auto;
    padding: 46px 26px 0;
    scrollbar-width: none;
}

.shelf-row::-webkit-scrollbar {
    display: none;
}

.shelf-board {
    background:
        var(--tex-woodh),
        linear-gradient(180deg, #9a6a3d 0, #6b4223 28%, #46290f 100%);
    border-radius: 0 0 3px 3px;
    box-shadow:
        inset 0 3px 0 rgba(255, 224, 170, 0.35),
        inset 0 -4px 0 rgba(0, 0, 0, 0.35),
        0 12px 14px -6px rgba(20, 8, 0, 0.6);
    height: 26px;
    margin: 0 -16px;
}

.shelf-hint {
    color: var(--muted);
    font-style: italic;
    margin: 20px 0 0;
    text-align: center;
}

/* ===== A book's spine ===== */

.vol {
    --sheen: linear-gradient(90deg, rgba(0, 0, 0, 0.55) 0, rgba(255, 255, 255, 0.2) 15%, rgba(255, 255, 255, 0) 36%, rgba(0, 0, 0, 0.1) 72%, rgba(0, 0, 0, 0.62) 100%);
    appearance: none;
    background-color: var(--c);
    background-image:
        var(--sheen),
        linear-gradient(180deg, rgba(255, 255, 255, calc(var(--fade) * 0.9)), transparent 38%, transparent 72%, rgba(0, 0, 0, 0.28)),
        radial-gradient(ellipse 60% 34% at var(--stain-x) var(--stain-y), rgba(45, 22, 0, 0.4), transparent 70%),
        var(--tex-leather);
    border: 0;
    border-radius: 2px 3px 0 0 / 4px 3px 0 0;
    box-shadow:
        inset 2px 0 0 rgba(255, 255, 255, 0.12),
        inset -3px 0 5px rgba(0, 0, 0, 0.4),
        7px 0 12px -5px rgba(0, 0, 0, 0.65);
    color: var(--foil);
    cursor: pointer;
    display: block;
    flex: none;
    font: inherit;
    height: calc(var(--vh) * var(--scale, 1));
    margin: 0;
    overflow: hidden;
    padding: 0;
    position: relative;
    transform: rotate(var(--tilt, 0deg));
    transform-origin: 50% 100%;
    transition: transform 0.25s ease, filter 0.25s ease, opacity 0.2s ease;
    width: calc(var(--vw) * var(--scale, 1));
}

.vol.cloth {
    background-image:
        var(--sheen),
        linear-gradient(180deg, rgba(255, 255, 255, calc(var(--fade) * 0.9)), transparent 38%, transparent 72%, rgba(0, 0, 0, 0.28)),
        radial-gradient(ellipse 60% 34% at var(--stain-x) var(--stain-y), rgba(45, 22, 0, 0.4), transparent 70%),
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.12) 0 1px, transparent 1px 3px),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.07) 0 1px, transparent 1px 3px);
}

span.vol {
    cursor: default;
}

button.vol:hover,
button.vol:focus-visible {
    filter: drop-shadow(8px 6px 8px rgba(0, 0, 0, 0.55)) brightness(1.1);
    transform: translateY(-16px) rotate(var(--tilt, 0deg));
}

button.vol:focus-visible {
    outline: 3px solid var(--cyan);
    outline-offset: 2px;
}

.vol.is-out {
    opacity: 0;
    pointer-events: none;
}

.vol-wear {
    background:
        radial-gradient(ellipse 90% 7% at 50% 0%, rgba(236, 212, 172, calc(var(--wear) * 0.55)), transparent 80%),
        radial-gradient(ellipse 80% 6% at 50% 100%, rgba(236, 212, 172, calc(var(--wear) * 0.6)), transparent 80%),
        linear-gradient(90deg, rgba(236, 212, 172, calc(var(--wear) * 0.22)) 0, transparent 9%, transparent 91%, rgba(236, 212, 172, calc(var(--wear) * 0.2)) 100%),
        linear-gradient(90deg, transparent 9%, rgba(0, 0, 0, 0.32) 9.6%, transparent 10.6%, transparent 89.4%, rgba(0, 0, 0, 0.3) 90.2%, transparent 91.2%),
        var(--tex-scuff);
    inset: 0;
    opacity: 0.5;
    pointer-events: none;
    position: absolute;
}

.vol-head,
.vol-foot {
    left: 0;
    position: absolute;
    right: 0;
}

.vol-head {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.12) 70%, transparent);
    height: 6%;
    top: 0;
}

.vol-foot {
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.5), transparent);
    bottom: 0;
    height: 5%;
}

.band {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.3), rgba(0, 0, 0, 0.04) 45%, rgba(0, 0, 0, 0.5));
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.55), 0 -1px 0 rgba(255, 255, 255, 0.14);
    height: 8px;
    left: 0;
    position: absolute;
    right: 0;
    transform: translateY(-50%);
}

.band::before,
.band::after {
    background: var(--foil);
    content: "";
    height: 1.5px;
    left: 0;
    opacity: 0.8;
    position: absolute;
    right: 0;
}

.band::before { top: -6px; }
.band::after { bottom: -6px; }

.vol-label {
    align-items: center;
    display: flex;
    height: 54%;
    justify-content: center;
    left: 50%;
    overflow: hidden;
    position: absolute;
    transform: translate(-50%, -50%);
    width: 74%;
    z-index: 2;
}

.label-paper .vol-label {
    background:
        var(--tex-stain),
        var(--paper-label);
    border: 1px solid rgba(60, 38, 10, 0.55);
    box-shadow: inset 0 0 7px rgba(120, 78, 20, 0.5), 1px 1px 2px rgba(0, 0, 0, 0.55);
    color: var(--label-ink);
}

.label-panel .vol-label {
    background: var(--c-dark);
    box-shadow: inset 0 0 0 2px var(--c-dark), inset 0 0 0 3px var(--foil), 1px 1px 2px rgba(0, 0, 0, 0.5);
    color: var(--foil);
}

.label-gilt .vol-label {
    color: var(--foil);
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.7), 0 -1px 0 rgba(255, 255, 210, 0.2);
}

.vol-label.blank {
    background: none;
    border: 0;
    box-shadow: none;
    color: var(--foil);
    opacity: 0.85;
}

.vol-label.blank .orn {
    width: 38%;
}

.vol-title {
    display: block;
    font-size: calc(clamp(11px, calc(var(--vw) * 0.24 * var(--scale, 1)), 17px) * var(--tl, 1));
    font-weight: 700;
    line-height: 1.05;
    max-height: 100%;
    overflow: hidden;
    padding: 4px 0;
    text-align: center;
    text-overflow: ellipsis;
    transform: rotate(180deg);
    white-space: nowrap;
    writing-mode: vertical-rl;
}

.vol-title.caps {
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.vol-title.italic {
    font-style: italic;
}

.vol-orn {
    bottom: 15%;
    color: var(--foil);
    left: 50%;
    opacity: 0.9;
    position: absolute;
    transform: translateX(-50%);
    width: 40%;
    z-index: 1;
}

.orn {
    display: block;
    overflow: visible;
    width: 100%;
}

/* ===== The reading room ===== */

body.room-open {
    overflow: hidden;
}

.room {
    --d: 320px;
    --h: 454px;
    --t: 48px;
    display: block;
    inset: 0;
    opacity: 0;
    overflow: hidden;
    position: fixed;
    transition: opacity 0.2s ease;
    z-index: 200;
}

.room.on {
    opacity: 1;
}

.room-backdrop {
    background: radial-gradient(ellipse at 50% 40%, rgba(58, 32, 14, 0.9), rgba(12, 6, 3, 0.97));
    inset: 0;
    position: absolute;
}

.room-floor {
    background:
        linear-gradient(180deg, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.1) 45%),
        var(--tex-woodh),
        #35200f;
    bottom: 0;
    box-shadow: inset 0 3px 0 rgba(255, 210, 150, 0.12);
    left: 0;
    pointer-events: none;
    position: absolute;
    right: 0;
    top: calc(46% + var(--h) / 2 + 2px);
}

.room-floor::before {
    background: radial-gradient(ellipse at 50% 0%, rgba(0, 0, 0, 0.75), transparent 68%);
    content: "";
    height: 70px;
    left: 50%;
    position: absolute;
    top: -6px;
    transform: translateX(-50%);
    width: min(720px, 92vw);
}

.room-dust {
    background: radial-gradient(ellipse at 50% 60%, rgba(214, 190, 150, 0.7), transparent 66%);
    height: 80px;
    left: 50%;
    opacity: 0;
    pointer-events: none;
    position: absolute;
    top: calc(46% + var(--h) / 2 - 40px);
    transform: translateX(-50%);
    width: min(520px, 90vw);
}

.room-dust.puff {
    animation: puff 1s ease-out;
}

@keyframes puff {
    0% { opacity: 0.85; transform: translateX(-50%) scale(0.2, 0.3); }
    100% { opacity: 0; transform: translateX(-50%) scale(1.3, 1); }
}

.scene {
    height: 0;
    left: 50%;
    perspective: 1900px;
    perspective-origin: 50% 40%;
    position: absolute;
    top: 46%;
    width: 0;
}

.fly,
.shift {
    left: 0;
    position: absolute;
    top: 0;
    transform-style: preserve-3d;
}

.book {
    --paper: #e8dab4;
    height: var(--h);
    left: calc(var(--d) / -2);
    position: absolute;
    top: calc(var(--h) / -2);
    transform-style: preserve-3d;
    width: var(--d);
}

.face {
    backface-visibility: hidden;
    position: absolute;
}

.f-back {
    background:
        radial-gradient(ellipse 60% 40% at var(--stain-x) var(--stain-y), rgba(45, 22, 0, 0.35), transparent 70%),
        var(--tex-leather),
        var(--c);
    height: var(--h);
    left: 0;
    top: 0;
    transform: translateZ(calc(var(--t) / -2)) rotateY(180deg);
    width: var(--d);
}

.f-spine {
    height: var(--h);
    left: calc(var(--t) / -2);
    top: 0;
    transform: rotateY(-90deg);
    width: var(--t);
}

.f-spine .vol {
    border-radius: 0;
    box-shadow: none;
    height: 100%;
    transform: none;
    width: 100%;
}

.f-right,
.f-top,
.f-bottom {
    background:
        repeating-linear-gradient(var(--edge-dir, 90deg), rgba(110, 80, 36, 0.35) 0 1px, transparent 1px 3px),
        var(--tex-paper),
        #d9c89c;
    box-shadow: inset 0 0 12px rgba(90, 60, 20, 0.5);
}

.f-right {
    --edge-dir: 0deg;
    height: calc(var(--h) - 8px);
    left: calc(var(--d) - var(--t) / 2 + 3px);
    top: 4px;
    transform: rotateY(90deg) translateZ(-3px);
    width: calc(var(--t) - 6px);
}

.f-top {
    height: calc(var(--t) - 6px);
    left: 3px;
    top: calc(var(--t) / -2 + 3px);
    transform: rotateX(90deg) translateZ(-3px);
    width: calc(var(--d) - 6px);
}

.f-bottom {
    height: calc(var(--t) - 6px);
    left: 3px;
    top: calc(var(--h) - var(--t) / 2 + 3px);
    transform: rotateX(-90deg) translateZ(-3px);
    width: calc(var(--d) - 6px);
}

/* the right-hand page */

.leaf {
    backface-visibility: hidden;
    background:
        linear-gradient(90deg, rgba(60, 38, 8, 0.38), transparent 7%),
        radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(110, 70, 20, 0.32)),
        var(--tex-stain),
        var(--tex-paper),
        var(--paper);
    box-shadow: 1px 1px 0 #ddcfa3, 2px 2px 0 #d1c190, 3px 3px 0 #c6b585, 4px 4px 0 #b9a877;
    color: #2b1b0b;
    font-family: Georgia, "Times New Roman", serif;
    height: calc(var(--h) - 8px);
    left: 3px;
    overflow: hidden;
    position: absolute;
    top: 4px;
    transform: translateZ(calc(var(--t) / 2 - 5px));
    width: calc(var(--d) - 6px);
}

.leaf-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    overflow-y: auto;
    padding: 9% 9% 7% 11%;
    scrollbar-color: rgba(90, 60, 20, 0.45) transparent;
    scrollbar-width: thin;
}

.leaf-rule {
    background:
        linear-gradient(#2b1b0b, #2b1b0b) 0 0 / 100% 1px no-repeat,
        linear-gradient(#2b1b0b, #2b1b0b) 0 4px / 100% 2px no-repeat;
    flex: none;
    height: 7px;
    opacity: 0.75;
}

.leaf-rule.low {
    margin-top: auto;
}

.leaf-title {
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.25rem, calc(var(--d) * 0.075), 1.9rem);
    font-variant: small-caps;
    letter-spacing: 0.04em;
    line-height: 1.12;
    margin: 4px 0 0;
    text-align: center;
}

.leaf-tags {
    color: #6b4a22;
    font-size: 0.78rem;
    font-style: italic;
    letter-spacing: 0.06em;
    margin: 0;
    text-align: center;
}

.leaf-plate {
    border: 5px solid #f3ead0;
    box-shadow: 0 2px 6px rgba(40, 20, 0, 0.5);
    display: none;
    height: auto;
    max-height: 150px;
    object-fit: cover;
    object-position: top;
    transform: rotate(-1deg);
    width: 100%;
}

.leaf-desc {
    font-size: clamp(0.82rem, calc(var(--d) * 0.045), 1rem);
    hyphens: auto;
    line-height: 1.55;
    margin: 0;
    text-align: justify;
}

.leaf-desc.dropcap::first-letter {
    color: var(--c);
    float: left;
    font-size: 3.1em;
    line-height: 0.82;
    margin: 0.06em 0.08em 0 0;
}

.leaf-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-top: 6px;
}

.stamp-link {
    border: 2px double var(--c);
    color: var(--c);
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    padding: 8px 14px;
    text-decoration: none;
    text-transform: uppercase;
    transform: rotate(-2deg);
    transition: background 0.2s ease, color 0.2s ease;
}

.stamp-link:hover,
.stamp-link:focus-visible {
    background: var(--c);
    color: #f1e6c6;
}

.leaf .link-button {
    color: #2b1b0b;
    font-family: inherit;
    font-size: 0.85rem;
}

.admin-actions {
    display: inline-flex;
    gap: 12px;
}

/* the cover, hinged on the spine side */

.cover3d {
    height: 100%;
    left: 0;
    position: absolute;
    top: 0;
    transform: translateZ(calc(var(--t) / 2));
    transform-origin: 0 50%;
    transform-style: preserve-3d;
    transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
}

.book.is-open .cover3d {
    transform: translateZ(calc(var(--t) / 2)) rotateY(-180deg);
}

.cover-front,
.cover-inside {
    backface-visibility: hidden;
    inset: 0;
    position: absolute;
}

.cover-front {
    background-color: var(--c);
    background-image:
        linear-gradient(90deg, rgba(0, 0, 0, 0.5) 0, rgba(255, 255, 255, 0.14) 3.5%, rgba(0, 0, 0, 0.18) 5.5%, transparent 16%, transparent 90%, rgba(0, 0, 0, 0.3) 100%),
        linear-gradient(180deg, rgba(255, 255, 255, calc(var(--fade) * 0.7)), transparent 40%, rgba(0, 0, 0, 0.25)),
        radial-gradient(ellipse 55% 40% at var(--stain-x) var(--stain-y), rgba(45, 22, 0, 0.42), transparent 72%),
        var(--tex-leather);
    border-radius: 3px 6px 6px 3px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4), inset 0 0 22px rgba(0, 0, 0, 0.35);
    color: var(--foil);
    overflow: hidden;
}

.book.cloth .cover-front {
    background-image:
        linear-gradient(90deg, rgba(0, 0, 0, 0.5) 0, rgba(255, 255, 255, 0.14) 3.5%, rgba(0, 0, 0, 0.18) 5.5%, transparent 16%, transparent 90%, rgba(0, 0, 0, 0.3) 100%),
        linear-gradient(180deg, rgba(255, 255, 255, calc(var(--fade) * 0.7)), transparent 40%, rgba(0, 0, 0, 0.25)),
        radial-gradient(ellipse 55% 40% at var(--stain-x) var(--stain-y), rgba(45, 22, 0, 0.42), transparent 72%),
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.12) 0 1px, transparent 1px 3px),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.07) 0 1px, transparent 1px 3px);
}

/* scuffs and rubbed edges */
.cover-front::after {
    background:
        radial-gradient(ellipse 14% 10% at 0% 0%, rgba(236, 212, 172, calc(var(--wear) * 0.65)), transparent 80%),
        radial-gradient(ellipse 14% 10% at 100% 0%, rgba(236, 212, 172, calc(var(--wear) * 0.55)), transparent 80%),
        radial-gradient(ellipse 14% 10% at 100% 100%, rgba(236, 212, 172, calc(var(--wear) * 0.7)), transparent 80%),
        radial-gradient(ellipse 14% 10% at 0% 100%, rgba(236, 212, 172, calc(var(--wear) * 0.6)), transparent 80%),
        linear-gradient(180deg, rgba(236, 212, 172, calc(var(--wear) * 0.25)) 0, transparent 3%, transparent 97%, rgba(236, 212, 172, calc(var(--wear) * 0.3)) 100%),
        var(--tex-scuff);
    content: "";
    inset: 0;
    opacity: 0.6;
    pointer-events: none;
    position: absolute;
}

.cf-frame,
.cf-orn,
.cf-title,
.cf-sub,
.cf-foot {
    position: absolute;
}

.cf-frame {
    inset: 7% 7% 7% 11%;
}

.cf-orn {
    color: var(--foil);
    left: 50%;
    opacity: 0.9;
    top: 14%;
    transform: translateX(-50%);
    width: 13%;
}

.cf-title {
    color: var(--foil);
    font-size: calc(var(--d) * 0.13 * var(--len, 1));
    font-weight: 700;
    hyphens: auto;
    left: 14%;
    line-height: 1.1;
    margin: 0;
    overflow-wrap: anywhere;
    right: 10%;
    text-align: center;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.7), 0 -1px 0 rgba(255, 255, 215, 0.22);
    top: 34%;
}

.cf-title.caps {
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.cf-title.italic {
    font-style: italic;
}

.cf-sub,
.cf-foot {
    color: var(--foil);
    font-family: Georgia, "Times New Roman", serif;
    left: 14%;
    letter-spacing: 0.3em;
    margin: 0;
    opacity: 0.85;
    right: 10%;
    text-align: center;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
    text-transform: uppercase;
}

.cf-sub {
    font-size: calc(var(--d) * 0.04);
    top: 66%;
}

.cf-foot {
    bottom: 12%;
    font-size: calc(var(--d) * 0.042);
}

.cf-corner {
    display: none;
}

/* four different ways to dress a cover */

.book[data-cover="0"] .cf-frame {
    border: 1.5px solid var(--foil);
    opacity: 0.85;
    outline: 1.5px solid var(--foil);
    outline-offset: 5px;
}

.book[data-cover="1"] .cf-frame {
    border: 3px solid rgba(0, 0, 0, 0.28);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.book[data-cover="1"] .cf-title {
    background: var(--c-dark);
    box-shadow: inset 0 0 0 1px var(--foil);
    left: 19%;
    padding: 6% 3%;
    right: 15%;
}

.book[data-cover="1"] .cf-orn {
    top: 76%;
}

.book[data-cover="2"] .cf-frame {
    border: 1px solid var(--foil);
    inset: 12% 10% 12% 14%;
    opacity: 0.7;
}

.book[data-cover="2"] .cf-corner {
    background: linear-gradient(135deg, var(--c-dark), rgba(0, 0, 0, 0.55));
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
    display: block;
    height: 17%;
    position: absolute;
    width: 17%;
}

.book[data-cover="2"] .cf-corner.tl { clip-path: polygon(0 0, 100% 0, 0 100%); left: 0; top: 0; }
.book[data-cover="2"] .cf-corner.tr { clip-path: polygon(0 0, 100% 0, 100% 100%); right: 0; top: 0; }
.book[data-cover="2"] .cf-corner.bl { bottom: 0; clip-path: polygon(0 0, 0 100%, 100% 100%); left: 0; }
.book[data-cover="2"] .cf-corner.br { bottom: 0; clip-path: polygon(100% 0, 100% 100%, 0 100%); right: 0; }

.book[data-cover="2"] .cf-title {
    background: var(--tex-stain), var(--paper-label);
    border: 1px solid rgba(60, 38, 10, 0.6);
    box-shadow: inset 0 0 8px rgba(120, 78, 20, 0.5), 1px 2px 3px rgba(0, 0, 0, 0.5);
    color: var(--label-ink);
    left: 20%;
    padding: 5% 3%;
    right: 16%;
    text-shadow: none;
    top: 32%;
}

.book[data-cover="3"] .cf-frame {
    background:
        linear-gradient(var(--foil), var(--foil)) 0 6% / 100% 3px no-repeat,
        linear-gradient(var(--foil), var(--foil)) 0 9% / 100% 1px no-repeat,
        linear-gradient(var(--foil), var(--foil)) 0 91% / 100% 1px no-repeat,
        linear-gradient(var(--foil), var(--foil)) 0 94% / 100% 3px no-repeat;
    opacity: 0.85;
}

.book[data-cover="3"] .cf-orn {
    top: 20%;
    width: 11%;
}

/* inside the cover: marbled endpaper and a picture pasted in */

.cover-inside {
    background:
        linear-gradient(270deg, rgba(0, 0, 0, 0.45) 0, transparent 9%),
        radial-gradient(ellipse at 50% 50%, transparent 50%, rgba(0, 0, 0, 0.3)),
        repeating-radial-gradient(circle at 0 0, transparent 0 7px, rgba(255, 255, 255, 0.24) 7px 9px) 0 0 / 36px 36px,
        repeating-radial-gradient(circle at 18px 18px, transparent 0 7px, rgba(0, 0, 0, 0.34) 7px 9px) 0 0 / 36px 36px,
        linear-gradient(135deg, var(--c), var(--c-dark));
    background-color: var(--c-dark);
    border-radius: 6px 3px 3px 6px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.45);
    transform: rotateY(180deg);
}

.mount {
    background: #efe5c6;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(60, 38, 10, 0.45);
    left: 9%;
    margin: 0;
    padding: 10px 10px 6px;
    position: absolute;
    top: 9%;
    transform: rotate(-1.2deg);
    width: 82%;
}

.mount img {
    aspect-ratio: 16 / 11;
    display: block;
    filter: sepia(0.18) contrast(0.96);
    object-fit: cover;
    object-position: top;
    width: 100%;
}

.mount.empty {
    align-items: center;
    display: flex;
    flex-direction: column;
    height: 52%;
    justify-content: center;
}

.mount-initials {
    color: var(--c);
    font-family: Georgia, serif;
    font-size: calc(var(--d) * 0.28);
    font-weight: 700;
    opacity: 0.8;
}

.mount-note {
    color: #6b4a22;
    font-family: Georgia, serif;
    font-size: 0.8rem;
    font-style: italic;
}

.mount figcaption {
    color: #4a3318;
    font-family: Georgia, serif;
    font-size: 0.72rem;
    font-style: italic;
    margin-top: 6px;
    text-align: center;
}

.pc {
    background: #2b1d10;
    height: 18px;
    position: absolute;
    width: 18px;
}

.pc.tl { clip-path: polygon(0 0, 100% 0, 0 100%); left: -3px; top: -3px; }
.pc.tr { clip-path: polygon(0 0, 100% 0, 100% 100%); right: -3px; top: -3px; }
.pc.bl { bottom: -3px; clip-path: polygon(0 0, 0 100%, 100% 100%); left: -3px; }
.pc.br { bottom: -3px; clip-path: polygon(100% 0, 100% 100%, 0 100%); right: -3px; }

.bookplate {
    background: #efe5c6;
    border: 1px solid rgba(60, 38, 10, 0.6);
    bottom: 7%;
    box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
    color: #3b2810;
    font-family: Georgia, serif;
    font-size: 0.7rem;
    font-style: italic;
    left: 50%;
    letter-spacing: 0.06em;
    margin: 0;
    padding: 5px 12px;
    position: absolute;
    transform: translateX(-50%);
    white-space: nowrap;
}

/* controls in the room */

.room-close,
.room-nav {
    background: #efe2bf;
    border: 2px solid #2b1b0b;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5);
    color: #2b1b0b;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    position: absolute;
    z-index: 5;
}

.room-close {
    border-radius: 999px;
    padding: 8px 16px;
    right: 16px;
    top: 16px;
}

.room-nav {
    border-radius: 50%;
    font-size: 1.3rem;
    height: 48px;
    opacity: 0;
    top: 46%;
    transform: translateY(-50%);
    transition: opacity 0.4s ease;
    width: 48px;
}

.room-nav[hidden] {
    display: none;
}

.room-nav.prev { left: 16px; }
.room-nav.next { right: 16px; }

.room.is-reading .room-nav {
    opacity: 1;
}

.room-close:focus-visible,
.room-nav:focus-visible {
    outline: 3px solid var(--cyan);
    outline-offset: 2px;
}

.room-caption {
    bottom: 14px;
    color: #cdb98f;
    font-size: 0.85rem;
    font-style: italic;
    left: 0;
    margin: 0;
    opacity: 0;
    position: absolute;
    right: 0;
    text-align: center;
    transition: opacity 0.25s ease;
}

.room.is-reading .room-caption {
    opacity: 1;
}

@media (max-width: 759px) {
    .mount { display: none; }
    .leaf-plate { display: block; }
    .room-nav { top: auto; bottom: 36px; transform: none; }
    .room-nav.prev { left: 22%; }
    .room-nav.next { right: 22%; }
}

@media (max-width: 560px) {
    .case { --scale: 0.82; padding: 10px 10px 0; }
    .shelf-row { padding: 36px 14px 0; }
    .shelf-board { margin: 0 -10px; }
}

@media (prefers-reduced-motion: reduce) {
    .cover3d, .vol, .room, .room-nav, .room-caption { transition: none; }
}
