/* Variables globales de pyShelf (Sobreescriben el tema oscuro de Pico CSS) */
html[data-theme="dark"] {
  --pico-background-color: #1A1615;
  --pico-card-background-color: #2E1E1E; /* Rojo desaturado oscuro y cálido */
  --pico-border-color: #4A3234;           /* Borde sutil con matiz rojizo */
  --pico-color: #F8F5F0;                  /* Texto principal: Blanco crema de alto contraste */
  --pico-muted-color: #C2B2A8;            /* Texto secundario/moteado legible */
  --pico-primary: #6B1D24;
  --pico-primary-background: #6B1D24;
  --pico-primary-border: #6B1D24;
  --pico-primary-underline: rgba(200, 138, 88, 0.5);
  --pico-primary-hover: #8C2E35;
  --pico-primary-hover-background: #8C2E35;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--pico-background-color);
  color: var(--pico-color);
}

/* Barra de navegación */
header.navbar {
  background-color: var(--pico-card-background-color);
  border-bottom: 1px solid var(--pico-border-color);
  padding: 0.75rem 1.5rem;
  margin-bottom: 1rem;
}

header.navbar nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

header.navbar form {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 0.5rem !important;
  margin: 0 !important;
}

header.navbar form select,
header.navbar form input,
header.navbar form button {
  width: auto !important;
  margin: 0 !important;
  height: 2.3rem !important;
  padding: 0 0.75rem !important;
  font-size: 0.85rem !important;
}

/* Cuadrícula principal de libros */
#book-shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.25rem;
  padding: 1.5rem 0;
  width: 100%;
}

/* Tarjetas de libros */
.book-card,
a.book {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 0.75rem;
  background-color: var(--pico-card-background-color);
  border: 1px solid var(--pico-border-color);
  border-radius: 8px;
  text-decoration: none !important;
  color: var(--pico-color) !important; /* Previene color azul/morado de enlace */
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

/* Hover con resplandor sutil */
#book-shelf .book-card:hover,
a.book:hover {
  transform: translateY(-4px);
  background-color: #382425;
  border-color: var(--pico-primary);
  box-shadow: 0 10px 20px -3px rgba(0, 0, 0, 0.6), 0 0 12px rgba(107, 29, 36, 0.4);
  color: #FFFFFF !important;
}

/* Miniaturas con relación de aspecto 2:3 */
.book-thumbnail {
  width: 100%;
  aspect-ratio: 2 / 3;
  margin: 0;
  overflow: hidden;
  border-radius: 4px;
  background-color: rgba(0, 0, 0, 0.2);
}

.book-thumbnail figure {
  width: 100%;
  height: 100%;
  margin: 0;
}

.book-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 4px;
}

/* Título de la tarjeta (Catálogo) */
.book-title-sub {
  width: 100%;
  margin-top: 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #F8F5F0 !important; /* Blanco Crema de alto contraste */
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* Excepción: Tarjeta destacada (Documento del día) */
div > .book-card {
  max-width: 100%;
  height: auto;
  padding: 1.5rem;
  align-items: stretch;
  color: var(--pico-color);
}

div > .book-card h1,
div > .book-card h2,
div > .book-card h3,
div > .book-card h4 {
  color: #F8F5F0 !important;
}

div > .book-card p,
div > .book-card span,
div > .book-card small {
  color: var(--pico-muted-color);
}

div > .book-card:hover {
  transform: none;
  border-color: var(--pico-border-color);
  box-shadow: none;
  background-color: var(--pico-card-background-color);
}

/* Marcos por colección */
#master-container {
  border-top: none !important;
}

#master-container.collection-frame {
  border-top: 4px solid #3b82f6 !important;
  border-radius: 4px !important;
}

#master-container.collection-Articulos,
#master-container.collection-articulos,
#master-container.collection-Libros,
#master-container.collection-libros {
  border-top-color: #C88A58 !important;
}

/* Modal Terminal About */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.about-terminal-box {
  background-color: var(--pico-background-color);
  border: 1px solid var(--pico-border-color);
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  font-family: monospace;
}

.about-terminal-header {
  background-color: #1e293b;
  padding: 10px 15px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #334155;
}

