/* Self-hosted fonts (SIL Open Font License; see fonts/LICENSES.md). Subsets: latin, latin-ext, runic. */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 300 500;
  font-display: swap;
  src: url(/fonts/fraunces-latin-ext-ed6f8e85.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 300 500;
  font-display: swap;
  src: url(/fonts/fraunces-latin-9e509503.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/ibm-plex-sans-latin-ext-effb1ea2.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/ibm-plex-sans-latin-f6667783.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Noto Sans Runic';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/noto-sans-runic-runic-ed20640a.woff2) format('woff2');
  unicode-range: U+16A0-16F8;
}
@font-face {
  font-family: 'Noto Sans Runic';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/noto-sans-runic-latin-ext-a3aef2d6.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Noto Sans Runic';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/noto-sans-runic-latin-008e9d99.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Beowulf reader. Charcoal table, two vellum leaves burnt at the edges (the manuscript, Cotton Vitellius A.xv,
   was damaged by fire in 1731), Old English left, Gummere right. The page itself never scrolls; scrolling,
   swiping or the arrow keys turn both leaves together. Without script the text reads as one long page. */
:root {
  --bg: #141311; --fg: #efe8db; --fg-soft: #b9b0a2; --rule: #2d2a25; --accent: #b08d57; --accent-ink: #141311; --focus: #d8b77a;
  --vellum: #d6c8aa; --vellum-deep: #c9b894; --ink: #2a2017; --ink-soft: #66543d; --rubric: #8e2b1c; --rubric-dot: #a3412b;
  --char: #1b110a; --scorch: #6b3a15; --shadow: rgba(0, 0, 0, 0.55);
  --display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --runic: "Noto Sans Runic", "Segoe UI Symbol", "Apple Symbols", Symbola, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #e9e2d5; --fg: #1b1916; --fg-soft: #5e574d; --rule: #d0c6b5; --accent: #7a5c30; --accent-ink: #f4efe6; --focus: #7a5c30;
    --vellum: #efe3c8; --vellum-deep: #e2d2ae; --shadow: rgba(60, 40, 20, 0.35);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #e9e2d5; --fg: #1b1916; --fg-soft: #5e574d; --rule: #d0c6b5; --accent: #7a5c30; --accent-ink: #f4efe6; --focus: #7a5c30;
  --vellum: #efe3c8; --vellum-deep: #e2d2ae; --shadow: rgba(60, 40, 20, 0.35);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--body); line-height: 1.5; }
a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 0.18em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 2px; }
::selection { background: var(--accent); color: var(--accent-ink); }
button { font: inherit; color: inherit; }

/* ---------- bar ---------- */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem 1.25rem; flex-wrap: wrap;
  padding: max(0.6rem, env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px)) 0.6rem max(1rem, env(safe-area-inset-left, 0px));
  font-size: 0.8125rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-soft);
}
.home { display: inline-flex; align-items: center; gap: 0.55rem; text-decoration: none; padding-block: 0.4rem; }
.home:hover { color: var(--fg); }
.home .rune { font-family: var(--runic); color: var(--accent); font-size: 1.35rem; line-height: 1; letter-spacing: 0; }
.work {
  margin: 0; font-family: var(--display); font-weight: 400; font-size: 1.35rem; letter-spacing: 0.02em; text-transform: none; color: var(--fg);
}
.ctl { display: flex; align-items: center; gap: 0.6rem; }
.modes { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; padding: 2px; }
.modes button, .toc-btn {
  background: transparent; border: 0; border-radius: 999px; cursor: pointer; padding: 0.4rem 0.75rem; min-height: 36px;
  font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-soft);
}
.modes button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.modes button:hover:not([aria-pressed="true"]), .toc-btn:hover { color: var(--fg); }
.toc-btn { border: 1px solid var(--accent); }

/* ---------- static text (no script, or before the reader starts) ---------- */
.book { padding-inline: max(1rem, env(safe-area-inset-left, 0px)) max(1rem, env(safe-area-inset-right, 0px)); }
.fitt { max-width: 72rem; margin: 0 auto; padding-block: 2rem; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 2.5rem; border-bottom: 1px solid var(--rule); }
.fitt > .fitt-head { grid-column: 1 / -1; }
@media (max-width: 760px) { .fitt { grid-template-columns: minmax(0, 1fr); } }
.fitt-head { display: flex; align-items: baseline; gap: 0.8rem; margin: 0 0 0.9em; }
.fitt-head .num { font-family: var(--display); font-size: 1.5em; color: var(--rubric); line-height: 1; }
.fitt-head .ttl { font-size: 0.68em; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft); font-family: var(--body); }
html:not(.js) .fitt-head .num { color: var(--accent); }
html:not(.js) .fitt-head .ttl { color: var(--fg-soft); }
.oe, .tr { font-family: var(--display); }
/* Each line is its own grid: b-verses line up after the usual a-verse width; a longer a-verse pushes only its own
   b-verse along. Line numbers sit in the margin outside the text column. */
