/* ═══════════════════════════════════════════════════════════════
   Juan Moisés de la Serna — Catálogo Académico
   Diseño: editorial refinado, tipografía académica con carácter
   ═══════════════════════════════════════════════════════════════ */

:root {
  --color-ink:        #1a1a2e;
  --color-ink-soft:   #3d3d5c;
  --color-accent:     #c0392b;
  --color-accent-2:   #2980b9;
  --color-surface:    #fafaf8;
  --color-card:       #ffffff;
  --color-border:     #e8e4dc;
  --color-muted:      #8a8578;
  --color-oa:         #27ae60;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Source Serif 4', Georgia, serif;
  --font-mono:    'JetBrains Mono', monospace;

  --radius: 4px;
  --shadow-card: 0 2px 12px rgba(26,26,46,0.08);
  --shadow-hover: 0 6px 24px rgba(26,26,46,0.14);
  --transition: 0.2s ease;

  --max-width: 1100px;
  --content-width: 720px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--color-ink);
  background: var(--color-surface);
}

a { color: var(--color-accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ── HEADER ──────────────────────────────────────────────────── */
.site-header {
  background: var(--color-ink);
  color: white;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 3px solid var(--color-accent);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  color: white;
  text-decoration: none;
}

.logo-initials {
  width: 40px;
  height: 40px;
  background: var(--color-accent);
  color: white;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  flex-shrink: 0;
}

.logo-text strong {
  display: block;
  font-family: var(--font-display);
  font-size: 0.95rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.logo-text span {
  display: block;
  font-size: 0.72rem;
  opacity: 0.65;
  font-style: italic;
}

.site-nav { display: flex; gap: 24px; }
.site-nav a {
  color: rgba(255,255,255,0.8);
  font-size: 0.88rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  transition: color var(--transition);
}
.site-nav a:hover { color: white; text-decoration: none; }

/* ── HERO / INDEX ────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--color-ink) 0%, #2c2c54 100%);
  color: white;
  padding: 80px 0 60px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 900;
  line-height: 1.15;
  position: relative;
}

.hero .hero-sub {
  font-size: 1.1rem;
  opacity: 0.75;
  margin-top: 12px;
  font-style: italic;
  position: relative;
}

.hero .hero-stats {
  display: flex;
  gap: 40px;
  justify-content: center;
  margin-top: 40px;
  position: relative;
}

.stat-item { text-align: center; }
.stat-item strong {
  display: block;
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--color-accent);
  line-height: 1;
}
.stat-item span { font-size: 0.82rem; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── FILTROS ─────────────────────────────────────────────────── */
.filters-bar {
  background: white;
  border-bottom: 1px solid var(--color-border);
  padding: 16px 0;
  position: sticky;
  top: 64px;
  z-index: 50;
}

.filters-bar .container {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 16px;
  border: 1px solid var(--color-border);
  background: white;
  border-radius: 20px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--color-ink-soft);
}

.filter-btn:hover,
.filter-btn.active {
  background: var(--color-ink);
  color: white;
  border-color: var(--color-ink);
}

.search-input {
  margin-left: auto;
  padding: 6px 16px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  width: 220px;
  outline: none;
  transition: border-color var(--transition);
}
.search-input:focus { border-color: var(--color-accent-2); }

/* ── GRID DE LIBROS ──────────────────────────────────────────── */
.books-section { padding: 48px 0; }

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  margin-top: 32px;
}

.book-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.book-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--color-accent);
  transform: scaleY(0);
  transition: transform var(--transition);
  transform-origin: bottom;
}

.book-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}
.book-card:hover::before { transform: scaleY(1); }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 8px;
}

.card-year {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-muted);
  letter-spacing: 0.05em;
}

