/* ═══════════════════════════════════════════════════════
   ESTANTE 3D INTERACTIVO - Estilos (corregido)
═══════════════════════════════════════════════════════ */

.shelf-3d-container {
  padding: 60px 20px;
  background: linear-gradient(160deg, #fff8ee, #fdecd0);
  border-radius: 24px;
  text-align: center;
  margin: 60px auto;
  max-width: 900px;
}

.hint-3d {
  font-size: 13px;
  color: #9a7e5a;
  margin-bottom: 2rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── STAGE DE LIBROS ──────────────────────────────────── */
.shelf-stage {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 40px;
  padding: 20px 40px 0;
  position: relative;
  z-index: 1;
  flex-wrap: wrap;
}

/* ── LIBRO 3D ─────────────────────────────────────────── */
.book-3d-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: grab;
  user-select: none;
}

.book-3d-wrap:active {
  cursor: grabbing;
}

.book-3d-scene {
  perspective: 900px;
  width: 160px;
  height: 220px;
}

.book-3d {
  width: 160px;
  height: 220px;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateY(-25deg) rotateX(5deg);
  transition: transform 0.05s linear;
  will-change: transform;
}

/* ════════════════════════════════════════════════════════
   CARAS DEL LIBRO — geometría corregida
   Caja: 160 × 220 × 44 px (profundidad = 2 × 22)
   • Frente:   z = +22   → translateZ(22px)
   • Atrás:    z = −22   → rotateY(180deg) translateZ(22px)
   • Lomo:     x =   0   → left:-23px, width:46px, rotateY(-90deg)
   • Páginas:  x = 160   → left:137px, width:46px, rotateY(90deg)
   • Arriba:   y =   0   → top:-23px,  height:46px, rotateX(90deg)
   • Abajo:    y = 220   → top:197px,  height:46px, rotateX(-90deg)
   Se añade 1 px de expansión en cada cara para tapar
   el gap sub-píxel que genera el anti-aliasing del navegador.
════════════════════════════════════════════════════════ */

.book-face {
  position: absolute;
  backface-visibility: hidden;
}

/* ── FRENTE ────────────────────────────────────────────── */
.book-front {
  width: 160px;
  height: 220px;
  left: 0;
  top: 0;
  transform: translateZ(22px);
  border-radius: 2px 10px 10px 2px;
  overflow: hidden;
  box-shadow: 4px 4px 20px rgba(0, 0, 0, 0.25);
  background: #fff8ee;
}

.book-front::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 10px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 2px 0 0 2px;
  z-index: 2;
}

.book-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

.book-cover-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  padding: 14px;
}

.placeholder-emoji {
  font-size: 3rem;
}

.placeholder-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: white;
  text-align: center;
  line-height: 1.3;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.price-badge {
  position: absolute;
  bottom: 12px;
  right: 10px;
  background: rgba(0, 0, 0, 0.35);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  z-index: 2;
  backdrop-filter: blur(4px);
}

/* ── ATRÁS ──────────────────────────────────────────────── */
.book-back {
  width: 160px;
  height: 220px;
  left: 0;
  top: 0;
  transform: rotateY(180deg) translateZ(22px);
  border-radius: 10px 2px 2px 10px;
  box-shadow: -4px 4px 20px rgba(0, 0, 0, 0.2);
}

/* ── LOMO (izquierda) ───────────────────────────────────── */
/*
  Centro del elemento en x=0 (center = left + width/2 = -23 + 23 = 0).
  rotateY(-90deg) rota alrededor de ese centro → la cara queda en el
  plano x=0, extendiéndose de z=-23 a z=+23 (1px de margen cada lado).
  ¡Sin translateZ! El translateZ anterior desplazaba el lomo +22px en X.
*/
.book-spine {
  width: 46px;
  height: 222px;
  left: -23px;
  top: -1px;
  transform: rotateY(-90deg);
  border-radius: 6px 0 0 6px;
  box-shadow: inset -4px 0 12px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  font-size: 11px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.08em;
  padding: 12px 0;
  text-transform: uppercase;
}

/* ── PÁGINAS (derecha) ──────────────────────────────────── */
/*
  Centro del elemento en x=160 (left=137, width=46 → center=137+23=160).
  rotateY(90deg) → cara en el plano x=160, z de -23 a +23.
*/
.book-pages {
  width: 46px;
  height: 222px;
  left: 137px;
  top: -1px;
  transform: rotateY(90deg);
  border-radius: 0 4px 4px 0;
  background: repeating-linear-gradient(
    to bottom,
    #f8f0e0 0px,
    #f8f0e0 1.5px,
    #ede0c6 2px,
    #f5ead4 3px
  );
  box-shadow: inset -3px 0 10px rgba(0, 0, 0, 0.15),
              inset  2px 0  6px rgba(255,255,255,0.4);
}

/* ── ARRIBA ─────────────────────────────────────────────── */
/*
  Centro en y=0 (top=-23, height=46 → center=0).
  rotateX(90deg): local +Y → original +Z
    → borde inferior (y=+23) queda en z=+23 (frente)
    → borde superior (y=-23) queda en z=-23 (atrás)
  Sin translateZ: la cara queda en y=0.
*/
.book-top {
  width: 162px;
  height: 46px;
  top: -23px;
  left: -1px;
  transform: rotateX(90deg);
  background: #f0e6d0;
  border-radius: 2px;
}

