/* Document reader. No page-turn animation: pages scroll or snap into place. */

.doc-reader {
  --doc-bar: #0b1f33;
  --doc-stage: #e7eeee;
  --doc-ink: #f4fbfa;
  display: flex;
  flex-direction: column;
  height: min(78vh, 880px);
  min-height: 520px;
  max-width: 100%;
  min-width: 0;
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: var(--doc-stage);
  box-shadow: 0 18px 50px rgba(11, 31, 51, 0.08);
  color: var(--ink);
}

.doc-reader-slides {
  --doc-stage: #071621;
  height: min(72vh, 740px);
  min-height: 420px;
  background: var(--doc-stage);
}

.doc-reader:fullscreen {
  width: 100%;
  height: 100%;
  max-height: none;
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
}

.doc-toolbar {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  min-height: 46px;
  padding: 0.3rem 0.45rem;
  background: var(--doc-bar);
  color: var(--doc-ink);
  overflow-x: auto;
  scrollbar-width: none;
  flex: 0 0 auto;
}

.doc-toolbar::-webkit-scrollbar { display: none; }

.doc-cluster { display: flex; align-items: center; gap: 0.12rem; flex: 0 0 auto; }

.doc-sep {
  width: 1px;
  height: 1.15rem;
  background: rgba(255, 255, 255, 0.16);
  margin: 0 0.2rem;
  flex: 0 0 auto;
}

.doc-grow { flex: 1 1 auto; min-width: 0.25rem; }

.doc-tool {
  appearance: none;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.doc-tool:hover { background: rgba(255, 255, 255, 0.08); }

.doc-tool[aria-pressed="true"],
.doc-tool[aria-checked="true"] { background: rgba(255, 255, 255, 0.16); }

.doc-tool:disabled { opacity: 0.35; cursor: default; }

.doc-tool:focus-visible,
.doc-page-input:focus-visible,
.doc-thumb:focus-visible {
  outline: 2px solid #9cf3ea;
  outline-offset: 2px;
}

.doc-page-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  flex: 0 0 auto;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.doc-reader input.doc-page-input {
  width: 4ch;
  min-width: 4ch;
  max-width: 4.5ch;
  height: 1.6rem;
  min-height: 0;
  margin: 0;
  padding: 0 0.15rem;
  flex: 0 0 auto;
  box-sizing: content-box;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  font: inherit;
  font-variant-numeric: tabular-nums;
  line-height: 1.6rem;
  text-align: center;
}

.doc-page-total { color: rgba(244, 251, 250, 0.82); }

.doc-zoom-label {
  min-width: 3.1rem;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: rgba(244, 251, 250, 0.82);
}

.doc-body { display: flex; flex: 1 1 auto; min-height: 0; min-width: 0; }

.doc-thumbs {
  position: relative;
  width: 148px;
  flex: 0 0 148px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0.75rem 0.6rem 1rem;
  background: #f6fafa;
  border-right: 1px solid var(--line);
}

.doc-thumbs[hidden] { display: none; }

.doc-reader-slides .doc-thumbs {
  background: #0c2233;
  border-right-color: rgba(255, 255, 255, 0.08);
}

.doc-thumbs-scroll { display: grid; gap: 0.45rem; }

.doc-thumb {
  display: grid;
  gap: 0.28rem;
  width: 100%;
  padding: 0.35rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
  cursor: pointer;
}

.doc-reader-slides .doc-thumb { color: rgba(244, 251, 250, 0.72); }

.doc-thumb canvas {
  display: block;
  width: 100%;
  height: auto;
  min-height: 4.2rem;
  background: white;
  box-shadow: 0 6px 16px rgba(11, 31, 51, 0.12);
}

.doc-reader-slides .doc-thumb canvas { min-height: 2.6rem; }

.doc-thumb.is-ready canvas { min-height: 0; }

.doc-thumb[aria-current="page"] {
  border-color: var(--teal);
  color: var(--navy);
  font-weight: 700;
}

.doc-reader-slides .doc-thumb[aria-current="page"] { color: white; }

.doc-stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(1000px 320px at 50% -10%, rgba(255, 255, 255, 0.65), transparent 55%),
    var(--doc-stage);
}

