/* ============================================================
   LIBRO LECTOR — modal de cuentos digitales interactivos
   ============================================================ */
.libro-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .25s ease;
  padding: 16px;
}
.libro-overlay-open { opacity: 1; }

.libro-modal {
  width: 100%;
  height: 100%;
  max-width: 1200px;
  max-height: 900px;
  background: #fdfaf4;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96);
  transition: transform .25s ease;
}
.libro-overlay-open .libro-modal { transform: scale(1); }

.libro-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--navy, #1a2e44);
  color: #fff;
  flex: 0 0 auto;
}
.libro-titulo {
  font-family: 'Fredoka One', cursive;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.libro-topbar-btns { display: flex; gap: 8px; }

.libro-btn {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: none;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.libro-btn:hover { background: rgba(255,255,255,0.25); }
.libro-btn-close { font-size: 1.1rem; }

.libro-stage {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #e9e4d8 0%, #d8d2c2 100%);
}

.libro-loading[hidden], .libro-error[hidden], .libro-book-wrap[hidden] {
  display: none;
}
.libro-loading, .libro-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--navy, #1a2e44);
  font-weight: 700;
  text-align: center;
  padding: 24px;
  max-width: 420px;
}
.libro-spinner {
  width: 40px; height: 40px;
  border: 5px solid rgba(26,46,68,0.15);
  border-top-color: var(--sky-dark, #2da8d8);
  border-radius: 50%;
  animation: libroSpin .9s linear infinite;
}
@keyframes libroSpin { to { transform: rotate(360deg); } }

.libro-error-msg { font-weight: 600; line-height: 1.4; }
.libro-error .libro-btn-reintentar {
  width: auto;
  height: auto;
  padding: 10px 22px;
  background: var(--navy, #1a2e44);
  color: #fff;
  border-radius: 50px;
  font-weight: 700;
  font-size: 0.9rem;
}
.libro-error .libro-btn-reintentar:hover { background: var(--sky-dark, #2da8d8); }

.libro-book-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.libro-book {
  box-shadow: 0 18px 50px rgba(0,0,0,0.35);
  position: relative;
}
.libro-spine-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 14px;
  margin-left: -7px;
  pointer-events: none;
  background: linear-gradient(
    to right,
    rgba(0,0,0,0) 0%,
    rgba(0,0,0,0.12) 42%,
    rgba(0,0,0,0.2) 50%,
    rgba(0,0,0,0.12) 58%,
    rgba(0,0,0,0) 100%
  );
  z-index: 2;
}
.libro-dogears {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
}
.libro-fold-mask {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 4;
  overflow: visible;
}
.libro-fold-outline {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 12;
  overflow: visible;
}
.libro-dogear {
  position: absolute;
  bottom: 0;
  width: 34px;
  height: 34px;
  transition: opacity .2s;
}
.libro-dogear[hidden] { display: none; }
.libro-dogear-right {
  right: 0;
  background: linear-gradient(225deg,
    #ffffff 0%, #ffffff 44%,
    #c9c9c9 45%, #e8e8e8 52%,
    #ffffff 53%, #ffffff 100%);
  clip-path: polygon(100% 100%, 0% 100%, 100% 0%);
  box-shadow: -3px -3px 8px rgba(0,0,0,0.22);
}
.libro-dogear-left {
  left: 0;
  background: linear-gradient(135deg,
    #ffffff 0%, #ffffff 44%,
    #c9c9c9 45%, #e8e8e8 52%,
    #ffffff 53%, #ffffff 100%);
  clip-path: polygon(0 100%, 100% 100%, 0 0%);
  box-shadow: 3px -3px 8px rgba(0,0,0,0.22);
}
@media (max-width: 680px) {
  .libro-dogear { width: 24px; height: 24px; }
}

.libro-page {
  background: #fff;
  overflow: hidden;
}
.libro-page canvas {
  display: block;
}


.libro-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.85);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--navy, #1a2e44);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transition: background .15s, opacity .15s;
}
.libro-nav:hover { background: #fff; }
.libro-nav:disabled { opacity: 0.3; cursor: default; }
.libro-nav-prev { left: 14px; }
.libro-nav-next { right: 14px; }
.libro-stage:has(.libro-loading:not([hidden])) .libro-nav,
.libro-stage:has(.libro-error:not([hidden])) .libro-nav {
  display: none;
}

.libro-footer {
  flex: 0 0 auto;
  padding: 8px 16px;
  text-align: center;
  background: #fdfaf4;
  border-top: 1px solid rgba(26,46,68,0.08);
}
.libro-progreso {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--navy, #1a2e44);
  opacity: 0.75;
}

@media (max-width: 680px) {
  .libro-overlay { padding: 6px; }
  .libro-topbar { padding: 8px 10px; }
  .libro-titulo { font-size: 0.85rem; }
  .libro-btn { width: 32px; height: 32px; }
  .libro-nav { width: 38px; height: 38px; font-size: 1.3rem; }
  .libro-nav-prev { left: 6px; }
  .libro-nav-next { right: 6px; }
}

/* ============================================================
   GALERÍA DE CUENTOS (sección del sitio)
   ============================================================ */
.cuentos-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
  margin: 32px auto 48px;
}
.cuento-card {
  flex: 0 0 220px;
  max-width: 220px;
  background: var(--white, #fff);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0,0,0,0.45);
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  border: none;
  text-align: left;
  padding: 0;
}
.cuento-card:hover { transform: translateY(-5px); box-shadow: 0 14px 40px rgba(0,0,0,0.15); }
.cuento-portada {
  width: 100%;
  aspect-ratio: 3/4;
  background: var(--sky-light, #a8e4f8);
  overflow: hidden;
  position: relative;
}
.cuento-portada img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cuento-portada-icono {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem;
}
.cuento-info {
  padding: 12px 14px 16px;
}
.cuento-info h4 {
  font-family: 'Fredoka One', cursive;
  font-size: 0.95rem;
  color: var(--navy, #1a2e44);
}
.cuentos-empty, .cuentos-error {
  text-align: center;
  color: var(--white, #fff);
  font-weight: 700;
  padding: 24px;
}
