/* Character books: Vassili's trading card that opens into a character sheet,
   with the flip-style death clock above it. Ported from the Desk page
   (st/sei_time/page/characters) for the site's cards; the pages are filled
   from the character's Foundry sheet. Every rule is scoped to .character-books
   so the short class names stay out of the rest of the site. Behaviour is in
   /assets/st/js/character_book.js. */

.character-books {
    --card-w: 226px;
    --card-h: 336px;
    --flip-dur: 0.72s;
    --flip-ease: cubic-bezier(0.33, 0, 0.2, 1);
    /* Page ink: purple text, deep-red titles. */
    --ink: #2e0b3d;
    --ink-soft: #5e3a6e;
    --plum: #5b1d73;
    --red: #8e1b2e;
    --gold: #9a7a28;

    display: flex;
    flex-wrap: wrap;
    gap: 40px 24px;
    margin: 1.5rem 0;
    justify-content: center;
}

/* A slot with a book reserves the open spread's width, so opening it never
   pushes the neighbours around. A card without a sheet only needs its own. */
.character-books .character-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: calc(var(--card-w) * 2);
    max-width: 100%;
}

.character-books .character-slot--card {
    width: var(--card-w);
}

/* =====================
   Deathclock
   ===================== */
.character-books .deathclock-title {
    color: #e8c858;
    text-align: center;
    font-size: 1.75em;
    font-weight: bold;
    font-family: Georgia, "Times New Roman", serif;
    text-transform: uppercase;
}
.character-books .deathclock-wrapper {
    width: var(--card-w);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0px 8px 8px;
    font-family: "Courier New", monospace;
}

.character-books .deathclock {
    display: flex;
    gap: 5px;
    padding: 2px;
}

.character-books .deathclock-none {
    height: 90px;
    display: flex;
    align-items: center;
    color: #a58fb3;
    font-size: 1.1em;
    font-style: italic;
}

.character-books .digit {
    position: relative;
    width: 50px;
    height: 90px;
    perspective: 700px;
}

.character-books .clock-colon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 90px;
    color: #e8c858;
    font-size: 56px;
    font-weight: bold;
    line-height: 1;
}

.character-books .flipcard {
    position: absolute;
    inset: 0;
    border-radius: 10px;
    background: linear-gradient(#1d1d1d, #050505);
    color: #e8c858;
    font-size: 56px;
    font-weight: bold;
    line-height: 95px;
    text-align: center;
    overflow: hidden;
}

.character-books .flipcard::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    background: #000;
    box-shadow:
      0 -1px rgba(255,255,255,0.08),
      0 1px rgba(255,255,255,0.05);
    z-index: 3;
}

