/* 3D Booklet Layout & Styles */

.book-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px 0;
  /* Centering the book and ensuring perspective */
  perspective: 2000px;
}

.book-container {
  position: relative;
  width: 900px;
  height: 550px;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
  transform-origin: center center;
}

/* Realistic Spine / Binding */
.book-spine {
  position: absolute;
  top: 0;
  left: calc(50% - 10px);
  width: 20px;
  height: 100%;
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.4) 0%,
    rgba(255, 255, 255, 0.1) 30%,
    rgba(0, 0, 0, 0.6) 50%,
    rgba(255, 255, 255, 0.1) 70%,
    rgba(0, 0, 0, 0.4) 100%
  );
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
  z-index: 10;
  pointer-events: none;
  border-radius: 2px;
}

/* Base Page Wrapper */
.book-page {
  position: absolute;
  width: 50%;
  height: 100%;
  top: 0;
  right: 0;
  transform-style: preserve-3d;
  transform-origin: left center;
  transition: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1);
  z-index: 1;
  pointer-events: none; /* Only allow pointer events on active page faces */
}

/* Prevent double click selection */
.book-page * {
  user-select: none;
  -webkit-user-drag: none;
}

/* Flipped State */
.book-page.flipped {
  transform: rotateY(-180deg);
}

/* Front & Back Faces */
.page-face {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  padding: 30px 40px;
  display: flex;
  flex-direction: column;
  background-color: #fcf9f2;
  background-image: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.5) 0%, rgba(244, 237, 222, 0.4) 100%);
  pointer-events: auto; /* Re-enable pointer events on the face */
  overflow: hidden;
  transition: transform 0.5s ease, opacity 0.5s ease;
}

.page-face.face-back {
  transform: rotateY(180deg);
  /* Spine shadow on the left of back face */
  box-shadow: inset 15px 0 20px -10px rgba(0, 0, 0, 0.15), 0 10px 25px rgba(0, 0, 0, 0.3);
}

.page-face.face-front {
  /* Spine shadow on the right of front face */
  box-shadow: inset -15px 0 20px -10px rgba(0, 0, 0, 0.15), 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* Page content and formatting */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(18, 74, 67, 0.15);
  padding-bottom: 8px;
  margin-bottom: 14px;
}

.page-category {
  font-family: var(--font-hindi);
  font-size: 0.75rem;
  color: var(--primary-light);
  letter-spacing: 0.5px;
  font-weight: 700;
  text-transform: uppercase;
}

.page-number {
  font-size: 0.75rem;
  color: var(--text-muted-light);
  font-weight: 600;
}

.page-title {
  font-family: var(--font-hindi);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 12px;
  line-height: 1.3;
}

.page-body {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.page-text {
  font-family: var(--font-hindi);
  font-size: 0.88rem;
  color: var(--text-dark);
  margin-bottom: 12px;
  line-height: 1.6;
}

.page-image-box {
  position: relative;
  width: 100%;
  height: 240px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(0,0,0,0.1);
  margin-top: auto;
  cursor: zoom-in;
}

.page-image-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition-smooth);
}

.page-image-box:hover img {
  transform: scale(1.05);
}

.page-image-zoom-indicator {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(18, 74, 67, 0.85);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--transition-smooth);
}

.page-image-box:hover .page-image-zoom-indicator {
  opacity: 1;
}

