/* ═══════════════════════════════════════════════════════════════════════
   18 · PDF VIEWER  —  styles for ui/pdf-viewer.js (AngelHubPdfViewer)
   ─────────────────────────────────────────────────────────────────────
   Full-screen reader matching the photo-viewer family: a surface header
   (reusing .kb-reader-action buttons), a theme-aware reading area with
   white page cards, a floating page-jump pill, and a loading / error
   state. Class ending in "-overlay" so ui/modal-stack.js stacks it.
   ═══════════════════════════════════════════════════════════════════════ */

.pdf-viewer-overlay {
  position: fixed;
  inset: 0;
  top: var(--banner-h, 0);          /* sit below the impersonation banner */
  z-index: 9000;                    /* same floor as the photo viewer */
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.pdf-viewer-overlay.is-open { opacity: 1; }
body.pdf-viewer-open { overflow: hidden; }

/* ── Header (surface bar, like .pv-header / .kb-reader-header) ──────── */
.pdf-viewer-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 12px 12px 12px 16px;
  /* Full-screen PDF viewer → clear the status bar robustly (see --safe-top). */
  padding-top: var(--safe-top);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: relative;   /* stay above the loading/error panel so the */
  z-index: 4;           /* close (X) button is ALWAYS clickable */
}
.pdf-viewer-titlewrap { min-width: 0; flex: 1 1 auto; }
.pdf-viewer-title {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pdf-viewer-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* ── Reading area (continuous vertical scroll, both axes when zoomed) ─ */
.pdf-viewer-scroll {
  position: relative;
  flex: 1 1 auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px 0 calc(20px + env(safe-area-inset-bottom));
  background: var(--bg-base);
}
.pdf-viewer-pages { width: 100%; }

/* Drag-to-pan affordance (the hand tool). The cursor is the only hint a
   desktop user gets that the page can be dragged — macOS hides the overlay
   scrollbar — so it appears ONLY while there is something to pan (`is-pannable`
   is set by the viewer after every layout/zoom): a grab cursor over a page that
   already fits would be a lying affordance. Pointer-fine only; on touch the
   native one-finger scroll does the panning and no cursor is drawn. */
@media (hover: hover) and (pointer: fine) {
  .pdf-viewer-scroll.is-pannable { cursor: grab; }
  .pdf-viewer-scroll.is-panning  { cursor: grabbing; }
}
/* While dragging, never let the gesture turn into a selection / image drag. */
.pdf-viewer-scroll.is-panning { user-select: none; -webkit-user-select: none; }
.pdf-viewer-scroll.is-panning .pdf-viewer-canvas { pointer-events: none; }
.pdf-viewer-page {
  margin: 0 auto 16px;              /* centres when narrower than the scroll */
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.18), 0 8px 26px -8px rgba(0,0,0,0.45);
}
.pdf-viewer-page:last-child { margin-bottom: 0; }
.pdf-viewer-canvas { display: block; border-radius: 2px; }

/* ── Floating page-jump pill (bottom-right) ────────────────────────── */
.pdf-viewer-pager {
  position: absolute;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  box-shadow: 0 6px 20px -6px rgba(0,0,0,0.45);
  z-index: 2;
}
.pdf-viewer-pagebtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--accent);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.12s ease, transform 0.08s ease;
}
.pdf-viewer-pagebtn:hover { background: var(--bg-elevated); }
.pdf-viewer-pagebtn:active { transform: scale(0.92); }
.pdf-viewer-pagebtn svg { width: 20px; height: 20px; }
.pdf-viewer-count {
  min-width: 48px;
  text-align: center;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ── Loading / error overlay ───────────────────────────────────────── */
.pdf-viewer-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  background: var(--bg-base);
  z-index: 3;
  padding: 24px;
}
.pdf-viewer-spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: pdfv-spin 0.8s linear infinite;
}
@keyframes pdfv-spin { to { transform: rotate(360deg); } }
.pdf-viewer-err { max-width: 320px; text-align: center; line-height: 1.5; }
.pdf-viewer-errbtns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }

/* ── Desktop polish ────────────────────────────────────────────────── */
@media (min-width: 1024px) {
  .pdf-viewer-scroll { padding-top: 24px; }
  .pdf-viewer-page { margin-bottom: 22px; }
}

/* Mobile width pass (2026-06-25): tighten horizontal padding on mobile so content
   uses the screen width. Appended at end-of-file so it beats the base rules AND any
   wider-breakpoint (600/640/767px) blocks at equal specificity (later source wins).
   Desktop (>=600px) untouched. */
@media (max-width: 599px) {
  /* Keep the mobile horizontal trim but re-apply --safe-top (the shorthand
     resets padding-top, which would strand the header behind the status bar). */
  .pdf-viewer-header { padding: 12px 12px; padding-top: var(--safe-top); }
  .pdf-viewer-loading { padding: 24px 12px; }
}
