.book-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 50px 20px;
  perspective: 2000px;
  perspective-origin: center center;
}

.real-book {
  position: relative;
  width: 350px;
  height: 500px;
  transform-style: preserve-3d;
  cursor: pointer;
  margin-bottom: 30px;
  transition: transform 0.5s ease;
}

.real-book.open {
  cursor: default;
}

.book-container {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  overflow: visible !important;
}

.book-front-cover {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  transform-origin: left;
  transform-style: preserve-3d;
  transition: transform 1s cubic-bezier(0.645, 0.045, 0.355, 1);
  z-index: 20;
  overflow: visible;
}

.book-right-cover {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  right: 0;
  background-color: #8B4513;
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(0,0,0,0.2);
  z-index: 10;
  overflow: visible;
}

.real-book.open .book-front-cover {
  transform: rotateY(-160deg);
}

.real-book.closing .book-front-cover {
  transform: rotateY(0deg);
}

.left-page, .right-page {
  box-sizing: border-box;
  position: relative;
  height: 96%;
  width: 98%;
  margin: 2% 0.1%;
  background-color: #ffffff;
  border-radius: 3px;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  padding: 0;
}

.left-page {
  margin: 2% 1.9%;
  background-image: linear-gradient(to right, rgba(0,0,0,0.03) 0%, rgba(0,0,0,0) 10%);
}

.right-page {
  background-image: linear-gradient(to left, rgba(0,0,0,0.03) 0%, rgba(0,0,0,0) 10%);
}

.page-content {
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  padding: 20px;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.left-page-content {
  border-right: 1px solid rgba(0,0,0,0.05);
}

.right-page-content {
  border-left: 1px solid rgba(0,0,0,0.05);
}

.content-wrapper {
  flex-grow: 1;
}

.page-content p {
  font-family: Georgia, 'Times New Roman', Times, serif;
  font-size: 18px;
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

.page-content.empty {
  background-color: #ffffff;
}

/* ----PRZEKŁADANIE STRON ---- */
.flipping-page-container {
  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 99999 !important;
  perspective: 8000px;
  transform-style: preserve-3d;
  pointer-events: none;
}

.flipping-page-container.right {
  right: 1.1%;
}

.flipping-page-container.left {
  left: -1.1%;
}

.flipping-page {
  position: absolute;
  width: 98%;
  height: 96%;
  top: 1.4%;
  transform-style: preserve-3d;
  transform-origin: left center;
  backface-visibility: hidden;
  z-index: 9999 !important;
}

.flipping-page-container.right .flipping-page {
  right: 1%;
  animation: flipForward 800ms cubic-bezier(0, 0.2, 0.255, 0.2) forwards;
}

.flipping-page-container.left .flipping-page {
  left: 1%;
  animation: flipBackward 800ms cubic-bezier(0, 0.2, 0.255, 0.8) forwards;
}

.flipping-page-front,
.flipping-page-back {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background-color: #fbfbfb !important;
  border-radius: 3px;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  backface-visibility: hidden;
  overflow: hidden;
  z-index: 9999 !important;
}

.flipping-page-front {
  transform: rotateY(0deg);
  z-index: 10;
}

.flipping-page-back {
  transform: rotateY(180deg);
  z-index: 10;
}

.flipping-page-back .page-content {
  background-color: #fbfbfb !important;
  opacity: 1 !important;
}

.flipping-page-front .right-page-content,
.flipping-page-back .left-page-content {
  background-image: linear-gradient(to left, rgba(0,0,0,0.03) 0%, rgba(0,0,0,0) 1%);
}

.flipping-page-front .left-page-content,
.flipping-page-back .right-page-content {
  background-image: linear-gradient(to right, rgba(0,0,0,0.03) 0%, rgba(0,0,0,0) 10%);
}

@keyframes flipForward {
  0% {
    transform: rotateY(0deg);
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
  }
  25% {
    box-shadow: -10px 5px 15px rgba(0,0,0,0.15);
  }
  50% {
    box-shadow: -20px 10px 30px rgba(0,0,0,0.2);
  }
  75% {
    box-shadow: -10px 5px 15px rgba(0,0,0,0.15);
  }
  100% {
    transform: rotateY(-180deg);
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
  }
}

@keyframes flipBackward {
  0% {
    transform: rotateY(-180deg);
    box-shadow: -5px 5px 15px rgba(0,0,0,0.2);
  }
  100% {
    transform: rotateY(0deg);
    box-shadow: -5px 5px 15px rgba(0,0,0,0.2);
  }
}

.page-number {
  font-size: 12px;
  color: #999;
  display: block;
  margin-top: 10px;
  height: 15px;
  position: relative;
}

.left-number {
  text-align: left;
}

.right-number {
  text-align: right;
}

.cover-outside {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  backface-visibility: hidden;
  background-color: #8B4513;
  border-radius: 0 4px 4px 0;
  box-shadow: 5px 5px 15px rgba(0,0,0,0.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  z-index: 10;
}

.cover-inside {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  transform: rotateY(180deg);
  backface-visibility: hidden;
  background-color: #e9e2d0;
  border-radius: 4px 0 0 4px;
  box-shadow: inset 5px 0 15px rgba(0,0,0,0.1);
  z-index: 8;
  overflow: visible;
}

.cover-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-title {
  position: relative;
  margin: 20px;
  padding: 15px;
  background-color: rgba(255,255,255,0.9);
  border-radius: 5px;
  text-align: center;
  z-index: 1;
}

.cover-title h2 {
  margin: 0 0 8px 0;
  font-size: 22px;
}

.cover-title p {
  margin: 0;
  font-style: italic;
  font-size: 16px;
}

.book-back-cover {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background-color: #6B4513;
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(0,0,0,0.2);
  z-index: 1;
}

.book-controls {
  display: flex;
  gap: 15px;
  margin-top: 10px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0s 0.5s;
}

.book-controls.visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.5s ease, visibility 0s;
}

.book-btn {
  padding: 10px 15px;
  background-color: #4a6fa5;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  transition: background-color 0.3s, transform 0.2s;
}

.book-btn:hover:not(:disabled) {
  background-color: #3b5998;
  transform: translateY(-2px);
}

.book-btn:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
}

.close-btn {
  background-color: #d93025;
}

.close-btn:hover:not(:disabled) {
  background-color: #c62828;
}

.real-book:not(.open):hover .book-front-cover {
  transform: rotateY(-15deg);
  box-shadow: -5px 5px 10px rgba(0,0,0,0.1);
}

.real-book.animating {
  pointer-events: none;
}

@media (max-width: 1600px) {
    .real-book {
        width: 300px;
        height: 400px;
    }
    .page-content p {
        font-size: 18px;
        line-height: 1.5;
    }
    .page-content {
        padding: 18px;
    }
}

@media (max-width: 1375px) {
    .real-book {
        width: 210px;
        height: 310px;
    }
    .page-content p {
        font-size: 12px;  
        line-height: 1.5;
    }
    
}