.terminal-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}
.terminal-dot.red { background-color: #ef4444; }
.terminal-dot.yellow { background-color: #f59e0b; }
.terminal-dot.green { background-color: #10b981; }

.terminal-title {
  color: #94a3b8;
  font-size: 0.85rem;
  margin-left: 10px;
  flex-grow: 1;
}

.modal-close-btn {
  color: #94a3b8;
  font-size: 1.5rem;
  text-decoration: none;
}
.modal-close-btn:hover { color: #fff; }

.about-terminal-body {
  padding: 20px;
  color: #38bdf8;
}

.plain-text-credits {
  background: transparent;
  color: #cbd5e1;
  font-size: 0.9rem;
  white-space: pre-wrap;
}

.txt-header { color: #f43f5e; font-weight: bold; }
.txt-label { color: #94a3b8; }
.txt-highlight { color: #38bdf8; }
.txt-link { color: #a855f7; }
.txt-ai { color: #10b981; }
.txt-github { color: #e2e8f0; }
.txt-user { color: #38bdf8; text-decoration: underline; }

/* Pie de página */
footer {
  background-color: var(--pico-background-color);
  border-top: 1px solid var(--pico-border-color);
  padding: 1rem;
  margin-top: auto;
  text-align: center;
  font-size: 0.85rem;
  color: var(--pico-muted-color);
}

/* Paginación */
.pagination-container {
  display: flex;
  justify-content: center;
  margin: 2rem 0;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.pagination-controls a[role="button"],
.pagination-controls button {
  width: auto;
  margin: 0;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
}

.pagination-status {
  font-weight: bold;
  color: var(--pico-muted-color);
}



/* Tarjeta destacada responsiva */
.featured-container {
  max-width: 650px;
  margin: 0 auto 2.5rem auto;
}

.featured-card {
  margin-bottom: 0;
  padding: 1.25rem;
  border-top: none;
}

.featured-grid {
  display: grid;
  grid-template-columns: 1fr; /* Columna única por defecto en móvil */
  gap: 1.25rem;
  align-items: center;
}

@media (min-width: 576px) {
  .featured-grid {
    grid-template-columns: 200px 1fr; /* En pantallas medianas en adelante pasa a 2 columnas */
  }
}

.featured-cover-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.featured-cover {
  max-width: 100%;
  height: 200px;
  object-fit: contain;
  border-radius: 6px;
}

.featured-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  text-align: left;
}

.featured-title {
  margin-bottom: 0.3rem;
  font-size: 1.1rem;
  line-height: 1.3;
}

.featured-author {
  font-size: 0.85rem;
  color: var(--pico-muted-color);
  margin-bottom: 0;
}

.featured-btn {
  width: fit-content;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
}

/* Filtros y Búsqueda */
.filter-bar {
  max-width: 400px;
  margin: 0 auto 2rem auto;
}

.search-indicator {
  margin: 0 0 1.5rem 0.5rem;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--pico-primary-hover);
}

.book-link {
  text-decoration: none;
  color: inherit;
  width: 100%;
}

.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 0;
  color: var(--pico-muted-color);
}

/* ============================================================
   Tarjeta con imagen a sangre y overlay en hover
   ============================================================ */

.book-card {
  position: relative;
  padding: 0 !important;
  overflow: hidden;
  border-radius: 8px;
  background-color: var(--pico-card-background-color);
  border: 1px solid var(--pico-border-color);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.book-card:hover {
  transform: translateY(-4px);
  border-color: var(--pico-primary);
  box-shadow: 0 10px 20px -3px rgba(0, 0, 0, 0.6), 0 0 12px rgba(107, 29, 36, 0.4);
}

.book-link {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

.book-thumbnail {
  width: 100%;
  aspect-ratio: 2 / 3;
  margin: 0;
  overflow: hidden;
  border-radius: 0;
  background-color: rgba(0, 0, 0, 0.2);
}

.book-thumbnail figure {
  width: 100%;
  height: 100%;
  margin: 0;
}

.book-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

/* Overlay en hover */
.book-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.95) 0%,
    rgba(0, 0, 0, 0.8) 45%,
    rgba(0, 0, 0, 0) 100%
  );
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1rem 0.75rem;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  color: #F8F5F0;
}

.book-card:hover .book-overlay {
  opacity: 1;
}

.book-overlay-title {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.35rem 0;
  color: #F8F5F0;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-overlay-author {
  font-size: 0.75rem;
  color: #C2B2A8;
  margin: 0 0 0.25rem 0;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-overlay-category {
  font-size: 0.7rem;
  color: #C88A58;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
