/* ==========================================================================
   Crónicas de Belleza · books.css
   Colección: libros en 3D, pack, próximos volúmenes y «Ver por dentro».
   ========================================================================== */

/* ---------- Colores de cada libro ---------- */
.book-card--piel,    .modal--piel    { --book-bg: #E2B2A6; --book-spine: #C79A8E; }
.book-card--rostro,  .modal--rostro  { --book-bg: #6F7D55; --book-spine: #66704B; }
.book-card--cabello, .modal--cabello { --book-bg: #8A5A3B; --book-spine: #6E4632; }

/* ---------- Rejilla de la colección ---------- */
.collection { padding-bottom: 140px; }
.books {
  margin-top: 90px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 80px 48px;
}

.book-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
  transition: transform .5s;
}

/* ---------- Libro 3D ---------- */
.shelf { padding: 20px 0 30px; perspective: 1600px; }
.book {
  position: relative;
  width: 240px;
  height: 360px;
  transform-style: preserve-3d;
  transform: rotateY(-24deg) rotateX(4deg);
}
.book__tilt { position: absolute; inset: 0; transform-style: preserve-3d; }
.book__body {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform .9s var(--ease-out);
}
.book-card:hover .book__body,
.book-card:focus-within .book__body { transform: rotateY(-18deg) translateZ(40px) translateY(-10px); }

.book__face { position: absolute; inset: 0; backface-visibility: hidden; }

.book__front {
  transform: translateZ(14px);
  border-radius: 3px 8px 8px 3px;
  overflow: hidden;
  background: var(--book-bg);
  box-shadow: inset 6px 0 10px -6px rgba(0, 0, 0, .35);
}
.book__front img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* Brillo que cruza la portada al pasar el ratón */
.book__front::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, .28) 46%, rgba(255, 255, 255, 0) 60%);
  transform: translateX(-100%);
  transition: transform 1.1s var(--ease-out);
}
.book-card:hover .book__front::after { transform: translateX(100%); }

/* Reflejo que sigue al ratón (lo mueve interactions.js) */
.book__glare {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--gx, 30%) var(--gy, 20%), rgba(255, 255, 255, .42), rgba(255, 255, 255, 0) 48%);
  mix-blend-mode: soft-light;
  opacity: 0;
  transition: opacity .4s;
  pointer-events: none;
}
.book-card:hover .book__glare { opacity: 1; }

.book__spine { left: -14px; width: 28px; border-radius: 3px; background: var(--book-spine); transform: rotateY(-90deg); }
.book__pages {
  left: auto; right: -13px; top: 4px; bottom: 4px;
  width: 26px;
  background: repeating-linear-gradient(90deg, #FBF6EE 0 2px, #E9DFCF 2px 3px);
  transform: rotateY(90deg);
}
.book__back { border-radius: 8px 3px 3px 8px; background: var(--book-spine); transform: translateZ(-14px) rotateY(180deg); }

.book__shadow {
  position: absolute;
  left: 10%; right: -6%; bottom: -34px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(59, 42, 32, .38), rgba(59, 42, 32, 0));
  transition: transform .9s var(--ease-out), opacity .9s;
}
.book-card:hover .book__shadow { transform: scale(.86); opacity: .7; }

/* ---------- Ficha del libro ---------- */
.book-card__info { width: 100%; max-width: 340px; }
.book-card__title { margin: 8px 0 0; font-family: var(--font-serif); font-size: 32px; font-weight: 400; line-height: 1.08; color: var(--ink); }
.book-card__meta { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.book-card__formats { margin: 22px 0 0; font-size: 14px; color: var(--muted); }
.book-card__price { margin: 6px 0 0; font-family: var(--font-serif); font-size: 26px; color: var(--ink); }
.book-card__buttons { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 10px; }

.chapters {
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 4px 10px;
}
.chapters li { display: contents; }
.chapters__num { font-family: var(--font-serif); font-size: 17px; font-style: italic; color: var(--gold); }
.chapters__name { font-size: 15px; line-height: 1.45; color: var(--text); }

.peek {
  margin-top: 10px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--copper);
  letter-spacing: .12em;
}

/* ---------- Pack de los tres libros ---------- */
.pack {
  margin-top: 130px;
  padding: 64px 40px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 40px 80px;
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 0 40px 80px -50px rgba(59, 42, 32, .5);
}
.fan { position: relative; width: 300px; height: 330px; perspective: 1400px; }
.fan__book {
  position: absolute;
  left: 50%; top: 10px;
  width: 190px; height: 285px;
  margin-left: -95px;
  border-radius: 3px 7px 7px 3px;
  overflow: hidden;
  box-shadow: 0 20px 40px -18px rgba(59, 42, 32, .55);
  transition: transform .8s var(--ease-out);
}
.fan__book img { width: 100%; height: 100%; object-fit: cover; }
.fan__book--1 { transform: rotate(-13deg) translateX(-62px) translateY(14px); }
.fan__book--2 { transform: translateY(-4px); z-index: 2; }
.fan__book--3 { transform: rotate(13deg) translateX(62px) translateY(14px); }
.pack:hover .fan__book--1 { transform: rotate(-20deg) translateX(-104px) translateY(22px); }
.pack:hover .fan__book--2 { transform: translateY(-22px) scale(1.04); }
.pack:hover .fan__book--3 { transform: rotate(20deg) translateX(104px) translateY(22px); }

