@font-face { font-family: Schola; src: url(fonts/schola-regular.woff2) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: Schola; src: url(fonts/schola-italic.woff2) format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: Schola; src: url(fonts/schola-bold.woff2) format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --ground: #d9d4c9;
  --ground-2: #cfc9bc;
  --ink: #2b2722;
  --ink-soft: #6b6458;
  --rule: rgba(43, 39, 34, .16);
  --paper: #f4f0e2;
  --panel: #efeadc;
  --red: #c4343a;
  --accent: #b02a30;
  --shadow: 0 1px 2px rgba(40, 32, 20, .18), 0 18px 48px -12px rgba(40, 32, 20, .38);
  --bar-h: 52px;
  --foot-h: 44px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #1d1b18; --ground-2: #24211d; --ink: #ebe4d4; --ink-soft: #a39a88;
    --rule: rgba(235, 228, 212, .14); --panel: #26231f; --accent: #e0686c;
    --shadow: 0 1px 2px rgba(0,0,0,.5), 0 24px 60px -16px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #1d1b18; --ground-2: #24211d; --ink: #ebe4d4; --ink-soft: #a39a88;
  --rule: rgba(235, 228, 212, .14); --panel: #26231f; --accent: #e0686c;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 24px 60px -16px rgba(0,0,0,.7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(120% 90% at 50% 45%, var(--ground) 0%, var(--ground-2) 100%) fixed var(--ground);
  color: var(--ink);
  font: 16px/1.45 Schola, "Century Schoolbook", Georgia, serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* bars */
.bar { position: fixed; left: 0; right: 0; display: flex; align-items: center; gap: 12px; padding: 0 16px; z-index: 5; }
.bar.top { top: 0; height: var(--bar-h); border-bottom: 1px solid var(--rule); }
.bar.bottom { bottom: 0; height: var(--foot-h); border-top: 1px solid var(--rule); font-size: 13px; color: var(--ink-soft); }
.where { flex: 1; min-width: 0; text-align: center; display: flex; flex-direction: column; line-height: 1.15; }
.book-title { color: var(--ink); text-decoration: none; font-variant: small-caps; letter-spacing: .12em; font-size: 15px; }
.loc { font-style: italic; font-size: 13px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools { display: flex; align-items: center; gap: 6px; }
.ghost { background: none; border: 1px solid transparent; border-radius: 6px; padding: 6px 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.ghost:hover { border-color: var(--rule); }
.ghost[aria-pressed="true"], .ghost[aria-expanded="true"] { border-color: var(--rule); background: var(--panel); }
.ghost:focus-visible, .seg button:focus-visible, .turn:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.back { color: var(--ink-soft); text-decoration: none; font-size: 14px; white-space: nowrap; }
.back:hover { color: var(--ink); }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 7px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 6px 11px; cursor: pointer; font-size: 14px; letter-spacing: .02em; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--ground); }
.folio { min-width: 110px; font-variant-numeric: lining-nums; color: var(--ink); }
.hint { min-width: 110px; text-align: right; }
#scrub { flex: 1; accent-color: var(--accent); max-width: 520px; margin: 0 auto; }

/* stage */
#stage { position: fixed; top: var(--bar-h); bottom: var(--foot-h); left: 0; right: 0; display: flex; align-items: center; justify-content: center; }
.spread { display: flex; box-shadow: var(--shadow); position: relative; background: var(--paper); }
.spread.single { box-shadow: var(--shadow); }
.page { position: relative; cursor: zoom-in; display: block; background: var(--paper); }
.page img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.page.blank { cursor: default; }
/* the fold: a soft shadow at the gutter */
.spread:not(.single) .page.verso::after, .spread:not(.single) .page.recto::after { content: ""; position: absolute; top: 0; bottom: 0; width: 5%; pointer-events: none; }
.spread:not(.single) .page.verso::after { right: 0; background: linear-gradient(to left, rgba(60,45,25,.16), rgba(60,45,25,0)); }
.spread:not(.single) .page.recto::after { left: 0; background: linear-gradient(to right, rgba(60,45,25,.2), rgba(60,45,25,0)); }
.turn { position: absolute; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--ink-soft); padding: 18px 10px; cursor: pointer; border-radius: 8px; }
.turn svg { width: 16px; height: 34px; stroke-width: 1.4; }
.turn:hover { color: var(--ink); background: var(--rule); }
.turn:disabled { opacity: .2; cursor: default; background: none; }
.turn.prev { left: 8px; } .turn.next { right: 8px; }

