/* Comxow/COMXOW, creada por A. Gavina Costero  2026, albertobicho@gmail.com */
/*
 * Librerías y código de terceros utilizados en este proyecto:
 *
 * - omggif (GIF encoder/decoder)
 *     Autor: Dean McNamee <dean@gmail.com>
 *     Licencia: MIT
 *     https://github.com/deanm/omggif
 *
 * - pako (compresión zlib/gzip)
 *     Autores: Andrei Tuputcyn, Vitaly Puzrin y colaboradores (Nodeca project)
 *     Licencia: MIT
 *     https://github.com/nodeca/pako
 *
 * - UPNG.js (codificador/decodificador PNG)
 *     Autor: Ivan Kutskir
 *     Licencia: MIT
 *     https://github.com/photopea/UPNG.js
 *
 * - LZW decompression (puerto JavaScript de implementación Java)
 *     Referencia original: https://gist.github.com/devunwired/4479231
 *     Licencia: dominio público / uso libre
 *
 * - Trix (editor de texto enriquecido)
 *     Autor: 37signals, LLC (Basecamp) — Javan Makhmali y Sam Stephenson
 *     Licencia: MIT
 *     https://trix-editor.org/  ·  https://github.com/basecamp/trix
 */
/* ============================================================
   home.css — Página de inicio
   ============================================================ */

/* ── VARIABLES DE ALTURA DE BARRAS ── */
:root {
  --header-h:  68px;   /* barra 1: logo/usuario (auto height, aprox) */
  --pagenav-h: 44px;   /* barra 2: menú de página */
  --bars-h: calc(var(--header-h) + var(--pagenav-h));
}

/* ── BARRA 1: cabecera global (posicionada en main.css) ── */
/* ya es sticky — aquí solo ajustamos altura */
.home-header { height: auto; }  /* altura libre, la mide adjustBars() */

/* ── BARRA 2: menú de página ── */
.page-nav {
  position: fixed;
  top: 0;  /* JS adjustBars() lo sobreescribe con el valor real */
  left: 0; right: 0;
  z-index: 900;
  height: var(--pagenav-h);
  display: flex;
  align-items: center;
  background: var(--white);
  border-bottom: 1.5px solid var(--gray-300);
  padding: 0 14px;
}
.page-nav::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: 100%;
  height: 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.22), transparent);
  pointer-events: none;
  z-index: 899;
}
.page-nav-sep {
  width: 1px; height: 18px;
  background: var(--gray-300); flex-shrink: 0;
}
.page-nav-item { flex: 1; display: flex; justify-content: center; }
.page-nav-btn {
  flex: 1;
  background: none; border: none;
  padding: 0 4px; height: var(--pagenav-h);
  font-family: var(--font-body);
  font-weight: 700; font-size: 0.88rem;
  color: var(--gray-500);
  cursor: pointer; text-align: center;
  position: relative; transition: color .15s;
  white-space: nowrap;
}
.page-nav-btn:hover  { color: var(--ink); }
.page-nav-btn.active { color: var(--ink); }
.page-nav-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 10%; right: 10%;
  height: 2.5px; background: var(--black); border-radius: 2px;
}
.page-nav-btn-create { color: var(--blue); }
.page-nav-btn-create:hover { color: var(--ink); }

/* Dropdown del menú de página */
.page-nav-dropdown {
  top: var(--pagenav-h) !important;
  left: 0 !important;
  min-width: 180px;
}
.coming-soon {
  font-size: 0.7rem; color: var(--gray-300);
  font-weight: 400; margin-left: 6px;
}

/* ── CONTENIDO SCROLLABLE ── */
/* Empuja el contenido para que no quede bajo las dos barras fijas */
.home-list {
  padding-top: var(--bars-h);  /* fallback CSS; router.js lo sobreescribe con valor real medido */
  max-width: var(--max-w);
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  min-height: 100vh;
  background: var(--paper);  /* fondo crema, no hereda el amarillo del body */
}

