/* ============================================================
   BookPreview — interactive, editorial page-flip component
   Premium / minimal / Apple-Books-like. No gimmicky 3D toys.
   ============================================================ */

.bp-root {
  --bp-max-w: 900px;
  --bp-radius: 16px;
  --bp-duration: 500ms;
  --bp-ease: cubic-bezier(.22, 1, .36, 1);
  max-width: var(--bp-max-w);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  outline: none;
}

.bp-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 1.5;      /* open two-page spread, landscape picture book */
  perspective: 2200px;
  perspective-origin: 50% 50%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Closed-book (cover-only) presentation, before the intro-open animation */
.bp-cover-stage {
  aspect-ratio: 16 / 9;
  max-width: 620px;
}
.bp-cover-stage .bp-cover-slot {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--bp-radius);
  overflow: hidden;
  box-shadow:
    0 2px 6px rgba(20, 18, 16, 0.10),
    0 24px 48px rgba(20, 18, 16, 0.18);
  background: #fff;
  transform-style: preserve-3d;
}

/* "Tap to open" affordance shown over the closed cover */
.bp-tap-hint {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(20, 18, 16, 0.55);
  padding: 7px 14px;
  border-radius: 999px;
  backdrop-filter: blur(3px);
  pointer-events: none;
}

.bp-spread {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  transform-style: preserve-3d;
}

.bp-slot {
  position: relative;
  width: 50%;
  height: 100%;
  background: #fffdf9;
  overflow: hidden;
}
.bp-slot.left  { border-radius: var(--bp-radius) 0 0 var(--bp-radius); }
.bp-slot.right { border-radius: 0 var(--bp-radius) var(--bp-radius) 0; }
.bp-slot.single { width: 100%; border-radius: var(--bp-radius); }

.bp-slot img,
.bp-face img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fffdf9;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* Book shell shadow + spine crease down the center */
.bp-book-shadow {
  position: absolute;
  inset: 0;
  border-radius: var(--bp-radius);
  box-shadow:
    0 2px 6px rgba(20, 18, 16, 0.10),
    0 28px 60px rgba(20, 18, 16, 0.20);
  pointer-events: none;
}
.bp-spine {
  position: absolute;
  top: 0; left: 50%; bottom: 0;
  width: 26px;
  margin-left: -13px;
  pointer-events: none;
  background: linear-gradient(
    to right,
    rgba(20, 18, 16, 0.14),
    rgba(20, 18, 16, 0.02) 35%,
    rgba(20, 18, 16, 0.02) 65%,
    rgba(20, 18, 16, 0.14)
  );
  z-index: 5;
}

/* The animated turning leaf (double-sided sheet) */
.bp-leaf {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  transform-style: preserve-3d;
  z-index: 8;
  cursor: pointer;
}
.bp-leaf.anchor-right { left: 50%; transform-origin: left center; }
.bp-leaf.anchor-left  { left: 0;   transform-origin: right center; }

.bp-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: #fffdf9;
  overflow: hidden;
}
.bp-face.front { border-radius: 0 var(--bp-radius) var(--bp-radius) 0; }
.bp-face.back  { border-radius: var(--bp-radius) 0 0 var(--bp-radius); transform: rotateY(180deg); }

/* Dynamic shadow overlay painted onto the leaf as it turns —
   simulates paper thickness + light falloff, not a flat gimmick. */
.bp-leaf-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to right, rgba(0,0,0,0.30), rgba(0,0,0,0) 60%);
}
.bp-leaf.anchor-left .bp-leaf-shade {
  background: linear-gradient(to left, rgba(0,0,0,0.30), rgba(0,0,0,0) 60%);
}

/* Click affordances */
.bp-click-zone {
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
  z-index: 6;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
}
.bp-click-zone.left  { left: 0; }
.bp-click-zone.right { right: 0; }
.bp-click-zone:focus-visible {
  outline: 2px solid var(--fg, #1A1612);
  outline-offset: -4px;
}

/* ---- Controls ---- */
.bp-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.bp-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border, #e4e0da);
  background: var(--bg, #fff);
  color: var(--fg, #1A1612);
  cursor: pointer;
  transition: background .2s, opacity .2s;
}
.bp-nav-btn:hover:not(:disabled) { background: var(--card, #f4f1ec); }
.bp-nav-btn:disabled { opacity: .3; cursor: default; }
.bp-page-indicator {
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted, #8a8377);
  min-width: 120px;
  text-align: center;
}

/* ---- Thumbnail strip ---- */
.bp-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  max-width: 100%;
  padding: 4px 2px 10px;
  scrollbar-width: thin;
}
.bp-thumb {
  flex: none;
  width: 46px;
  height: 34px;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid transparent;
  cursor: pointer;
  opacity: .55;
  transition: opacity .2s, border-color .2s;
  background: #fffdf9;
}
.bp-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bp-thumb.active { opacity: 1; border-color: var(--fg, #1A1612); }
.bp-thumb:hover { opacity: .85; }
.bp-thumb-cover { margin-right: 6px; border-right: 1.5px dashed var(--border, #e4e0da); border-radius: 8px; padding-right: 0; }

/* Mobile: single-page reading mode */
@media (max-width: 640px) {
  .bp-stage { aspect-ratio: 4 / 3; }
  .bp-cover-stage { aspect-ratio: 16 / 9; max-width: 100%; }
  .bp-slot.left { display: none; }
  .bp-slot.right { width: 100%; border-radius: var(--bp-radius); }
  .bp-spine { display: none; }
  .bp-leaf { width: 100%; left: 0 !important; }
  .bp-click-zone.left { width: 35%; }
  .bp-click-zone.right { width: 65%; }
}

@media (prefers-reduced-motion: reduce) {
  .bp-leaf, .bp-cover-slot { transition: none !important; }
}