.pack__info { flex: 0 1 420px; min-width: 0; }
.pack__title { margin: 10px 0 0; font-family: var(--font-serif); font-weight: 400; font-size: clamp(30px, 3.6vw, 42px); line-height: 1.08; }
.pack__text { margin: 14px 0 0; font-size: 16px; line-height: 1.65; color: var(--text); }
.pack__price { margin: 16px 0 18px; font-family: var(--font-serif); font-size: 28px; color: var(--ink); }

/* ---------- Próximos volúmenes ---------- */
.upcoming__intro { margin-top: 110px; text-align: center; }
.upcoming__title { margin: 12px 0 0; font-family: var(--font-serif); font-weight: 400; font-size: clamp(30px, 4vw, 48px); }
.upcoming__text { margin: 12px auto 0; max-width: 560px; font-size: 17px; line-height: 1.6; color: var(--text); }

.upcoming { margin-top: 44px; display: flex; flex-wrap: wrap; justify-content: center; gap: 48px; }
.soon { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.soon .navlink { padding: 0 6px; }

.ghost-book {
  width: 150px;
  height: 225px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  border: 1.5px dashed var(--gold-soft);
  border-radius: 3px 8px 8px 3px;
  transition: transform .6s var(--ease-out), border-color .4s, background .4s;
}
.soon:hover .ghost-book { transform: translateY(-8px) rotate(-2deg); border-style: solid; background: rgba(201, 165, 92, .08); }
.ghost-book .orn { width: 30px; }
.ghost-book__num { font-family: var(--font-serif); font-size: 26px; line-height: 1.1; color: var(--copper); }
.ghost-book__tag { font-size: 10px; letter-spacing: .24em; color: var(--gold); }

/* ---------- «Ver por dentro» (ventana con el libro abierto) ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  overflow: auto;
  background: rgba(46, 34, 27, .86);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: fade .4s ease both;
}
.modal__close { position: absolute; right: 20px; top: 20px; }
.modal__title { margin: 0; font-size: 13px; letter-spacing: .3em; text-transform: uppercase; color: var(--gold-light); }
.modal__buy { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

.flipbook-wrap {
  width: min(760px, 92vw);
  transform: translateX(-25%);
  transition: transform .9s cubic-bezier(.4, .1, .2, 1);
  animation: bookPop .7s var(--ease-out) both;
}
.flipbook-wrap.is-open { transform: none; }
@keyframes bookPop { from { opacity: 0; transform: scale(.85) rotateX(14deg); } to { opacity: 1; } }

.flipbook { position: relative; width: 100%; aspect-ratio: 4 / 3; perspective: 2400px; }
.leaf {
  position: absolute;
  left: 50%; top: 0;
  width: 50%; height: 100%;
  transform-style: preserve-3d;
  transform-origin: 0 50%;
  transition: transform 1.1s cubic-bezier(.4, .1, .2, 1), z-index 0s linear .55s;
}
.leaf.is-turned { transform: rotateY(-180deg); }

.page {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #FBF6EE;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: inset 10px 0 18px -12px rgba(0, 0, 0, .25);
}
.page--back { transform: rotateY(180deg); box-shadow: inset -10px 0 18px -12px rgba(0, 0, 0, .25); }
.page img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.page--cover { background: var(--book-bg); }
.page--blank { background: var(--book-spine); }

/* Última página: fin de la muestra */
.page--end {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5%;
  padding: 9% 10%;
  text-align: center;
  font-size: clamp(9px, 1.5vw, 13px);
  line-height: 1.5;
  background: #F4EADC;
}
.page--end::before {
  content: "";
  position: absolute;
  inset: 8% 10% auto;
  height: 34%;
  background: repeating-linear-gradient(0deg, transparent 0 13px, #DCCBB2 13px 14px);
  filter: blur(2px);
  opacity: .6;
}
.page__end-title { font-family: var(--font-serif); font-size: 1.7em; line-height: 1.1; color: var(--copper); }
.page__end-text { color: var(--text); }

.flipbook-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; color: #F4EADC; }
.flipbook-controls__label { min-width: 140px; text-align: center; font-size: 14px; letter-spacing: .08em; }

.round {
  width: 52px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--gold-light);
  border-radius: 50%;
  background: none;
  color: #F4EADC;
  cursor: pointer;
  transition: background .3s, transform .3s;
}
.round:hover { background: rgba(217, 184, 113, .2); transform: scale(1.06); }
.round:disabled { opacity: .3; cursor: default; transform: none; background: none; }
