/* Flip-through book viewer (Pages/_BookViewer.cshtml + js/book-viewer.js).
   Shared by the homepage and /examples. */

.book-viewer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  /* Above the cookie consent banner (9999, set in js/tracking-consent.js), which would
     otherwise cover the book and, on phones, the page-turn buttons. */
  z-index: 10000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 24px;
}
.book-viewer-overlay.open {
  display: flex;
}
.book-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 900px;
  margin-bottom: 16px;
}
.book-viewer-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-white);
}
.book-viewer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: none;
  cursor: pointer;
  color: var(--color-white);
  transition: background 0.15s;
}
.book-viewer-close:hover {
  background: rgba(255,255,255,0.25);
}
.book-viewer-container {
  position: relative;
  width: 100%;
  max-width: 900px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#flipbook-container {
  /* StPageFlip will inject canvas here */
  transition: transform 0.4s ease;
}
.flipbook-page {
  background: #fff;
}
.flipbook-page.is-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 3px solid rgba(17, 51, 98, 0.15);
  border-top-color: #113362;
  border-radius: 50%;
  animation: book-viewer-spin 0.8s linear infinite;
}
.flipbook-page.is-loading img {
  visibility: hidden;
}
.flipbook-page img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  user-select: none;
  -webkit-user-drag: none;
}
#flipbook-container.is-front-cover {
  transform: translateX(-25%);
  clip-path: inset(0 0 0 50%);
}
#flipbook-container.is-back-cover {
  transform: translateX(25%);
  clip-path: inset(0 50% 0 0);
}
.book-viewer-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
}
.book-viewer-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: none;
  cursor: pointer;
  color: var(--color-white);
  transition: background 0.15s;
}
.book-viewer-btn:hover {
  background: rgba(255,255,255,0.25);
}
.book-viewer-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.book-viewer-page-info {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.7);
  min-width: 100px;
  text-align: center;
}
.book-viewer-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--color-white);
}
.book-viewer-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--color-white);
  border-radius: 50%;
  animation: book-viewer-spin 0.8s linear infinite;
}
@keyframes book-viewer-spin {
  to { transform: rotate(360deg); }
}
.book-viewer-loading p {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.7);
}

@media (max-width: 640px) {
  .book-viewer-header { flex-direction: row; }
  .book-viewer-overlay { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .book-viewer-close,
  .book-viewer-btn { transition: none; }
  .book-viewer-spinner,
  .flipbook-page.is-loading::after,
  #flipbook-container { animation: none; transition: none; }
}

@media print {
  .book-viewer-overlay { display: none; }
}