.character-books .top,
.character-books .bottom {
    position: absolute;
    left: 0;
    width: 100%;
    height: 50%;
    overflow: hidden;
    background: linear-gradient(#202020, #080808);
    color: #e8c858;
    font-size: 56px;
    font-weight: bold;
    text-align: center;
    backface-visibility: hidden;
}

.character-books .top {
    top: 0;
    line-height: 90px;
    border-radius: 10px 10px 0 0;
    transform-origin: bottom;
}

.character-books .bottom {
    bottom: 0;
    line-height: 0;
    border-radius: 0 0 10px 10px;
    transform-origin: top;
}

.character-books .flip-top {
    animation: flipTop 0.28s ease-in forwards;
    z-index: 5;
}

.character-books .flip-bottom {
    animation: flipBottom 0.28s ease-out forwards;
    z-index: 5;
}

@keyframes flipTop {
    from { transform: rotateX(0deg); }
    to   { transform: rotateX(-90deg); }
}

@keyframes flipBottom {
    from { transform: rotateX(90deg); }
    to   { transform: rotateX(0deg); }
}

.character-books .shine {
    position: absolute;
    inset: 0;
    border-radius: 10px;
    pointer-events: none;
    background: linear-gradient(
        115deg,
        rgba(255,255,255,0.12),
        transparent 35%,
        transparent 70%,
        rgba(255,255,255,0.05)
    );
    z-index: 10;
}

/* =====================
   Book

   The book is a stack of leaves hinged on the spine at the centre of the
   stage. Closed, the whole stack is shifted half a page to the left so the
   cover sits centred in the slot; opening slides it back to centre the
   spread.
   ===================== */

.character-books .book-stage {
    position: relative;
    width: calc(var(--card-w) * 2);
    height: var(--card-h);
    perspective: 2200px;
    cursor: pointer;
    outline: none;
    -webkit-user-select: none;
    user-select: none;
}

.character-books .book-stage:focus-visible {
    box-shadow: 0 0 0 2px rgba(232, 200, 88, 0.6);
    border-radius: 4px;
}

/* One page wide, centred in the stage, with the spine on its left edge. The
   closed book therefore needs no transform at all; opening slides the spine
   to the middle of the stage so the turned pages have somewhere to land. */
.character-books .book {
    position: absolute;
    top: 0;
    left: calc(50% - var(--card-w) / 2);
    width: var(--card-w);
    height: 100%;
    transform-style: preserve-3d;
    transition: transform var(--flip-dur) var(--flip-ease);
}

.character-books .character-slot.is-open .book {
    transform: translateX(calc(var(--card-w) / 2));
}

.character-books .book-shadow {
    position: absolute;
    bottom: -16px;
    left: 50%;
    width: var(--card-w);
    height: 26px;
    transform: translateX(-50%);
    background: radial-gradient(ellipse, rgba(0, 0, 0, 0.75), transparent 70%);
    filter: blur(8px);
    transition: width var(--flip-dur) var(--flip-ease);
    pointer-events: none;
}

.character-books .character-slot.is-open .book-shadow {
    width: calc(var(--card-w) * 2 - 20px);
}

/* Static right-hand page with the fore-edge stack peeking out */
.character-books .page-block {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--card-w);
    height: 100%;
    background: linear-gradient(105deg, #f6ecd4, #e6d9b6);
    border-radius: 2px 8px 8px 2px;
    box-shadow:
        inset 9px 0 12px -8px rgba(70, 30, 90, 0.5),
        2px 0 0 #e2d4b0,
        4px 1px 0 #d5c49c,
        6px 1px 0 #e2d4b0,
        8px 2px 0 #d5c49c,
        10px 2px 8px rgba(20, 0, 30, 0.55);
    z-index: 1;
}

.character-books .leaf {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--card-w);
    height: 100%;
    transform-origin: left center;
    transform-style: preserve-3d;
    transform: rotateY(0deg);
    transition: transform var(--flip-dur) var(--flip-ease);
    will-change: transform;
}

.character-books .leaf.flipped {
    transform: rotateY(-178deg);
}

/* Closed books crack the cover open on hover instead of floating up. */
.character-books .character-slot:not(.is-open) .book-stage:hover .leaf-cover,
.character-books .character-slot:not(.is-open) .book-stage:focus-visible .leaf-cover {
    transform: rotateY(-12deg);
}

/* The two printed faces are lifted a hair off the core so they are never
   coplanar — coplanar faces let the browser paint the front through the
   back, which shows the cover art mirrored on the endpaper. */
.character-books .leaf-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    overflow: hidden;
    transform: translateZ(0.7px);
}

.character-books .leaf-face.back {
    transform: rotateY(180deg) translateZ(0.7px);
}

/* Opaque stock between the faces, so neither side can ever show through. */
.character-books .leaf-core {
    position: absolute;
    inset: 0;
    background: #efe3c4;
    border-radius: 2px 8px 8px 2px;
}

.character-books .leaf-cover .leaf-core {
    background: #1c0026;
    border-radius: 0 0 12px 12px;
}

.character-books .book-hint {
    margin-top: 22px;
    text-align: center;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(232, 200, 88, 0.45);
}

