
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Georgia", serif;
  /* background: linear-gradient(135deg, #8b4513, #a0522d); */
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  /* padding: 20px; */
  overflow: hidden;
}

.reader-container {
  background: transparent;
  max-width: 1200px;
  width: 100%;
  position: relative;
}

.controls {
  background: rgba(139, 69, 19, 0.9);
  backdrop-filter: blur(10px);
  padding: 15px 20px;
  border-radius: 15px 15px 0 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-bottom: 10px;
  display: none;
}

.book-container {
  position: relative;
  perspective: 2000px;
  background: #2c2c2c;
  border-radius: 0 0 15px 15px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.book {
  width: 100%;
  height: calc(100vw * 3 / 2);
  position: relative;
  transform-style: preserve-3d;
  display: flex;
}

.book-spread {
  display: flex;
}


.page-left,
.page-right {
  width: 50%;
  height: 100%;
  background: #000;
  position: relative;
  overflow: hidden;
  border-radius: 0;
}

.page-left {
  transform-origin: right center;
}

.page-right {
  transform-origin: left center;
}
.page-image {
  width: 100%;
  height: 100%;
  object-fit: fill; /* riempie completamente */
  background: transparent;
}

.empty-page {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 18px;
  background: #1a1a1a;
}

.page-number {
  position: absolute;
  bottom: 15px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  background: rgba(0, 0, 0, 0.5);
  padding: 4px 10px;
  border-radius: 4px;
}

.page-left .page-number {
  left: 15px;
}

.page-right .page-number {
  right: 15px;
}

.binding-gutter {
  position: absolute;
  left: 50%;
  top: 20%;
  width: 20px;
  height: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: linear-gradient(
    to right,
    transparent 0%,
    rgba(0, 0, 0, 0.3) 50%,
    transparent 100%
  );
}

.flipping-page {
  position: absolute;
  top: 20%;
  width: 50%;
  height: 50%; /* più alta rispetto alle altre */
  background: transparent;
  transform-style: preserve-3d;
  transition: transform 0.8s ease-out;
  z-index: 5;
  overflow: hidden;
}


.flipping-page.next-flip { 
	right: 0; 
	transform-origin: left center; 
}

.flipping-page.prev-flip { 
	left: 0;
	transform-origin: right center; 
 }

.flipping-page .page-front,
.flipping-page .page-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}

.flipping-page .page-back {
  transform: rotateY(180deg);
}

.flipping-page .page-back img {
  transform: scaleX(-1);
}

.flipping-page.flipping.next-flip {
  transform: rotateY(-180deg);
}

.flipping-page.flipping.prev-flip {
  transform: rotateY(180deg);
}

.click-areas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  display: flex;
}

.click-area {
  height: 100%;
  width: 50%;
  cursor: pointer;
}


.page-indicator {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  z-index: 25;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  height: 100%;
  color: #999;
  text-align: center;
  padding: 40px;
}

.placeholder-icon {
  font-size: 64px;
  opacity: 0.5;
}

@media (max-width: 768px) {
  .book-container {
    position: relative;
    perspective: 2000px;
    background: transparent; /* trasparente */
    border-radius: 0 0 15px 15px;
    box-shadow: none;
    overflow: visible; /* per permettere l’animazione oltre i bordi */
  }
  
  .page-left, .page-right {
    width: 50%;
    height: 50%; /* piÃ¹ basse rispetto alla flipping page */
    position: relative;
    overflow: hidden;
    background: transparent;
    z-index: 1;
    top: 20%; /* centrata verticalmente */
  }

  .page-left {
    margin-right: 4px;
  }

  .page-right {
    margin-left: 4px;
  }

  .flipping-page {
    width: calc(50% - 4px);
  }

  .flipping-page.next-flip {
    right: 4px;
  }

  .flipping-page.prev-flip {
    left: 4px;
  }
}