/* ═════════════════════════════════════════════
   OlivEU Book Viewer – Fullscreen Flipbook Popup
   Uses StPageFlip for realistic page-turning
   Fully scoped — no dependency on theme defaults
   ═════════════════════════════════════════════ */

/* ── Reset all elements inside overlay to prevent theme bleed ── */
.oliveu-book-overlay,
.oliveu-book-overlay *,
.oliveu-book-overlay *::before,
.oliveu-book-overlay *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  font: inherit;
  color: inherit;
  background: transparent;
  text-decoration: none;
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.5;
  vertical-align: baseline;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  box-shadow: none;
  text-shadow: none;
}
/* Restore SVG presentation attributes after reset */
.oliveu-book-overlay svg {
  color: inherit;
  overflow: visible;
}
.oliveu-book-overlay svg polyline,
.oliveu-book-overlay svg line,
.oliveu-book-overlay svg path,
.oliveu-book-overlay svg circle,
.oliveu-book-overlay svg rect {
  fill: none;
  stroke: currentColor;
  vector-effect: non-scaling-stroke;
}

/* ── Overlay ── */
.oliveu-book-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  justify-content: center;
  align-items: center;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.35s ease;
  font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: #fff;
  line-height: 1.5;
}
.oliveu-book-overlay.is-open {
  display: flex;
  opacity: 1;
}
.oliveu-book-overlay.is-closing {
  opacity: 0;
}

/* ── Close button ── */
.oliveu-book-overlay .oliveu-book-close {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 10;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  max-width: 44px;
  max-height: 44px;
  border-radius: 50%;
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  padding: 0;
}
.oliveu-book-overlay .oliveu-book-close:hover,
.oliveu-book-overlay .oliveu-book-close:focus {
  background: rgba(255,255,255,0.25);
  transform: scale(1.08);
  color: #fff;
  border-color: rgba(255,255,255,0.3);
}

/* ── Top bar ── */
.oliveu-book-overlay .oliveu-book-topbar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 10;
}
.oliveu-book-overlay .oliveu-book-topbar .page-info {
  color: rgba(255,255,255,0.7);
  font-family: 'Quicksand', sans-serif;
  font-size: 14px;
  font-weight: 500;
  min-width: 100px;
  text-align: center;
  line-height: 1.4;
}

/* ── Book container ── */
.oliveu-book-overlay .oliveu-book-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 70px 20px 80px;
}

/* The flipbook wrapper */
.oliveu-book-overlay .oliveu-book-flipbook {
  /* StPageFlip sizes this dynamically */
}

/* Individual page styling */
.oliveu-book-overlay .oliveu-book-page {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.oliveu-book-overlay .oliveu-book-page canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── Navigation arrows ── */
.oliveu-book-overlay .oliveu-book-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff;
  width: 52px;
  height: 52px;
  min-width: 52px;
  min-height: 52px;
  max-width: 52px;
  max-height: 52px;
  border-radius: 50%;
  font-size: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
  padding: 0;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}
.oliveu-book-overlay .oliveu-book-nav svg {
  width: 22px;
  height: 22px;
  stroke: #fff;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
  pointer-events: none;
}
.oliveu-book-overlay .oliveu-book-nav:hover,
.oliveu-book-overlay .oliveu-book-nav:focus {
  background: rgba(122, 211, 0, 0.18);
  border-color: rgba(122, 211, 0, 0.4);
  transform: translateY(-50%) scale(1.08);
  color: #fff;
}
.oliveu-book-overlay .oliveu-book-nav:hover svg,
.oliveu-book-overlay .oliveu-book-nav:focus svg {
  stroke: #7AD300;
}
.oliveu-book-overlay .oliveu-book-nav.prev { left: 12px; }
.oliveu-book-overlay .oliveu-book-nav.next { right: 12px; }

/* Ensure arrows stay above StPageFlip wrapper */
.oliveu-book-overlay .oliveu-book-container .stf__wrapper {
  z-index: 1 !important;
}
.oliveu-book-overlay .oliveu-book-nav:disabled {
  opacity: 0.2;
  cursor: default;
  pointer-events: none;
}
.oliveu-book-overlay .oliveu-book-nav:disabled:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.18);
  transform: translateY(-50%);
}