.character-books .book-hint .hint-open,
.character-books .character-slot.is-open .book-hint .hint-closed {
    display: none;
}

.character-books .character-slot.is-open .book-hint .hint-open {
    display: inline;
}

/* =====================
   Trading Card (the front cover)
   ===================== */

.character-books .trading-card {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: linear-gradient(170deg, #3a0a4f 0%, #2c003e 50%, #320848 100%);
    border: 2px solid #9a7a28;
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow:
        0 0 0 1px #4a1060,
        0 16px 40px rgba(0, 0, 0, 0.8),
        0 4px 12px rgba(184, 148, 58, 0.12);
    overflow: hidden;
    position: relative;
    transition: box-shadow 0.2s ease;
}

.character-books .character-slot:not(.is-open) .book-stage:hover .trading-card {
    box-shadow:
        0 0 0 1px #c8a84b,
        0 22px 50px rgba(0, 0, 0, 0.9),
        0 6px 20px rgba(200, 168, 75, 0.28);
}

/* Inner border inlay */
.character-books .trading-card::before {
    content: '';
    position: absolute;
    inset: 5px;
    border: 1px solid rgba(250, 204, 21, 0.18);
    border-top: none;
    border-radius: 0 0 8px 8px;
    pointer-events: none;
    z-index: 20;
}

/* Diagonal gloss sheen */
.character-books .trading-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.055) 0%,
        transparent 45%
    );
    pointer-events: none;
    z-index: 15;
    border-radius: inherit;
}

/* =====================
   Card Name Band
   ===================== */

.character-books .card-name-band {
    background: linear-gradient(to right,
        #150020 0%, #2c003e 25%, #3a0a4f 50%, #2c003e 75%, #150020 100%
    );
    border-bottom: 2px solid #9a7a28;
    padding: 9px 14px 8px;
    text-align: center;
    position: relative;
    z-index: 5;
}

