.books-container {
  display: grid;
  grid-gap: 2rem;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Keeps the grid layout */
  justify-items: center;
  align-items: center;
  margin: 11rem auto;
  padding: 1rem;
  max-height: 100vh;
  width: 100%;
  box-sizing: border-box;
}

.book {
  height: 340px;
  width: 270px;
  perspective: 1000px;
}


.book:hover > .book-front,
.book.open > .book-front {
  transform: rotateY(-180deg) translateZ(0);
  z-index: 0;
}
.book:hover > .book-pages div:nth-child(1),
.book.open > .book-pages div:nth-child(1) {
  transform: rotateY(-30deg);
  transition-duration: 1.5s;
}
.book:hover > .book-pages div:nth-child(2),
.book.open > .book-pages div:nth-child(2) {
  transform: rotateY(-35deg);
  transition-duration: 1.8s;
}
.book:hover > .book-pages div:nth-child(3),
.book.open > .book-pages div:nth-child(3) {
  transform: rotateY(-118deg);
  transition-duration: 1.6s;
}
.book:hover > .book-pages div:nth-child(4),
.book.open > .book-pages div:nth-child(4) {
  transform: rotateY(-130deg);
  transition-duration: 1.4s;
}
.book:hover > .book-pages div:nth-child(5),
.book.open > .book-pages div:nth-child(5) {
  transform: rotateY(-140deg);
  transition-duration: 1.2s;
}

.book-cover {
  height: 100%;
  width: 100%;
}

.book-front {
  height: 100%;
  width: 100%;
  left: 0;
  top: 0;
  position: absolute;
  transform-style: preserve-3d;
  transform: rotateY(-34deg) translateZ(-6px);
  transform-origin: 0 100%;
  transition: all 800ms ease;
  z-index: 10;
}
.book-front div {
  height: 100%;
  width: 100%;
  left: 0;
  top: 0;
  position: absolute;
  transform-style: preserve-3d;
}
.book-front div:first-child::before,
.book-front div:last-child::before {
  background-color: var(--theme);
  content: "";
  left: 0;
  top: 0;
  position: absolute;
}
.book-front div:first-child {
  backface-visibility: hidden;
  background-color: #FFF;
  transform: translateZ(2px);
  user-select: none;
}
.book-front div:first-child::after {
  background-color: var(--theme);
  content: "";
  height: 100%;
  width: 4px;
  left: -4px;
  position: absolute;
  top: 0;
}
.book-front div:first-child::before {
  height: 100%;
  width: 6px;
  transform: rotateY(90deg) translateZ(268px);
}
.book-front div:last-child {
  background-color: #FFFBEC;
  transform: rotateY(180deg) translateZ(2px);
}

.book-front div:last-child::before {
  box-shadow: 0 -30px 30px 14px rgba(0, 0, 0, 0.3);
  height: 80%;
  transform: rotateX(90deg) rotateZ(90deg) translateZ(-220px) translateX(-20px) translateY(-70px);
}


.book-pages {
  height: 100%;
  width: 100%;
  left: 3%;
  top: 1%;
  max-height: 98%;
  position: absolute;
  transform-style: preserve-3d;
  z-index: 5;
}
.book-pages div {
  background: linear-gradient(to right, #E1DDD8, #FFFBF6);
  border-radius: 0 8px 8px 0;
  box-shadow: inset 0 -1px 2px rgba(50, 50, 50, 0.1), inset -1px 0 1px rgba(150, 150, 150, 0.2);
  height: 100%;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
  transform-style: preserve-3d;
  transform-origin: left center;
  transition-property: transform;
  transition-timing-function: ease;
}
.book-pages div:nth-child(1) {
  transform: rotateY(-28deg);
}
.book-pages div:nth-child(2) {
  transform: rotateY(-30deg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px;
}
.book-pages div:nth-child(3) {
  transform: rotateY(-32deg);
}
.book-pages div:nth-child(4) {
  transform: rotateY(-34deg);
}
.book-pages div:nth-child(5) {
  transform: rotateY(-36deg);
}
.book-pages div:nth-child(1),
.book-pages div:nth-child(2),
.book-pages div:nth-child(5) {
  transition-duration: 600ms;
}
.book-pages div:nth-child(3) {
  transition-duration: 400ms;
}
.book-pages div:nth-child(4) {
  transition-duration: 500ms;
}

.book-back {
  background-color: #FFFBEC;
  height: 100%;
  width: 100%;
  left: 0;
  top: 0;
  position: absolute;
  transform-style: preserve-3d;
  transform: rotateY(-15deg) translateZ(-8px);
  transform-origin: 0 100%;
}
.book-back::after,
.book-back::before {
  background-color: var(--theme);
  content: "";
  position: absolute;
  top: 0;
  left: 0;
}
.book-back::before {
  height: 100%;
  width: 15px;
  transform: rotateY(90deg) translateZ(265px) translateX(2px);
}

.book-back::after {
  box-shadow: 10px 1px 50px 25px var(--theme); /* Increase spread for larger size */
  top: 100%;
  width: 100%; /* Full width to match new size */
  transform: rotateX(90deg) rotateZ(18deg) translateZ(10px) translateX(50px) translateY(120px); /* Adjusted for larger book */
}

.title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--theme);
  padding: 2%;
}

.author,
.summary {
  font-size: 12px;
  font-weight: 700;
  color: var(--blackbg);
}

.summary {
  font-size: 12px;
  font-weight: 400;
  overflow-y: auto;
  line-height: 2;
}

.year {
  font-size: 12px;
  font-weight: 300;
  margin-bottom: 6px;
  color: var(--theme);
}

.touch-control {
  touch-action: manipulation;
  user-select: none;
}



.toggle-debug {
  margin-top: 70px; /* Add controlled space between the book and the button */
  padding: 2.27%; /* Adjust padding for a larger, clickable button */
  font-size: 16px; /* Make the font size more readable */
  cursor: pointer; /* Show pointer cursor on hover */
  border-radius: 5px; /* Add rounded corners for a cleaner look */
  background-color:var(--theme); /* You can choose a color that fits your theme */
  color: white; /* Text color */
  border: none; /* Remove border for a cleaner look */
  transition: background-color 0.3s ease; /* Add smooth color transition */
}


/* Make sure the button is responsive */
@media (max-width: 600px) {
  .toggle-debug {
    font-size: 18px;
    padding: 12px 24px;
  }
}

/* Allow book animations to overflow */
.swiper2 {
  overflow: visible !important;
}
