/*
  Hollow Horn Bear: a cinematic scroll story.
  Layout: a fixed full-screen stage driven by the scroll; captions arrive on the stage; the written
  record lives in a drawer. Grounds follow the medium of the record: ledger paper for the drawn
  scenes, hide for the winter counts, black for photographs and silence.
  Single deliberate look (dark frame); every colour is set explicitly.
*/
:root {
    color-scheme: dark;
    --ink: #1d1611;
    --paper: #ece3cc;
    --hide: #c3a781;
    --night: #0b0b0c;
    --bone: #ece8e1;
    --muted-dark: #a59e93;
    --muted-light: #5a4a3a;
    --ochre: #b5382b;
    --ochre-bright: #d8643f;
    --blue: #2f5c9c;

    --f-display: "Old Standard TT", "Iowan Old Style", "Times New Roman", serif;
    --f-text: "Source Serif 4", "Iowan Old Style", Georgia, serif;
    --f-label: "IBM Plex Sans Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;

    --gl: max(16px, env(safe-area-inset-left, 0px));
    --gr: max(16px, env(safe-area-inset-right, 0px));
    --top: env(safe-area-inset-top, 0px);
    --bot: env(safe-area-inset-bottom, 0px);

    --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.25  0 0 0 0 0.18  0 0 0 0 0.1  0 0 0 0.55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; max-width: 100%; }
@supports not (overflow: clip) { html { overflow-x: hidden; } }
body {
    margin: 0; background: var(--night); color: var(--bone);
    font-family: var(--f-text); font-size: clamp(1.02rem, 0.95rem + 0.3vw, 1.18rem); line-height: 1.55;
    -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-underline-offset: 0.18em; }
:focus-visible { outline: 2px solid var(--ochre-bright); outline-offset: 3px; }
.caps { font-variant: small-caps; letter-spacing: 0.04em; }
.skip { position: absolute; left: -999px; top: 0; z-index: 200; background: var(--bone); color: var(--night); padding: 0.6rem 1rem; }
.skip:focus { left: var(--gl); top: calc(var(--top) + 0.5rem); }

/* ---------- smooth scrolling (Lenis) ---------- */
html.lenis, html.lenis body { height: auto; }
.lenis:not(.lenis-autoToggle).lenis-stopped { overflow: clip; }
.lenis [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-smooth iframe { pointer-events: none; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }

/* ---------- stage ---------- */
.stage { position: fixed; inset: 0; overflow: hidden; background: var(--night); }
.js .track { position: relative; z-index: 0; pointer-events: none; }
.stage .paper { display: none; }
.layer { position: absolute; inset: 0; visibility: hidden; opacity: 0; overflow: hidden; contain: strict; will-change: opacity, transform; backface-visibility: hidden; }
@media (max-width: 820px) {
    :root { --noise: url(../media/ledger-tex/grain.png); }
    html .open-account, html .made-by { -webkit-backdrop-filter: none; backdrop-filter: none; }
    .layer.is-off { will-change: auto; backface-visibility: visible; }
}
.layer.is-off { content-visibility: hidden; }
.layer > svg { position: absolute; inset: 0; width: 100%; height: 100%; }

.ledger-paper,
.layer.scene, .layer.card.card-fights, .layer.doc {
    background-color: var(--paper);
    background-image:
        radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(80, 55, 25, 0.28) 100%),
        linear-gradient(to right, transparent calc(6vw - 2px), rgba(176, 52, 38, 0.45) calc(6vw - 2px), rgba(176, 52, 38, 0.45) calc(6vw), transparent calc(6vw), transparent calc(6vw + 4px), rgba(176, 52, 38, 0.35) calc(6vw + 4px), rgba(176, 52, 38, 0.35) calc(6vw + 6px), transparent calc(6vw + 6px)),
        repeating-linear-gradient(to bottom, transparent 0, transparent 37px, rgba(56, 92, 158, 0.2) 37px, rgba(56, 92, 158, 0.2) 38px),
        var(--noise);
}
.layer.scene::before {
    content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3;
    background: linear-gradient(to bottom, rgba(236, 227, 204, 0.42), rgba(236, 227, 204, 0) 26%);
}
/* real ledger pages */
.layer.on-paper { background: #e6d9bd var(--paper-l) center / cover no-repeat; }
@media (orientation: portrait) { .layer.on-paper { background-image: var(--paper-p); } }
/* the drawing sits in the paper: multiplied onto the page, with the page's tooth showing through */
.layer.on-paper > svg { mix-blend-mode: multiply; }
.layer.on-paper::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
    background: inherit;
    will-change: transform;
    -webkit-mask: url(../media/ledger-tex/tooth.png) 0 0 / clamp(200px, 21vw, 340px);
            mask: url(../media/ledger-tex/tooth.png) 0 0 / clamp(200px, 21vw, 340px);
}