.character-books .card-name-band a {
    color: #e8c858;
    font-size: 0.88rem;
    font-weight: bold;
    text-decoration: none;
    text-shadow:
        0 0 14px rgba(232, 200, 64, 0.35),
        0 1px 4px rgba(0, 0, 0, 0.95);
    letter-spacing: 0.08em;
    font-family: Georgia, "Times New Roman", serif;
    text-transform: uppercase;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.character-books .card-name-band a:hover {
    color: #ffe070;
    text-shadow:
        0 0 20px rgba(255, 220, 80, 0.55),
        0 1px 4px rgba(0, 0, 0, 0.95);
    text-decoration: none;
}

/* =====================
   Image Stack
   ===================== */

.character-books .image-stack {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
}

.character-books .image-stack .layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.character-books .image-stack .bg {
    z-index: 1;
}

.character-books .image-stack .fg {
    top: 15%;
    height: 72%;
    padding: 0 12%;
    z-index: 2;
}

.character-books .image-stack .frame {
    z-index: 3;
}

/* =====================
   Card Info Band
   ===================== */

.character-books .card-info-band {
    background: linear-gradient(to right,
        #150020 0%, #2c003e 25%, #3a0a4f 50%, #2c003e 75%, #150020 100%
    );
    border-top: 2px solid #9a7a28;
    padding: 7px 14px 9px;
    text-align: center;
    color: #fcd34d;
    font-size: 0.72rem;
    font-style: italic;
    letter-spacing: 0.1em;
    position: relative;
    z-index: 5;
    font-family: Georgia, "Times New Roman", serif;
}

/* =====================
   Sheet pages
   ===================== */

.character-books .page {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: 14px 15px 16px 17px;
    background: linear-gradient(105deg, #f6ecd4, #e9dcba);
    border-radius: 2px 8px 8px 2px;
    box-shadow: inset 9px 0 12px -8px rgba(70, 30, 90, 0.55);
    color: var(--ink);
    font-family: Georgia, "Times New Roman", serif;
    overflow: hidden;
}

/* Back faces are mirrored, so their spine edge is on the local right. */
.character-books .leaf-face.back .page {
    background: linear-gradient(-105deg, #f6ecd4, #e9dcba);
    border-radius: 8px 2px 2px 8px;
    box-shadow: inset -9px 0 12px -8px rgba(70, 30, 90, 0.55);
    padding: 14px 17px 16px 15px;
}

/* Faint laid-paper texture */
.character-books .page::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(120, 80, 30, 0.055) 0.5px, transparent 0.6px);
    background-size: 4px 4px;
    pointer-events: none;
}

.character-books .leaf-face.back .page.page-empty {
    background: linear-gradient(-105deg, #f2e7cd, #e4d6b2);
}

.character-books .page-title {
    font-size: 9px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    text-align: center;
    color: var(--plum);
    font-weight: bold;
}

.character-books .page-rule {
    height: 1px;
    margin: 5px 0 8px;
    background: linear-gradient(to right, transparent, var(--gold), transparent);
}

.character-books .page-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.character-books .page-foot {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 6px;
    font-size: 6px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(107, 90, 68, 0.65);
}

.character-books .page-tag {
    font-style: italic;
    letter-spacing: 0.5px;
    opacity: 0.7;
}

.character-books .sub-title {
    font-size: 7px;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--plum);
    border-bottom: 1px solid rgba(154, 122, 40, 0.4);
    margin: 9px 0 5px;
    padding-bottom: 2px;
}

.character-books .sub-title:first-child {
    margin-top: 0;
}

/* --- Endpaper / frontispiece --- */

/* Specific enough to beat the generic back-face page rule above. */
.character-books .leaf-face.back .page.endpaper {
    background: linear-gradient(-160deg, #3a0a4f 0%, #26002f 55%, #1c0026 100%);
    box-shadow: inset -9px 0 14px -8px rgba(0, 0, 0, 0.8);
    color: #e6d3a3;
    padding: 12px;
    align-items: center;
}

.character-books .leaf-face.back .page.endpaper::before {
    background-image: radial-gradient(rgba(232, 200, 88, 0.05) 0.5px, transparent 0.6px);
}

.character-books .plate-frame {
    position: relative;
    flex: 1;
    width: 100%;
    border: 1px double rgba(200, 168, 75, 0.55);
    border-radius: 4px;
    padding: 12px 14px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.character-books .plate-kicker {
    font-size: 7px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: rgba(232, 200, 88, 0.6);
}

.character-books .plate-portrait {
    width: 62px;
    height: 62px;
    margin: 8px 0 6px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(200, 168, 75, 0.7);
    box-shadow: 0 0 14px rgba(0, 0, 0, 0.6);
}

.character-books .plate-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: rgba(232, 200, 88, 0.4);
    background: rgba(0, 0, 0, 0.25);
}

.character-books .plate-name {
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #e8c858;
    line-height: 1.2;
}

.character-books .plate-sub {
    font-size: 8px;
    font-style: italic;
    color: rgba(230, 211, 163, 0.75);
    margin-top: 3px;
}

.character-books .plate-rule {
    width: 46px;
    height: 1px;
    background: rgba(200, 168, 75, 0.6);
    margin: 9px 0;
}

.character-books .plate-meta {
    width: 100%;
    margin: 0;
    display: grid;
    grid-template-columns: auto auto;
    justify-content: space-between;
    row-gap: 3px;
    font-size: 8px;
    text-align: left;
}

.character-books .plate-meta dt {
    font-weight: normal;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-size: 6.5px;
    color: rgba(230, 211, 163, 0.55);
    align-self: center;
}

.character-books .plate-meta dd {
    margin: 0;
    text-align: right;
    color: #e6d3a3;
}

.character-books .plate-quote {
    margin-top: auto;
    font-size: 8px;
    font-style: italic;
    line-height: 1.45;
    color: rgba(230, 211, 163, 0.7);
}

/* --- Abilities --- */

.character-books .stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.character-books .stat-box {
    border: 1px solid rgba(154, 122, 40, 0.55);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.28);
    padding: 4px 0 3px;
    text-align: center;
}

.character-books .stat-abbr {
    font-size: 6.5px;
    letter-spacing: 1.4px;
    color: var(--plum);
}

.character-books .stat-score {
    font-family: "Courier New", monospace;
    font-size: 19px;
    font-weight: bold;
    line-height: 1.05;
    color: var(--ink);
}

.character-books .stat-mod {
    font-family: "Courier New", monospace;
    font-size: 9px;
    color: var(--ink-soft);
}

.character-books .chip-row {
    display: flex;
    gap: 5px;
    margin-top: 8px;
}

.character-books .chip {
    flex: 1;
    border: 1px solid rgba(154, 122, 40, 0.45);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 1px;
    text-align: center;
    min-width: 0;
}

.character-books .chip-val {
    display: block;
    font-family: "Courier New", monospace;
    font-size: 12px;
    font-weight: bold;
    line-height: 1.15;
}

.character-books .chip-label {
    display: block;
    font-size: 6px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--ink-soft);
    white-space: nowrap;
}