/* text view */
.textview { position: fixed; top: var(--bar-h); bottom: var(--foot-h); left: 0; right: 0; overflow: auto; background: var(--ground); z-index: 3; }
.textcols { max-width: 1120px; margin: 0 auto; padding: 28px 24px 64px; display: grid; grid-template-columns: 1fr 1fr; gap: 48px; }
.textcols article { font-size: 17px; line-height: 1.55; }
.textcols h3 { font-weight: 400; font-variant: small-caps; letter-spacing: .08em; font-size: 15px; color: var(--ink-soft); border-bottom: 1px solid var(--rule); padding-bottom: 6px; margin: 0 0 14px; }
.textcols p { margin: 0 0 .7em; text-wrap: pretty; hyphens: auto; }
.textcols p.cap { font-size: 14px; color: var(--ink-soft); }
.textcols p.head { text-align: center; letter-spacing: .06em; margin-top: 1.2em; }

/* drawers */
.drawer { position: fixed; top: 0; bottom: 0; width: min(420px, 92vw); background: var(--panel); z-index: 8; display: flex; flex-direction: column; box-shadow: 0 0 40px rgba(0,0,0,.25); }
.drawer.left { left: 0; } .drawer.right { right: 0; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.drawer-head h2 { margin: 0; font-weight: 400; font-variant: small-caps; letter-spacing: .14em; font-size: 18px; }
.close { font-size: 22px; line-height: 1; padding: 2px 10px; }
.scrim { position: fixed; inset: 0; background: rgba(20,16,10,.35); z-index: 7; }
.toc { overflow: auto; padding: 8px 16px 40px; font-size: 15px; }
.toc h3 { font-weight: 400; font-variant: small-caps; letter-spacing: .1em; font-size: 15px; margin: 20px 0 6px; color: var(--ink-soft); }
.toc a { display: flex; gap: 8px; align-items: baseline; color: var(--ink); text-decoration: none; padding: 3px 4px; border-radius: 4px; }
.toc a:hover { background: var(--rule); }
.toc a .t { flex: 1; min-width: 0; }
.toc a .dots { flex: 1; border-bottom: 1px dotted var(--ink-soft); opacity: .5; transform: translateY(-4px); min-width: 12px; }
.toc a .p { font-variant-numeric: lining-nums tabular-nums; color: var(--ink-soft); }
.toc a.chapter { font-variant: small-caps; letter-spacing: .08em; font-size: 16px; margin-top: 6px; }
.toc a.section { padding-left: 18px; font-size: 14px; }
.toc a.fig { font-size: 14px; }
.toc a.fig .n { min-width: 56px; color: var(--ink-soft); }
.toc a.here { background: var(--rule); }
#q { margin: 14px 16px 4px; padding: 9px 12px; font: inherit; font-size: 16px; border: 1px solid var(--rule); border-radius: 6px; background: var(--ground); color: var(--ink); }
.count { margin: 4px 16px 6px; font-size: 13px; color: var(--ink-soft); font-style: italic; min-height: 1em; }
.results { list-style: none; margin: 0; padding: 0 8px 40px; overflow: auto; }
.results li a { display: block; padding: 8px 10px; border-radius: 5px; color: var(--ink); text-decoration: none; font-size: 14px; line-height: 1.45; }
.results li a:hover, .results li a:focus-visible { background: var(--rule); }
.results .rp { font-variant: small-caps; letter-spacing: .06em; color: var(--ink-soft); font-size: 13px; display: block; }
.results mark { background: none; color: var(--accent); font-weight: 700; }

/* zoom */
.zoom { position: fixed; inset: 0; z-index: 10; background: #12100d; display: flex; flex-direction: column; }
.zoom-bar { height: 46px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 18px; color: #e6dfcf; font-style: italic; font-size: 14px; }
.zoom-tools { display: inline-flex; gap: 6px; }
.zoom .ghost { color: #e6dfcf; }
.zoom .ghost:hover { border-color: rgba(255,255,255,.2); }
.zoom-pane { flex: 1; overflow: auto; cursor: grab; display: grid; place-items: center; }
.zoom-pane.dragging { cursor: grabbing; }
.zoom-pane img { display: block; user-select: none; -webkit-user-drag: none; max-width: none; }
.zoom-pane.fit img { max-width: calc(100vw - 24px); max-height: calc(100dvh - 58px); width: auto; height: auto; cursor: zoom-in; }
.zoom-pane.full { place-items: start; }

@media (max-width: 820px), (orientation: portrait) and (max-width: 1100px) {
  .ghost span { display: none; }
  .hint { display: none; }
  .turn { padding: 12px 4px; }
  .turn.prev { left: 0; } .turn.next { right: 0; }
  .textcols { grid-template-columns: 1fr; gap: 24px; }
  .book-title { display: none; }
  .loc { font-size: 14px; color: var(--ink); }
  .bar { padding: 0 8px; gap: 6px; }
  .seg button { padding: 6px 9px; }
}
@media (prefers-reduced-motion: no-preference) {
  .spread { transition: opacity .18s ease; }
  .spread.fading { opacity: .35; }
}
.textcols p.labels { font-size: 13px; font-style: italic; color: var(--ink-soft); margin-bottom: .3em; }
.textcols p.labels span { font-style: normal; font-variant: small-caps; letter-spacing: .06em; }
.textcols p.cap { border-left: 2px solid var(--rule); padding-left: 10px; }