/* the flight canvas */
.gl-wrap { position: absolute; inset: 0; visibility: hidden; background: #0d0d10; }
.gl-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#flight-labels { position: absolute; inset: 0; pointer-events: none; }
.layer.flight { background: var(--lm-bg, #d8c4a0); }
.fl-map, .fl-gl { position: absolute; inset: 0; }
.fl-map { z-index: 0; background: var(--lm-bg, #d8c4a0); }
.fl-gl { z-index: 1; opacity: 0; }
/* the map is drawn on hide: grain and a darkened edge, like the winter counts */
.fl-map::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(ellipse at 50% 46%, transparent 48%, rgba(60, 38, 18, 0.34) 100%), var(--noise);
    opacity: 0.85;
}
.lmap { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.lm-rivers { stroke: var(--lm-river); stroke-linecap: round; stroke-linejoin: round; }
.lm-rivers.r2 { stroke-opacity: 0.85; }
.lm-rivers.r3 { stroke-opacity: 0.6; }
.lm-states { stroke: var(--lm-ink); stroke-opacity: 0.7; }
.lm-county { stroke: var(--lm-ink); stroke-width: 1.4px; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.lm-county.red { fill: rgba(181, 56, 43, 0.5); }
.lm-county.gold { fill: rgba(214, 164, 64, 0.5); }
.lm-county-shadow { fill: rgba(40, 24, 10, 0.55); }
.lm-route path { stroke: var(--lm-route); stroke-linecap: round; stroke-linejoin: round; }
.lm-head { fill: var(--lm-ink); }
.lm-label text {
    font-family: var(--f-label); font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; fill: var(--lm-ink);
    paint-order: stroke; stroke: var(--lm-halo); stroke-width: 4px; stroke-linejoin: round;
}
.lm-label.river text { font-family: var(--f-display); font-style: italic; font-size: 18px; letter-spacing: 0.01em; text-transform: none; fill: var(--lm-river); }
.lm-label.region text { font-family: var(--f-display); font-size: 22px; letter-spacing: 0.32em; fill-opacity: 0.75; }
.lm-label.key text { font-family: var(--f-display); font-size: 27px; letter-spacing: 0; text-transform: none; fill: var(--lm-ink); }
.lm-label text.lm-note { font-family: var(--f-text); font-style: italic; font-size: 14px; letter-spacing: 0; text-transform: none; }
.lm-label.key text.lm-note { font-size: 16px; }
.lm-dot { fill: var(--lm-ink); }
.lm-label.key .lm-dot { fill: var(--lm-route); stroke: var(--lm-ink); stroke-width: 1.5px; }
/* words over a flight: ink on the paper map, bone over the terrain or the night map */
.layer.flight::after {
    content: ""; position: absolute; inset: auto 0 0 0; height: 48%; pointer-events: none; z-index: 2;
    background: linear-gradient(to top, rgba(226, 209, 178, 0.78), rgba(226, 209, 178, 0)); transition: opacity 0.6s ease;
}
.layer.flight::before {
    content: ""; position: absolute; inset: auto 0 0 0; height: 48%; pointer-events: none; z-index: 2; opacity: 0;
    background: linear-gradient(to top, rgba(8, 8, 10, 0.74), transparent); transition: opacity 0.6s ease;
}
.layer.flight.gl-on::after, .layer.flight.dark-ground::after { opacity: 0; }
/* over terrain, the HUD sits on a soft dark band so it reads whatever the land's colour */
.layer.flight.gl-on::before, .layer.flight.dark-ground::before { opacity: 1; }
.layer.flight .cap { color: var(--ink); text-shadow: 0 0 14px rgba(232, 216, 186, 0.95), 0 0 2px rgba(232, 216, 186, 0.9); transition: color 0.6s ease, text-shadow 0.6s ease; }
.layer.flight.gl-on .cap, .layer.flight.dark-ground .cap { color: var(--bone); text-shadow: 0 1px 18px rgba(0, 0, 0, 0.6); }

/* a soft cut through dark, for long jumps between acts */
.stage-veil { position: absolute; inset: 0; z-index: 9999; background: var(--night); opacity: 0; pointer-events: none; transition: opacity 0.6s ease; }
.stage-veil.on { opacity: 1; transition-duration: 0.3s; }

/* title */
.layer.title { background: var(--night); }
.t-face { position: absolute; inset: 0; opacity: 0; transform-origin: 50% 30%; will-change: transform, opacity; }
.t-face img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 24%; filter: grayscale(1) contrast(1.05) brightness(0.92); }
.t-face::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(11, 11, 12, 0.95) 0%, rgba(11, 11, 12, 0.55) 35%, rgba(11, 11, 12, 0.1) 70%, rgba(11, 11, 12, 0.5)), linear-gradient(to right, rgba(11, 11, 12, 0.6), transparent 60%); }
.t-stamp { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); transform-origin: 50% 50%; will-change: transform, opacity; }
.t-stamp img { height: min(38vh, 70vw); width: auto; filter: drop-shadow(0 22px 40px rgba(0, 0, 0, 0.7)); }

/* plates: photographs and documents */
.layer.plate, .layer.pair { background: #0c0d0f; }
.plate-fig { position: absolute; inset: 0; margin: 0; }
.plate-frame { position: absolute; inset: 0; overflow: hidden; }
.plate-frame img { width: 100%; height: 100%; object-fit: cover; will-change: transform; }
.plate-fig.contain .plate-frame { inset: calc(var(--top) + 4.5rem) 42vw calc(var(--bot) + 4rem) var(--gl); }
.plate-fig:not(.contain):not(.wide) .plate-frame { right: 38vw; -webkit-mask-image: linear-gradient(to right, #000 72%, transparent); mask-image: linear-gradient(to right, #000 72%, transparent); }
.plate-fig:not(.contain):not(.wide) .plate-frame::after { background: radial-gradient(ellipse at 45% 40%, transparent 55%, rgba(0, 0, 0, 0.5) 100%); }
.plate-fig.contain .plate-frame img { object-fit: contain; object-position: 50% 50%; }
.layer.plate:not(.contain-like) .plate-frame::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(to left, rgba(12, 13, 15, 0.92) 0%, rgba(12, 13, 15, 0.6) 32%, transparent 58%), radial-gradient(ellipse at 40% 45%, transparent 50%, rgba(0, 0, 0, 0.55) 100%);
}
.plate-fig.contain .plate-frame::after { display: none; }
.plate-fig figcaption {
    position: absolute; left: var(--gl); bottom: calc(var(--bot) + 2.8rem); max-width: 50vw;
    font-family: var(--f-label); font-size: 0.72rem; letter-spacing: 0.03em; color: rgba(236, 232, 225, 0.6);
}
.pair-row { position: absolute; inset: calc(var(--top) + 5rem) var(--gr) calc(var(--bot) + 9rem) var(--gl); display: flex; justify-content: center; align-items: center; gap: 4vw; }
.pair-row figure { margin: 0; height: 100%; display: grid; grid-template-rows: 1fr auto; gap: 0.6rem; }
.pair-row img { height: 100%; width: auto; object-fit: contain; min-height: 0; }
.pair-row figcaption { font-family: var(--f-display); font-style: italic; font-size: 1.3rem; text-align: center; }

/* winter counts on hide */
.layer.count { background: #8c7154; background-image: radial-gradient(ellipse at 50% 50%, #9a7d5c, #5e4630 90%); }
.layer.count::before { content: ""; position: absolute; inset: 3vh 3vw; background: rgba(40, 24, 10, 0.55); filter: blur(18px); transform: translateY(14px); -webkit-mask: inherit; }
.layer.count .hide {
    position: absolute; inset: 2vh 2vw;
    background-color: var(--hide);
    background-image: radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(70, 42, 18, 0.45) 100%), var(--noise), var(--noise);
    -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 730' preserveAspectRatio='none'%3E%3Cpath d='M230%2C120 C203%2C118 193%2C103 170%2C90 C147%2C77 108%2C43 90%2C40 C72%2C37 57%2C53 60%2C70 C63%2C87 95%2C118 110%2C140 C125%2C162 147%2C175 150%2C200 C153%2C225 136%2C263 130%2C290 C124%2C317 112%2C335 112%2C360 C112%2C385 124%2C413 130%2C440 C136%2C467 153%2C497 150%2C520 C147%2C543 125%2C558 110%2C580 C95%2C602 63%2C632 60%2C650 C57%2C668 72%2C692 90%2C690 C108%2C688 147%2C655 170%2C640 C193%2C625 203%2C603 230%2C600 C257%2C597 298%2C617 330%2C622 C362%2C627 395%2C627 420%2C630 C445%2C633 465%2C630 478%2C642 C491%2C654 493%2C700 500%2C700 C507%2C700 509%2C654 522%2C642 C535%2C630 555%2C633 580%2C630 C605%2C627 638%2C627 670%2C622 C702%2C617 743%2C597 770%2C600 C797%2C603 807%2C625 830%2C640 C853%2C655 892%2C688 910%2C690 C928%2C692 943%2C668 940%2C650 C937%2C632 905%2C602 890%2C580 C875%2C558 853%2C543 850%2C520 C847%2C497 864%2C467 870%2C440 C876%2C413 888%2C385 888%2C360 C888%2C335 876%2C317 870%2C290 C864%2C263 847%2C225 850%2C200 C853%2C175 875%2C162 890%2C140 C905%2C118 937%2C87 940%2C70 C943%2C53 928%2C37 910%2C40 C892%2C43 853%2C77 830%2C90 C807%2C103 797%2C118 770%2C120 C743%2C122 702%2C107 670%2C102 C638%2C97 602%2C99 580%2C92 C558%2C85 553%2C71 540%2C62 C527%2C53 513%2C38 500%2C38 C487%2C38 473%2C53 460%2C62 C447%2C71 442%2C85 420%2C92 C398%2C99 362%2C97 330%2C102 C298%2C107 257%2C122 230%2C120Z' fill='black'/%3E%3C/svg%3E") center / 100% 100% no-repeat; mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 730' preserveAspectRatio='none'%3E%3Cpath d='M230%2C120 C203%2C118 193%2C103 170%2C90 C147%2C77 108%2C43 90%2C40 C72%2C37 57%2C53 60%2C70 C63%2C87 95%2C118 110%2C140 C125%2C162 147%2C175 150%2C200 C153%2C225 136%2C263 130%2C290 C124%2C317 112%2C335 112%2C360 C112%2C385 124%2C413 130%2C440 C136%2C467 153%2C497 150%2C520 C147%2C543 125%2C558 110%2C580 C95%2C602 63%2C632 60%2C650 C57%2C668 72%2C692 90%2C690 C108%2C688 147%2C655 170%2C640 C193%2C625 203%2C603 230%2C600 C257%2C597 298%2C617 330%2C622 C362%2C627 395%2C627 420%2C630 C445%2C633 465%2C630 478%2C642 C491%2C654 493%2C700 500%2C700 C507%2C700 509%2C654 522%2C642 C535%2C630 555%2C633 580%2C630 C605%2C627 638%2C627 670%2C622 C702%2C617 743%2C597 770%2C600 C797%2C603 807%2C625 830%2C640 C853%2C655 892%2C688 910%2C690 C928%2C692 943%2C668 940%2C650 C937%2C632 905%2C602 890%2C580 C875%2C558 853%2C543 850%2C520 C847%2C497 864%2C467 870%2C440 C876%2C413 888%2C385 888%2C360 C888%2C335 876%2C317 870%2C290 C864%2C263 847%2C225 850%2C200 C853%2C175 875%2C162 890%2C140 C905%2C118 937%2C87 940%2C70 C943%2C53 928%2C37 910%2C40 C892%2C43 853%2C77 830%2C90 C807%2C103 797%2C118 770%2C120 C743%2C122 702%2C107 670%2C102 C638%2C97 602%2C99 580%2C92 C558%2C85 553%2C71 540%2C62 C527%2C53 513%2C38 500%2C38 C487%2C38 473%2C53 460%2C62 C447%2C71 442%2C85 420%2C92 C398%2C99 362%2C97 330%2C102 C298%2C107 257%2C122 230%2C120Z' fill='black'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.count-wrap { position: absolute; inset: 15vh 50vw 15vh 18vw; display: grid; align-content: center; justify-items: start; gap: 0.9rem; color: var(--ink); }
.count-year { display: none; margin: 0 0 0.6rem; font-family: var(--f-label); text-transform: uppercase; letter-spacing: 0.2em; font-size: 0.85rem; color: #4a3725; }
.count-art {
    width: min(34vw, 30rem); aspect-ratio: var(--ar, 1.2); max-height: 48vh;
    position: relative;
}
.count-art::before, .count-art::after {
    content: ""; position: absolute; inset: 0; background: #241509;
    -webkit-mask: var(--mask) left center / contain no-repeat; mask: var(--mask) left center / contain no-repeat;
}
.count-art::before { opacity: 0.1; }
.count-art::after { clip-path: inset(0 var(--reveal, 0%) 0 0); }
.count-name { margin: 0; font-family: var(--f-display); font-style: italic; font-size: clamp(1.4rem, 1rem + 1.6vw, 2.4rem); line-height: 1.15; max-width: 22ch; }
.count-src { margin: 0; font-family: var(--f-label); font-size: 0.78rem; color: #4a3725; max-width: 34ch; }

/* cards */
.layer.card { background-color: var(--night); }
.layer.card-plain { background: #111214; }
.layer.card-act { background: radial-gradient(ellipse at 50% 60%, #2a1a12, #0b0b0c 70%); }
.layer.card-count1913 { background-color: var(--hide); background-image: radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(70, 42, 18, 0.55) 100%), var(--noise); }
.layer.card-today { background: linear-gradient(to bottom, #1d2a3a, #384a5c 60%, #b98d5a); }
.layer.card-end { background: var(--night); }
.tally-board { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr auto; align-content: center; padding-top: 8vh !important; gap: 2rem 6vw; padding: 0 var(--gr) 0 12vw; color: var(--ink); }
.tallies { display: flex; flex-wrap: wrap; gap: 0 26px; max-width: 46vw; }
.tallies i { display: inline-block; width: 5px; height: 84px; background: var(--ink); border-radius: 3px; margin-right: 12px; opacity: 0; transform: rotate(4deg) scaleY(0.6); transition: opacity 0.2s, transform 0.25s; }
.tallies i.cross { width: 5px; height: 100px; margin-left: -88px; margin-right: 34px; transform: rotate(62deg) scaleY(0.6); }
.tallies i.on { opacity: 1; transform: rotate(4deg) scaleY(1); }
.tallies i.cross.on { transform: rotate(62deg) scaleY(1); }
.tally-count { font-family: var(--f-display); font-size: clamp(6rem, 3rem + 10vw, 13rem); line-height: 0.8; grid-row: 1 / 3; grid-column: 2; align-self: center; font-variant-numeric: lining-nums tabular-nums; }
.nations { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; font-family: var(--f-display); font-style: italic; font-size: clamp(1.1rem, 0.9rem + 0.8vw, 1.6rem); max-width: 46vw; }
.nations li { opacity: 0.15; transition: opacity 0.5s; }
.nations li.on { opacity: 1; }
.doc-sheet { position: absolute; left: 50%; top: 50%; width: min(46rem, 88vw); height: min(78vh, 60rem); transform: translate(-50%, -50%) rotate(-0.6deg); background: #f6f1e4; box-shadow: 0 30px 80px rgba(40, 25, 10, 0.35); }
.doc-sheet::before { content: ""; position: absolute; inset: 0; background: var(--noise); opacity: 0.35; }

/* scenes the drawing hasn't reached yet: the ledger page alone carries the words */
.layer.scene.scene-missing::after { display: none; }

/* ---------- captions ---------- */
.cap { position: absolute; visibility: hidden; opacity: 0; z-index: 5; will-change: opacity, translate; }
.cap p, .cap h1, .cap h2 { margin: 0; }
.cap > * + * { margin-top: 0.55em; }
.cap .kicker { font-family: var(--f-label); text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.78rem; opacity: 0.8; }
.cap em { font-style: italic; }
.cap blockquote { margin: 0; }
.cap blockquote p { font-family: var(--f-display); font-style: italic; line-height: 1.22; }
.cap blockquote p::before { content: "\201C"; } .cap blockquote p::after { content: "\201D"; }
.cap blockquote footer { margin-top: 0.8rem; font-family: var(--f-label); font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.75; }

/* light captions over dark grounds; ink captions over paper */
.layer.light-caps .cap { color: var(--bone) !important; text-shadow: 0 1px 18px rgba(0, 0, 0, 0.7) !important; }
.layer.light-caps::after { background: linear-gradient(to bottom, rgba(20, 18, 24, 0.7), transparent 45%) !important; }
.cap { color: var(--bone); text-shadow: 0 1px 18px rgba(0, 0, 0, 0.55); }
.layer.scene .cap, .layer.count .cap, .layer.card.card-fights .cap, .layer.doc .cap, .layer.card-count1913 .cap { color: var(--ink); text-shadow: 0 0 14px rgba(236, 227, 204, 0.9), 0 0 2px rgba(236, 227, 204, 0.9); }

.cap-low { left: var(--gl); bottom: calc(var(--bot) + 5.5rem); max-width: min(36rem, calc(100vw - var(--gl) - var(--gr))); font-size: clamp(1.15rem, 1rem + 0.6vw, 1.5rem); line-height: 1.4; }
.cap-high { left: calc(6vw + 2.2rem); top: calc(var(--top) + 5.2rem); max-width: min(34rem, calc(100vw - 6vw - 2.2rem - var(--gr))); font-size: clamp(1.15rem, 1rem + 0.6vw, 1.5rem); line-height: 1.4; }
.cap-quote { left: calc(6vw + 2.2rem); top: calc(var(--top) + 5rem); max-width: min(46rem, calc(100vw - 6vw - 2.2rem - var(--gr))); }
.cap-quote blockquote p { font-size: clamp(1.6rem, 1.1rem + 2.1vw, 3.1rem); }
.layer.plate .cap-quote, .layer.flight .cap-quote, .layer.card .cap-quote { top: auto; bottom: calc(var(--bot) + 5.5rem); left: var(--gl); }
.layer.flight .cap-quote { max-width: min(36rem, calc(100vw - var(--gl) - var(--gr))); }
.layer.flight .cap-quote blockquote p { font-size: clamp(1.3rem, 1rem + 1.1vw, 2rem); }
.cap-big { left: 0; right: 0; top: 40%; text-align: center; font-family: var(--f-display); font-size: clamp(2.2rem, 1.4rem + 4vw, 5.4rem); line-height: 1.05; padding: 0 var(--gr) 0 var(--gl); }
.cap-mid { left: 50%; top: 50%; transform: translate(-50%, -50%) !important; width: min(44rem, calc(100vw - var(--gl) - var(--gr))); text-align: center; font-family: var(--f-display); font-size: clamp(1.4rem, 1.05rem + 1.5vw, 2.4rem); line-height: 1.25; }
.cap-side { right: calc(var(--gr) + 6vw); top: 50%; transform: translateY(-50%) !important; width: min(28rem, 36vw); font-size: clamp(1.1rem, 0.98rem + 0.5vw, 1.4rem); line-height: 1.45; }
.cap-side blockquote p { font-size: clamp(1.4rem, 1.05rem + 1.3vw, 2.2rem); }
.cap-side .death { font-family: var(--f-display); font-size: clamp(1.8rem, 1.2rem + 2vw, 3rem); line-height: 1.1; }
.cap-act { left: 50%; top: 50%; transform: translate(-50%, -50%) !important; width: min(52rem, calc(100vw - var(--gl) - var(--gr))); text-align: center; }
.layer.scene .cap-act { top: 38%; }
.cap-act h2 { font-family: var(--f-display); font-weight: 400; font-size: clamp(3rem, 1.8rem + 6vw, 8rem); line-height: 0.95; }
.cap-act blockquote p { font-size: clamp(1.8rem, 1.2rem + 2.6vw, 3.6rem); }
.cap-act .count-line { font-family: var(--f-display); font-style: italic; font-size: clamp(1.6rem, 1.1rem + 2vw, 3rem); line-height: 1.22; }
.cap-title { left: var(--gl); right: var(--gr); bottom: calc(var(--bot) + 4.5rem); }
.cap-title h1 { font-family: var(--f-display); font-weight: 400; font-size: clamp(3.4rem, 1.4rem + 10vw, 11rem); line-height: 0.88; letter-spacing: -0.015em; }
.cap-title .lede { font-size: clamp(1.15rem, 1rem + 0.7vw, 1.6rem); max-width: 34ch; }
.cap-title .scroll-hint { font-family: var(--f-label); text-transform: uppercase; letter-spacing: 0.18em; font-size: 0.78rem; opacity: 0.7; margin-top: 1.6rem; }
.cap-doc { left: 50%; top: 50%; transform: translate(-50%, -50%) !important; width: min(38rem, 78vw); }
.cap-doc .doc-text { font-family: var(--f-display); font-size: clamp(1.4rem, 1rem + 1.4vw, 2.2rem); line-height: 1.3; margin-top: 1rem; }
.cap .placeholder { font-style: italic; opacity: 0.75; }
.end-links button, .cap button {
    font: inherit; font-family: var(--f-label); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.82rem;
    color: inherit; background: transparent; border: 1px solid currentColor; border-radius: 999px; padding: 0.6rem 1.1rem; cursor: pointer; margin-top: 2rem;
}
.layer .cap { pointer-events: none; }
.layer .cap button { pointer-events: auto; }

/* flight labels (styles shared with flight.js) */
.fl-label { font-family: var(--f-label); color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8); }

/* ---------- heads-up display ---------- */
.hud {
    position: fixed; z-index: 100; top: 0; left: 0; right: 0;
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
    padding: calc(var(--top) + 0.9rem) var(--gr) 0.9rem var(--gl);
    font-family: var(--f-label); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.12em;
    color: var(--bone); pointer-events: none;
}
.hud > * { pointer-events: auto; }
/* --pk is set by the stage every frame: 0 over dark grounds, 1 over paper and hide, between during a cut */
@supports (color: color-mix(in srgb, red 50%, blue)) {
    .hud, .acts, .open-account { --pk: 0; --hud-fg: color-mix(in srgb, var(--ink) calc(var(--pk) * 100%), var(--bone)); }
    html .hud, html[data-tone] .hud, html .acts button, html[data-tone] .acts button { color: var(--hud-fg); }
    html .open-account, html[data-tone] .open-account {
        color: var(--hud-fg);
        background: color-mix(in srgb, rgba(236, 227, 204, 0.72) calc(var(--pk) * 100%), rgba(11, 11, 12, 0.55));
        border-color: color-mix(in srgb, rgba(29, 22, 17, 0.4) calc(var(--pk) * 100%), rgba(236, 232, 225, 0.4));
    }
}
html[data-tone="paper"] .hud { color: var(--ink); }
.mark { text-decoration: none; font-weight: 600; }
.hud-year { margin: 0; justify-self: center; display: flex; flex-direction: column; align-items: center; gap: 0.1rem; }
#hud-year { font-family: var(--f-display); font-size: 1.6rem; letter-spacing: 0.02em; text-transform: none; line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
#hud-act { font-size: 0.66rem; opacity: 0.75; }
.song {
    justify-self: end; display: inline-flex; align-items: center; gap: 0.5em;
    font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit;
    background: transparent; border: 1px solid currentColor; border-radius: 999px; padding: 0.45em 0.95em; cursor: pointer;
}
.song svg { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 1.5; }
.song[aria-pressed="true"] svg { animation: spin 3.2s linear infinite; }
.song[aria-pressed="true"] { background: var(--ochre); border-color: var(--ochre); color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

.acts { position: fixed; z-index: 100; left: var(--gl); bottom: calc(var(--bot) + 1rem); }
.acts ol { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; }
.acts button { display: block; width: 26px; height: 22px; padding: 0; border: 0; background: transparent; cursor: pointer; position: relative; color: var(--bone); }
html[data-tone="paper"] .acts button { color: var(--ink); }
.acts button::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px; background: currentColor; opacity: 0.35; transition: opacity 0.3s, height 0.3s; }
.acts button.on::before { opacity: 1; height: 4px; background: var(--ochre-bright); }
.acts button span { position: absolute; left: 0; bottom: 100%; white-space: nowrap; font-family: var(--f-label); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0; transform: translateY(4px); transition: opacity 0.2s, transform 0.2s; pointer-events: none; }
.acts button:hover span, .acts button:focus-visible span { opacity: 1; transform: none; }

.open-account {
    position: fixed; z-index: 100; right: var(--gr); bottom: calc(var(--bot) + 0.8rem);
    font-family: var(--f-label); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.12em;
    color: var(--bone); background: rgba(11, 11, 12, 0.55); border: 1px solid rgba(236, 232, 225, 0.4); border-radius: 999px;
    padding: 0.55rem 1rem; cursor: pointer; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
html[data-tone="paper"] .open-account { color: var(--ink); background: rgba(236, 227, 204, 0.7); border-color: rgba(29, 22, 17, 0.4); }
.open-account:hover { border-color: var(--ochre-bright); }

/* ---------- the account drawer ---------- */
.drawer {
    position: fixed; inset: 0 0 0 auto; margin: 0; height: 100dvh; max-height: none; width: min(46rem, 100vw); max-width: 100vw;
    padding: 0; border: 0; background: #f1eadb; color: var(--ink);
    display: grid; grid-template-rows: auto 1fr auto;
}
.drawer:not([open]) { display: none; }
.drawer::backdrop { background: rgba(0, 0, 0, 0.55); }
.account-head { padding: calc(var(--top) + 1.4rem) var(--gr) 1rem 2rem; border-bottom: 1px solid rgba(29, 22, 17, 0.15); position: relative; }
.account-kicker { margin: 0; font-family: var(--f-label); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted-light); }
.account-head h2 { margin: 0.2rem 0 0; font-family: var(--f-display); font-weight: 400; font-size: clamp(2rem, 1.5rem + 2vw, 3rem); line-height: 1.05; }
.account-close, .account-foot button {
    font-family: var(--f-label); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.12em;
    background: transparent; color: var(--ink); border: 1px solid rgba(29, 22, 17, 0.35); border-radius: 999px; padding: 0.5rem 1rem; cursor: pointer;
}
.account-close { position: absolute; right: var(--gr); top: calc(var(--top) + 1.4rem); }
.account-body { overflow-y: auto; padding: 1.5rem var(--gr) 3rem 2rem; overscroll-behavior: contain; }
.account-foot { display: flex; justify-content: space-between; padding: 0.8rem var(--gr) calc(var(--bot) + 0.8rem) 2rem; border-top: 1px solid rgba(29, 22, 17, 0.15); }
.account-body h2 { font-family: var(--f-display); font-weight: 400; font-size: 1.9rem; line-height: 1.1; margin: 2.2rem 0 0.8rem; }
.account-body .acct-part:first-child h2 { margin-top: 0; }
.account-body p { margin: 0.9em 0 0; }

/* shared record typography (drawer and no-JS page) */
.minor { font-family: var(--f-label); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted-light); margin-top: 2.2em; }
.note { font-size: 0.92em; color: var(--muted-light); font-style: italic; }
.lead-in { font-family: var(--f-display); font-style: italic; font-size: 1.25rem; margin-top: 1.8em !important; }
.death { font-family: var(--f-display); font-size: 1.6rem; line-height: 1.15; }
blockquote { margin: 0; }
blockquote.his { margin: 1.4em 0 !important; padding-left: 1.4rem; position: relative; font-size: 1.18em; line-height: 1.42; }
blockquote.his p { font-style: italic; }
blockquote.his::before { content: "\201C"; position: absolute; left: -0.1rem; top: -0.4rem; font-family: var(--f-display); font-size: 2.6em; color: var(--ochre); line-height: 1; }
blockquote.his.big p { font-family: var(--f-display); font-size: 1.2em; line-height: 1.25; }
blockquote.record { font-family: var(--f-display); font-size: 1.15em; border-top: 1px solid rgba(29, 22, 17, 0.2); border-bottom: 1px solid rgba(29, 22, 17, 0.2); padding: 0.8rem 0; margin: 1.4em 0 !important; }
blockquote footer, .account .src, .account-body .src { font-family: var(--f-label); font-size: 0.76rem; letter-spacing: 0.04em; color: var(--muted-light); margin-top: 0.5rem; }
.accounts { display: grid; gap: 1.2rem; margin-top: 1.2em; }
.accounts .account { border-top: 2px solid var(--ochre); padding-top: 0.9rem; display: grid; gap: 0.6rem; }
.accounts .who { font-family: var(--f-label); font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.76rem; margin: 0; color: var(--ochre); }
.accounts .account p { margin: 0; }
.spellings { list-style: none; padding: 0; margin: 1em 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.2rem 1.2rem; }
.spellings li { display: grid; gap: 0.1rem; padding: 0.6rem 0; border-top: 1px solid rgba(29, 22, 17, 0.15); }
.spellings .sp { font-size: 1.2rem; }
.spellings .by { font-family: var(--f-label); font-size: 0.74rem; color: var(--muted-light); }
.sources { margin-top: 2em; border-top: 1px solid rgba(29, 22, 17, 0.15); padding-top: 0.8rem; font-size: 0.9em; }
.sources summary { cursor: pointer; font-family: var(--f-label); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted-light); font-size: 0.8rem; }
.sources ul { list-style: none; padding: 0; margin: 0.8rem 0 0; display: grid; gap: 0.6rem; }
.conf { display: inline-block; font-family: var(--f-label); font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; padding: 0.08rem 0.4rem; margin-right: 0.3rem; border: 1px solid currentColor; border-radius: 2px; }
.c2 { color: var(--muted-light); border-style: dashed; }
.c3, .c4, .c5 { color: var(--ochre); }
.c5 { text-decoration: line-through; }
.table-wrap { overflow-x: auto; }
.myths { width: 100%; border-collapse: collapse; font-size: 0.92em; margin-top: 0.8rem; }
.myths th { text-align: left; font-family: var(--f-label); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.7rem; color: var(--muted-light); padding: 0 0.6rem 0.4rem 0; }
.myths td { border-top: 1px solid rgba(29, 22, 17, 0.15); padding: 0.55rem 0.6rem 0.55rem 0; vertical-align: top; }
.myths td:first-child { text-decoration: line-through; text-decoration-color: var(--ochre); color: var(--muted-light); }
.acct-years { display: none; }

/* the record, for readers without JavaScript */
main.record { max-width: 44rem; margin: 0 auto; padding: 4rem var(--gr) 6rem var(--gl); background: #f1eadb; color: var(--ink); }
main.record h1 { font-family: var(--f-display); font-weight: 400; font-size: 3.2rem; margin: 0; }
main.record .acct { margin-top: 3rem; }
main.record h2 { font-family: var(--f-display); font-weight: 400; }
.credits ul { list-style: none; padding: 0; font-family: var(--f-label); font-size: 0.78rem; color: var(--muted-light); display: grid; gap: 0.5rem; }
.js main.record { position: fixed; left: 0; top: 0; width: 1px; height: 1px; max-width: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: normal; padding: 0; margin: 0; }
.js main.record * { max-width: 1px; }
html:not(.js) .stage, html:not(.js) .hud, html:not(.js) .acts, html:not(.js) .open-account { display: none; }

/* ---------- narrow and portrait screens ---------- */
@media (max-width: 820px), (orientation: portrait) {
    .cap-high, .cap-quote { left: var(--gl); right: var(--gr); top: calc(var(--top) + 4.6rem); max-width: none; }
    .cap-low, .cap-side, .layer.plate .cap-quote, .layer.flight .cap-quote, .layer.card .cap-quote {
        left: var(--gl); right: var(--gr); top: auto; bottom: calc(var(--bot) + 4.4rem); width: auto; max-width: none; transform: none !important;
    }
    .cap-side { background: linear-gradient(to top, rgba(8, 8, 10, 0.85), rgba(8, 8, 10, 0.5) 80%, transparent); padding: 3rem 0 0.5rem; margin: 0 calc(-1 * var(--gr)) 0 calc(-1 * var(--gl)); padding-left: var(--gl); padding-right: var(--gr); }
    .layer.count .cap-side, .layer.card-fights .cap-side { background: linear-gradient(to top, rgba(195, 167, 129, 0.95), rgba(195, 167, 129, 0.7) 80%, transparent); }
    .count-wrap { padding: 0 var(--gr) 30vh var(--gl); justify-items: center; text-align: center; }
    .count-art { width: min(70vw, 22rem); max-height: 32vh; }
    .count-art::before, .count-art::after { -webkit-mask-position: center; mask-position: center; }
    .plate-fig.contain .plate-frame { inset: calc(var(--top) + 4rem) var(--gr) 34vh var(--gl); }
    .layer.plate .plate-frame::after { background: linear-gradient(to top, rgba(12, 13, 15, 0.92) 0%, rgba(12, 13, 15, 0.5) 34%, transparent 60%); }
    .plate-fig:not(.contain):not(.wide) .plate-frame { right: 0; bottom: 26vh; -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent); mask-image: linear-gradient(to bottom, #000 70%, transparent); }
    .plate-fig figcaption { display: none; }
    .tally-board { grid-template-columns: 1fr; padding: calc(var(--top) + 5rem) var(--gr) 0 var(--gl); align-content: start; }
    .tally-count { grid-row: auto; grid-column: auto; }
    .tallies, .nations { max-width: none; }
    .tally-board { padding-top: calc(var(--top) + 11rem) !important; }
    .tallies { gap: 0 14px; }
    .tallies i { height: 46px; width: 4px; margin-right: 7px; }
    .tallies i.cross { height: 56px; margin-left: -50px; margin-right: 20px; }
    .pair-row { inset: calc(var(--top) + 4.5rem) var(--gr) 34vh var(--gl); gap: 3vw; }
    /* phones: the act ticks and the account button share the bottom row without touching (checked down to 320px) */
    .acts ol { gap: 3px; }
    .acts button { width: 14px; height: 28px; }
    .open-account .wide { display: none; }
    .acts button span { display: none; }
    .hud .mark { font-size: 0.68rem; }
    .song .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .open-account { font-size: 0.7rem; padding: 0.45rem 0.8rem; }
    .layer.scene::before { background: linear-gradient(to bottom, rgba(236, 227, 204, 0.7), rgba(236, 227, 204, 0) 34%); }
}
@media (prefers-reduced-motion: reduce) {
    .song[aria-pressed="true"] svg { animation: none; }
}

/* the family line in the account */
.lineage { list-style: none; padding: 0 0 0 1.2rem; margin: 1rem 0 0; border-left: 2px solid rgba(29, 22, 17, 0.35); display: grid; gap: 0.9rem; }
.lineage li { position: relative; }
.lineage li::before { content: ""; position: absolute; left: calc(-1.2rem - 5px); top: 0.55em; width: 8px; height: 8px; border-radius: 50%; background: var(--ink); }

/* ---------- legibility ----------
   Every caption gets a ground made for it, by what lies behind it. Checked caption by caption, at phone
   and desktop sizes, terrain on and off, by tools/legibility.mjs (contrast against the worst pixels
   under each line, clipping, the interface, busy art).
     drawn scenes, the ledger map, the tally card, the document: a slip of printed paper pasted on the
       page, ink on it, cut by hand and set a hair off square;
     act titles and the one-line beats on the drawings: a clearing of paper, feathered into the page;
     terrain, night maps, photographs: a feathered smoke of dark under bone text;
     the hides: words kept inside the hide, ink on hide. */

/* attributions and kickers take the caption's own colour (the drawer's muted brown vanished on dark grounds) */
.cap blockquote footer { color: inherit; opacity: 0.82; }
.cap .kicker { opacity: 0.88; }
.cap { isolation: isolate; }
.cap::before, .cap::after { pointer-events: none; }

/* the paper slip */
.layer.scene:not(.light-caps) .cap:not(.cap-act):not(.cap-big)::before,
.layer.flight .cap::before,
.layer.card-fights .cap::before,
.layer.doc .cap:not(.cap-doc)::before {
    content: ""; position: absolute; z-index: -1; inset: -0.85rem -1.15rem -0.95rem;
    background-color: #f3ecd9;
    background-image:
        linear-gradient(to bottom, rgba(255, 252, 242, 0.5), rgba(243, 236, 217, 0.62) 45%, rgba(236, 226, 202, 0.62)),
        var(--noise);
    background-size: auto, 200px 200px;
    border-radius: 2px 3px 2px 4px / 3px 2px 4px 2px;
    box-shadow:
        0 1px 1px rgba(60, 40, 20, 0.22),
        0 12px 22px -14px rgba(60, 40, 20, 0.55),
        inset 0 0 0 1px rgba(120, 90, 50, 0.13),
        inset 0 0 26px rgba(160, 120, 60, 0.18);
    transform: rotate(-0.35deg);
}
.layer .cap:nth-of-type(even)::before { transform: rotate(0.28deg); }
/* the slip carries the words now: no glow needed around them */
.layer.scene:not(.light-caps) .cap, .layer.card-fights .cap, .layer.doc .cap { text-shadow: none; }

/* act titles and single beats: a clearing of paper, not a slip */
.layer.scene:not(.light-caps) .cap-act::before,
.layer.scene:not(.light-caps) .cap-big p::before {
    content: ""; position: absolute; z-index: -1;
    --fx: 6rem; --fy: 3rem;
    background: rgba(239, 231, 210, 0.92);
}
.cap-big p { position: relative; display: table; margin: 0 auto; }

/* smoke: terrain, night maps, photographs */
.layer.flight .cap::after,
.layer.plate .cap::after,
.layer.pair .cap::after,
.layer.title .cap-low::after {
    content: ""; position: absolute; z-index: -2;
    --fx: 4rem; --fy: 3rem;
    background: rgba(10, 10, 12, 0.76);
}
/* clearings and smoke: a rectangle feathered on every side, with an eased edge (--fx, --fy wide) */
.layer.scene:not(.light-caps) .cap-act::before,
.layer.scene:not(.light-caps) .cap-big p::before,
.layer.flight .cap::after, .layer.plate .cap::after, .layer.pair .cap::after, .layer.title .cap-low::after {
    inset: calc(-1 * var(--fy)) calc(-1 * var(--fx));
    --ex: transparent, rgba(0, 0, 0, 0.1) calc(var(--fx) * 0.25), rgba(0, 0, 0, 0.5) calc(var(--fx) * 0.5), rgba(0, 0, 0, 0.9) calc(var(--fx) * 0.75), #000 var(--fx),
          #000 calc(100% - var(--fx)), rgba(0, 0, 0, 0.9) calc(100% - var(--fx) * 0.75), rgba(0, 0, 0, 0.5) calc(100% - var(--fx) * 0.5), rgba(0, 0, 0, 0.1) calc(100% - var(--fx) * 0.25), transparent;
    --ey: transparent, rgba(0, 0, 0, 0.1) calc(var(--fy) * 0.25), rgba(0, 0, 0, 0.5) calc(var(--fy) * 0.5), rgba(0, 0, 0, 0.9) calc(var(--fy) * 0.75), #000 var(--fy),
          #000 calc(100% - var(--fy)), rgba(0, 0, 0, 0.9) calc(100% - var(--fy) * 0.75), rgba(0, 0, 0, 0.5) calc(100% - var(--fy) * 0.5), rgba(0, 0, 0, 0.1) calc(100% - var(--fy) * 0.25), transparent;
    -webkit-mask: linear-gradient(to right, var(--ex)), linear-gradient(to bottom, var(--ey));
    -webkit-mask-composite: source-in;
            mask: linear-gradient(to right, var(--ex)), linear-gradient(to bottom, var(--ey));
            mask-composite: intersect;
}
/* a flight swaps the slip for smoke as the terrain (or the night) comes in */
.layer.flight .cap::before, .layer.flight .cap::after { transition: opacity 0.6s ease; }
.layer.flight:not(.gl-on):not(.dark-ground) .cap::after { opacity: 0; }
.layer.flight.gl-on .cap::before, .layer.flight.dark-ground .cap::before { opacity: 0; }
.layer.flight.gl-on .cap, .layer.flight.dark-ground .cap { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6), 0 0 14px rgba(0, 0, 0, 0.45); }
.layer.flight:not(.gl-on):not(.dark-ground) .cap { text-shadow: none; }

/* the title: the face darkens toward the words */
.t-face::after {
    background:
        linear-gradient(to top, rgba(11, 11, 12, 0.97) 0%, rgba(11, 11, 12, 0.86) 30%, rgba(11, 11, 12, 0.5) 52%, rgba(11, 11, 12, 0.1) 74%, rgba(11, 11, 12, 0.5)),
        linear-gradient(to right, rgba(11, 11, 12, 0.6), transparent 60%);
}

/* the title: the stamp grows behind the first words; the kicker at full strength */
.layer.title .cap .kicker { opacity: 0.96; }

/* the pair: the photographs and their names stand clear of the caption below them */
.layer.pair .pair-row { bottom: calc(var(--bot) + 15.5rem); }

/* the hides: words stay inside the hide's safe middle */
.layer.count .cap-side { right: 17vw; width: min(24rem, 28vw); }
.count-art { max-height: 40vh !important; width: min(30vw, 28rem) !important; }
.count-name { max-width: 20ch; }
.layer.count .cap, .layer.card-count1913 .cap { text-shadow: none; }
/* on the hide, small labels are at full ink: the hide is darker than paper */
.layer.count .cap .kicker, .layer.card-count1913 .cap .kicker, .layer.count .cap blockquote footer, .layer.card-count1913 .cap blockquote footer { opacity: 1; }

/* the top bar: a halo behind its dark text, so it reads over dark margins and busy drawings too */
html[data-tone="paper"] .hud .mark, html[data-tone="paper"] .hud .hud-year {
    text-shadow: 0 0 6px rgba(238, 229, 207, 0.95), 0 0 14px rgba(238, 229, 207, 0.85);
}
html[data-tone="paper"] .song { background: rgba(238, 229, 207, 0.78); }

@media (max-width: 820px), (orientation: portrait) {
    .layer.scene:not(.light-caps) .cap:not(.cap-act):not(.cap-big)::before,
    .layer.flight .cap::before, .layer.card-fights .cap::before, .layer.doc .cap:not(.cap-doc)::before { inset: -0.7rem -0.65rem -0.8rem; }
    .layer.flight .cap::after, .layer.plate .cap::after, .layer.pair .cap::after, .layer.title .cap-low::after,
    .layer.scene:not(.light-caps) .cap-act::before, .layer.scene:not(.light-caps) .cap-big p::before { --fx: 1rem; --fy: 2.2rem; }
    .layer.pair .pair-row { bottom: 34vh; }
    /* the hide spreads past the screen's sides, so its body is as wide as the phone and the words sit on it */
    .layer.count .hide { inset: 1vh -17vw; }
    .layer.count::before { inset: 2vh -15vw; }
    .count-wrap { inset: calc(var(--top) + 9vh) 9vw 32vh 9vw; justify-items: center; text-align: center; align-content: start; gap: 0.5rem; }
    .count-name { font-size: clamp(1.15rem, 0.9rem + 1.6vw, 1.5rem); }
    .count-src { font-size: 0.7rem; }
    .count-art { width: min(56vw, 16rem) !important; max-height: 20vh !important; }
    .layer.count .cap-side {
        left: 9vw; right: 9vw; bottom: 24vh; width: auto;
        margin: 0; padding: 0; background: none;
        font-size: 1.02rem; line-height: 1.42;
    }
}
/* short phones: the figure, its name and source shrink so the words fit on the hide below them */
@media (orientation: portrait) and (max-height: 720px) {
    .count-art { max-height: 15vh !important; }
    .count-wrap { inset: calc(var(--top) + 8vh) 9vw 34vh 9vw; gap: 0.35rem; }
    .count-name { font-size: 1.1rem; }
    .count-src { font-size: 0.64rem; line-height: 1.35; }
    .layer.count .cap-side { bottom: 22vh; font-size: 0.95rem; line-height: 1.38; }
}

/* hides on wide screens: the left column starts high and stays above the hide's lower-left curve */
@media (min-width: 821px) and (orientation: landscape) {
    .count-wrap { inset: 18vh 50vw 20vh 19vw; align-content: start; gap: 0.7rem; }
    .count-art { max-height: 29vh !important; width: min(25vw, 23rem) !important; }
    .count-name { font-size: clamp(1.25rem, 0.9rem + 1.1vw, 1.85rem); max-width: 24ch; }
    .count-src { max-width: 42ch; }
}

/* ---------- the maker's credit: shown on the last two shots of the story ---------- */
.made-by {
    position: fixed; z-index: 100; right: var(--gr); bottom: calc(var(--bot) + 3.9rem);
    font-family: var(--f-label); font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase; text-decoration: none;
    color: var(--ink); background: rgba(236, 227, 204, 0.72); border: 1px solid rgba(29, 22, 17, 0.3); border-radius: 999px;
    padding: 0.5rem 0.95rem; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    opacity: 0; visibility: hidden; transform: translateY(6px);
    transition: opacity 0.5s ease, transform 0.5s ease, visibility 0s linear 0.5s;
}
.made-by b { font-weight: 600; letter-spacing: 0.06em; text-transform: none; font-size: 0.86rem; color: var(--red, #8c2a1c); }
.made-by:hover, .made-by:focus-visible { border-color: var(--ochre-bright); }
html[data-shot="end"] .made-by, html[data-shot="lineage"].tree-end .made-by { opacity: 1; visibility: visible; transform: none; transition: opacity 0.5s ease, transform 0.5s ease; }
html:not(.js) .made-by { display: none; }
@media (prefers-reduced-motion: reduce) { .made-by { transition: none; } }

/* the family tree scrolls under the top bar: a band of page colour keeps the bar clear of the names */
html[data-shot="lineage"] .hud { background: linear-gradient(to bottom, rgba(234, 224, 199, 0.97) 55%, rgba(234, 224, 199, 0)); padding-bottom: 1.6rem; }

/* the hides: the top bar sits on the dark border around the hide, so it is bone on dark there */
/* (wide screens only: on phones the hide spreads under the bar, and dark ink reads there) */
@media (min-width: 821px) and (orientation: landscape) {
    html[data-kind="count"] .hud, html[data-kind="count"] .acts button { color: var(--bone); }
    html[data-kind="count"] .hud .mark, html[data-kind="count"] .hud .hud-year { text-shadow: 0 0 6px rgba(20, 14, 9, 0.9), 0 0 14px rgba(20, 14, 9, 0.7); }
    html[data-kind="count"] .song { background: rgba(20, 14, 9, 0.45); }
}

/* ---------- from the visual review ---------- */
/* photo credits: a faint dark backing, so the line reads over bright parts of a photograph (feathers, a white mount) */
.plate-fig figcaption {
    left: calc(var(--gl) - 0.45rem); padding: 0.14rem 0.45rem; border-radius: 2px;
    background: rgba(12, 13, 15, 0.58); color: rgba(236, 232, 225, 0.86);
}
@media (max-width: 820px), (orientation: portrait) {
    /* a wide photograph keeps its whole width on a phone: the six riders of 1905 can be counted from the left */
    .plate-fig.wide .plate-frame { inset: calc(var(--top) + 4rem) 0 34vh 0; }
    .plate-fig.wide .plate-frame img { object-fit: contain; }
    .layer.plate .plate-fig.wide .plate-frame::after { display: none; }
    /* the pair: each name sits right under its photograph */
    .pair-row figure { height: auto; flex: 1 1 0; min-width: 0; grid-template-rows: auto auto; gap: 0.45rem; }
    .pair-row img { width: 100%; height: auto; max-height: calc(66vh - 8.5rem); }
    .pair-row figcaption { font-size: 1.15rem; }
    /* the title's second line crosses the stamp's lettering as it grows: a fuller smoke under it */
    .layer.title .cap-low::after { --fy: 2.8rem; background: rgba(10, 10, 12, 0.9); }
}
/* the flat map: a river's name fades when a place's name has to lie over it (ledgermap.js) */
.lm-label.river, .lm-label.region { transition: opacity 0.3s ease; }
/* river names over the terrain: a firmer dark edge, so the pale letters hold on snow */
#flight-labels .fl-label.river .fl-name {
    text-shadow: 0 0 1px rgba(8, 20, 42, 0.95), 0 0 3px rgba(8, 20, 42, 0.9), 0 1px 4px rgba(8, 20, 42, 0.8), 0 0 16px rgba(8, 20, 42, 0.55);
}

/* ---------- phones held sideways (short, wide screens) ----------
   The wide layout at every width, with smaller type: art to one side and words to the other, nothing under
   the top bar, the hides' words inside the hide. Checked at 844x390 and 740x360. */
@media (orientation: landscape) and (max-height: 500px) {
    /* photographs: the picture left, the words right (the narrow rules would stack them) */
    .cap-side {
        left: auto; right: calc(var(--gr) + 4vw); top: 50%; bottom: auto; width: min(26rem, 36vw); max-width: none;
        transform: translateY(-50%) !important; background: none; margin: 0; padding: 0;
        font-size: 1rem; line-height: 1.4;
    }
    .cap-side blockquote p { font-size: 1.25rem; }
    .cap-side .death { font-size: 1.6rem; }
    .plate-fig.contain .plate-frame { inset: calc(var(--top) + 3.2rem) 44vw calc(var(--bot) + 2.6rem) var(--gl); }
    .plate-fig:not(.contain):not(.wide) .plate-frame { right: 38vw; bottom: 0; -webkit-mask-image: linear-gradient(to right, #000 72%, transparent); mask-image: linear-gradient(to right, #000 72%, transparent); }
    .plate-fig.wide .plate-frame { inset: 0; }
    .plate-fig.wide .plate-frame img { object-fit: cover; }
    .layer.plate .plate-fig.wide .plate-frame::after { display: block; }
    .plate-fig figcaption { display: none; }

    /* the pair: the two photographs at full height on the left, the words on the right */
    .layer.pair .pair-row { inset: calc(var(--top) + 3.6rem) 48vw calc(var(--bot) + 2.6rem) var(--gl); gap: 3vw; }
    .pair-row figure { height: 100%; flex: 0 1 auto; grid-template-rows: minmax(0, 1fr) auto; gap: 0.3rem; transform: none !important; }
    .pair-row img { height: 100%; width: auto; max-height: none; }
    .pair-row figcaption { font-size: 1rem; }
    .layer.pair .cap-low { left: 56vw; right: var(--gr); top: 50%; bottom: auto; max-width: none; transform: translateY(-50%) !important; font-size: 1rem; line-height: 1.4; }

    /* the tally card: small marks in one row under the caption, the count to the right */
    .layer.card-fights .cap-high { top: calc(var(--top) + 4.3rem); font-size: 1rem; }
    .tally-board { grid-template-columns: 1fr auto; align-content: start; gap: 0.7rem 5vw; padding: 0 var(--gr) 0 10vw; padding-top: calc(var(--top) + 9.7rem) !important; }
    .tally-count { grid-row: 1 / 3; grid-column: 2; align-self: center; font-size: 5.5rem; }
    .tallies { gap: 0 14px; max-width: 60vw; }
    .tallies i { height: 46px; width: 4px; margin-right: 7px; }
    .tallies i.cross { height: 56px; margin-left: -50px; margin-right: 20px; }
    .nations { max-width: 60vw; font-size: 1rem; }

    /* the hides: figure and name on the left, the words on the right, all inside the hide; the source line
       is left to the full account */
    html .layer.count .hide { inset: 2vh 2vw; }
    html .layer.count::before { inset: 3vh 3vw; }
    html .count-wrap { inset: 21vh 53vw 21vh 20vw; padding: 0; justify-items: start; text-align: left; align-content: center; gap: 0.4rem; }
    html .count-art { width: min(22vw, 12rem) !important; max-height: 24vh !important; }
    html .count-art::before, html .count-art::after { -webkit-mask-position: left center; mask-position: left center; }
    html .count-name { font-size: 1rem; line-height: 1.2; max-width: 26ch; }
    html .count-src { display: none; }
    html .layer.count .cap-side { left: auto; right: 19vw; top: 50%; bottom: auto; width: 32vw; font-size: 0.82rem; line-height: 1.36; }
    html .layer.count .cap-side > * + * { margin-top: 0.4em; }

    /* words on the drawn scenes: a smaller slip in the top left corner, so the figures under it show */
    .layer.scene .cap-high, .layer.scene .cap-quote { left: calc(6vw + 1.6rem); right: auto; top: calc(var(--top) + 4.1rem); max-width: min(32rem, 62vw); }
    .layer.scene .cap-high { font-size: 1rem; line-height: 1.38; }
    .layer.scene .cap-quote blockquote p { font-size: 1.15rem; }
    .layer.scene .cap blockquote footer { margin-top: 0.4rem; font-size: 0.66rem; }

    /* single beats, act titles and the closing words: small, and set under the top bar, clear of the drawing */
    .cap-big { top: calc(var(--top) + 4.3rem); font-size: 1.7rem; line-height: 1.12; }
    .cap-act h2 { font-size: 2.5rem; }
    .cap-act > p:not(.kicker):not(.end-links):not(.count-line) { font-size: 0.95rem; line-height: 1.4; }
    .cap-act blockquote p { font-size: 1.5rem; }
    .cap-act .count-line { font-size: 1.3rem; }
    .layer.scene .cap-act { top: calc(var(--top) + 4.4rem); transform: translateX(-50%) !important; }
    .cap-act .end-links button { margin-top: 0.5rem; }
}

/* the 1913 count card: its hide is a layer of its own so it can drift under the words */
.c1913-bg { position: absolute; inset: -5%; background: inherit; will-change: transform; }