/* --- Saves & skills --- */

.character-books .save-list,
.character-books .skill-list,
.character-books .gear-list,
.character-books .spell-list,
.character-books .note-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.character-books .save-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px 6px;
}

.character-books .save-list li,
.character-books .skill-list li {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 7.5px;
    line-height: 1.5;
    color: var(--ink-soft);
}

.character-books .save-list li.on,
.character-books .skill-list li.on {
    color: var(--ink);
    font-weight: bold;
}

.character-books .skill-list {
    columns: 2;
    column-gap: 10px;
}

.character-books .skill-list li {
    break-inside: avoid;
}

.character-books .skill-list .nm {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.character-books .dot {
    flex: none;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    border: 1px solid rgba(82, 36, 107, 0.55);
}

.character-books li.on .dot {
    background: var(--plum);
}

.character-books .save-list .val,
.character-books .skill-list .val {
    font-family: "Courier New", monospace;
    font-size: 7.5px;
}

/* --- Proficiencies & features --- */

.character-books .prof-row {
    display: flex;
    gap: 6px;
    font-size: 7.5px;
    line-height: 1.45;
    margin-bottom: 4px;
}

.character-books .prof-label {
    flex: none;
    width: 46px;
    font-size: 6.5px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--plum);
    padding-top: 1px;
}

.character-books .prof-value {
    flex: 1;
}

.character-books .feature {
    margin-bottom: 6px;
}

.character-books .feature-name {
    font-size: 8px;
    font-weight: bold;
    color: var(--plum);
}

.character-books .feature-text {
    font-size: 7.5px;
    line-height: 1.5;
    text-align: justify;
    hyphens: auto;
}

/* --- Attacks & gear --- */

.character-books .atk-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 7.5px;
}

.character-books .atk-table th {
    font-size: 6.5px;
    font-weight: normal;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--plum);
    text-align: left;
    border-bottom: 1px solid rgba(154, 122, 40, 0.4);
    padding-bottom: 2px;
}

.character-books .atk-table td {
    padding: 3px 0;
    border-bottom: 1px dotted rgba(154, 122, 40, 0.3);
    vertical-align: top;
}

.character-books .atk-table .atk-bonus,
.character-books .atk-table .atk-dmg {
    font-family: "Courier New", monospace;
}

.character-books .atk-table .atk-bonus {
    width: 26px;
    text-align: center;
}

.character-books .atk-table .atk-dmg {
    width: 74px;
    text-align: right;
}

.character-books .gear-list li,
.character-books .spell-list li,
.character-books .note-list li {
    position: relative;
    padding-left: 9px;
    font-size: 7.5px;
    line-height: 1.6;
}

.character-books .gear-list li::before,
.character-books .spell-list li::before,
.character-books .note-list li::before {
    content: '\2022';
    position: absolute;
    left: 1px;
    color: rgba(154, 122, 40, 0.9);
}

