/**
 * PDF reader (assets/js/pdf-reader.js): inline reader and the pop-up book reader.
 */
.pdf-reader {
  margin: 1.5rem auto 2.5rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--cream);
  overflow: hidden;
  outline: none;
}
.pdf-reader:focus-visible { box-shadow: 0 0 0 3px var(--gold-light); }
.pdf-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
}
.pdf-group { display: flex; align-items: center; gap: 0.4rem; }
.pdf-page { display: flex; align-items: center; gap: 0.35rem; margin: 0; font-size: 0.9rem; }
.pdf-reader .pdf-page-input { width: 3.6rem; text-align: center; padding-inline: 0.25rem; }
.pdf-zoom-label { min-width: 3rem; text-align: center; color: var(--text-muted, #6c757d); }
.pdf-stage {
  position: relative;
  min-height: 420px;
  padding: 1rem 0;
  overflow: auto;
  text-align: center;
  touch-action: pan-y pinch-zoom;
}
.pdf-stage canvas {
  display: inline-block;
  max-width: none;
  background: #fff;
  box-shadow: var(--shadow-card);
}
.pdf-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  color: var(--text-muted, #6c757d);
}
.pdf-status[hidden] { display: none; }
.pdf-hint { margin: 0; padding: 0 0 0.75rem; color: var(--text-muted, #6c757d); }
.pdf-reader:fullscreen { display: flex; flex-direction: column; border-radius: 0; }
.pdf-reader:fullscreen .pdf-stage { flex: 1; }

.pdf-hint { margin: 0; padding: 0 0 0.75rem; text-align: center; color: var(--text-muted, #6c757d); }

/* ---------- Pop-up reader ---------- */
html.pdf-modal-open, html.pdf-modal-open body { overflow: hidden; }
.pdf-modal { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: stretch; justify-content: center; }
.pdf-modal[hidden] { display: none; }
.pdf-modal-backdrop { position: absolute; inset: 0; background: rgba(10, 30, 20, 0.72); }
.pdf-modal-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1100px, 100%);
  margin: 1.25rem;
  background: var(--surface, #fff);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.pdf-modal-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 3px solid var(--gold, #c9a227);
}
.pdf-modal-title {
  flex: 1;
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-dark, #14532d);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pdf-modal-newtab { color: var(--primary, #198754); }
.pdf-reader--modal {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
}
.pdf-reader--modal .pdf-stage { flex: 1; min-height: 0; }
@media (max-width: 575.98px) {
  .pdf-modal-dialog { margin: 0; border-radius: 0; }
  .pdf-toolbar { justify-content: center; }
}

/* Books from other sites: shown in the browser's own PDF viewer */
.pdf-reader--embed .pdf-toolbar .pdf-group:first-child,
.pdf-reader--embed [data-act="zoom-in"], .pdf-reader--embed [data-act="zoom-out"],
.pdf-reader--embed .pdf-zoom-label, .pdf-reader--embed canvas { display: none !important; }
.pdf-reader--embed .pdf-stage { padding: 0; overflow: hidden; }
.pdf-frame { display: block; width: 100%; height: 100%; min-height: 70vh; border: 0; background: #fff; }
.pdf-frame-note { margin: 0; padding: 0.4rem 0.75rem; text-align: center; color: var(--text-muted, #6c757d); border-top: 1px solid var(--border-subtle, #dee2e6); }

/* Fallback look for older pages that don't load Bootstrap. :where() keeps these at
   zero specificity, so Bootstrap's own button styles win wherever Bootstrap is present. */
:where(.pdf-modal) { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 16px; line-height: 1.5; color: #1d1d1d; }
:where(.pdf-modal) :where(.btn) {
  display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .7rem; font-size: .875rem; font-weight: 500;
  border-radius: .375rem; border: 1px solid #198754; background: #fff; color: #198754; cursor: pointer; text-decoration: none;
}
:where(.pdf-modal) :where(.btn-success) { background: #198754; color: #fff; }
:where(.pdf-modal) :where(.btn:disabled) { opacity: .55; cursor: default; }
:where(.pdf-modal) :where(.form-control) { border: 1px solid #ced4da; border-radius: .375rem; padding: .2rem .3rem; font: inherit; }
:where(.pdf-modal) :where(.visually-hidden), :where(.pdf-modal) :where(.d-none) { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (min-width: 576px) { :where(.pdf-modal) :where(.d-sm-inline) { position: static !important; width: auto; height: auto; clip: auto; } }

.pdf-modal-close {
  display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem;
  border: 0; border-radius: 50%; background: transparent; color: #1d1d1d; font-size: 1.15rem; line-height: 1; cursor: pointer;
}
.pdf-modal-close:hover, .pdf-modal-close:focus-visible { background: rgba(0, 0, 0, 0.07); }