/* Covers (Front and Back) */
.page-face.face-cover {
  background: linear-gradient(135deg, #1b3d39 0%, #0d1e1c 100%);
  color: var(--text-light);
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  border: 3px double var(--secondary);
  border-radius: 0 8px 8px 0;
}

.page-face.face-cover::before {
  content: '';
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 10px;
  border: 1px solid rgba(212, 175, 55, 0.3);
  pointer-events: none;
  border-radius: 4px;
}

.page-face.face-cover-back {
  border-radius: 8px 0 0 8px;
}

/* Cover Content styling */
.cover-logo {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 25px;
  box-shadow: var(--shadow-gold), 0 10px 20px rgba(0,0,0,0.3);
}

.cover-logo svg {
  width: 44px;
  height: 44px;
  fill: var(--bg-dark);
}

.cover-title {
  font-family: var(--font-hindi);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-light);
  line-height: 1.2;
  margin-bottom: 5px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
  background: linear-gradient(135deg, #ffffff, var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.cover-subtitle {
  font-family: var(--font-hindi);
  font-size: 1.1rem;
  color: var(--secondary);
  margin-bottom: 30px;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.cover-badge {
  font-family: var(--font-hindi);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 20px;
  border: 1px solid var(--secondary);
  border-radius: 30px;
  color: var(--secondary);
  background: rgba(212, 175, 55, 0.05);
}

.cover-hint {
  position: absolute;
  bottom: 35px;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-hindi);
}

.cover-hint svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  animation: bounceX 1.5s infinite;
}

/* Inner Page styling elements */
.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 15px;
}

.toc-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition-smooth);
}

.toc-item:hover {
  background: rgba(18, 74, 67, 0.08);
  color: var(--primary-light);
}

.toc-chapter {
  font-family: var(--font-hindi);
  font-size: 0.95rem;
}

.toc-dots {
  flex-grow: 1;
  border-bottom: 2px dotted rgba(18, 74, 67, 0.2);
  margin: 0 15px;
}

.toc-page {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--secondary-dark);
}

/* Animations */
@keyframes bounceX {
  0%, 100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(6px);
  }
}

/* Real-page shadow overlay when turning */
.page-shadow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
  background: linear-gradient(to right, rgba(0,0,0,0.1) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.5s ease;
}

.book-page.flipped .page-shadow-overlay {
  opacity: 1;
}

/* ========================================================================= */
/* ================== MOBILE FULL-WIDTH CARD SLIDER ENGINE ================== */
/* ========================================================================= */
@media (max-width: 767px) {
  .booklet-desk {
    padding: 30px 12px 24px 12px !important;
    border-width: 2px !important;
    border-radius: var(--radius-md) !important;
  }
  
  .book-wrapper {
    padding: 10px 0 !important;
  }

  .book-container {
    width: 100% !important;
    height: 480px !important;
    transform: none !important;
    perspective: none !important;
  }
  
  .book-spine {
    display: none !important;
  }
  
  /* Disable 3D container pivots on mobile */
  .book-page {
    width: 100% !important;
    height: 100% !important;
    left: 0 !important;
    top: 0 !important;
    right: 0 !important;
    transform: none !important;
    transform-style: flat !important;
    pointer-events: none !important;
  }
  
  /* Style all face cards as absolute stack */
  .page-face {
    position: absolute !important;
    width: 100% !important;
    height: 100% !important;
    left: 0 !important;
    top: 0 !important;
    transform: none !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4) !important;
    padding: 20px !important;
    border-radius: var(--radius-md) !important;
    transition: transform 0.4s ease, opacity 0.4s ease !important;
  }
  
  .page-face.face-cover {
    border-radius: var(--radius-md) !important;
  }
  
  .page-image-box {
    height: 180px !important;
  }

  /* Slide Animation states (Horizontal Swipe overrides) */
  .page-face.mobile-hidden {
    transform: translateX(105%) !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }
  
  .page-face.mobile-active {
    transform: translateX(0) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 10 !important;
  }
  
  .page-face.mobile-flipped {
    transform: translateX(-105%) !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }
  
  .toc-list {
    gap: 8px !important;
  }
  
  .toc-item {
    padding: 6px 8px !important;
  }
  
  .toc-chapter {
    font-size: 0.85rem !important;
  }
  
  .page-title {
    font-size: 1.15rem !important;
    margin-bottom: 8px !important;
  }
  
  .page-text {
    font-size: 0.8rem !important;
    margin-bottom: 8px !important;
  }
}
