/* ============================================================
   In-browser PDF viewer overlay
   Sits above the CRT scanline/vignette layers (z-index 100/101 in
   style.css) so the actual scanned page stays legible.
   ============================================================ */

.pdfv-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.94);
}

.pdfv-overlay.open { display: flex; }

.pdfv-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--m7-black);
  border-bottom: 2px solid var(--m7-green);
  font-family: var(--font-beeb);
  color: var(--m7-white);
  user-select: none;
}

.pdfv-toolbar button {
  font-family: var(--font-beeb);
  font-size: 18px;
  background: transparent;
  color: var(--m7-cyan);
  border: 2px solid var(--m7-cyan);
  padding: 4px 10px;
  min-height: 36px;
  min-width: 36px;
  cursor: pointer;
}

.pdfv-toolbar button:hover,
.pdfv-toolbar button:focus-visible {
  background: var(--m7-cyan);
  color: var(--m7-black);
  outline: none;
}

.pdfv-toolbar button:disabled {
  opacity: 0.35;
  cursor: default;
  background: transparent;
  color: var(--m7-cyan);
}

.pdfv-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
  color: var(--m7-yellow);
}

.pdfv-page-indicator {
  font-size: 18px;
  min-width: 6em;
  text-align: center;
}

.pdfv-close {
  border-color: var(--m7-red) !important;
  color: var(--m7-red) !important;
}
.pdfv-close:hover, .pdfv-close:focus-visible {
  background: var(--m7-red) !important;
  color: var(--m7-black) !important;
}

.pdfv-viewport {
  flex: 1 1 auto;
  overflow: auto;
  position: relative;
  cursor: grab;
  touch-action: none; /* we handle pan/pinch ourselves */
  background: #1a1a1a;
}

.pdfv-viewport.dragging { cursor: grabbing; }

.pdfv-page-wrap {
  position: relative;
  margin: 24px auto;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.6);
  /* width/height set inline in JS to match the rendered canvas */
}

.pdfv-page-wrap canvas {
  display: block;
}

/* pdf.js text layer overlay: kept present (for highlight positioning and
   screen readers) but not mouse-interactive — dragging over text must pan,
   never select, and text is not meant to be easily copy/pasted. */
.pdfv-page-wrap .textLayer {
  pointer-events: none;
  user-select: none;
}

.pdfv-page-wrap .textLayer mark.pdfv-highlight {
  /* Plain alpha transparency, not mix-blend-mode: pdf.js's own CSS gives
     .textLayer position:absolute + z-index:0, which creates an isolated
     stacking context — a blend mode on a descendant here can only blend
     with other things inside that same context, not through to the
     canvas sitting outside it, so it silently has no visible effect. */
  background: rgba(255, 255, 34, 0.5);
  color: transparent; /* text layer glyphs are already transparent by design */
  border-radius: 2px;
}

.pdfv-progress-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--m7-green);
  font-family: var(--font-beeb);
  font-size: 20px;
}

.pdfv-progress-bar {
  width: min(320px, 70vw);
  height: 14px;
  border: 2px solid var(--m7-green);
  padding: 2px;
}

.pdfv-progress-bar > div {
  height: 100%;
  background: var(--m7-green);
  width: 0%;
  transition: width 0.15s linear;
}

.pdfv-error {
  color: var(--m7-red);
  font-family: var(--font-beeb);
  font-size: 20px;
  text-align: center;
  padding: 24px;
}

@media (max-width: 640px) {
  .pdfv-toolbar { gap: 6px; padding: 6px 8px; }
  .pdfv-toolbar button { font-size: 16px; padding: 4px 8px; }
  .pdfv-title { display: none; } /* reclaim space for nav/zoom controls */
  .pdfv-page-wrap { margin: 12px auto; }
}

@media print {
  .pdfv-overlay.open { display: none !important; }
}
