/**
 * ASN GOLD — 3D Interactive FlipBook CSS Engine
 * Realistic Dual-Page 3D Perspective, Page Shading, Spine Depth, & Luxury Theater UI
 */

/* ==========================================================================
   1. FLIPBOOK THEATER MODAL
   ========================================================================== */
.asn-flipbook-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at center, #1e293b 0%, #0b1120 70%, #050811 100%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.35s ease;
  overflow: hidden;
  user-select: none;
}

.asn-flipbook-modal.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ==========================================================================
   2. TOP & BOTTOM CONTROL BARS
   ========================================================================== */
.asn-fb-topbar,
.asn-fb-bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: rgba(11, 17, 32, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 50;
  gap: 1rem;
}

.asn-fb-bottombar {
  border-bottom: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  justify-content: center;
}

.asn-fb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: all 0.2s ease;
  cursor: pointer;
  outline: none;
}

.asn-fb-btn:hover {
  color: #ffffff;
  background: rgba(212, 175, 55, 0.18);
  border-color: #d4af37;
  transform: translateY(-1px);
}

.asn-fb-btn.is-active {
  color: #0b1120;
  background: #d4af37;
  border-color: #d4af37;
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
}

/* Sound Wave Animation */
.asn-fb-sound-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}

.asn-fb-sound-bar {
  width: 2px;
  height: 100%;
  background: currentColor;
  border-radius: 1px;
  animation: fbSoundPulse 0.8s ease-in-out infinite alternate;
}

.asn-fb-sound-bar:nth-child(2) { animation-delay: 0.2s; }
.asn-fb-sound-bar:nth-child(3) { animation-delay: 0.4s; }

@keyframes fbSoundPulse {
  0% { height: 3px; }
  100% { height: 12px; }
}

.asn-fb-btn:not(.is-active) .asn-fb-sound-bar {
  animation: none;
  height: 3px;
}

/* ==========================================================================
   3. 3D BOOK VIEWPORT & STAGE
   ========================================================================== */
.asn-fb-viewport {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 2400px;
  overflow: hidden;
  padding: 1.5rem;
}

.asn-fb-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-style: preserve-3d;
  transition: transform 0.2s ease-out;
}

/* Realistic Multi-Layer Page Depth & Edge Thickness */
.asn-fb-book {
  position: relative;
  display: flex;
  background: #ffffff;
  border-radius: 6px;
  box-shadow: 
    0 25px 60px -15px rgba(0, 0, 0, 0.7),
    0 0 80px rgba(212, 175, 55, 0.12),
    0 10px 20px rgba(0, 0, 0, 0.4);
  transform-style: preserve-3d;
}

/* Stacked Paper Edge Simulation on Sides */
.asn-fb-book::before,
.asn-fb-book::after {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 6px;
  background: repeating-linear-gradient(to right, #e2e8f0 0px, #cbd5e1 1px, #f8fafc 2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
  z-index: 1;
}
.asn-fb-book::before {
  left: -6px;
  border-radius: 4px 0 0 4px;
}
.asn-fb-book::after {
  right: -6px;
  border-radius: 0 4px 4px 0;
}

/* Book Center Spine Groove */
.asn-fb-spine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 44px;
  transform: translateX(-50%);
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.22) 0%,
    rgba(0, 0, 0, 0.08) 25%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(0, 0, 0, 0.08) 75%,
    rgba(0, 0, 0, 0.22) 100%
  );
  z-index: 25;
  pointer-events: none;
}

/* ==========================================================================
   4. STATIC & FLIPPING PAGES
   ========================================================================== */
.asn-fb-page {
  position: relative;
  width: 420px;
  height: 594px; /* A4 aspect ratio 1:1.414 */
  background: #ffffff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.03);
}

.asn-fb-page-left {
  border-radius: 4px 0 0 4px;
  box-shadow: inset -15px 0 25px -10px rgba(0, 0, 0, 0.15);
}

.asn-fb-page-right {
  border-radius: 0 4px 4px 0;
  box-shadow: inset 15px 0 25px -10px rgba(0, 0, 0, 0.15);
}

.asn-fb-page canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Active 3D Flipping Leaf */
.asn-fb-leaf {
  position: absolute;
  top: 0;
  width: 420px;
  height: 594px;
  transform-style: preserve-3d;
  z-index: 30;
  pointer-events: none;
  transition: transform 0.65s cubic-bezier(0.25, 1, 0.5, 1);
}

.asn-fb-leaf.flip-forward {
  right: 0;
  transform-origin: left center;
}

.asn-fb-leaf.flip-backward {
  left: 0;
  transform-origin: right center;
}

