/* Biblioteca EPUB — estilos.
   Objetivo: Safari 9 (iPad mini 1). Todo con prefijos -webkit- y sin variables CSS,
   que en esa versión no existen. Colores escritos a mano por tema. */

* { -webkit-box-sizing: border-box; box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
  font-family: -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  overflow: hidden;
}

/* ---------- temas ---------- */
body.tema-sepia  { background: #d8cdb8; color: #3a3226; }
body.tema-claro  { background: #e9e9ec; color: #1d1d1f; }
body.tema-oscuro { background: #121114; color: #cfcbc4; }

body.tema-sepia  .hoja-papel { background: #f4ecd8; }
body.tema-claro  .hoja-papel { background: #ffffff; }
body.tema-oscuro .hoja-papel { background: #1c1b1f; }

.oculto { display: none !important; }

/* ---------- pantallas ---------- */
.pantalla {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: none; -webkit-overflow-scrolling: touch;
}
.pantalla.activa { display: block; }
#estante, #ficha { overflow-y: auto; }

/* ---------- barra superior ---------- */
.barra {
  position: relative; display: -webkit-box; display: -webkit-flex; display: flex;
  -webkit-box-align: center; -webkit-align-items: center; align-items: center;
  -webkit-justify-content: space-between; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid rgba(0,0,0,0.12);
}
body.tema-oscuro .barra { border-bottom-color: rgba(255,255,255,0.10); }
.barra h1 {
  margin: 0; font-size: 19px; font-weight: 600; letter-spacing: 0.3px;
  white-space: nowrap; overflow: hidden; -o-text-overflow: ellipsis; text-overflow: ellipsis;
}
.barra-acciones { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; }

.btn-icono {
  -webkit-appearance: none; appearance: none; border: 0; background: transparent;
  color: inherit; font-size: 22px; line-height: 1; padding: 6px 10px; cursor: pointer;
}
.btn-icono:active { opacity: 0.5; }

.senal {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 10px; background: #8a8a8a;
}
.senal.en-linea { background: #2fa36b; }
.senal.sin-linea { background: #c2603f; }

/* Vistas del estante: colecciones agrupadas o lista plana. */
.vistas { padding: 12px 16px 0 16px; }
.btn-vista {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  border: 1px solid rgba(0,0,0,0.20); background: rgba(255,255,255,0.45);
  color: inherit; font-size: 13px; padding: 6px 14px; border-radius: 16px;
  margin-right: 8px; font-family: inherit;
}
body.tema-oscuro .btn-vista { border-color: rgba(255,255,255,0.18); background: rgba(255,255,255,0.06); }
.btn-vista.activo { background: #6b4f2a; border-color: #6b4f2a; color: #fff; }

.cabecera-serie {
  display: -webkit-box; display: -webkit-flex; display: flex;
  -webkit-box-align: center; -webkit-align-items: center; align-items: center;
  padding: 12px 16px 0 16px; font-size: 16px; font-weight: 600;
}
.cabecera-serie span { margin-left: 12px; }

/* Una colección se dibuja como una pila: se nota que adentro hay varios. */
.tarjeta-portada.pila:before, .tarjeta-portada.pila:after {
  content: ""; position: absolute; top: -4px; bottom: 4px; border-radius: 3px;
  background: rgba(150,135,110,0.55); z-index: -1;
}
.tarjeta-portada.pila:before { left: 5px; right: -5px; }
.tarjeta-portada.pila:after  { left: 9px; right: -9px; background: rgba(150,135,110,0.30); }
.tarjeta-portada.pila { overflow: visible; }
.tarjeta-portada.pila img { border-radius: 3px; }
.insignia.serie {
  background: rgba(107,79,42,0.95); font-size: 11px; padding: 3px 8px;
  right: auto; left: 5px; bottom: 5px;
}

/* ---------- rejilla de libros ---------- */
.rejilla {
  display: -webkit-box; display: -webkit-flex; display: flex;
  -webkit-flex-wrap: wrap; flex-wrap: wrap;
  padding: 14px 8px 4px 8px;
}
.tarjeta {
  width: 33.33%; padding: 8px; cursor: pointer;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}
.tarjeta:active { opacity: 0.65; }
.tarjeta-portada {
  position: relative; width: 100%; padding-top: 148%;
  background: #b9ab90; border-radius: 3px; overflow: hidden;
  -webkit-box-shadow: 0 3px 10px rgba(0,0,0,0.30); box-shadow: 0 3px 10px rgba(0,0,0,0.30);
}
body.tema-oscuro .tarjeta-portada { background: #2a2830; }
.tarjeta-portada img {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: block;
}
/* Las portadas llegan de a poco (carga diferida). Sin esto aparecen de golpe y
   el estante parpadea; con la aparición suave el hueco de color se siente parte
   del diseño y no un error. El alto ya lo reserva .tarjeta-portada con su
   padding-top, así que nada salta de lugar. */
.tarjeta-portada img.difiere { opacity: 0; }
.tarjeta-portada img.cargada {
  opacity: 1;
  -webkit-transition: opacity 0.28s ease-out;
  transition: opacity 0.28s ease-out;
}
.tarjeta-sinportada {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  padding: 10px; display: -webkit-box; display: -webkit-flex; display: flex;
  -webkit-box-align: center; -webkit-align-items: center; align-items: center;
  -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center;
  text-align: center; font-size: 12px; line-height: 1.35; color: #4a4030;
  font-family: Georgia, "Times New Roman", serif;
}
body.tema-oscuro .tarjeta-sinportada { color: #b8b2a8; }
.tarjeta-lomo {
  position: absolute; top: 0; left: 0; bottom: 0; width: 7px;
  background: -webkit-linear-gradient(left, rgba(0,0,0,0.30), rgba(0,0,0,0));
  background: linear-gradient(to right, rgba(0,0,0,0.30), rgba(0,0,0,0));
}
.tarjeta-titulo {
  margin: 7px 2px 0 2px; font-size: 12px; line-height: 1.3; font-weight: 600;
  overflow: hidden;
}
.tarjeta-autor { margin: 2px 2px 0 2px; font-size: 11px; opacity: 0.68; overflow: hidden; }
.insignia {
  position: absolute; right: 5px; bottom: 5px;
  background: rgba(20,20,20,0.82); color: #fff; font-size: 9px; letter-spacing: 0.4px;
  padding: 2px 6px; border-radius: 9px; text-transform: uppercase;
}
.insignia.guardado { background: rgba(31,120,80,0.92); }

/* ---------- ficha ---------- */
.ficha-cuerpo { display: -webkit-box; display: -webkit-flex; display: flex; padding: 16px; }
.ficha-portada {
  width: 132px; min-width: 132px; height: auto; border-radius: 3px; background: #b9ab90;
  -webkit-box-shadow: 0 4px 14px rgba(0,0,0,0.30); box-shadow: 0 4px 14px rgba(0,0,0,0.30);
}
.ficha-datos { padding-left: 16px; -webkit-box-flex: 1; -webkit-flex: 1; flex: 1; }
.ficha-datos h2 { margin: 0 0 4px 0; font-size: 20px; line-height: 1.25; }
.ficha-autor { margin: 0 0 8px 0; opacity: 0.7; font-size: 14px; }
.ficha-estado { margin: 0 0 12px 0; font-size: 12px; opacity: 0.7; }
.ficha-desc { margin: 14px 0 0 0; font-size: 13px; line-height: 1.5; opacity: 0.85; }
.ficha-botones { margin-bottom: 8px; }

.btn {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  border: 1px solid rgba(0,0,0,0.25); background: rgba(255,255,255,0.5);
  color: inherit; font-size: 14px; padding: 9px 16px; border-radius: 6px;
  margin: 0 8px 8px 0; font-family: inherit;
}
body.tema-oscuro .btn { border-color: rgba(255,255,255,0.20); background: rgba(255,255,255,0.07); }
.btn:active { opacity: 0.6; }
.btn.primario { background: #6b4f2a; border-color: #6b4f2a; color: #fff; }
body.tema-oscuro .btn.primario { background: #7a6a52; border-color: #7a6a52; }
.btn.peligro { color: #a33b2a; }
.btn[disabled] { opacity: 0.45; cursor: default; }

.btn-mini {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  border: 1px solid rgba(0,0,0,0.22); background: rgba(255,255,255,0.45);
  color: inherit; font-size: 13px; padding: 6px 11px; border-radius: 5px;
  margin-left: 6px; font-family: inherit;
}
body.tema-oscuro .btn-mini { border-color: rgba(255,255,255,0.20); background: rgba(255,255,255,0.07); }
.btn-mini.activo { background: #6b4f2a; border-color: #6b4f2a; color: #fff; }

.progreso {
  height: 5px; background: rgba(0,0,0,0.13); border-radius: 3px; overflow: hidden;
  margin: 4px 0 10px 0;
}
.progreso div { height: 100%; width: 0; background: #6b4f2a; }

.indice { padding: 0 16px 28px 16px; }
.indice h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.8px; opacity: 0.6; }
.indice ol { margin: 0; padding-left: 22px; }
.indice li { padding: 7px 0; font-size: 14px; cursor: pointer; line-height: 1.35; }
.indice li:active { opacity: 0.5; }

/* Ficha de cómic: la portada es la protagonista, no una lista de números. */
#ficha.es-comic .ficha-portada { width: 260px; min-width: 260px; }
#ficha.es-comic .ficha-datos h2 { font-size: 24px; }
@media (max-width: 560px) {
  #ficha.es-comic .ficha-portada { width: 140px; min-width: 140px; }
  #ficha.es-comic .ficha-datos h2 { font-size: 19px; }
}

.saltar {
  display: -webkit-box; display: -webkit-flex; display: flex;
  -webkit-box-align: center; -webkit-align-items: center; align-items: center;
  padding: 4px 16px 30px 16px; font-size: 14px;
}
.saltar label { opacity: 0.75; margin-right: 10px; }
.saltar input {
  -webkit-appearance: none; appearance: none; width: 74px; font-size: 15px;
  padding: 7px 9px; border-radius: 6px; font-family: inherit; color: inherit;
  border: 1px solid rgba(0,0,0,0.25); background: rgba(255,255,255,0.55);
}
body.tema-oscuro .saltar input {
  border-color: rgba(255,255,255,0.22); background: rgba(255,255,255,0.08);
}
.saltar-total { margin: 0 4px 0 8px; opacity: 0.65; }

.aviso {
  margin: 12px 16px; padding: 10px 12px; border-radius: 6px; font-size: 13px;
  background: rgba(190,120,60,0.16); border: 1px solid rgba(190,120,60,0.35);
}
.vacio { padding: 40px 28px; text-align: center; opacity: 0.75; line-height: 1.6; }
.vacio-titulo { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.vacio code { background: rgba(0,0,0,0.10); padding: 2px 5px; border-radius: 3px; }
.pie { padding: 0 16px 24px 16px; font-size: 11px; opacity: 0.55; text-align: center; }

/* Indicador de descargas: fijo y por encima de todo, porque la gracia es
   justamente poder irse a otra pantalla mientras baja. */
.descargas {
  position: fixed; left: 50%; bottom: 18px; z-index: 60;
  -webkit-transform: translateX(-50%); transform: translateX(-50%);
  width: 90%; max-width: 420px;
  background: rgba(20,18,16,0.94); color: #f0ece6;
  border-radius: 12px; padding: 9px 12px 10px 12px;
  -webkit-box-shadow: 0 6px 22px rgba(0,0,0,0.45); box-shadow: 0 6px 22px rgba(0,0,0,0.45);
}
.descargas-fila {
  display: -webkit-box; display: -webkit-flex; display: flex;
  -webkit-box-align: center; -webkit-align-items: center; align-items: center;
}
.descargas-flecha { font-size: 15px; opacity: 0.8; margin-right: 8px; }
.descargas-texto {
  -webkit-box-flex: 1; -webkit-flex: 1; flex: 1; font-size: 13px;
  white-space: nowrap; overflow: hidden; -o-text-overflow: ellipsis; text-overflow: ellipsis;
}
.descargas-cancelar {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.08);
  color: #f0ece6; font-size: 11px; padding: 4px 10px; border-radius: 5px;
  margin-left: 10px; font-family: inherit;
}
.descargas-barra {
  height: 3px; background: rgba(255,255,255,0.16); border-radius: 2px;
  margin-top: 7px; overflow: hidden;
}
.descargas-barra div {
  height: 100%; width: 0; background: #c9a86b;
  -webkit-transition: width 250ms ease-out; transition: width 250ms ease-out;
}

.insignia.bajando { background: rgba(160,110,40,0.95); }
.insignia.espera  { background: rgba(70,70,76,0.90); }

#bajarSerie { margin-left: auto; }

/* ---------- LECTOR ---------- */
.lector { background: inherit; }
.libro-marco {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  -webkit-perspective: 1600px; perspective: 1600px;
  overflow: hidden;
}
.visor {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
}
/* Capa de zoom: se escala y se arrastra sin tocar la paginación. */
.zoom {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  -webkit-transform-origin: 0 0; transform-origin: 0 0;
  -webkit-transform: translate3d(0,0,0); transform: translate3d(0,0,0);
}
.zoom.suave {
  -webkit-transition: -webkit-transform 200ms ease-out;
  transition: transform 200ms ease-out;
}

/* Aviso del nivel de zoom, para saber que está ampliado y cómo volver. */
.nivel-zoom {
  position: absolute; top: 12px; left: 50%; z-index: 26;
  -webkit-transform: translateX(-50%); transform: translateX(-50%);
  background: rgba(20,18,16,0.82); color: #f0ece6;
  padding: 5px 12px; border-radius: 14px; font-size: 12px;
  -webkit-transition: opacity 300ms ease; transition: opacity 300ms ease;
}
.nivel-zoom.yendose { opacity: 0; }

/* La hoja de papel donde vive el texto */
.paginas {
  position: absolute; top: 0; left: 0;
  -webkit-column-gap: 0; column-gap: 0;
  -webkit-column-fill: auto; column-fill: auto;
  font-family: Georgia, "Times New Roman", serif;
  -webkit-transform: translate3d(0,0,0); transform: translate3d(0,0,0);
}
.paginas.animada {
  -webkit-transition: -webkit-transform 260ms ease-out;
  transition: transform 260ms ease-out;
}
body.tema-sepia  .visor { background: #f4ecd8; }
body.tema-claro  .visor { background: #ffffff; }
body.tema-oscuro .visor { background: #1c1b1f; }

/* Tipografía del contenido del libro */
.paginas p { margin: 0 0 0.85em 0; text-align: justify; -webkit-hyphens: auto; hyphens: auto; }
.paginas h1, .paginas h2, .paginas h3, .paginas h4 {
  font-weight: 600; line-height: 1.25; margin: 0 0 0.6em 0;
  -webkit-column-break-after: avoid; break-after: avoid;
}
.paginas h1 { font-size: 1.5em; }
.paginas h2 { font-size: 1.3em; }
.paginas h3 { font-size: 1.12em; }
.paginas img {
  max-width: 100%; height: auto; display: block; margin: 0.8em auto;
}
.paginas a { color: inherit; text-decoration: underline; }

/* Página de cómic: ocupa toda la hoja, centrada y sin márgenes de texto. */
.paginas .comic-pagina {
  display: -webkit-box; display: -webkit-flex; display: flex;
  -webkit-box-align: center; -webkit-align-items: center; align-items: center;
  -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center;
  width: 100%; overflow: hidden;
}
.paginas .comic-pagina img {
  max-width: 100%; width: auto; height: auto; margin: 0; display: block;
  -webkit-box-shadow: 0 2px 12px rgba(0,0,0,0.35); box-shadow: 0 2px 12px rgba(0,0,0,0.35);
}
/* En cómic el fondo va oscuro siempre: resalta la página y no encandila. */
.lector.comic .visor { background: #14131a; }
.paginas blockquote { margin: 0 0 0.9em 1.2em; font-style: italic; opacity: 0.9; }
.paginas hr { border: 0; border-top: 1px solid rgba(0,0,0,0.2); margin: 1.2em 0; }
body.tema-oscuro .paginas hr { border-top-color: rgba(255,255,255,0.18); }

/* La hoja que gira al pasar de página */
/* Cubre la página entera y gira sobre el lomo (borde izquierdo). */
.hoja {
  position: absolute; top: 0; bottom: 0; left: 0; width: 100%;
  display: none;
  -webkit-transform-origin: left center; transform-origin: left center;
  -webkit-transform-style: preserve-3d; transform-style: preserve-3d;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
  z-index: 5;
}
.hoja.visible { display: block; }
.hoja-cara {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
body.tema-sepia  .hoja-cara { background: -webkit-linear-gradient(left, #e7dcc2, #f6efdd); }
body.tema-claro  .hoja-cara { background: -webkit-linear-gradient(left, #eeeeee, #ffffff); }
body.tema-oscuro .hoja-cara { background: -webkit-linear-gradient(left, #131215, #201f24); }
.hoja-cara {
  -webkit-box-shadow: 0 0 22px rgba(0,0,0,0.35); box-shadow: 0 0 22px rgba(0,0,0,0.35);
}

/* zonas de toque */
.zona { position: absolute; top: 0; bottom: 0; z-index: 8; }
.zona-izq { left: 0; width: 30%; }
.zona-centro { left: 30%; width: 40%; }
.zona-der { right: 0; width: 30%; }

.cargando {
  position: absolute; top: 50%; left: 0; right: 0; margin-top: -12px;
  text-align: center; font-size: 13px; opacity: 0.6; z-index: 12;
}

.barra-lector {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 8px 10px 12px 10px;
  background: rgba(20,18,16,0.90); color: #f0ece6;
  -webkit-transform: translate3d(0,0,0); transform: translate3d(0,0,0);
}
.barra-lector.oculta { display: none; }
.barra-lector-fila {
  display: -webkit-box; display: -webkit-flex; display: flex;
  -webkit-box-align: center; -webkit-align-items: center; align-items: center;
  -webkit-justify-content: space-between; justify-content: space-between;
  padding: 3px 0;
}
.lector-titulo {
  font-size: 13px; opacity: 0.9; overflow: hidden; white-space: nowrap;
  -o-text-overflow: ellipsis; text-overflow: ellipsis; padding: 0 8px;
  -webkit-box-flex: 1; -webkit-flex: 1; flex: 1; text-align: center;
}
.progreso-texto { font-size: 12px; opacity: 0.75; }

/* Salida del lector: tiene que leerse como botón, no como un símbolo suelto. */
.btn-salir {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.28); background: rgba(255,255,255,0.10);
  color: #f0ece6; font-size: 13px; padding: 7px 13px; border-radius: 6px;
  font-family: inherit; white-space: nowrap;
}
.btn-salir:active { opacity: 0.6; }

/* Salida siempre a la vista: discreta, pero nunca hay que adivinar cómo volver. */
.salida-fija {
  position: absolute; top: 8px; left: 8px; z-index: 25;
  -webkit-appearance: none; appearance: none; cursor: pointer;
  width: 38px; height: 38px; padding: 0; line-height: 34px; text-align: center;
  border: 0; border-radius: 19px; font-size: 22px; font-family: inherit;
  background: rgba(20,18,16,0.30); color: rgba(255,255,255,0.92);
}
.salida-fija:active { background: rgba(20,18,16,0.60); }
body.tema-claro .salida-fija, body.tema-sepia .salida-fija {
  background: rgba(30,26,20,0.22); color: rgba(255,255,255,0.95);
}

/* Barra de avance del libro: fina, al pie, y se puede tocar para saltar. */
.avance {
  position: absolute; left: 0; right: 0; bottom: 0; height: 14px; z-index: 24;
  cursor: pointer;
}
.avance:before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: rgba(0,0,0,0.16);
}
body.tema-oscuro .avance:before { background: rgba(255,255,255,0.14); }
.lector.comic .avance:before { background: rgba(255,255,255,0.16); }
.avance-relleno {
  position: absolute; left: 0; bottom: 0; height: 3px; width: 0;
  background: #6b4f2a;
  -webkit-transition: width 220ms ease-out; transition: width 220ms ease-out;
}
body.tema-oscuro .avance-relleno, .lector.comic .avance-relleno { background: #b99a6a; }

/* Pista de la primera vez: sin esto nadie adivina que hay controles escondidos. */
.pista {
  position: absolute; left: 50%; bottom: 96px; z-index: 30;
  -webkit-transform: translateX(-50%); transform: translateX(-50%);
  background: rgba(20,18,16,0.92); color: #f0ece6;
  padding: 11px 17px; border-radius: 22px; font-size: 13px; line-height: 1.4;
  max-width: 88%; text-align: center;
  -webkit-transition: opacity 400ms ease; transition: opacity 400ms ease;
}
.pista.yendose { opacity: 0; }
.barra-lector .btn-icono { color: #f0ece6; }
.barra-lector .btn-mini {
  color: #f0ece6; border-color: rgba(255,255,255,0.25); background: rgba(255,255,255,0.08);
}

.panel-ajustes {
  position: absolute; left: 0; right: 0; bottom: 74px; z-index: 21;
  background: rgba(20,18,16,0.95); color: #f0ece6; padding: 10px 14px 14px 14px;
}
.ajuste {
  display: -webkit-box; display: -webkit-flex; display: flex;
  -webkit-box-align: center; -webkit-align-items: center; align-items: center;
  -webkit-justify-content: space-between; justify-content: space-between;
  padding: 7px 0; font-size: 14px;
}
.panel-ajustes .btn-mini {
  color: #f0ece6; border-color: rgba(255,255,255,0.25); background: rgba(255,255,255,0.08);
}
.ajuste-nota { font-size: 11px; opacity: 0.6; margin: 6px 0 0 0; line-height: 1.4; }

/* columnas del estante según el ancho real de la pantalla.
   El iPad mini 1 da 768 de ancho en vertical y 1024 en horizontal. */
@media (max-width: 500px)  { .tarjeta { width: 50%; }
                             .ficha-portada { width: 104px; min-width: 104px; } }
@media (min-width: 501px) and (max-width: 820px) { .tarjeta { width: 33.33%; } }
@media (min-width: 821px)  { .tarjeta { width: 25%; } }
