/* --- The book reader (pdf.js, self-hosted) --------------------------------
   The chrome around the pages. The .textLayer block at the end is pdf.js's own,
   flattened from web/pdf_viewer.css of pdfjs-dist 6.3.289 — it positions the
   invisible text over the picture and is coupled to that version, so re-extract
   it when the vendored copy changes.                                        */
.pdfv { position: relative; }
.pdfv__bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--color-surface);
}
.pdfv__btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-inline-size: 34px; min-block-size: 34px; padding: 0 var(--space-2);
  border: 1px solid transparent; border-radius: var(--radius-md);
  background: none; color: var(--color-text); font: inherit; font-size: var(--text-sm);
  cursor: pointer;
}
.pdfv__btn:hover { background: var(--color-surface-sunk); }
.pdfv__btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.pdfv__btn[aria-expanded="true"] { background: var(--color-surface-sunk); border-color: var(--color-border); }
/* Forward and back share one chevron from the sprite, turned round for the
   forward one. The theme already flips .icon--dir in RTL, which the back arrow
   uses; the forward arrow must therefore be flipped in LTR and left alone in RTL,
   and the selector has to out-specify [dir="rtl"] .icon--dir to say so. */
.pdfv__flip { transform: scaleX(-1); }
[dir="rtl"] .pdfv__flip { transform: none; }
.pdfv__page-input {
  inline-size: 4.5em; padding: var(--space-1) var(--space-2); text-align: center;
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface-sunk); color: var(--color-text); font: inherit; font-size: var(--text-sm);
}
.pdfv__of { color: var(--color-text-muted); font-size: var(--text-sm); white-space: nowrap; }
.pdfv__sep { flex: 0 0 1px; align-self: stretch; margin-inline: var(--space-2); background: var(--color-border); }
.pdfv__stage {
  block-size: min(82vh, 1100px); min-block-size: 420px;
  overflow: auto; overscroll-behavior: contain;
  padding: var(--space-4) 16px;
  border: 1px solid var(--color-border); border-block-start: 0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--color-surface-sunk);
  scroll-behavior: smooth;
}
.pdfv__page {
  position: relative; margin: 0 auto var(--space-4);
  background: #fff; box-shadow: var(--shadow-sm);
  /* A page that has not been drawn yet is a blank sheet of the right shape, so
     the scrollbar means what it says from the first frame. */
}
.pdfv__page-no {
  position: absolute; inset-block-start: 50%; inset-inline-start: 50%;
  transform: translate(-50%, -50%);
  color: #9a9a9a; font-size: var(--text-sm);
}
.pdfv__page.is-rendered .pdfv__page-no { display: none; }
.pdfv__canvas { display: block; }
.pdfv__password { display: grid; gap: var(--space-3); justify-items: center; padding: var(--space-8) var(--space-4); text-align: center; }
.pdfv__password .input { max-inline-size: 18em; }

/* Full screen: the stage takes the whole screen and the bar sits on top of it. */
.pdfv:fullscreen { background: var(--color-surface-sunk); }
.pdfv:fullscreen .pdfv__bar { border-radius: 0; }
.pdfv:fullscreen .pdfv__stage { block-size: calc(100vh - 52px); min-block-size: 0; border-radius: 0; }

/* The search panel */
.pdfv__find {
  padding: var(--space-3);
  border: 1px solid var(--color-border); border-block-start: 0;
  background: var(--color-surface);
}
.pdfv__find-form { display: flex; gap: var(--space-2); }
.pdfv__find-input { flex: 1 1 auto; min-inline-size: 0; }
.pdfv__find-status { margin: var(--space-2) 0 0; color: var(--color-text-muted); font-size: var(--text-sm); }
.pdfv__find-list { max-block-size: 30vh; overflow: auto; margin: var(--space-2) 0 0; padding: 0; list-style: none; }
.pdfv__find-hit + .pdfv__find-hit { border-block-start: 1px solid var(--color-border); }
.pdfv__find-jump {
  display: grid; gap: 2px; inline-size: 100%; padding: var(--space-2);
  border: 0; border-radius: var(--radius-md); background: none;
  color: inherit; font: inherit; text-align: start; cursor: pointer;
}
.pdfv__find-jump:hover { background: var(--color-surface-sunk); }
.pdfv__find-page { color: var(--color-accent); font-size: var(--text-xs); font-weight: 600; }
.pdfv__find-text { color: var(--color-text-muted); font-size: var(--text-sm); }

/* Before the module runs, and if it never does. */
.pdfv__loading { display: grid; place-items: center; gap: var(--space-3); padding: var(--space-8); color: var(--color-text-muted); }
.pdfv.is-ready .pdfv__loading { display: none; }

/* --- pdf.js's text layer, flattened (pdfjs-dist 6.3.289) ------------------ */
.textLayer {
  position: absolute; inset: 0; z-index: 0;
  overflow: clip; opacity: 1; line-height: 1;
  text-align: initial; letter-spacing: normal; word-spacing: normal;
  text-size-adjust: none; forced-color-adjust: none;
  transform-origin: 0 0; caret-color: CanvasText;
  --min-font-size: 1;
  --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));
  --min-font-size-inv: calc(1 / var(--min-font-size));
}
.textLayer span,
.textLayer br {
  position: absolute; color: transparent; white-space: pre;
  cursor: text; transform-origin: 0% 0%; user-select: text;
}
.textLayer > :not(.markedContent),
.textLayer .markedContent span:not(.markedContent) {
  z-index: 1;
  --font-height: 0;
  --scale-x: 1;
  --rotate: 0deg;
  font-size: calc(var(--text-scale-factor) * var(--font-height));
  transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
}
.textLayer .markedContent { display: contents; }
.textLayer span[role="img"] { user-select: none; cursor: default; }
.textLayer ::selection { background: rgba(0 0 255 / 0.25); color: transparent; }
.textLayer .endOfContent {
  display: block; position: absolute; inset: 100% 0 0; z-index: 0;
  cursor: default; user-select: none;
}
.textLayer.selecting .endOfContent { top: 0; }
