/* Online issue reader. Builds on the tokens in site.css. */
html, body { height: 100%; }
body.reader-body { overflow: hidden; background: #1d2a35; }
:root[data-theme="dark"] body.reader-body { background: #0a131b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body.reader-body { background: #0a131b; } }

.reader { display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); height: 100dvh; }
.reader-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; min-height: 60px;
  background: var(--navy); color: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.25); z-index: 5;
}
.reader-bar .icon-btn { width: 40px; height: 40px; }
.reader-title { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.35; overflow: hidden; }
.reader-title strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-title span { font-size: 13px; color: rgba(255,255,255,.72); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-pager { display: flex; align-items: center; gap: 6px; font-size: 14px; color: rgba(255,255,255,.8); }
.reader-pager input { width: 64px; height: 38px; border-radius: 10px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.1); color: #fff; text-align: center; font-weight: 600; }
.reader-pager input:focus { outline: 2px solid var(--gold); }
.reader-tools { display: flex; align-items: center; gap: 6px; }
.reader-zoom { min-width: 48px; text-align: center; font-size: 13px; color: rgba(255,255,255,.8); }
.reader-sep { width: 1px; height: 26px; background: rgba(255,255,255,.18); margin-inline: 2px; }

.reader-main { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); min-height: 0; }
.reader-toc {
  width: 330px; background: var(--surface); color: var(--ink); border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0; transition: margin .2s ease;
}
.reader-toc[hidden] { display: flex; margin-inline-start: -330px; visibility: hidden; }
.reader-toc__head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.reader-toc__head h2 { font-family: var(--font-body); font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.reader-toc__head input { width: 100%; height: 40px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-2); padding-inline: 12px; font-size: 14px; }
.reader-toc__list { overflow-y: auto; padding: 6px; flex: 1; }
.reader-toc__item { display: flex; gap: 10px; align-items: baseline; width: 100%; text-align: start; padding: 9px 10px; border-radius: 10px; border: 0; background: none; color: var(--ink); font-size: 14px; line-height: 1.6; }
.reader-toc__item:hover { background: var(--surface-2); }
.reader-toc__item.is-current { background: var(--chip-bg); color: var(--chip-ink); }
.reader-toc__item .pg { flex: none; min-width: 34px; font-weight: 700; font-size: 13px; color: var(--accent-ink); }
.reader-toc__item small { display: block; color: var(--ink-3); font-size: 12.5px; }
.reader-toc__item.is-sub { padding-inline-start: 28px; font-size: 13.5px; }
.reader-toc__empty { padding: 20px; color: var(--ink-3); font-size: 14px; text-align: center; }

.reader-pages { overflow: auto; min-height: 0; padding: 18px 12px 80px; scroll-behavior: auto; overscroll-behavior: contain; }
.reader-page { position: relative; margin: 0 auto 14px; background: #fff; box-shadow: 0 4px 18px rgba(0,0,0,.35); direction: ltr; --user-unit: 1; --total-scale-factor: calc(var(--scale-factor) * var(--user-unit)); --scale-round-x: 1px; --scale-round-y: 1px; }
.reader-page canvas { display: block; width: 100%; height: 100%; }
.reader-page__num { position: absolute; bottom: -2px; left: 50%; transform: translate(-50%, 100%); font-size: 12px; color: rgba(255,255,255,.55); padding-top: 2px; }
.reader-page.is-loading::after { content: ""; position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; margin: -15px; border-radius: 50%; border: 3px solid #d9e2e8; border-top-color: var(--blue); animation: spin .8s linear infinite; }

.reader-status { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; text-align: center; padding: 24px; z-index: 3; }
.reader-status[hidden] { display: none; }
.reader-status__box { max-width: 440px; }
.reader-status__box h2 { color: #fff; font-family: var(--font-body); font-size: 19px; margin: 14px 0 6px; }
.reader-status__box p { color: rgba(255,255,255,.75); }
.reader-progress { width: 220px; height: 6px; border-radius: 999px; background: rgba(255,255,255,.15); overflow: hidden; margin: 16px auto 0; }
.reader-progress span { display: block; height: 100%; width: 0; background: var(--gold); transition: width .2s; }
.reader-spinner { width: 42px; height: 42px; margin: 0 auto; border-radius: 50%; border: 3px solid rgba(255,255,255,.2); border-top-color: var(--gold); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.reader-float { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: none; align-items: center; gap: 4px; background: rgba(7,45,77,.94); color: #fff; border-radius: 999px; padding: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index: 6; }
.reader-float button { width: 40px; height: 40px; border-radius: 50%; border: 0; background: none; color: #fff; display: grid; place-items: center; }
.reader-float span { font-size: 14px; padding-inline: 8px; font-weight: 600; }

/* PDF.js text layer, so text can be selected and copied (from pdf_viewer.css). */
.textLayer { position: absolute; text-align: initial; inset: 0; overflow: clip; opacity: 1; line-height: 1; -webkit-text-size-adjust: none; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; caret-color: CanvasText; z-index: 0; }
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; user-select: text; }
.textLayer { --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 > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) { z-index: 1; --font-height: 0; font-size: calc(var(--text-scale-factor) * var(--font-height)); --scale-x: 1; --rotate: 0deg; transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv)); }
.textLayer .markedContent { display: contents; }
.textLayer ::selection { background: color-mix(in srgb, #0094bc, transparent 60%); color: transparent; }
.textLayer br::selection { background: transparent; }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default; user-select: none; }
.textLayer.selecting .endOfContent { top: 0; }

@media (max-width: 860px) {
  .reader-toc { position: absolute; inset-block: 0; inset-inline-start: 0; z-index: 4; box-shadow: var(--shadow-2); width: min(330px, 86vw); }
  .reader-toc[hidden] { margin-inline-start: max(-330px, -86vw); }
  .reader-main { grid-template-columns: minmax(0, 1fr); }
  .reader-hide-sm { display: none !important; }
  .reader-float { display: flex; }
  .reader-pages { padding-inline: 6px; }
}
@media (max-width: 520px) {
  .reader-bar { gap: 6px; padding-inline: 8px; }
  .reader-pager { display: none; }
}
