/* ============================================================
   PDFBOOK — leitor de PDF com layout de livro e busca textual
   Usa PDF.js para renderizar canvas + camada de texto selecionavel.
   ============================================================ */

.pb-root {
  --pb-accent: #004aad;
  --pb-pw: 420px;
  --pb-ph: 594px;
  height: calc(100vh - 62px);
  display: flex;
  flex-direction: column;
  background: radial-gradient(120% 90% at 50% 0%, #eef2f8 0%, #dde5ef 70%, #cdd7e6 100%);
}

.pb-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px 18px;
  overflow: hidden;
  perspective: 2600px;
}

.pb-book {
  position: relative;
  width: calc(var(--pb-pw) * 2);
  height: var(--pb-ph);
  filter: drop-shadow(0 20px 44px rgba(15, 34, 66, 0.34));
  transition: opacity 0.18s ease, transform 0.18s ease, width 0.18s ease, height 0.18s ease;
  transform-style: preserve-3d;
}

.pb-book.single {
  width: var(--pb-pw);
}

.pb-book.wide {
  width: calc(var(--pb-pw) * 2);
}

.pb-book.pb-turn-next {
  opacity: 0.45;
  transform: translateX(-14px) rotateY(-5deg);
}

.pb-book.pb-turn-prev {
  opacity: 0.45;
  transform: translateX(14px) rotateY(5deg);
}

.pb-book::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 34px;
  margin-left: -17px;
  background: linear-gradient(90deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.16) 48%,
              rgba(0,0,0,0.16) 52%, rgba(0,0,0,0) 100%);
  z-index: 4;
  pointer-events: none;
}

.pb-book.single::after {
  display: none;
}

.pb-book.wide::after {
  display: block;
  opacity: 0.5;
}

.pb-page {
  position: absolute;
  top: 0;
  width: var(--pb-pw);
  height: var(--pb-ph);
  background: #fff;
  overflow: hidden;
}

.pb-left {
  left: 0;
  box-shadow: inset -14px 0 24px -14px rgba(0,0,0,0.22);
}

.pb-right {
  left: var(--pb-pw);
  box-shadow: inset 14px 0 24px -14px rgba(0,0,0,0.22);
}

.pb-book.single .pb-right {
  display: none;
}

.pb-book.wide .pb-left {
  left: 0;
  width: calc(var(--pb-pw) * 2);
  box-shadow: none;
}

.pb-book.wide .pb-right {
  display: none;
}

.pb-book.single .pb-page {
  box-shadow: none;
}

.pb-wide-slot .pb-canvas,
.pb-wide-slot .textLayer {
  width: 100%;
  height: 100%;
}

.pb-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.pb-page .textLayer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 1;
  line-height: 1;
  text-align: initial;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
}

.pb-page .textLayer span,
.pb-page .textLayer br {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}

.pb-page .textLayer ::selection {
  background: rgba(0, 74, 173, 0.28);
}

.pb-page mark {
  background: rgba(255, 210, 66, 0.65);
  color: transparent;
  border-radius: 2px;
}

.pb-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: #7f8c8d;
  text-align: center;
  font-weight: 700;
  background: #fff;
}

.pb-root.animating .pb-page .textLayer {
  pointer-events: none;
}

.pb-leaf {
  position: absolute;
  top: 0;
  left: var(--pb-pw);
  width: var(--pb-pw);
  height: var(--pb-ph);
  z-index: 12;
  transform-origin: left center;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
  transition: transform 0.62s cubic-bezier(0.42, 0.02, 0.35, 1);
  filter: drop-shadow(-12px 8px 22px rgba(10, 22, 40, 0.20));
  will-change: transform;
}

.pb-leaf.turn {
  transform: rotateY(-180deg);
}

.pb-face {
  position: absolute;
  inset: 0;
  background: #fff;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.pb-face.back {
  transform: rotateY(180deg);
}

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

.pb-face::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.62s ease;
}

.pb-leaf.next .front::after {
  background: linear-gradient(90deg, rgba(0,0,0,0.22), rgba(0,0,0,0) 38%);
}

.pb-leaf.next.turn .front::after {
  opacity: 0.62;
}

.pb-leaf.prev .back::after {
  background: linear-gradient(270deg, rgba(0,0,0,0.20), rgba(0,0,0,0) 38%);
}

.pb-leaf.prev:not(.turn) .back::after {
  opacity: 0.58;
}

.pb-toolbar {
  display: grid;
  grid-template-columns: auto auto minmax(130px, 1fr) auto minmax(220px, 0.9fr) auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 18px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -2px 10px rgba(15, 34, 66, 0.06);
}

.pb-btn {
  border: none;
  background: var(--pb-accent);
  color: #fff;
  min-width: 40px;
  height: 40px;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.pb-btn:hover {
  transform: scale(1.06);
}

.pb-btn:disabled {
  opacity: 0.32;
  cursor: default;
  transform: none;
}

.pb-btn-light {
  background: #eef2fb;
  color: var(--pb-accent);
}

.pb-indicator {
  min-width: 104px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  color: #2c3e50;
  white-space: nowrap;
}

.pb-slider {
  width: 100%;
  accent-color: var(--pb-accent);
  cursor: pointer;
}

.pb-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.pb-search-input {
  flex: 1;
  min-width: 0;
  height: 38px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.pb-search-input:focus {
  border-color: var(--pb-accent);
  box-shadow: 0 0 0 3px rgba(0, 74, 173, 0.10);
}

.pb-search-status {
  min-width: 104px;
  font-size: 12px;
  color: #5a6b7b;
  white-space: nowrap;
}

.pb-open-pdf {
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: #eef2fb;
  color: var(--pb-accent);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pb-loading {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(245, 247, 250, 0.82);
  color: #2c3e50;
  font-weight: 800;
}

.pb-root.loading .pb-loading {
  display: flex;
}

@media (max-width: 960px) {
  .pb-toolbar {
    grid-template-columns: auto auto minmax(100px, 1fr) auto auto auto;
  }
  .pb-search {
    grid-column: 1 / -1;
  }
  .pb-search-status {
    min-width: 72px;
  }
}

@media (max-width: 640px) {
  .pb-root {
    height: calc(100vh - 112px);
  }
  .pb-stage {
    padding: 14px 10px;
  }
  .pb-toolbar {
    gap: 8px;
    padding: 8px 10px;
  }
  .pb-open-pdf {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pb-book,
  .pb-btn {
    transition: none;
  }
}
