/* ═══════════════════════════════════════════════
   LIBROS — catálogo (/libros/) y lector PDF
═══════════════════════════════════════════════ */

/* ── Catálogo ── */
.libros-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 480px), 1fr));
  gap: 2rem;
}
.libro-card {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 1.75rem;
  padding: 1.75rem;
  background: var(--g2);
  border: 1px solid var(--border);
  border-radius: var(--r2);
}
.libro-portada {
  display: block;
  align-self: start;
  aspect-ratio: 2 / 3;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgb(var(--navy-rgb) / .12), 0 14px 30px rgb(var(--navy-rgb) / .18);
  transition: transform .2s, box-shadow .2s;
}
a.libro-portada:hover { transform: translateY(-3px); box-shadow: 0 4px 8px rgb(var(--navy-rgb) / .14), 0 20px 40px rgb(var(--navy-rgb) / .22); }
.libro-portada img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Portada tipográfica cuando no se sube imagen */
.libro-portada-tipo {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.1rem .95rem;
  background: var(--navy);
  border-left: 6px solid var(--blue);
  color: var(--on-dark);
}
.lpt-titulo { font-family: var(--ffc); font-size: 1.15rem; line-height: 1.15; overflow-wrap: anywhere; }
.lpt-autor  { font-size: .66rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--green); }

.libro-info { display: flex; flex-direction: column; min-width: 0; }
.libro-anio { font-family: var(--ffm); font-size: .72rem; letter-spacing: .14em; color: var(--text3); margin-bottom: .4rem; }
.libro-titulo { font-family: var(--ffc); font-weight: 400; font-size: 1.6rem; line-height: 1.15; color: var(--navy); }
.libro-subtitulo { margin-top: .35rem; font-size: .95rem; font-weight: 600; color: var(--text2); line-height: 1.45; }
.libro-desc { white-space: pre-line; margin-top: .9rem; font-size: .92rem; color: var(--text2); line-height: 1.7; }
.libro-acciones { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: auto; padding-top: 1.25rem; }
.libro-acciones .btn { padding: .7rem 1.2rem; font-size: .86rem; }
.libro-acciones .btn small { font-weight: 500; color: var(--text3); font-size: .74rem; }

.libros-vacio {
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
  padding: 3rem 2rem;
  background: var(--g2);
  border: 1px dashed var(--border2);
  border-radius: var(--r2);
}
.libros-vacio h2 { font-family: var(--ffc); font-weight: 400; font-size: 1.7rem; color: var(--navy); margin-bottom: .75rem; }
.libros-vacio p { color: var(--text2); line-height: 1.7; margin-bottom: 1.5rem; }

/* Celular: portada junto al título; descripción y botones a todo el ancho */
@media (max-width: 600px) {
  .libro-card { grid-template-columns: 100px 1fr; grid-auto-rows: auto; column-gap: 1rem; row-gap: 0; padding: 1.1rem; align-items: start; }
  .libro-info { display: contents; }
  .libro-portada { grid-row: 1 / span 3; }
  .libro-anio, .libro-titulo, .libro-subtitulo { grid-column: 2; }
  .libro-titulo { font-size: 1.3rem; }
  .libro-subtitulo { font-size: .86rem; }
  .libro-desc, .libro-acciones { grid-column: 1 / -1; }
  .libro-desc { margin-top: 1.1rem; }
  .libro-acciones .btn { flex: 1 1 auto; justify-content: center; white-space: nowrap; }
  .lpt-titulo { font-size: .8rem; }
}


/* ── Lector ── */
.lector-body { overflow: hidden; }
.lector-body #nav { background: var(--navy); }
.lector-body .sticky-cta { display: none; }

.lector {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding-top: 68px;
  background: var(--g0);
}
.lector:fullscreen { padding-top: 0; }

.lector-barra {
  display: flex;
  align-items: center;
  gap: .75rem 1rem;
  flex-wrap: wrap;
  padding: .55rem 1.25rem;
  background: var(--g2);
  border-bottom: 1px solid var(--border2);
}
.lector-volver {
  display: inline-flex; align-items: center; gap: .2rem;
  font-size: .86rem; font-weight: 700; color: var(--blue);
}
.lector-volver svg { width: 18px; height: 18px; }
.lector-titulo {
  flex: 1;
  min-width: 0;
  font-family: var(--ffc);
  font-weight: 400;
  font-size: 1.1rem;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lector-grupo { display: flex; align-items: center; gap: .25rem; }
.lector-grupo button,
.lector-grupo a {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 .5rem;
  border: 1px solid transparent; border-radius: var(--r);
  background: transparent; color: var(--navy);
  font: 700 .8rem var(--ffb);
  cursor: pointer;
}
.lector-grupo button:hover,
.lector-grupo a:hover { background: var(--g3); border-color: var(--border); }
.lector-grupo button:focus-visible,
.lector-grupo a:focus-visible,
.lector-pag input:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.lector-grupo svg { width: 18px; height: 18px; }
.lector-grupo [hidden] { display: none; }
.lector-pct { min-width: 64px !important; }
.lector-epub { border-color: var(--border2) !important; }
.lector-pag input {
  width: 3.6rem; height: 36px;
  padding: 0 .4rem;
  border: 1px solid var(--border2); border-radius: var(--r);
  background: var(--g1);
  font: 600 .9rem var(--ffb); color: var(--text);
  text-align: center;
  -moz-appearance: textfield;
}
.lector-pag input::-webkit-inner-spin-button,
.lector-pag input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.lector-total { font-size: .85rem; color: var(--text3); white-space: nowrap; }

.lector-visor {
  flex: 1;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  outline: none;
  position: relative;
  scrollbar-gutter: stable;   /* el ancho no cambia al aparecer la barra: sin scroll horizontal */
}
.lector-paginas {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 16px;
  width: max-content;
  min-width: 100%;
}
.lector-pagina {
  position: relative;
  flex-shrink: 0;
  background: #fff;
  box-shadow: 0 1px 3px rgb(var(--navy-rgb) / .14), 0 8px 24px rgb(var(--navy-rgb) / .1);
}
.lector-pagina:not(.lista)::after {
  content: attr(data-n);
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font: 600 .9rem var(--ffb); color: var(--g4);
}
.lector-pagina canvas { display: block; width: 100%; height: 100%; }

.lector-estado {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 2rem;
  text-align: center;
  font-size: .95rem; color: var(--text2);
}
.lector-estado.error { color: #B42318; }

@media (max-width: 760px) {
  .lector-barra { padding: .45rem .75rem; gap: .4rem .5rem; }
  .lector-titulo { display: none; }
  .lector-volver span { display: none; }
  .lector-pct { min-width: 52px !important; }
}

/* Celular angosto: los controles caben en una sola fila
   (el EPUB se sigue descargando desde el catálogo) */
@media (max-width: 480px) {
  .lector-barra { flex-wrap: nowrap; justify-content: space-between; gap: .15rem; padding: .4rem .5rem; }
  .lector-grupo { gap: .1rem; }
  .lector-grupo button, .lector-grupo a { min-width: 32px; height: 34px; padding: 0 .3rem; }
  .lector-pct { min-width: 0 !important; font-size: .74rem !important; }
  .lector-pag input { width: 2.9rem; height: 34px; }
  .lector-total { font-size: .78rem; }
  .lector-epub { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .libro-portada { transition: none; }
  a.libro-portada:hover { transform: none; }
}