.l { position: relative; display: grid; grid-template-columns: minmax(var(--aw, 12em), max-content) minmax(0, 1fr); column-gap: 1.1em; margin: 0; }
.l .a, .l .b { min-width: 0; }
.l.solo .a { grid-column: 1 / -1; }
.l .no { position: absolute; right: -3.3em; top: 0; width: 2.2em; text-align: right; font-family: var(--body); font-size: 0.66em; line-height: inherit; letter-spacing: 0.04em; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
html:not(.js) .l { grid-template-columns: minmax(var(--aw, 12em), max-content) minmax(0, 1fr) 2.4em; }
html:not(.js) .l .no { position: static; grid-column: 3; grid-row: 1; width: auto; }
html:not(.js) .ctl { display: none; }
html:not(.js) .l .no { color: var(--fg-soft); }
.t { margin: 0; padding-left: 1.4em; text-indent: -1.4em; }
.t.ps { margin-top: 0.55em; }
.k { font-weight: 500; -webkit-text-stroke: 0.035em currentColor; color: var(--rubric); }
html:not(.js) .k { color: var(--accent); }
.lac { color: var(--ink-soft); letter-spacing: 0.08em; background: radial-gradient(ellipse at center, rgba(107, 58, 21, 0.38), rgba(107, 58, 21, 0) 70%); border-radius: 40%; }
.cap, .fw { font: inherit; }

/* ---------- reader (script on) ---------- */
html.js, html.js body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html.js .reader { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
html.js .book { position: relative; min-height: 0; padding-block: 0.25rem 0.5rem; touch-action: pinch-zoom; }
html.js .book > .fitt { display: none; }
.spread {
  height: 100%; width: 100%; max-width: 78rem; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(0.4rem, 1.6vw, 1.5rem);
}
.reader[data-mode="oe"] .spread, .reader[data-mode="tr"] .spread { grid-template-columns: minmax(0, 44rem); justify-content: center; }
.reader[data-mode="oe"] .leaf-tr, .reader[data-mode="tr"] .leaf-oe { display: none; }
/* Side by side only when both leaves are wide enough for a verse line; tablets in portrait stack them. */
@media (max-width: 900px) {
  .spread { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
  .reader[data-mode="oe"] .spread, .reader[data-mode="tr"] .spread { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
}

.leaf {
  --u: 14px;
  container-type: size;
  position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column;
  padding: calc(var(--u) * 4.1) calc(var(--u) * 2.5) calc(var(--u) * 3.3) calc(var(--u) * 2.5);
  color: var(--ink);
}
.leaf.turning { will-change: transform, opacity; }
.burn { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.burn .v { flood-color: var(--vellum); }
.burn .vd { flood-color: var(--vellum-deep); }
.burn .c { flood-color: var(--char); }
.burn .s { flood-color: var(--scorch); }
.burn .sh { flood-color: var(--shadow); }
.rh {
  position: relative; display: flex; justify-content: space-between; gap: 1rem; margin: calc(var(--u) * -0.6) calc(var(--u) * 1.2) calc(var(--u) * 0.6);
  font-family: var(--body); font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; height: 1.6em; line-height: 1.6em; flex: none;
}
.rh span { overflow: hidden; text-overflow: ellipsis; }
.rh span:first-child { flex: 1 1 auto; min-width: 0; }
.rh span:last-child { flex: none; }
.txt {
  position: relative; flex: 1 1 auto; min-height: 0; overflow-x: visible; overflow-y: clip;
  padding-left: var(--lane); --lane: 3.3em;
  font-size: var(--fs); line-height: 1.52;
}
.txt.oe { --fs: clamp(0.86rem, 0.55rem + 0.95vh, 1.12rem); padding-right: 2.2em; }
.txt.tr { --fs: clamp(0.84rem, 0.53rem + 0.92vh, 1.08rem); font-weight: 350; color: #3a2e21; }
/* the type also follows the leaf's width, so a verse line (about 31 em with margins) never has to wrap */
@media (min-width: 561px) {
  .txt.oe { --fs: max(0.74rem, min(clamp(0.86rem, 0.55rem + 0.95vh, 1.12rem), 3.05cqi)); }
  .txt.tr { --fs: max(0.74rem, min(clamp(0.84rem, 0.53rem + 0.92vh, 1.08rem), 3.4cqi)); }
}
@media (max-width: 560px) {
  /* narrow: a-verse and b-verse run on one line with a wide caesura and wrap with a hanging indent */
  .l { display: block; padding-left: 1.2em; text-indent: -1.2em; }
  .l .a { margin-right: 1.1em; }
  .txt { --lane: 1.7em; }
  /* the fitt's initial is set into the text: its first lines step in */
  .txt.oe .first, .txt.oe .first + p, .txt.oe .first + p + p, .txt.tr .first, .txt.tr .first + p { margin-left: 2.1em; }
}
.txt > .fitt-head { margin: 0 0 0.75em calc(var(--lane) * -1); padding-left: var(--lane); }
.txt .t:first-child { margin-top: 0; }
.probe { position: absolute !important; visibility: hidden; left: 0; top: 0; height: auto !important; flex: none; overflow: visible; }
.probe.unwrapped > p { white-space: nowrap; width: max-content; }
.mA .l { display: block; }
.mA .l .b, .mA .l .no { display: none; }
.mA .l .a { display: inline-block; white-space: nowrap; }

/* Fitt initial: the first letter hangs in the margin lane, drawn on a canvas with Insular red dotting. */
.first .cap { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.first .fw { text-transform: uppercase; letter-spacing: 0.06em; }
.txt.tr .first .fw { letter-spacing: 0.04em; }
.l.incipit .a, .l.incipit .b { text-transform: uppercase; letter-spacing: 0.07em; }
.ini { position: absolute; left: 0; pointer-events: none; display: block; }
.ini canvas { display: block; }

/* ---------- footer ---------- */
.foot {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.15rem 0.8rem;
  padding: 0.25rem max(1rem, env(safe-area-inset-right, 0px)) max(0.6rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
  color: var(--fg-soft); font-size: 0.75rem;
}
html:not(.js) .foot .nav, html:not(.js) .foot .prog, html:not(.js) .foot .where { display: none; }
.nav {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--rule); background: transparent; cursor: pointer;
  font-family: var(--display); font-size: 1.35rem; line-height: 1; color: var(--fg-soft); display: grid; place-items: center; padding: 0 0 0.12em;
}
.nav:hover:not(:disabled) { border-color: var(--accent); color: var(--fg); }
.nav:disabled { opacity: 0.35; cursor: default; }
.prog { position: relative; height: 18px; cursor: pointer; touch-action: none; }
.prog::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--rule); }
.fill { position: absolute; left: 0; top: 50%; height: 2px; width: 100%; margin-top: -0.5px; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); transition: transform 300ms ease; }
.ticks { position: absolute; inset: 0; }
.ticks i { position: absolute; top: 50%; width: 1px; height: 7px; margin-top: -3.5px; background: var(--fg-soft); opacity: 0.45; }
.where { grid-column: 1 / 3; margin: 0; font-variant-numeric: tabular-nums; letter-spacing: 0.03em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legal { grid-column: 3; margin: 0; text-align: right; white-space: nowrap; }
.legal .mark { font-family: var(--runic); color: var(--accent); margin-right: 0.4rem; }
.modes .sm { display: none; }
/* up to tablet width the mode labels shorten, so the bar stays one line with the creatures' sound button in it */
@media (max-width: 700px) {
  .modes .lg { display: none; }
  .modes .sm { display: inline; }
  .bar .home-t { display: none; }
}
@media (max-width: 560px) {
  .bar { flex-wrap: nowrap; gap: 0.5rem; padding-block: max(0.4rem, env(safe-area-inset-top, 0px)) 0.35rem; }
  .bar .home-t { display: none; }
  .work { font-size: 1.15rem; }
  .ctl { gap: 0.4rem; }
  .modes button, .toc-btn { padding-inline: 0.55rem; font-size: 0.7rem; min-height: 34px; }
  .modes .lg { display: none; }
  .modes .sm { display: inline; }
  .legal { display: none; }
  .foot { gap: 0.1rem 0.6rem; }
  .nav { width: 36px; height: 36px; }
  .where { grid-column: 1 / -1; text-align: center; }
  .leaf { padding: calc(var(--u) * 3.4) calc(var(--u) * 1.5) calc(var(--u) * 2.6) calc(var(--u) * 1.5); }
  .rh { margin-inline: calc(var(--u) * 1.5); }
  .l .no { display: none; }
  .l.incipit .a, .l.incipit .b { letter-spacing: 0.01em; }
  .txt.oe { padding-right: 0; --fs: clamp(0.76rem, 0.5rem + 0.75vh, 0.9rem); }
  .txt.tr { --fs: clamp(0.76rem, 0.5rem + 0.72vh, 0.88rem); }
}
/* narrow phones: the header (title, sound, three modes, panel) must fit in 320-420 px without widening the page */
@media (max-width: 420px) {
  .bar { padding-inline: 12px; gap: 0.35rem; }
  .ctl { gap: 0.25rem; }
  .work { font-size: 1.05rem; min-width: 0; }
  .modes button, .toc-btn { padding-inline: 0.42rem; letter-spacing: 0.05em; }
  .bar .wc-sound.in-bar { width: 32px; height: 32px; }
}
@media (max-width: 350px) {
  .work { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
html:not(.js) .foot { display: flex; justify-content: space-between; padding-block: 2rem 3rem; }

/* ---------- the panel: Fitts · Bestiary · About ---------- */
.toc {
  width: min(54rem, calc(100% - 2rem)); height: min(46rem, calc(100% - 2rem)); padding: 0; border: 1px solid var(--rule); border-radius: 12px;
  background: var(--bg); color: var(--fg); overflow: hidden; display: none; flex-direction: column;
}
.toc[open] { display: flex; }
.toc::backdrop { background: rgba(10, 9, 8, 0.6); }
.toc-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 0.9rem 0.75rem 1.25rem; border-bottom: 1px solid var(--rule); flex: none; }
.tabs { display: flex; gap: 0.25rem; min-width: 0; }
.tabs button {
  background: transparent; border: 0; border-radius: 999px; cursor: pointer; padding: 0.45rem 0.85rem; min-height: 36px;
  font-family: var(--display); font-size: 1.05rem; color: var(--fg-soft);
}
.tabs button[aria-selected="true"] { background: var(--bg-raise, rgba(255, 255, 255, 0.06)); color: var(--fg); box-shadow: inset 0 0 0 1px var(--rule); }
.tabs button:hover { color: var(--fg); }
.x { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--rule); background: transparent; color: var(--fg-soft); font-size: 1.3rem; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0 0 0.1em; }
.x:hover { color: var(--fg); border-color: var(--accent); }
.pane { overflow-y: auto; padding: 1rem 1.25rem 1.4rem; min-height: 0; flex: 1 1 auto; }
.pane[hidden] { display: none; }

/* fitts: two columns read down then across, every row shared by both columns so neighbours line up */
.fitts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-auto-flow: column; column-gap: 1.6rem; }
.fitts li { min-width: 0; border-bottom: 1px solid var(--rule); display: flex; }
.fitts a { flex: 1; display: grid; grid-template-columns: 4.6rem minmax(0, 1fr) auto; column-gap: 0.6rem; align-items: baseline; padding: 0.5rem 0.25rem; text-decoration: none; font-size: 0.86rem; line-height: 1.35; }
.fitts .num { font-family: var(--display); color: var(--accent); font-size: 0.95rem; }
.fitts .ttl { min-width: 0; }
.fitts .ln { color: var(--fg-soft); font-variant-numeric: tabular-nums; font-size: 0.76rem; white-space: nowrap; }
.fitts a:hover .ttl { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 0.2em; }
.fitts a[aria-current="true"] { background: var(--bg-raise, rgba(255, 255, 255, 0.05)); border-radius: 6px; }
.fitts a[aria-current="true"] .ttl { color: var(--accent); }
@media (max-width: 620px) { .fitts { grid-template-columns: minmax(0, 1fr); grid-auto-flow: row; grid-template-rows: none !important; } }

.pane .lead { margin: 0 0 1rem; font-size: 0.86rem; line-height: 1.55; color: var(--fg-soft); max-width: 62ch; }
.about h3 { margin: 1.3rem 0 0.4rem; font-family: var(--display); font-weight: 400; font-size: 1.05rem; color: var(--fg); }
.about h3:first-child { margin-top: 0.2rem; }
.about p { margin: 0 0 0.6rem; font-size: 0.86rem; line-height: 1.55; color: var(--fg-soft); max-width: 64ch; }
.about a { color: var(--fg); }
.about .k { color: var(--accent); -webkit-text-stroke: 0; }
.sources { list-style: none; margin: 0.3rem 0 0.4rem; padding: 0; border-top: 1px solid var(--rule); }
.sources li { display: grid; grid-template-columns: minmax(0, 13rem) minmax(0, 1fr); gap: 0.2rem 1rem; padding: 0.45rem 0; border-bottom: 1px solid var(--rule); font-size: 0.82rem; line-height: 1.45; }
.sources li span:first-child { color: var(--fg); }
.sources li span:last-child { color: var(--fg-soft); }
@media (max-width: 620px) { .sources li { grid-template-columns: minmax(0, 1fr); } .toc-head { padding-left: 0.8rem; } .tabs button { padding-inline: 0.6rem; font-size: 0.98rem; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