.card-badges { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-oa { background: #d5f5e3; color: #1e8449; }
.badge-private { background: #fdebd0; color: #935116; }
.badge-lang { background: #eaf2ff; color: #154360; }

.card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--color-ink);
  margin-bottom: 10px;
  flex: 1;
}

.card-title a {
  color: inherit;
  text-decoration: none;
}
.card-title a:hover { color: var(--color-accent); }

.card-authors {
  font-size: 0.82rem;
  color: var(--color-muted);
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
  font-style: italic;
}

/* ── PÁGINA DE LIBRO ─────────────────────────────────────────── */
.book-page { padding: 40px 0 80px; }

.breadcrumb {
  font-size: 0.82rem;
  color: var(--color-muted);
  margin-bottom: 32px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--color-accent-2); }

.book-header { margin-bottom: 32px; }

.book-meta-top {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.book-year {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-muted);
  background: #f0ede8;
  padding: 2px 10px;
  border-radius: 3px;
}

.lang-es { background: #fde8e8; color: #922b21; }
.lang-en { background: #e8f4fd; color: #1a5276; }
.lang-fr { background: #eaf5fb; color: #117a65; }
.lang-de { background: #fef9e7; color: #7d6608; }
.lang-it { background: #fdf2f8; color: #76448a; }
.lang-pt { background: #e9f7ef; color: #1e8449; }
.lang-ar { background: #fef5e7; color: #935116; }
.lang-ro { background: #fde8e8; color: #7b241c; }
.lang-id { background: #e8f6f3; color: #0e6655; }

.book-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 900;
  line-height: 1.2;
  color: var(--color-ink);
  margin-bottom: 16px;
}

.book-authors {
  font-size: 1rem;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.author-main { color: var(--color-accent); font-weight: 600; }
.author-co { color: var(--color-ink-soft); }
.author-sep { color: var(--color-border); }

.book-date { font-size: 0.88rem; color: var(--color-muted); font-style: italic; }

/* ── ACCIONES ────────────────────────────────────────────────── */
.book-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 28px 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 22px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: 2px solid transparent;
  text-decoration: none;
}

.btn-primary { background: var(--color-accent); color: white; }
.btn-primary:hover { background: #a93226; color: white; text-decoration: none; }

.btn-secondary { background: var(--color-accent-2); color: white; }
.btn-secondary:hover { background: #1a6fa3; color: white; text-decoration: none; }

.btn-outline {
  background: transparent;
  color: var(--color-ink);
  border-color: var(--color-border);
}
.btn-outline:hover {
  border-color: var(--color-ink);
  text-decoration: none;
}

/* ── CITA ────────────────────────────────────────────────────── */
.citation-box {
  background: #f5f3ef;
  border-left: 4px solid var(--color-accent);
  padding: 16px 20px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 24px 0;
}

.citation-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  margin-bottom: 6px;
  font-family: var(--font-mono);
}

.citation-text {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--color-ink-soft);
  font-style: italic;
}

/* ── CAPÍTULOS ───────────────────────────────────────────────── */
.chapters-section { margin-top: 48px; }
.chapters-section h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--color-border);
}

.chapters-list {
  list-style: none;
  counter-reset: chapters;
}

.chapter-item {
  counter-increment: chapters;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.chapter-item::before {
  content: counter(chapters, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--color-muted);
  flex-shrink: 0;
  min-width: 28px;
}

.chapter-link {
  color: var(--color-ink);
  font-size: 0.97rem;
  flex: 1;
}
.chapter-link:hover { color: var(--color-accent); }
.chapter-date { font-size: 0.8rem; color: var(--color-muted); font-style: italic; }

.chapters-placeholder {
  color: var(--color-muted);
  font-style: italic;
  padding: 20px 0;
}

/* ── EDICIONES ───────────────────────────────────────────────── */
.editions-section { margin-top: 40px; }
.editions-section h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.editions-list { list-style: none; }
.edition-item {
  display: flex;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--color-border);
  font-size: 0.9rem;
}
.edition-year {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--color-accent);
  min-width: 48px;
}

/* ── RELACIONADOS ────────────────────────────────────────────── */
.related-section { margin-top: 48px; padding-top: 32px; border-top: 2px solid var(--color-border); }
.related-section h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 16px;
}

/* ── CAPÍTULO PAGE ───────────────────────────────────────────── */
.chapter-page { padding: 40px 0 80px; }
.chapter-header { margin-bottom: 28px; }
.chapter-book-ref { font-size: 0.85rem; color: var(--color-muted); margin-bottom: 10px; }
.chapter-book-ref a { color: var(--color-accent-2); }
.chapter-title {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  font-weight: 900;
  line-height: 1.25;
  margin-bottom: 10px;
}
.chapter-meta { font-size: 0.85rem; color: var(--color-muted); }
.chapter-content { max-width: var(--content-width); margin-top: 32px; }
.chapter-content h2 { font-family: var(--font-display); margin: 32px 0 12px; }
.chapter-content p { margin-bottom: 1.2em; }

.versions-section { margin-top: 40px; }
.versions-section h3 { font-family: var(--font-display); font-size: 1rem; margin-bottom: 12px; }
.versions-list { list-style: none; }
.version-year { font-family: var(--font-mono); font-size: 0.82rem; color: var(--color-accent); margin-right: 12px; }

/* ── FOOTER ──────────────────────────────────────────────────── */
.site-footer {
  background: var(--color-ink);
  color: rgba(255,255,255,0.6);
  padding: 32px 0;
  margin-top: 80px;
  font-size: 0.85rem;
  text-align: center;
  line-height: 2;
}
.site-footer a { color: rgba(255,255,255,0.8); }
.site-footer a:hover { color: white; }
.footer-note { font-size: 0.75rem; opacity: 0.5; margin-top: 4px; }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .site-header .container { height: auto; padding: 12px 16px; flex-direction: column; gap: 10px; }
  .hero .hero-stats { gap: 24px; flex-wrap: wrap; }
  .books-grid { grid-template-columns: 1fr; }
  .book-actions { flex-direction: column; }
  .filters-bar { top: auto; position: static; }
  .logo-text span { display: none; }
}

/* ── ANIMACIONES ─────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.book-card {
  animation: fadeUp 0.4s ease both;
}

.book-card:nth-child(1)  { animation-delay: 0.02s; }
.book-card:nth-child(2)  { animation-delay: 0.04s; }
.book-card:nth-child(3)  { animation-delay: 0.06s; }
.book-card:nth-child(4)  { animation-delay: 0.08s; }
.book-card:nth-child(5)  { animation-delay: 0.10s; }
.book-card:nth-child(6)  { animation-delay: 0.12s; }