/* ── FILA DE CÓMIC ── */
.comic-row:first-child {
  border-top: 1px solid var(--gray-300);
}
.comic-row {
  display: flex; align-items: flex-start;
  gap: 12px; padding: 12px 14px;
  border-bottom: 1px solid var(--gray-300);
  background: var(--white);
  scroll-margin-top: var(--bars-h);
}
.comic-row-thumb {
  width: 72px; height: 72px; min-width: 72px;
  flex-shrink: 0; background: var(--gray-100);
  overflow: hidden; display: flex;
  align-items: center; justify-content: center;
  font-size: 1.8rem; color: var(--gray-300);
}
.comic-row-thumb img {
  width: 72px; height: 72px; min-width: 72px; max-width: 72px;
  object-fit: cover; display: block;
}
.comic-row-info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 3px; padding-top: 1px;
}
.comic-row-title {
  font-weight: 900; font-size: 0.95rem; color: var(--ink);
  line-height: 1.2; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.comic-row-author { font-size: 0.78rem; color: var(--gray-500); font-weight: 600; }
.comic-row-author a { color: var(--blue); font-weight: 700; }
.comic-row-actions { display: flex; gap: 14px; margin-top: 6px; flex-wrap: wrap; }
.comic-row-btn {
  background: none; border: none; padding: 0;
  font-family: var(--font-body); font-weight: 700;
  font-size: 0.82rem; color: var(--blue);
  cursor: pointer; text-decoration: none;
}
.comic-row-btn:hover { text-decoration: underline; }
.comic-row-btn.edit  { color: var(--gray-700); }
.comic-row-btn.unpub { color: var(--gray-500); }
.comic-row-btn.del   { color: var(--red); }

/* ── VACÍO ── */
.home-empty {
  text-align: center; padding: 60px 20px;
  color: var(--gray-500); font-size: 0.95rem; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.home-empty span { font-size: 3rem; }
.home-empty.hidden { display: none !important; }

@media(min-width: 600px) {
  .page-nav { padding: 0 24px; }
  .comic-row { padding: 14px 24px; gap: 16px; }
  .comic-row-thumb     { width: 88px; height: 88px; min-width: 88px; }
  .comic-row-thumb img { width: 88px; height: 88px; min-width: 88px; max-width: 88px; }
  .comic-row-title { font-size: 1rem; }
}

/* ── BADGE DE GÉNERO ── */
.genre-badge {
  display: inline-block;
  font-size: 0.7rem; font-weight: 700;
  color: var(--gray-700);
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: 3px;
  padding: 1px 5px;
  vertical-align: middle;
}

/* ── ITEM ACTIVO EN FILTROS ── */
.dropdown-item.active {
  color: var(--ink);
  font-weight: 900;
}
.dropdown-item.active::before {
  content: '✓ ';
}

/* ── VERSIÓN ── */
.app-version {
  text-align: center;
  padding: 20px 0 32px;
  font-size: 0.7rem;
  color: var(--gray-300);
  font-weight: 600;
  letter-spacing: .05em;
  user-select: none;
}

/* ── MODAL MY-COMICS ── */
.mc-modal-overlay {
  /* Idéntico a .auth-main: fixed overlay z:2000 por encima de todo */
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0 16px 32px;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  overflow-y: auto;
  /* oculto por defecto */
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s;
}
.mc-modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

/* En pantallas altas centrar verticalmente como auth */
@media (min-height: 500px) {
  .mc-modal-overlay {
    align-items: center;
    padding: 16px;
  }
  .mc-modal-box {
    border-radius: 16px;
    border-top: 2.5px solid var(--black);
  }
}

.mc-modal-box {
  background: var(--white);
  border: 2.5px solid var(--black);
  border-top: none;
  border-radius: 0 0 16px 16px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 40px rgba(0,0,0,.25);
  flex-shrink: 0;
  animation: none;  /* se activa al abrir */
  padding-bottom: 24px;
}
.mc-modal-overlay.open .mc-modal-box {
  animation: authSlideDown .22s cubic-bezier(.4,0,.2,1) both;
}

.mc-modal-handle { display: none; }

/* Cabecera amarilla igual que auth-card-header */
.mc-modal-title {
  position: relative;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: 1px;
  color: var(--black);
  padding: 14px 20px 12px;
  background: linear-gradient(to right, var(--yellow) 33%, #fff8cc 50%, var(--yellow) 67%);
  border-bottom: 2.5px solid var(--black);
  border-radius: inherit;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  margin: 0;
}
.mc-modal-title-text { position: relative; z-index: 1; }
/* Franja blanca tras el título — mismo criterio que en el editor: desde el
   borde izquierdo de la ventana hasta el final del texto, semicírculo a la
   derecha. Tamaño real fijado por JS (_mcFitAllTitlePills). */
.win-title-pill {
  position: absolute;
  left: 0;
  background: var(--white);
  border-radius: 0 999px 999px 0;
  z-index: 0;
  pointer-events: none;
  width: 0;
}

.mc-field { margin: 0 20px 12px; }
.mc-field:first-of-type { margin-top: 18px; }
.mc-field label {
  display: block; font-size: 0.72rem; font-weight: 900;
  color: var(--gray-500); text-transform: uppercase;
  letter-spacing: .06em; margin-bottom: 5px;
}
.mc-field input,
.mc-field select {
  width: 100%;
  box-sizing: border-box;
  background: var(--gray-100);
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: var(--font-body); font-size: 0.95rem; font-weight: 600;
  color: var(--black); outline: none;
  transition: border-color .15s;
}
.mc-field input:focus,
.mc-field select:focus {
  border-color: var(--black);
  box-shadow: 2px 2px 0 var(--black);
}
.mc-field select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='%23333'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px;
}

.mc-modal-actions {
  display: flex; gap: 10px; margin: 18px 20px 0;
}