.character-books .spell-list {
    columns: 2;
    column-gap: 10px;
}

.character-books .spell-list li {
    break-inside: avoid;
}

.character-books .purse {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(154, 122, 40, 0.35);
    font-family: "Courier New", monospace;
    font-size: 8px;
}

.character-books .purse em {
    font-style: normal;
    font-size: 6.5px;
    letter-spacing: 0.5px;
    color: var(--ink-soft);
}

/* --- Spellcasting --- */

.character-books .slot-row {
    display: flex;
    gap: 4px;
}

.character-books .slot {
    flex: 1;
    border: 1px solid rgba(154, 122, 40, 0.45);
    border-radius: 3px;
    text-align: center;
    padding: 2px 0;
}

.character-books .slot-lvl {
    display: block;
    font-size: 6px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--plum);
}

.character-books .slot-count {
    display: block;
    font-family: "Courier New", monospace;
    font-size: 10px;
    font-weight: bold;
}

/* --- Journal --- */

.character-books .journal-entry {
    margin-bottom: 7px;
}

.character-books .journal-label {
    font-size: 6.5px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--plum);
}

.character-books .journal-text {
    font-size: 8px;
    font-style: italic;
    line-height: 1.5;
}


/* =====================
   Site additions
   ===================== */

/* The portrait sits in the frame's window, the frame's transparent margin
   cropped away: the Character Type frames are 606x768 with the art running
   from about (65, 36) to (535, 736). */
.character-books .image-stack .frame-box {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    aspect-ratio: 470 / 700;
    transform: translateX(-50%);
    overflow: hidden;
}

.character-books .image-stack .frame-stage {
    position: absolute;
    left: -13.83%;
    top: -5.14%;
    width: 128.94%;
    height: 109.71%;
}

.character-books .image-stack .frame-stage .layer {
    object-fit: fill;
}

.character-books .image-stack .frame-stage .fg {
    left: 14.2%;
    top: 7.6%;
    width: 70.8%;
    height: 82.2%;
    padding: 0;
    object-fit: cover;
    object-position: center top;
}

.character-books .image-stack .no-picture {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    opacity: 0.6;
}

