/* =========================================================
   ANTOLOGÍA DE CUENTOS — ESTILOS PRINCIPALES
   Tarjetas: libros cerrados 3D con efecto de apertura
   ========================================================= */

:root {
  --color-bg:        #0f0c29;
  --color-bg2:       #302b63;
  --color-bg3:       #24243e;
  --color-accent:    #FFD93D;
  --color-text:      #ffffff;
  --color-text-soft: #c5c5e8;
  --font-display:    'Baloo 2', cursive;
  --font-body:       'Nunito', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: linear-gradient(135deg, var(--color-bg), var(--color-bg2), var(--color-bg3));
  min-height: 100vh;
  color: var(--color-text);
  overflow-x: hidden;
}

/* ── Estrellas ─────────────────────────────────────────── */
.stars { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.star {
  position: absolute; border-radius: 50%; background: #fff;
  animation: twinkle var(--dur,3s) ease-in-out infinite alternate;
  animation-delay: var(--delay,0s);
}
@keyframes twinkle {
  from { opacity: .1; transform: scale(1); }
  to   { opacity: .9; transform: scale(1.4); }
}

/* ── Hero ──────────────────────────────────────────────── */
.hero {
  position: relative; z-index: 1;
  text-align: center; padding: 60px 20px 40px;
}
.hero-badge {
  display: inline-block;
  background: var(--color-accent); color: #1a1a2e;
  font-family: var(--font-display); font-weight: 800; font-size: 1rem;
  padding: 6px 20px; border-radius: 50px; margin-bottom: 20px;
  box-shadow: 0 4px 16px rgba(255,217,61,0.4);
  animation: bounceIn .7s cubic-bezier(.36,1.56,.64,1) both;
}
.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.8rem,8vw,5.5rem);
  font-weight: 800; line-height: 1.1; letter-spacing: -1px; margin-bottom: 16px;
}
.word { display: inline-block; margin: 0 6px; }
.word-1 { color: #FF6B6B; animation: popIn .5s .1s  cubic-bezier(.36,1.56,.64,1) both; }
.word-2 { color: var(--color-accent); animation: popIn .5s .25s cubic-bezier(.36,1.56,.64,1) both; }
.word-3 {
  color: transparent; -webkit-text-stroke: 3px #6BCB77;
  animation: popIn .5s .4s cubic-bezier(.36,1.56,.64,1) both;
}
.hero-sub {
  font-size: clamp(1.1rem,3vw,1.5rem); color: var(--color-text-soft);
  font-weight: 700; animation: fadeUp .6s .6s both;
}
.hero-deco {
  font-size: 2.5rem; animation: spin 6s linear infinite;
  display: inline-block; margin-top: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Biblioteca ────────────────────────────────────────── */
.library {
  position: relative; z-index: 1;
  max-width: 1200px; margin: 0 auto; padding: 20px 24px 80px;
}

/* Grid: una fila de libros sobre un estante */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 32px 24px;
  align-items: end;
}

/* ════════════════════════════════════════════════════════
   LIBRO CERRADO 3D
   Estructura:
     .book-wrap           perspectiva y click
       .book-3d           el libro en sí, gira en Y
         .book-cover      tapa frontal
           .cover-top     franja superior con emoji
           .cover-body    área central con título
           .cover-spine-l lomo izquierdo simulado
         .book-back       contratapa (se ve al hover)
       .book-shadow       sombra en el estante
   ════════════════════════════════════════════════════════ */

.book-wrap {
  perspective: 900px;
  cursor: pointer;
  /* Stagger de entrada */
  animation: riseUp .6s var(--book-delay, 0s) cubic-bezier(.36,1.56,.64,1) both;
}

@keyframes riseUp {
  from { opacity: 0; transform: translateY(40px) scale(.85); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.book-3d {
  position: relative;
  width: 100%;
  padding-top: 140%;          /* ratio tapa ~7:10 */
  transform-style: preserve-3d;
  transform: rotateY(0deg);
  transition: transform .55s cubic-bezier(.4,0,.2,1);
  transform-origin: left center;
}

/* Al hacer hover: el libro se abre ligeramente (≈28°) */
.book-wrap:hover .book-3d {
  transform: rotateY(-28deg);
}

/* ── Tapa ──────────────────────────────────────────────── */
.book-cover {
  position: absolute; inset: 0;
  border-radius: 3px 10px 10px 3px;
  background: linear-gradient(160deg, var(--c1), var(--c2));
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow:
    4px 6px 20px rgba(0,0,0,0.55),
    inset -3px 0 8px rgba(0,0,0,0.15);
  backface-visibility: hidden;
}

/* Lomo simulado (franja izquierda más oscura) */
.book-cover::before {
  content: '';
  position: absolute; top: 0; left: 0; bottom: 0; width: 14px;
  background: linear-gradient(to right,
    rgba(0,0,0,0.35) 0%,
    rgba(0,0,0,0.10) 60%,
    rgba(0,0,0,0) 100%);
  border-radius: 3px 0 0 3px;
  z-index: 2;
}

/* Brillo en la esquina superior derecha */
.book-cover::after {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 50%; height: 40%;
  background: radial-gradient(ellipse at top right,
    rgba(255,255,255,0.22) 0%,
    transparent 70%);
  pointer-events: none;
}

/* Zona superior: emoji flotante */
.cover-top {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.cover-emoji {
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.3));
  animation: float 3s ease-in-out infinite;
  animation-delay: var(--book-delay, 0s);
}
@keyframes float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

/* Franja inferior: título */
.cover-body {
  background: rgba(0,0,0,0.28);
  backdrop-filter: blur(4px);
  padding: 10px 12px 12px;
  text-align: center;
}
.cover-title {
  font-family: var(--font-display);
  font-size: clamp(.72rem, 1.6vw, .88rem);
  font-weight: 800; line-height: 1.25; color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* Líneas decorativas de fondo (textura de tapa) */
.cover-lines {
  position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: repeating-linear-gradient(
    -45deg,
    rgba(255,255,255,0) 0px,
    rgba(255,255,255,0) 8px,
    rgba(255,255,255,0.03) 8px,
    rgba(255,255,255,0.03) 9px
  );
}

/* ── Contratapa (cara trasera) ─────────────────────────── */
.book-back {
  position: absolute; inset: 0;
  border-radius: 3px 10px 10px 3px;
  background: linear-gradient(160deg, var(--c2), var(--c1));
  backface-visibility: hidden;
  transform: rotateY(180deg);
  display: flex; align-items: center; justify-content: center;
  box-shadow: -4px 6px 20px rgba(0,0,0,0.4);
}

/* ── Sombra en el estante ──────────────────────────────── */
.book-shadow {
  width: 100%; height: 12px;
  margin-top: 4px;
  background: radial-gradient(ellipse at center,
    rgba(0,0,0,0.45) 0%,
    transparent 75%);
  transition: transform .55s ease, opacity .55s ease;
}
.book-wrap:hover .book-shadow {
  transform: scaleX(.75) translateX(12px);
  opacity: .7;
}

/* ── Etiqueta "Leer" que aparece al hover ──────────────── */
.book-label {
  position: absolute;
  bottom: -36px;
  left: 50%; transform: translateX(-50%);
  background: linear-gradient(90deg, var(--c1), var(--c2));
  color: #fff;
  font-family: var(--font-display); font-weight: 800; font-size: .82rem;
  padding: 6px 18px; border-radius: 50px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .3s, bottom .3s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  pointer-events: none;
}
.book-wrap:hover .book-label {
  opacity: 1; bottom: -32px;
}

/* ── Stagger delays ────────────────────────────────────── */
.book-wrap:nth-child(1)  { --book-delay:.05s; }
.book-wrap:nth-child(2)  { --book-delay:.10s; }
.book-wrap:nth-child(3)  { --book-delay:.15s; }
.book-wrap:nth-child(4)  { --book-delay:.20s; }
.book-wrap:nth-child(5)  { --book-delay:.25s; }
.book-wrap:nth-child(6)  { --book-delay:.30s; }
.book-wrap:nth-child(7)  { --book-delay:.35s; }
.book-wrap:nth-child(8)  { --book-delay:.40s; }
.book-wrap:nth-child(9)  { --book-delay:.45s; }
.book-wrap:nth-child(10) { --book-delay:.50s; }
.book-wrap:nth-child(11) { --book-delay:.55s; }
.book-wrap:nth-child(12) { --book-delay:.60s; }
.book-wrap:nth-child(13) { --book-delay:.65s; }
.book-wrap:nth-child(14) { --book-delay:.70s; }
.book-wrap:nth-child(15) { --book-delay:.75s; }


/* ── Reseña al hover ───────────────────────────────────── */
/* Panel que aparece deslizándose desde abajo sobre la tapa */
.book-review {
  position: absolute;
  inset: 0;
  border-radius: 3px 10px 10px 3px;
  background: rgba(10, 8, 30, 0.88);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 12px;
  text-align: center;
  gap: 8px;
  /* Empieza oculto abajo */
  clip-path: inset(100% 0 0 0);
  transition: clip-path .4s cubic-bezier(.4,0,.2,1);
  z-index: 3;
  pointer-events: none;
}

.book-wrap:hover .book-review {
  clip-path: inset(0% 0 0 0);
  pointer-events: auto;  /* habilita clicks en los botones al hacer hover */
}

.review-emoji {
  font-size: 1.6rem;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
}

.review-title {
  font-family: var(--font-display);
  font-size: .72rem;
  font-weight: 800;
  color: var(--color-accent);
  line-height: 1.2;
}

.review-text {
  font-family: var(--font-body);
  font-size: .68rem;
  font-weight: 600;
  color: rgba(255,255,255,0.88);
  line-height: 1.45;
}

.review-cta {
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: .68rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(90deg, var(--c1), var(--c2));
  padding: 5px 14px;
  border-radius: 50px;
  letter-spacing: .02em;
  text-decoration: none;
  display: inline-block;
}

/* ── Dos botones en panel de reseña ────────────────────── */
.review-btns {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 4px;
}
.review-btns .review-cta { margin-top: 0; }

.review-cta-activity {
  background: linear-gradient(90deg, #6c5ce7, #a29bfe);
}


/* ── Botón Actividad debajo del libro ──────────────────── */
.book-under-btns {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}
.book-under-btns button {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: .75rem;
  color: #fff;
  background: linear-gradient(90deg, #6c5ce7, #a29bfe);
  border: none;
  border-radius: 50px;
  padding: 7px 16px;
  cursor: pointer;
  transition: transform .2s;
}
.book-under-btns button:hover {
  transform: scale(1.07);
}

/* ── Footer ────────────────────────────────────────────── */
.site-footer {
  text-align: center; padding: 24px;
  color: var(--color-text-soft); font-size: .9rem;
  position: relative; z-index: 1;
}

/* ── Keyframes ─────────────────────────────────────────── */
@keyframes popIn {
  from { opacity: 0; transform: scale(.4) rotate(-5deg); }
  to   { opacity: 1; transform: scale(1) rotate(0deg); }
}
@keyframes bounceIn {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 600px) {
  .hero { padding: 40px 16px 24px; }
  .books-grid { grid-template-columns: repeat(auto-fill, minmax(130px,1fr)); gap: 24px 16px; }
  .book-label { display: none; }
}