/* ── Loading spinner ── */
.oliveu-book-overlay .oliveu-book-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 5;
  color: rgba(255,255,255,0.8);
  font-family: 'Quicksand', sans-serif;
  font-size: 15px;
}
.oliveu-book-overlay .oliveu-book-loader .spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: #7AD300;
  border-radius: 50%;
  animation: oliveu-spin 0.8s linear infinite;
}
@keyframes oliveu-spin {
  to { transform: rotate(360deg); }
}
.oliveu-book-overlay .oliveu-book-loader.hidden { display: none; }

/* ── Trigger button (styled like press-release toggle) ── */
.oliveu-book-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  margin-left: auto;
  padding: 0;
  background: transparent;
  border: none;
  color: inherit;
  font-family: 'Quicksand', sans-serif;
  cursor: pointer;
  text-decoration: none;
  width: auto;
  box-shadow: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  outline: none;
}
.oliveu-book-trigger:hover,
.oliveu-book-trigger:focus {
  transform: none;
  box-shadow: none;
  text-decoration: none;
  background: transparent;
  color: inherit;
}
.oliveu-book-trigger .oliveu-book-trigger-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #7AD300;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  transition: color 0.2s ease;
}
.oliveu-book-trigger:hover .oliveu-book-trigger-label {
  color: #7AD300;
}
.oliveu-book-trigger .oliveu-book-trigger-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2.5px solid #7AD300;
  background: transparent;
  color: #7AD300;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.25s ease;
}
.oliveu-book-trigger:hover .oliveu-book-trigger-icon {
  background: rgba(122, 211, 0, 0.12);
  transform: scale(1.05);
}
.oliveu-book-trigger .oliveu-book-trigger-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ── Bottom page slider ── */
.oliveu-book-overlay .oliveu-book-slider-wrap {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 10;
}
.oliveu-book-overlay .oliveu-book-slider {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 260px;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  border: none;
  outline: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
}
.oliveu-book-overlay .oliveu-book-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #7AD300;
  cursor: pointer;
  border: 2px solid #fff;
  margin-top: -6px;
}
.oliveu-book-overlay .oliveu-book-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #7AD300;
  cursor: pointer;
  border: 2px solid #fff;
}
.oliveu-book-overlay .oliveu-book-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  border: none;
}
.oliveu-book-overlay .oliveu-book-slider::-moz-range-track {
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  border: none;
}
.oliveu-book-overlay .oliveu-book-slider:focus {
  outline: none;
  border: none;
}

/* ── Responsive ── */

/* Tablets */
@media (max-width: 1024px) {
  .oliveu-book-overlay .oliveu-book-container { padding: 65px 12px 75px; }
  .oliveu-book-overlay .oliveu-book-nav {
    width: 44px; height: 44px;
    min-width: 44px; min-height: 44px;
    max-width: 44px; max-height: 44px;
  }
  .oliveu-book-overlay .oliveu-book-nav svg { width: 18px; height: 18px; }
  .oliveu-book-overlay .oliveu-book-nav.prev { left: 6px; }
  .oliveu-book-overlay .oliveu-book-nav.next { right: 6px; }
}

/* Mobile */
@media (max-width: 768px) {
  .oliveu-book-overlay .oliveu-book-container { padding: 60px 6px 70px; }
  .oliveu-book-overlay .oliveu-book-nav {
    width: 38px; height: 38px;
    min-width: 38px; min-height: 38px;
    max-width: 38px; max-height: 38px;
  }
  .oliveu-book-overlay .oliveu-book-nav svg { width: 16px; height: 16px; }
  .oliveu-book-overlay .oliveu-book-nav.prev { left: 4px; }
  .oliveu-book-overlay .oliveu-book-nav.next { right: 4px; }
  .oliveu-book-overlay .oliveu-book-close {
    top: 10px; right: 10px;
    width: 38px; height: 38px;
    min-width: 38px; min-height: 38px;
    max-width: 38px; max-height: 38px;
    font-size: 18px;
  }
  .oliveu-book-overlay .oliveu-book-topbar { top: 12px; gap: 8px; }
  .oliveu-book-overlay .oliveu-book-topbar .page-info { font-size: 12px; }
  .oliveu-book-overlay .oliveu-book-slider { width: 180px; }
}