.character-books .card-name-band span {
    color: #e8c858;
    font-size: 0.88rem;
    font-weight: bold;
    text-shadow: 0 0 14px rgba(232, 200, 64, 0.35), 0 1px 4px rgba(0, 0, 0, 0.95);
    letter-spacing: 0.08em;
    font-family: Georgia, "Times New Roman", serif;
    text-transform: uppercase;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* A card with no sheet doesn't open. */
.character-books .book-stage--closed {
    width: var(--card-w);
    cursor: default;
}

.character-books .book-stage--closed .book {
    left: 0;
}

.character-books .deathclock-state {
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.6em;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.character-books .deathclock-state--dead {
    color: #ff8a8a;
}

.character-books .deathclock-title--dying {
    color: #ffd166;
}

.character-books .deathclock-note {
    color: #ffd166;
    font-size: 0.85rem;
    text-align: center;
    margin: 0;
}

/* Every card keeps the clock's room, clock or not, so a row lines up. */
.character-books .deathclock-area {
    height: 136px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

.character-books .character-slot--dead .image-stack img {
    filter: grayscale(0.85) contrast(1.05);
}

.character-books .character-extra {
    margin-top: 14px;
    text-align: center;
    color: #f4ecf7;
}

.character-books .more {
    font-style: italic;
    color: var(--ink-soft);
}

/* --- Page ink ---

   The site theme forces `p, span, div, td, th` to gold and `li` to grey,
   both !important, which can't be read on the beige pages. These win on
   specificity. */

.character-books .page:not(.endpaper),
.character-books .page:not(.endpaper) * {
    color: var(--ink) !important;
}

.character-books .page .page-title,
.character-books .page .journal-label,
.character-books .page .feature-name,
.character-books .page .slot-lvl,
.character-books .page .companion-name {
    color: var(--red) !important;
}

.character-books .page .sub-title,
.character-books .page .stat-abbr,
.character-books .page .prof-label,
.character-books .page .atk-table th,
.character-books .page .companion-kind {
    color: var(--plum) !important;
}

.character-books .page .stat-mod,
.character-books .page .chip-label,
.character-books .page .page-foot,
.character-books .page .page-foot *,
.character-books .page .save-list li,
.character-books .page .skill-list li,
.character-books .page .save-list li *,
.character-books .page .skill-list li *,
.character-books .page .purse em,
.character-books .page .more {
    color: var(--ink-soft) !important;
}

.character-books .page .save-list li.on,
.character-books .page .skill-list li.on,
.character-books .page .save-list li.on *,
.character-books .page .skill-list li.on * {
    color: var(--ink) !important;
}

.character-books .page .gear-list li.on {
    font-weight: bold;
}

/* One line per entry: long item and spell names are cut short. */
.character-books .page .gear-list li,
.character-books .page .spell-list li {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.character-books .book-hint,
.character-books .book-hint * {
    color: rgba(232, 200, 88, 0.55) !important;
}

.character-books .deathclock-state--dead {
    color: #ff8a8a !important;
}

/* --- Companion page --- */

.character-books .companion-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.character-books .companion-head .plate-portrait {
    width: 46px;
    height: 46px;
    margin: 0;
}

.character-books .companion-name {
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.2;
}

.character-books .companion-kind {
    font-size: 7.5px;
    font-style: italic;
    margin-top: 2px;
}

.character-books .stat-grid--small {
    grid-template-columns: repeat(6, 1fr);
    gap: 3px;
    margin: 8px 0 6px;
}

.character-books .stat-grid--small .stat-score {
    font-size: 12px;
}

/* --- Focus mode --- */

.character-books .book-focus {
    position: absolute;
    top: 6px;
    left: 8px;
    z-index: 30;
    padding: 2px 6px;
    border: 1px solid rgba(200, 168, 75, 0.6);
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.35);
    color: #e8c858 !important;
    font: 7px Georgia, "Times New Roman", serif;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
}

.character-books .book-focus:hover,
.character-books .book-focus:focus-visible {
    background: rgba(232, 200, 88, 0.2);
    outline: none;
}

.character-books.book-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    background: rgba(10, 0, 16, 0.85);
}

.character-books.book-modal .character-slot {
    zoom: var(--focus-zoom, 2);
}

.character-books.book-modal .book-focus,
.character-books.book-modal .book-hint {
    display: none;
}

.character-books .book-modal__close {
    position: fixed;
    top: 14px;
    right: 18px;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(232, 200, 88, 0.6);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #e8c858 !important;
    font-size: 26px;
    line-height: 36px;
    cursor: pointer;
}

/* On a phone held upright focus mode shows one page at a time, zoomed to the
   window's width, and the reader swipes between the two (focus() adds the
   class). The stage's halves are the snap points. */
.character-books.book-modal--pan {
    justify-content: flex-start;
    padding: 0 3vw;
    overflow-x: auto;
    overscroll-behavior: contain;
    scroll-snap-type: x mandatory;
}

.character-books.book-modal--pan .book-stage::before,
.character-books.book-modal--pan .book-stage::after {
    content: "";
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    pointer-events: none;
    scroll-snap-align: center;
}

.character-books.book-modal--pan .book-stage::before {
    left: 0;
}

.character-books.book-modal--pan .book-stage::after {
    right: 0;
}

/* A spread is 452px: on a phone the whole slot shrinks to fit, and tapping
   the book brings it up in focus mode. */
@media (max-width: 520px) {
    .character-books .character-slot {
        zoom: 0.7;
        max-width: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .character-books .book,
    .character-books .leaf,
    .character-books .book-shadow {
        transition: none;
    }
}
