/* 🧱 Book Container — stays in lower right, but now larger */
#book-container {
  position: absolute;
  right: 30vw;
  bottom: 12vh;
  width: 70vw;
  aspect-ratio: 1.414 / 1; /* A4 landscape */
  max-height: 80vh;
  height: auto;
  perspective: 3000px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  overflow: visible;
  transform-style: preserve-3d;
  background: transparent; /* optional: add backdrop if needed */
}

#book-container,
#book {
  overflow: visible;
}

/* 🖱️ Tabs */
#book-tabs {
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
}

#book-tabs button {
  background: rgba(240, 240, 240, 0.95);
  border: 1px solid #ccc;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  font-size: 0.9rem;
  transition: background 0.2s ease;
}

#book-tabs button:hover {
  background: #ddd;
  z-index: 100;
}

/* 📖 Book Layout */
#book {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0.8); /* scale down the book */
  transform-origin: center center;
  transform-style: preserve-3d;
  overflow: visible;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}
/* Spread */
.spread {
  position: absolute;
  top: 0;
  left: 0;
  width: auto;
  height: 100%;
  display: flex;
  gap: 0;
  transform-style: preserve-3d;
  perspective: 5000px;
}

/* 🧩 Sheet Styling */
.book-sheet {
  flex: 0 0 auto;
  aspect-ratio: 1.414 / 1; /* A4 landscape */
  height: 100%;
  width: auto;
  padding: 0;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  transform-style: preserve-3d;
  backface-visibility: hidden;
}

/* 🖼️ Image-Only Sheet Modifier */
.book-sheet.image-only {
  padding: 0;
  background-color: #000; /* Optional: cinematic black background */
}

/* 🖼️ Full-Page Image Styling */
.book-sheet img.full-page {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}


/* Decorative Edges */
.book-sheet::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, #ccc, #eee);
  left: 0;
  z-index: -1;
}

.book-sheet::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 30px;
  right: 0;
  background: linear-gradient(to left, rgba(255,255,255,0.3), rgba(255,255,255,0));
  pointer-events: none;
  transition: opacity 0.4s ease;
  opacity: 0;
}

.book-sheet.flipped::after {
  opacity: 1;
}

/* 📘 Left and Right Sheets */
.book-sheet.left,
.book-sheet.right {
  transform-style: preserve-3d;
  backface-visibility: hidden;
  transition: transform 0.4s ease;
  z-index: 2;
}

.book-sheet.left {
  transform-origin: right center;
}

.book-sheet.right {
  transform-origin: left center;
  transition: transform 0.4s ease, box-shadow 0.3s ease;
}

/* ✅ Flipped State */
.book-sheet.left.flipped {
  transform: rotateY(180deg);
  box-shadow: 10px 0 20px rgba(0, 0, 0, 0.2);
  mask-image: radial-gradient(circle at right center, rgba(0,0,0,1) 60%, rgba(0,0,0,0) 100%);
  -webkit-mask-image: radial-gradient(circle at right center, rgba(0,0,0,1) 60%, rgba(0,0,0,0) 100%);
  z-index: 1;
}

.book-sheet.right.flipped {
  transform: rotateY(-180deg);
  box-shadow: -10px 0 20px rgba(0, 0, 0, 0.2);
  mask-image: radial-gradient(circle at left center, rgba(0,0,0,1) 60%, rgba(0,0,0,0) 100%);
  -webkit-mask-image: radial-gradient(circle at left center, rgba(0,0,0,1) 60%, rgba(0,0,0,0) 100%);
}

/* 🧾 Page Faces */
.book-sheet .front {
  background: white;
}

.book-sheet .back {
  background: #f0f0f0;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  padding: 20px;
  box-sizing: border-box;
  backface-visibility: hidden;
  transform: rotateY(180deg);
  color: #333;
}

/* 🎬 Curling Animation Trigger */
.book-sheet.flipping {
  animation: pageCurl 1s ease-in-out forwards;
  z-index: 100;
  pointer-events: none;
}

.book-sheet .curl-shadow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, rgba(0,0,0,0.2), transparent 80%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.book-sheet.flipping .curl-shadow {
  opacity: 1;
}

/* 🌪️ Enhanced Cinematic Curl */
@keyframes pageCurl {
  0% {
    transform: rotateY(0deg) rotateX(0deg) translateZ(0px) scale(1);
  }
  20% {
    transform: rotateY(-60deg) rotateX(60deg) translateZ(200px) scale(1.1);
  }
  40% {
    transform: rotateY(-120deg) rotateX(30deg) translateZ(100px) scale(1.05);
  }
  60% {
    transform: rotateY(-150deg) rotateX(15deg) translateZ(50px) scale(1.02);
  }
  80% {
    transform: rotateY(-170deg) rotateX(5deg) translateZ(20px) scale(1);
  }
  100% {
    transform: rotateY(-180deg) rotateX(0deg) translateZ(0px) scale(1);
  }
}