.doc-reader-slides .doc-stage {
  background:
    radial-gradient(900px 360px at 50% -8%, rgba(26, 163, 150, 0.18), transparent 58%),
    var(--doc-stage);
}

.doc-stage:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px #1aa396;
}

.doc-scroller {
  position: relative;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-behavior: auto;
  touch-action: pan-x pan-y;
}

.doc-reader[data-view="single"] .doc-scroller,
.doc-reader[data-view="spread"] .doc-scroller {
  scroll-snap-type: y mandatory;
}

.doc-reader[data-zoomed="true"] .doc-scroller { scroll-snap-type: none; }

.doc-sheet {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  box-sizing: border-box;
  padding: 1.25rem 1rem;
}

.doc-reader[data-view="continuous"] .doc-sheet {
  align-items: flex-start;
  padding: 0.85rem 1rem 0.35rem;
}

.doc-reader[data-view="single"] .doc-sheet,
.doc-reader[data-view="spread"] .doc-sheet {
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.doc-page {
  position: relative;
  flex: 0 0 auto;
  background: white;
  box-shadow:
    0 1px 1px rgba(11, 31, 51, 0.05),
    0 14px 40px rgba(11, 31, 51, 0.14);
  line-height: 0;
}

.doc-reader-slides .doc-page {
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.38);
}

.doc-page-pending {
  width: min(100% - 2rem, 640px);
  aspect-ratio: 5 / 7;
}

.doc-page-slide,
.doc-reader-slides .doc-page-pending {
  width: min(100% - 2rem, 960px);
  aspect-ratio: 16 / 9;
}

.doc-canvas { display: block; width: 100%; height: 100%; }

.doc-skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, #f3f6f6 28%, #e3ebeb 46%, #f3f6f6 64%);
  background-size: 220% 100%;
  animation: doc-shimmer 1.35s ease-in-out infinite;
}

.doc-page.is-ready .doc-skeleton { display: none; }

.doc-fallback,
.doc-error {
  max-width: 38rem;
  margin: 0 auto 1.5rem;
  padding: 0 1.25rem;
  color: var(--ink);
  line-height: 1.5;
}

.doc-reader-slides .doc-fallback,
.doc-reader-slides .doc-error { color: #e7f4f2; }

.doc-error {
  margin-top: 2rem;
  padding: 1.1rem 1.25rem;
  background: white;
  color: var(--ink);
  border-radius: 12px;
}

.doc-retry {
  display: inline-block;
  margin: 0 0.35rem;
  padding: 0.28rem 0.7rem;
  border: 0;
  border-radius: 8px;
  background: var(--navy, #0b1f33);
  color: white;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.doc-retry:focus-visible {
  outline: 2px solid #1aa396;
  outline-offset: 2px;
}

@keyframes doc-shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

.reader-page { padding: 1.1rem 0 1.6rem; }

.reader-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1.25rem;
  margin-bottom: 0.85rem;
}

.reader-page-head h1 {
  font-size: clamp(1.55rem, 2.4vw, 2rem);
  margin: 0;
}

.reader-back { font-weight: 650; text-decoration: none; }

.reader-page .doc-reader {
  height: calc(100dvh - 11.5rem);
  min-height: 540px;
  margin-top: 0;
}

.doc-open { margin: 0.75rem 0 0; font-weight: 650; }

@media (max-width: 720px) {
  .doc-reader { height: 78vh; min-height: 460px; border-radius: 14px; }
  .doc-reader-slides { height: 70vh; min-height: 280px; }
  .doc-thumbs { width: 112px; flex-basis: 112px; }
  .reader-page .doc-reader { height: calc(100dvh - 10rem); min-height: 480px; }
  .doc-zoom-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .doc-scroller { scroll-behavior: auto; }
  .doc-skeleton { animation: none; }
}