.asn-fb-leaf-face {
  position: absolute;
  inset: 0;
  background: #ffffff;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

.asn-fb-leaf-face.back {
  transform: rotateY(180deg);
}

.asn-fb-leaf-face canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Dynamic Page Shading Overlay during 3D Flip */
.asn-fb-shadow-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.65s ease;
}

.asn-fb-leaf.is-flipping .asn-fb-shadow-overlay {
  opacity: 0.6;
}

/* Page Corner Curl Cue on Hover */
.asn-fb-corner-cue {
  position: absolute;
  top: 0;
  width: 45px;
  height: 45px;
  z-index: 20;
  cursor: pointer;
  transition: transform 0.25s ease;
}

.asn-fb-corner-cue.right {
  right: 0;
  background: linear-gradient(135deg, transparent 50%, rgba(212, 175, 55, 0.4) 50%, #d4af37 100%);
  border-bottom-left-radius: 12px;
}

.asn-fb-corner-cue.left {
  left: 0;
  background: linear-gradient(225deg, transparent 50%, rgba(212, 175, 55, 0.4) 50%, #d4af37 100%);
  border-bottom-right-radius: 12px;
}

.asn-fb-corner-cue:hover {
  transform: scale(1.2);
}

/* ==========================================================================
   5. FLOATING 3D NAVIGATION ARROWS
   ========================================================================== */
.asn-fb-nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(212, 175, 55, 0.4);
  color: #f5e6be;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 40;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  transition: all 0.25s ease;
  outline: none;
}

.asn-fb-nav-arrow:hover {
  background: #d4af37;
  color: #0f172a;
  border-color: #d4af37;
  box-shadow: 0 0 25px rgba(212, 175, 55, 0.6);
  transform: translateY(-50%) scale(1.08);
}

.asn-fb-nav-arrow:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  pointer-events: none;
}

.asn-fb-nav-prev { left: 1.5rem; }
.asn-fb-nav-next { right: 1.5rem; }

/* ==========================================================================
   6. THUMBNAIL SCRUBBER TRAY
   ========================================================================== */
.asn-fb-thumbs-tray {
  position: absolute;
  bottom: 3.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  width: min(90vw, 850px);
  max-height: 110px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 16px;
  padding: 0.75rem;
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  z-index: 45;
  backdrop-filter: blur(16px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.asn-fb-thumbs-tray.is-visible {
  transform: translateX(-50%) translateY(0);
}

.asn-fb-thumb-item {
  flex-shrink: 0;
  width: 55px;
  height: 78px;
  border-radius: 6px;
  border: 2px solid transparent;
  background: #1e293b;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.asn-fb-thumb-item img,
.asn-fb-thumb-item canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.asn-fb-thumb-item:hover {
  transform: scale(1.06);
  border-color: rgba(212, 175, 55, 0.6);
}

.asn-fb-thumb-item.is-active {
  border-color: #d4af37;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.6);
}

.asn-fb-thumb-num {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
}

/* ==========================================================================
   7. LOADING & SPINNER
   ========================================================================= */
.asn-fb-loader {
  position: absolute;
  inset: 0;
  background: rgba(11, 17, 32, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 60;
  transition: opacity 0.3s ease;
}

.asn-fb-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(212, 175, 55, 0.2);
  border-top-color: #d4af37;
  border-radius: 50%;
  animation: fbSpin 0.9s linear infinite;
}

@keyframes fbSpin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   8. RESPONSIVE / MOBILE SINGLE-PAGE SPREAD
   ========================================================================== */
@media (max-width: 900px) {
  .asn-fb-page {
    width: min(85vw, 360px);
    height: min(120vw, 510px);
  }
  .asn-fb-leaf {
    width: min(85vw, 360px);
    height: min(120vw, 510px);
  }
  .asn-fb-page-left {
    display: none !important; /* Single page view on mobile */
  }
  .asn-fb-spine {
    display: none;
  }
  .asn-fb-book::before {
    display: none;
  }
  .asn-fb-nav-arrow {
    width: 42px;
    height: 42px;
  }
  .asn-fb-nav-prev { left: 0.5rem; }
  .asn-fb-nav-next { right: 0.5rem; }
}

/* ==========================================================================
   9. EMBEDDED FALLBACK VIEWER
   ========================================================================== */
.asn-fb-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.5rem;
  gap: 0.75rem;
  z-index: 50;
  background: #020617;
}

.asn-fb-fallback-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(212, 175, 55, 0.3);
  color: #cbd5e1;
  font-size: 0.75rem;
}

.asn-fb-fallback iframe {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 1rem;
  background: #0f172a;
}

