/* ==========================================================================
   TARAQQI-E-TALEEM PUBLICATION — E-CATALOGUE FLIPBOOK ENGINE STYLES
   Authentic 3D Physics Page-Turn & Facing Textbook Spread Engine
   ========================================================================== */

/* Lightbox Modal Overlay */
.flipbook-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 24, 43, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  user-select: none;
}

.flipbook-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Top Navigation Header */
.flipbook-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(15, 39, 68, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  z-index: 10;
}

.flipbook-brand-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.flipbook-book-title {
  font-family: var(--font-display, 'Playfair Display', serif);
  font-size: clamp(0.82rem, 3vw, 1.15rem);
  font-weight: 700;
  color: #FFFFFF;
  margin: 0;
  line-height: 1.25;
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  max-width: 100%;
}

.flipbook-book-badge {
  background: #F59E0B;
  color: #0F2744;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.flipbook-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.flipbook-btn-whatsapp {
  background: #25D366;
  color: #FFFFFF;
  border: none;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}

.flipbook-btn-whatsapp:hover {
  background: #20BA5A;
  transform: translateY(-1px);
}

.flipbook-btn-close {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.flipbook-btn-close:hover {
  background: #EF4444;
  border-color: #EF4444;
  transform: rotate(90deg);
}

/* Main Flipbook Stage Area */
.flipbook-main-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 10px 50px;
}

/* Side Navigation Arrows */
.flipbook-nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background: rgba(15, 39, 68, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  color: #FFFFFF;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 40;
  transition: all 0.25s ease;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.flipbook-nav-arrow:hover:not(:disabled) {
  background: #F59E0B;
  color: #0F2744;
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 8px 25px rgba(245, 158, 11, 0.4);
}

.flipbook-nav-arrow:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.flipbook-nav-arrow.prev { left: 24px; }
.flipbook-nav-arrow.next { right: 24px; }

/* StPageFlip Interactive Book Container */
.flipbook-viewport {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 96vw;
  max-height: 80vh;
  margin: 0 auto;
  touch-action: none;
  transform-origin: center center;
}

.st-flipbook-stage {
  display: block;
  margin: 0 auto;
  box-shadow: 0 28px 75px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: #FFFFFF;
}

.st-page {
  background-color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.st-page img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  background: #FFFFFF;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* Authentic 3D Front & Back Hardcovers with Spine Crease */
.st-page.--hard {
  background-color: #0B192C;
  border-radius: 4px;
}

.st-page.--hard:first-child {
  box-shadow: inset 18px 0 24px -10px rgba(0, 0, 0, 0.6), inset -4px 0 10px rgba(0, 0, 0, 0.2);
}

.st-page.--hard:first-child::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 22px;
  background: linear-gradient(to right, rgba(0,0,0,0.35) 0%, rgba(255,255,255,0.15) 30%, rgba(0,0,0,0.2) 70%, transparent 100%);
  pointer-events: none;
  z-index: 5;
}

/* Back Cover closing on Left with spine on Right */
.st-page.--hard:last-child {
  box-shadow: inset -18px 0 24px -10px rgba(0, 0, 0, 0.6), inset 4px 0 10px rgba(0, 0, 0, 0.2);
}

.st-page.--hard:last-child::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  left: auto;
  width: 22px;
  background: linear-gradient(to left, rgba(0,0,0,0.35) 0%, rgba(255,255,255,0.15) 30%, rgba(0,0,0,0.2) 70%, transparent 100%);
  pointer-events: none;
  z-index: 5;
}

/* Inner Real Scanned Pages with Center Gutter Shadow */
.st-page.--soft {
  background-color: #FFFFFF;
}

.st-page.--soft:nth-child(even) {
  box-shadow: inset 16px 0 20px -10px rgba(0, 0, 0, 0.22), inset -4px 0 8px -4px rgba(0, 0, 0, 0.08);
}

.st-page.--soft:nth-child(odd) {
  box-shadow: inset -16px 0 20px -10px rgba(0, 0, 0, 0.22), inset 4px 0 8px -4px rgba(0, 0, 0, 0.08);
}

.flipbook-turning-leaf.flip-forward {
  right: 0;
  transform-origin: left center;
}

.flipbook-turning-leaf.flip-backward {
  left: 0;
  transform-origin: right center;
}

.flipbook-leaf-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: #FFFFFF;
  overflow: hidden;
}

.flipbook-leaf-face img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.flipbook-leaf-back {
  transform: rotateY(180deg);
  border-right: 1px solid rgba(0,0,0,0.1);
}

/* Dynamic Page Fold Shading Overlay */
.flipbook-turning-leaf::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgba(0,0,0,0.2) 0%, transparent 60%);
  pointer-events: none;
  z-index: 5;
}

/* Bottom Control Toolbar */
.flipbook-bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: rgba(15, 39, 68, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
  z-index: 10;
}

.flipbook-page-counter {
  font-family: var(--font-body, 'Plus Jakarta Sans', sans-serif);
  font-size: 0.9rem;
  font-weight: 700;
  color: #E2E8F0;
  background: rgba(255, 255, 255, 0.1);
  padding: 5px 14px;
  border-radius: 20px;
}

.flipbook-tools-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.flipbook-tool-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.flipbook-tool-btn:hover {
  background: #F59E0B;
  color: #0F2744;
  border-color: #F59E0B;
}

.flipbook-tool-btn.active {
  background: #3B82F6;
  border-color: #3B82F6;
}

/* Page Thumbnails Drawer */
.flipbook-thumbnails-tray {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: rgba(10, 24, 43, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  overflow-x: auto;
  max-width: 90vw;
  z-index: 30;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.flipbook-thumbnails-tray.active {
  transform: translateX(-50%) translateY(0);
}

.flipbook-thumb-item {
  position: relative;
  width: 65px;
  height: 90px;
  border-radius: 4px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  background: #1E293B;
}

.flipbook-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.flipbook-thumb-item .thumb-num {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.75);
  color: #FFFFFF;
  font-size: 0.65rem;
  padding: 1px 4px;
  border-radius: 3px;
}

.flipbook-thumb-item:hover {
  transform: translateY(-3px);
  border-color: #F59E0B;
}

.flipbook-thumb-item.active {
  border-color: #F59E0B;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

/* Mobile & Tablet Adaptations */
@media (max-width: 860px) {
  .flipbook-main-stage {
    padding: 8px 6px;
  }
  .flipbook-nav-arrow {
    width: 36px;
    height: 36px;
    font-size: 0.95rem;
  }
  .flipbook-nav-arrow.prev { left: 4px; }
  .flipbook-nav-arrow.next { right: 4px; }
  .flipbook-book-title { max-width: 100%; font-size: 0.88rem; word-break: break-word; }
}

@media (max-width: 680px) {
  .flipbook-topbar {
    padding: 8px 12px;
  }
  .flipbook-bottombar {
    padding: 8px 10px;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }
  .flipbook-page-counter {
    font-size: 11px;
    order: -1;
    width: 100%;
    text-align: center;
  }
  .flipbook-tools-group {
    gap: 4px;
  }
  .flipbook-tool-btn {
    padding: 5px 8px;
    font-size: 11px;
  }
  .flipbook-viewport {
    width: 98vw;
    max-height: 70vh;
    padding: 0;
  }
  .flipbook-btn-whatsapp span {
    display: none;
  }
  .flipbook-nav-arrow {
    width: 32px;
    height: 32px;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.6);
  }
}