/* ── ABAJO ──────────────────────────────────────────────── */
/*
  Centro en y=220 (top=197, height=46 → center=220).
  rotateX(-90deg): local +Y → original -Z
    → borde inferior (y=+23) queda en z=-23 (atrás)
    → borde superior (y=-23) queda en z=+23 (frente)
*/
.book-bottom {
  width: 162px;
  height: 46px;
  top: 197px;
  left: -1px;
  transform: rotateX(-90deg);
  background: #e6d8c0;
}

.book-label {
  font-size: 13px;
  font-weight: 800;
  color: #6b4f2a;
  text-align: center;
  letter-spacing: 0.01em;
  max-width: 160px;
}

/* ── ESTANTE DE MADERA ────────────────────────────────── */
.shelf-wood-wrap {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  position: relative;
}

.shelf-decor-top {
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin-bottom: 1rem;
  height: 60px;
}

.modal-overlay-3d {
  position: fixed;
  inset: 0;
  background: rgba(26, 18, 40, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(4px);
}

.modal-overlay-3d.visible {
  display: flex;
  opacity: 1;
}

.modal-card-3d {
  background: #fff8ee;
  border-radius: 24px;
  padding: 48px 48px 48px 60px; /* Reducido para que la tapa no deje hueco gigante */
  max-width: 920px;
  width: 90%;
  display: flex;
  gap: 48px;
  align-items: center;
  position: relative;
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-lg);
}

@keyframes popIn {
  from { transform: scale(0.7) translateY(30px); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.modal-close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 38px;
  height: 38px;
  background: rgba(61, 44, 94, 0.12);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #3d2c5e;
  transition: background 0.2s, transform 0.2s;
  z-index: 10;
}

.modal-close-btn:hover {
  background: #e84040;
  color: white;
  transform: scale(1.1) rotate(90deg);
}

/* ── LIBRO EN MODAL (GEOMETRÍA ROBUSTA) ─────────────────── */
.modal-book-3d {
  width: 220px;
  flex-shrink: 0;
  perspective: 1500px;
  height: 300px;
  position: relative;
  margin-left: 120px; /* Deja espacio a la izquierda para la tapa abierta */
}

.modal-book-inner {
  width: 220px;
  height: 300px;
  margin-top: 0;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateY(-15deg) rotateX(5deg);
  transition: transform 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-book-inner.open {
  transform: rotateY(5deg) rotateX(5deg) scale(1.05);
}

/* ── FRENTE (Tapa que se abre) ── */
.m-front {
  position: absolute;
  width: 220px;
  height: 300px;
  left: 0;
  top: 0;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 5;
}

.modal-book-inner.open .m-front {
  transform: rotateY(-150deg);
}

.m-front-outer {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 0 8px 8px 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 4px 4px 15px rgba(0,0,0,0.15);
}

.m-front-outer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

.m-front-inner-page {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 8px 0 0 8px;
  transform: rotateY(180deg);
  background: #fdfaf2;
  border-right: 4px solid #e5dec9;
  box-shadow: inset -16px 0 30px rgba(0,0,0,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.page-content-decor {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
}

.page-emoji {
  font-size: 2.8rem;
}

.page-quote {
  font-family: 'Baloo 2', cursive;
  font-size: 1.1rem;
  font-weight: 700;
  color: #8b7d72;
  line-height: 1.4;
}

/* ── PÁGINAS INTERIORES ── */
.m-inside-pages {
  position: absolute;
  width: 212px;
  height: 292px;
  left: 4px;
  top: 4px;
  transform: translateZ(-15px); /* Medio del libro */
  background: #fdfaf2;
  border-radius: 0 6px 6px 0;
  box-shadow: inset 10px 0 20px rgba(0,0,0,0.05), 4px 4px 10px rgba(0,0,0,0.05);
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  border-right: 4px solid #e7dec9;
}

.m-inside-text {
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: #6d5b4f;
  line-height: 1.5;
  text-align: left;
  width: 100%;
}

.m-inside-text p {
  margin: 0;
  color: #6d5b4f;
  font-weight: 600;
}

.m-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  position: absolute;
  inset: 0;
}

.m-placeholder span:first-child {
  font-size: 3.5rem;
}

.m-placeholder span:last-child {
  font-size: 1.1rem;
  font-weight: 800;
  color: white;
  text-align: center;
  line-height: 1.3;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ── LOMO ── */
.m-spine {
  position: absolute;
  width: 30px;
  height: 300px;
  left: 0;
  top: 0;
  transform-origin: left;
  transform: rotateY(90deg);
  border-radius: 0 4px 4px 0;
  box-shadow: inset 4px 0 10px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  font-size: 13px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 12px 0;
}

/* ── ATRÁS ── */
.m-back {
  position: absolute;
  width: 220px;
  height: 300px;
  left: 0;
  top: 0;
  transform: translateZ(-30px);
  border-radius: 0 8px 8px 0;
  backface-visibility: hidden;
  box-shadow: 4px 4px 15px rgba(0,0,0,0.15);
  overflow: hidden;
}

/* ── ARRIBA ── */
.m-top {
  position: absolute;
  width: 220px;
  height: 30px;
  left: 0;
  top: 0;
  transform-origin: top;
  transform: rotateX(-90deg);
  background: #f0e6d0;
  backface-visibility: hidden;
}

/* ── ABAJO ── */
.m-bottom {
  position: absolute;
  width: 220px;
  height: 30px;
  left: 0;
  bottom: 0;
  transform-origin: bottom;
  transform: rotateX(90deg);
  background: #e6d8c0;
  backface-visibility: hidden;
}

/* Remover .m-pages y .m-page ya que el acordeón estaba rompiendo el render y no era necesario */


@keyframes pageFlip {
  0%   { transform: rotateY(-8deg); }
  40%  { transform: rotateY(-5deg); }
  100% { transform: rotateY(-2deg); }
}

/* ── INFO DEL MODAL ───────────────────────────────────── */
.modal-info {
  flex: 1;
}

.modal-badge {
  display: inline-block;
  background: rgba(244, 168, 40, 0.18);
  color: #a06010;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 10px;
}

.modal-title-text {
  font-size: 2rem;
  font-weight: 800;
  color: #1a1228;
  margin-bottom: 8px;
  line-height: 1.2;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
}

.modal-desc-text {
  font-size: 1.05rem;
  color: #7a6890;
  line-height: 1.65;
  margin-bottom: 14px;
}

.themes-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.theme-pill {
  background: rgba(123, 94, 167, 0.12);
  color: #5a3e8a;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
}

.price-row {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-bottom: 18px;
}

.price-lbl {
  font-size: 0.95rem;
  color: #7a6890;
  font-weight: 600;
}

.price-val {
  font-size: 2.2rem;
  font-weight: 800;
  color: #1a1228;
}

.price-cur {
  font-size: 1rem;
  color: #7a6890;
  font-weight: 600;
}

/* ── BOTONES ──────────────────────────────────────────── */
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-wa, .btn-ebook {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: white;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 14px 22px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  text-decoration: none;
}

.btn-wa {
  background: #25d366;
}

.btn-wa:hover {
  background: #1da852;
  transform: translateY(-2px);
}

.btn-ebook {
  background: linear-gradient(135deg, #7b5ea7, #5a3e8a);
}

.btn-ebook:hover {
  opacity: 0.88;
  transform: translateY(-2px);
}

.soon-badge {
  display: inline-block;
  background: rgba(123, 94, 167, 0.12);
  color: #5a3e8a;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 8px;
  text-align: center;
}

/* ── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 768px) {
  .shelf-stage {
    gap: 20px;
    padding: 20px 10px 0;
  }

  /* Mobile: libro 120×165, profundidad 33px (2×16.5) */
  .book-3d-scene {
    width: 120px;
    height: 165px;
  }

  .book-3d {
    width: 120px;
    height: 165px;
  }

  .book-front,
  .book-back {
    width: 120px;
    height: 165px;
  }

  .book-spine {
    width: 35px;
    height: 167px;
    left: -17.5px;
    top: -1px;
    font-size: 9px;
  }

  .book-pages {
    width: 35px;
    height: 167px;
    left: 102.5px; /* 120 - 17.5 */
    top: -1px;
  }

  .book-top {
    width: 122px;
    height: 35px;
    top: -17.5px;
    left: -1px;
  }

  .book-bottom {
    width: 122px;
    height: 35px;
    top: 147.5px; /* 165 - 17.5 */
    left: -1px;
  }

  .modal-card-3d {
    flex-direction: column;
    gap: 32px;
    padding: 48px 24px 32px;
    align-items: center;
    max-width: 92%;
    margin: 0 auto;
  }

  .modal-book-3d {
    width: 140px;
    height: 190px;
    margin-left: 0;
    margin-top: 10px;
  }

  .modal-book-inner {
    width: 140px;
    height: 190px;
  }

  .m-front, .m-back {
    width: 140px;
    height: 190px;
  }

  /* El lomo en móvil tendrá 20px de ancho */
  .m-spine {
    width: 20px;
    height: 190px;
    font-size: 9px;
  }

  .m-back {
    transform: translateZ(-20px);
  }

  .m-top, .m-bottom {
    width: 140px;
    height: 20px;
  }

  .m-inside-pages {
    width: 136px;
    height: 184px;
    left: 2px;
    top: 3px;
    transform: translateZ(-10px);
    padding: 12px;
  }

  .m-inside-text {
    font-size: 0.72rem;
    line-height: 1.45;
  }

  .page-quote {
    font-size: 0.75rem;
  }

  .page-emoji {
    font-size: 1.8rem;
  }

  .modal-title-text {
    font-size: 1.5rem;
    text-align: center;
  }

  .modal-desc-text {
    font-size: 0.95rem;
    text-align: center;
  }

  .themes-row {
    justify-content: center;
  }

  .price-row {
    justify-content: center;
  }
}

