@import url('fonts.css');

/* ─────────────────────────────────────────────────────────
   CLEMENZO — SISTEMA DE DISEÑO
   Dirección: Editorial + Documental mínimo
   ───────────────────────────────────────────────────────── */

/* ─── TOKENS ──────────────────────────────────────────── */
:root {
  --bg:        #f6f6f4;
  --surface:   #ffffff;
  --border:    #e8e8e6;
  --text:      #1a1a1a;
  --muted:     #5a5040;
  --accent:    #2d4a3e;
  --on-accent: #cad7d0;
  --sidebar-w: 200px;
  --nav-h:     52px;
  color-scheme: light;
}

/* ─── MODO OSCURO · paleta «Pizarra neutra» ───────────── */
[data-theme="dark"] {
  --bg:        #16181a;
  --surface:   #1f2225;
  --border:    #33373b;
  --text:      #e8eaec;
  --muted:     #9aa3a8;
  --accent:    #5fb389;
  --on-accent: #0f1f17;
  color-scheme: dark;
}

/* Resaltado (==texto==) legible en oscuro */
html[data-theme="dark"] mark {
  background: #4a4424;
  color: #f1e9c8;
}

/* Botón de cambio de tema (sol/luna) en el nav */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 7px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.theme-toggle:hover { color: var(--text); background: rgba(127, 127, 127, 0.12); }
.theme-toggle svg { width: 18px; height: 18px; }

/* ─── SKIP LINK + SR-ONLY ─────────────────────────────── */
.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  padding: 8px 16px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  z-index: 10000;
  transform: translateY(-100%);
  /* opacity:0 cuando no tiene foco → no aparece como rectángulo al hacer overscroll
     (rubber-band) por encima del origen del documento. */
  opacity: 0;
  pointer-events: none;
  transition: transform 0.15s, opacity 0.15s;
}
.skip-link:focus {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─── RESET ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

/* ─── BASE ────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
}

/* ─── SITE NAV ────────────────────────────────────────── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.nav-brand {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s;
}

.nav-brand:hover { color: var(--accent); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.nav-link:hover { color: var(--text); }

.nav-mobile-link { display: none; }

/* ─── SITE LAYOUT ─────────────────────────────────────── */
.site-body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ─── SIDEBAR ─────────────────────────────────────────── */
.site-sidebar {
  height: 100%;
  overflow-y: auto;
  padding: 40px 0 20px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0 16px;
  gap: 3px;
  flex: 1;
}

.sidebar-bottom {
  padding: 12px 16px 0;
  margin-top: 16px;
}

/* Links de la sidebar: ícono Material Symbols + etiqueta en mayúsculas.
   El ítem activo es una píldora verde (acento) con texto e ícono claros. */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 13px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #45544c;
  text-decoration: none;
  padding: 11px 14px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
  line-height: 1.25;
  min-height: 44px; /* evita CLS: JS defer inyecta íconos de 22px después del primer paint */
}

/* Ícono: oculto hasta que la fuente Material Symbols esté lista (evita el
   flash del texto de la ligadura). Dimensiones fijas para no saltar. */
.sidebar-icon {
  font-size: 20px;
  line-height: 1;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  visibility: hidden;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'opsz' 24;
}

html.ms-ready .sidebar-icon { visibility: visible; }

.sidebar-link:hover {
  color: var(--text);
  background: rgba(45, 74, 62, 0.07);
}

.sidebar-link.is-active,
.sidebar-link.is-active:hover {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

.sidebar-link.is-active .sidebar-icon { color: var(--on-accent); }

/* El color base del sidebar está pensado para fondo claro; en oscuro
   necesita aclararse para tener contraste suficiente. */
[data-theme="dark"] .sidebar-link { color: #aeb6bc; }
[data-theme="dark"] .sidebar-link--minor { color: #8b939a; }

/* El ítem activo conserva el texto oscuro sobre la píldora verde. */
[data-theme="dark"] .sidebar-link.is-active,
[data-theme="dark"] .sidebar-link.is-active:hover { color: var(--on-accent); }
[data-theme="dark"] .sidebar-link.is-active .sidebar-icon { color: var(--on-accent); }

/* Cambios — secundario, al pie */
.sidebar-link--minor {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
}

.sidebar-link--minor:hover {
  color: var(--text);
  background: rgba(45, 74, 62, 0.07);
}

/* ─── MAIN CONTENT ────────────────────────────────────── */
.site-main {
  min-width: 0;
  max-width: 100%;
  background: var(--surface);
  padding: 48px 56px 80px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ─── FOOTER ──────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  min-height: 52px;
}

.footer-desc {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
}

.footer-mobile-nav {
  display: none;
  align-items: center;
  gap: 20px;
}

.footer-nav-link {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-nav-link:hover { color: var(--text); }

.footer-changelog-link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-changelog-link:hover { color: var(--text); }

/* ─── HOME DOCUMENT ───────────────────────────────────── */
.home-doc {
  max-width: 900px;
  margin: 0 auto;
}

.home-doc-header {
  margin-bottom: 40px;
}

.home-doc-title {
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
  margin: 0 0 10px;
}

.home-doc-tagline {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 17px;
  color: var(--text);
  margin: 0;
  line-height: 1.75;
  text-align: center;
}

.home-cover {
  margin: 0 0 44px;
  padding: 0;
}

.home-cover img {
  width: 100%;
  aspect-ratio: 2/1;
  object-fit: cover;
  display: block;
  filter: grayscale(100%) contrast(140%);
}

.home-cover figcaption {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--muted);
  margin-top: 7px;
  text-align: center;
}

.home-body-text {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 17px;
  line-height: 1.8;
  color: var(--text);
  margin: 0 0 36px;
}

.home-section {
  padding-top: 52px;
  margin-top: 52px;
  border-top: 1px solid var(--border);
}

.home-section-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 24px;
}

/* Texto descriptivo bajo un section-label (ej. invite a la wiki en la home) */
.home-section-desc {
  font-family: 'Source Serif 4', serif;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--muted);
  margin: -8px 0 24px;
}

/* ── Chapter / navigation links ─────────────────────── */
.home-chapter-nav {
  display: flex;
  flex-direction: column;
}

.home-chapter-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 10px;
  margin: 0 -10px;
  border-radius: 5px;
  text-decoration: none;
  color: inherit;
  transition: background 0.1s;
}

.home-chapter-link:hover {
  background: rgba(0, 0, 0, 0.04);
}

.home-chapter-title {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.home-chapter-desc {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--muted);
}

/* ── Heraldry ────────────────────────────────────────── */
.home-herald-row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.home-herald-item {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

/* Escudos con fondo transparente (el blanco exterior se quitó por flood-fill).
   Una sombra suave con la forma del escudo les da profundidad en claro y oscuro. */
.home-herald-item img {
  height: 130px;
  width: auto;
  max-width: 100%;
  display: block;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.35));
}

.home-herald-item figcaption {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
  margin-top: 8px;
}

/* ── Latest entry ────────────────────────────────────── */
.home-latest-link {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: opacity 0.15s;
}

.home-latest-link:hover { opacity: 0.72; }

.home-latest-title {
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  margin: 0 0 7px;
  letter-spacing: -0.01em;
}

.home-latest-desc {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  margin: 0 0 10px;
}

.home-latest-read {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
}

/* ── Selector de idioma (Home, Sobre) ────────────────── */
.lang-selector { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.lang-pillbox {
  display: inline-flex; align-items: center; gap: 2px;
  border: 1px solid var(--border); border-radius: 20px; padding: 3px 8px;
}
.lang-pillbox > svg { width: 14px; height: 14px; color: var(--muted); margin-right: 4px; }
.lang-opt {
  font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 600;
  color: var(--muted); background: none; border: none; border-radius: 12px;
  padding: 3px 9px; cursor: pointer; transition: color 0.12s, background 0.12s;
}
.lang-opt:hover { color: var(--text); }
.lang-opt.is-active { background: var(--accent); color: var(--surface); }

/* ── Tree stats + CTA ────────────────────────────────── */
.home-section--spacious {
  margin-top: 60px;
  padding-top: 52px;
}

.home-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 0 0 22px;
}

.home-stat {
  text-align: center;
  padding: 18px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.home-stat-num {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.home-stat-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-top: 7px;
}

.home-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--surface);
  background: var(--accent);
  border-radius: 7px;
  padding: 11px 20px;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.15s;
}

.home-cta-btn:hover { opacity: 0.9; transform: translateX(2px); }
.home-cta-btn svg { width: 16px; height: 16px; }
/* Fila de CTAs + variante secundaria (contorno) para un segundo enlace */
.home-cta-row { display: flex; flex-wrap: wrap; gap: 10px; }
.home-cta-btn--ghost { background: transparent; color: var(--text); border: 1px solid var(--border); padding: 10px 19px; }
.home-cta-btn--ghost:hover { border-color: var(--accent); opacity: 1; }

@media (max-width: 640px) {
  .home-doc-title { font-size: 28px; }
  .home-herald-item img { height: 90px; }
  .home-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ─── BLOG LISTING ────────────────────────────────────── */
.blog-header {
  max-width: 1128px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.blog-header-title {
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 6px 0;
}

.blog-header-subtitle {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 14px;
  color: var(--muted);
  margin: 0;
}

.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 360px));
  max-width: 1128px;
  margin-left: auto;
  margin-right: auto;
  gap: 24px;
}

.blog-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}

.blog-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 16px rgba(28, 24, 20, 0.08);
}


.blog-card-content {
  padding: 16px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.blog-card-category {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.blog-card-title {
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--text);
}

.blog-card-desc {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.blog-card-meta {
  margin-top: auto;
  padding-top: 12px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.blog-card-langs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.blog-card-langs .lang-globe {
  width: 12px;
  height: 12px;
  color: var(--muted);
}

.lang-chip {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(45, 74, 62, 0.08);
  border: 1px solid rgba(45, 74, 62, 0.18);
  border-radius: 4px;
  padding: 2px 6px;
  line-height: 1.2;
}

.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 14px;
}

/* ─── LOADING ─────────────────────────────────────────── */
.loading-cards {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 13px;
  gap: 12px;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--muted);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── ARTICLES ────────────────────────────────────────── */
.article-container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 0 80px 0;
  overflow-wrap: break-word;
  min-width: 0;
}

.top-bar {
  padding: 16px 0;
  display: none;
}

.back-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
}

.back-home:hover {
  color: var(--text);
  border-color: var(--text);
}

.back-home svg { width: 14px; height: 14px; }

.article-header { padding: 40px 0 24px; max-width: 1020px; margin-left: auto; margin-right: auto; }

.article-kicker {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.01em;
  margin: 0 0 14px 0;
}

.article-title {
  margin: 0 0 20px 0;
  font-family: 'Hanken Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(34px, 5.5vw, 60px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--text);
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.author-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--border);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--text);
}

.author-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* El avatar es un dibujo de líneas negras sobre fondo transparente:
   en modo oscuro necesita fondo claro para no perderse. */
[data-theme="dark"] .author-avatar {
  background: #e8eaec;
  border-color: #e8eaec;
}

.meta-text { line-height: 1.35; font-size: 13px; }
.meta-text strong { color: var(--text); font-weight: 600; }

.article-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 56px;
  margin-top: 40px;
  min-width: 0;
}

.article-content {
  min-width: 0;
  max-width: 1020px;
  margin-left: auto;
  margin-right: auto;
}

.article-content .mermaid {
  max-width: 100%;
  overflow-x: auto;
  margin: 32px 0;
}

.article-grid:has(> .article-aside:has(*)) {
  grid-template-columns: minmax(0, 1fr) minmax(0, 260px);
}

.article-content p {
  margin: 0 0 26px 0;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 19.5px;
  line-height: 1.75;
  color: var(--text);
}

.article-content h2 {
  margin: 60px 0 20px 0;
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: clamp(30px, 3.5vw, 42px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
}

.article-content h3 {
  margin: 32px 0 10px 0;
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: clamp(22px, 2.5vw, 28px);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--text);
}

.article-content ul,
.article-content ol {
  margin: 16px 0 24px 0;
  padding-left: 24px;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 19.5px;
  line-height: 1.75;
  color: var(--text);
}

.article-content li { margin: 6px 0; line-height: 1.75; }
.article-content ul li { list-style-type: disc; }
.article-content ol li { list-style-type: decimal; }

.article-content figure {
  margin: 80px 0;
  text-align: center;
}

/* Imágenes apiladas: no sumar márgenes, usar uno solo */
.article-content figure + figure { margin-top: 0; }

.article-content figure img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  margin: 0;
}

/* Galería de imágenes: grid sobrio, sin caja */
.article-content .image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin: 80px 0;
}
.article-content .image-gallery figure { margin: 0; }

/* ── Lightbox editorial ─────────────────────────────── */
.lbx { position: fixed; inset: 0; z-index: 10000; display: flex; align-items: center; justify-content: center;
       padding: 3vh 2vw; background: rgba(10,10,12,0.62); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.lbx[hidden] { display: none; }
.lbx-modal { position: relative; display: flex; width: min(1320px, 96vw); height: min(88vh, 840px);
             background: var(--surface); border-radius: 10px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,0.45); }
.lbx-stage { position: relative; flex: 1; display: flex; align-items: center; justify-content: center;
             overflow: hidden; background: #141416; cursor: zoom-in; }
.lbx-stage.zoomed { cursor: grab; }
.lbx-img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none;
           transition: transform .12s ease; will-change: transform; }
.lbx-stage.zoomed .lbx-img { transition: none; }
.lbx-panel { width: 320px; flex-shrink: 0; background: var(--surface); border-left: 1px solid var(--border);
             padding: 48px 26px 26px; overflow-y: auto; }
.lbx-panel[hidden] { display: none; }
.lbx-count { font-family: 'Inter', sans-serif; font-size: 12px; letter-spacing: .05em; color: var(--muted); margin-bottom: 14px; }
.lbx-cap { font-family: 'Source Serif 4', Georgia, serif; font-size: 15px; line-height: 1.7; color: var(--text); }
.lbx-cap em { color: var(--muted); }
/* Variante sans (bitácora de la home): pie en IBM Plex en vez de la serif editorial */
.lbx--sans .lbx-cap { font-family: 'IBM Plex Sans', system-ui, sans-serif; }
.lbx-btn { position: absolute; z-index: 3; background: rgba(0,0,0,0.45); border: none; color: #fff; cursor: pointer;
           display: grid; place-items: center; border-radius: 50%; transition: background .15s; }
.lbx-btn:hover { background: rgba(0,0,0,0.72); }
.lbx-close { top: 12px; right: 12px; width: 36px; height: 36px; font-size: 18px; }
.lbx-nav { top: 50%; transform: translateY(-50%); width: 42px; height: 42px; font-size: 24px; }
.lbx-prev { left: 12px; }
.lbx-next { right: 12px; }
.lbx-hint { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); z-index: 3; color: #fff;
            font-family: 'Inter', sans-serif; font-size: 12px; background: rgba(0,0,0,0.5); padding: 5px 13px;
            border-radius: 20px; pointer-events: none; white-space: nowrap; }
@media (max-width: 760px) {
  .lbx { padding: 0; }
  .lbx-modal { width: 100vw; height: 100vh; border-radius: 0; flex-direction: column; }
  .lbx-panel { width: auto; max-height: 38%; border-left: none; border-top: 1px solid var(--border); padding: 20px; }
}

.article-content figure figcaption {
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--muted);
  font-family: 'Inter', sans-serif;
  line-height: 1.4;
  font-style: italic;
}

.article-content iframe {
  margin: 32px 0;
  max-width: 100%;
  border-radius: 4px;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* ── Hypothesis cards (posts de investigación; antes inline en cada post) ── */
.hypothesis-card {
  border: 1px solid var(--border);
  border-left: 4px solid #9ca3af;
  border-radius: 0 8px 8px 0;
  padding: 20px 24px;
  margin: 35px 0;
  background: var(--bg);
}
.hypothesis-card + hr { display: none; }
.hypothesis-card--confirmed          { border-left-color: #16a34a; background: color-mix(in srgb, #16a34a 7%, var(--surface)); border-color: color-mix(in srgb, #16a34a 28%, var(--border)); }
.hypothesis-card--confirmed-informal { border-left-color: #4ade80; background: color-mix(in srgb, #16a34a 7%, var(--surface)); border-color: color-mix(in srgb, #16a34a 28%, var(--border)); }
.hypothesis-card--solida             { border-left-color: #2563eb; background: color-mix(in srgb, #2563eb 7%, var(--surface)); border-color: color-mix(in srgb, #2563eb 28%, var(--border)); }
.hypothesis-card--plausible          { border-left-color: #d97706; background: color-mix(in srgb, #d97706 8%, var(--surface)); border-color: color-mix(in srgb, #d97706 30%, var(--border)); }
.hypothesis-card--speculative        { border-left-color: #9ca3af; }
.hypothesis-card--directa            { outline: 2px solid rgba(252, 165, 165, 0.4); outline-offset: 2px; }
.hypothesis-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.hypothesis-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hypothesis-number {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--border);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.05em;
  font-family: monospace;
}
.hypothesis-badge-directa {
  font-size: 0.7rem;
  font-weight: 600;
  color: #b91c1c;
  background: color-mix(in srgb, #b91c1c 12%, var(--surface));
  border: 1px solid color-mix(in srgb, #b91c1c 35%, var(--border));
  padding: 2px 8px;
  border-radius: 4px;
}
[data-theme="dark"] .hypothesis-badge-directa { color: #f0a5a5; }
.hypothesis-status {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
}
.hypothesis-status--confirmed,
.hypothesis-status--confirmed-informal { color: #15803d; background: color-mix(in srgb, #16a34a 16%, var(--surface)); }
.hypothesis-status--solida             { color: #1d4ed8; background: color-mix(in srgb, #2563eb 14%, var(--surface)); }
.hypothesis-status--plausible          { color: #92400e; background: color-mix(in srgb, #d97706 16%, var(--surface)); }
.hypothesis-status--speculative        { color: var(--muted); background: var(--border); }
[data-theme="dark"] .hypothesis-status--confirmed,
[data-theme="dark"] .hypothesis-status--confirmed-informal { color: #7fd8a2; }
[data-theme="dark"] .hypothesis-status--solida             { color: #93b4ff; }
[data-theme="dark"] .hypothesis-status--plausible          { color: #f2c078; }
.hypothesis-title {
  font-size: 0.97rem;
  font-weight: 600;
  margin: 0 0 14px 0;
  color: var(--text);
  line-height: 1.4;
}
.hypothesis-body { font-size: 0.9rem; }
.hypothesis-body .table-wrapper { margin-top: 0; }

.article-content img {
  max-width: 100%;
  height: auto;
}

.article-content blockquote {
  margin: 36px 0 32px 0;
  padding: 20px 24px;
  border-left: 3px solid var(--accent);
  background: rgba(0, 0, 0, 0.04);
  font-family: 'Inter', sans-serif;
  font-size: clamp(15px, 1.2vw, 16px);
  line-height: 1.6;
  color: var(--text);
  font-style: italic;
}

.article-content blockquote p { margin: 0; }

.article-content pre {
  margin: 24px 0;
  padding: 20px;
  background: #1e1e1e;
  border-radius: 4px;
  overflow-x: auto;
}

.article-content pre code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #e2e2e2;
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
}

.article-content code:not(pre code) {
  background: rgba(0, 0, 0, 0.06);
  color: var(--accent);
  padding: 2px 5px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88em;
}

/* mark / highlight (==texto==) */
.article-content mark {
  background: #fef08a;
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

/* tables */
.article-content .table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 44px 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.article-content table {
  border-collapse: collapse;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  width: 100%;
}

.article-content th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 9px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.article-content th:last-child { border-right: none; }

.article-content td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}

.article-content td:last-child { border-right: none; }
.article-content tr:last-child td { border-bottom: none; }

/* hr */
.article-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

/* callouts */
.callout {
  margin: 28px 0;
  padding: 14px 18px;
  border-radius: 4px;
  border-left: 3px solid var(--accent);
  background: rgba(45, 74, 62, 0.05);
}

.callout-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.callout-title:only-child { margin-bottom: 0; }

.callout-icon {
  font-style: normal;
  line-height: 1;
}

.callout-body {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}

.callout-body p { margin: 0 0 8px; }
.callout-body p:last-child { margin-bottom: 0; }

/* callout type variants */
.callout--warning,
.callout--caution,
.callout--attention {
  border-left-color: #d97706;
  background: rgba(217, 119, 6, 0.05);
}
.callout--warning .callout-title,
.callout--caution .callout-title,
.callout--attention .callout-title { color: #d97706; }

.callout--danger,
.callout--error,
.callout--bug,
.callout--failure,
.callout--fail,
.callout--missing {
  border-left-color: #dc2626;
  background: rgba(220, 38, 38, 0.05);
}
.callout--danger .callout-title,
.callout--error .callout-title,
.callout--bug .callout-title,
.callout--failure .callout-title,
.callout--fail .callout-title,
.callout--missing .callout-title { color: #dc2626; }

.callout--success,
.callout--check,
.callout--done {
  border-left-color: #16a34a;
  background: rgba(22, 163, 74, 0.05);
}
.callout--success .callout-title,
.callout--check .callout-title,
.callout--done .callout-title { color: #16a34a; }

.callout--quote,
.callout--cite {
  border-left-color: var(--muted);
  background: transparent;
}
.callout--quote .callout-title,
.callout--cite .callout-title { color: var(--muted); }
.callout--quote .callout-body,
.callout--cite .callout-body { font-style: italic; }

/* Tipos propios de las fichas de investigación de la Wiki */
.callout--hallazgo { border-left-color: #2563eb; background: rgba(37, 99, 235, 0.05); }
.callout--hallazgo .callout-title { color: #2563eb; }

.callout--duda { border-left-color: #d97706; background: rgba(217, 119, 6, 0.06); }
.callout--duda .callout-title { color: #d97706; }

.callout--fuente { border-left-color: var(--muted); background: rgba(90, 80, 64, 0.05); }
.callout--fuente .callout-title { color: var(--muted); }
.callout--fuente .callout-body { font-style: italic; }

.article-aside {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 14px;
  line-height: 1.65;
  color: var(--muted);
  padding-top: 40px;
  border-top: 1px solid var(--border);
}


.article-aside p { margin: 0 0 16px 0; }
.article-aside img { max-width: 100%; border-radius: 2px; border: 1px solid var(--border); }

/* ─── CHANGELOG ───────────────────────────────────────── */
.changelog-content {
  width: 100%;
}

.changelog-entry {
  padding-bottom: 36px;
  margin-bottom: 36px;
  border-bottom: 1px solid var(--border);
}

.changelog-entry:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.changelog-date {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px 0;
}

.changelog-title {
  font-family: 'Inter', sans-serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 12px 0;
}

.changelog-desc {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
  margin: 0;
}

.changelog-list {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
  margin: 12px 0 0 0;
  padding-left: 20px;
}

.changelog-list li {
  margin-bottom: 6px;
}

.changelog-list li:last-child {
  margin-bottom: 0;
}

/* ─── MAPA ────────────────────────────────────────────── */
.map-container {
  margin: 32px 0;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}

.interactive-map {
  height: 500px;
  width: 100%;
  background: var(--bg);
}

.map-legend {
  padding: 20px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.map-legend h3 {
  margin: 0 0 16px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text);
}

.legend-marker {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.legend-marker.birth     { background: #4a7c59; }
.legend-marker.death     { background: #8b3a3a; }
.legend-marker.residence { background: #3a5a8b; }
.legend-marker.migration { background: #6b4a8b; }

.places-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.place-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 18px;
  transition: border-color 0.15s;
}

.place-card:hover { border-color: var(--accent); }

.place-card h3 { margin: 0 0 10px 0; font-size: 16px; font-weight: 600; color: var(--text); }
.place-card p  { margin: 0 0 14px 0; font-size: 13px; line-height: 1.5; color: var(--muted); }

.place-type {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.place-type.birth     { background: #d4e8da; color: #2a5c3a; }
.place-type.treatment { background: #e8d4d4; color: #5c2a2a; }
.place-type.origin    { background: #d4dce8; color: #2a3c5c; }
.place-type.marriage  { background: #e8e4d4; color: #5c4a2a; }

.migration-timeline {
  margin: 32px 0;
  position: relative;
}

.migration-timeline::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
  position: relative;
}

.timeline-marker {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--border);
  flex-shrink: 0;
  margin-top: 5px;
}

.timeline-content h4 { margin: 0 0 6px 0; font-size: 15px; font-weight: 600; color: var(--text); }
.timeline-content p  { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); }

.map-stats {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 24px;
  margin-top: 20px;
}

.map-stats h3 { margin: 0 0 18px 0; font-size: 16px; font-weight: 600; color: var(--text); }

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.stat-item:last-child { border-bottom: none; }

.stat-number { font-size: 22px; font-weight: 700; color: var(--accent); }
.stat-label  { font-size: 13px; color: var(--muted); }

.clemenzo-popup .leaflet-popup-content-wrapper,
.route-popup   .leaflet-popup-content-wrapper {
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.popup-content h3 { margin: 0 0 6px 0; font-size: 15px; font-weight: 600; color: var(--text); }
.popup-description { margin: 0 0 8px 0; font-size: 13px; line-height: 1.4; color: var(--muted); }
.popup-year {
  display: inline-block;
  background: var(--bg);
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
}

/* ─── ÁRBOL ───────────────────────────────────────────── */
.tree-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px;
}

#tree { width: 100%; height: 620px; }
#tree svg { width: 100%; height: 100%; display: block; }
.tree-link { fill: none; stroke: var(--border); stroke-width: 1.4; }
.tree-node text { font-family: 'Inter', system-ui, sans-serif; fill: var(--muted); }
.avatar-circle { transition: transform .15s ease; }
.tree-node:hover .avatar-circle { transform: scale(1.04); }
.details-banner .card { border: 1px solid var(--border); background: var(--surface); }
.highlight text { fill: var(--text) !important; font-weight: 600; }

/* ─── CONTACT MODAL ───────────────────────────────────── */
.contact-modal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(28, 24, 20, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.contact-card {
  background: var(--surface);
  border-radius: 6px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 40px rgba(28, 24, 20, 0.15);
  max-width: 440px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideIn 0.25s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)     scale(1);    }
}

.contact-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.contact-header h2 {
  margin: 0;
  font-family: 'Source Serif 4', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.close-contact {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
}

.close-contact:hover { background: var(--border); color: var(--text); }

.contact-body { padding: 16px 24px 24px; }

.contact-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.contact-item:last-child { border-bottom: none; }

.contact-icon {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  color: var(--muted);
  flex-shrink: 0;
}

.contact-info h3 {
  margin: 0 8px 0 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: inline;
}

.contact-info a,
.contact-info span {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  transition: opacity 0.15s;
  display: inline;
}

.contact-info a:hover { opacity: 0.7; }

/* ─── MOBILE DRAWER (base) ────────────────────────────── */
.nav-hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  align-items: center;
  justify-content: center;
}

.nav-hamburger:hover { color: var(--text); }

/* ─── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 960px) {
  .site-body {
    grid-template-columns: 1fr;
  }

  .site-sidebar {
    display: none;
  }

  .nav-mobile-link { display: none; }
  .nav-hamburger   { display: flex; }

  .site-footer { display: none; }

  .site-main {
    padding: 32px 24px 60px;
  }

  .top-bar { display: block; }

  .article-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .interactive-map { height: 380px; }

  .footer-changelog { display: none; }

  .blog-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (max-width: 640px) {
  .site-nav { padding: 0 16px; }
  .nav-brand { font-size: 18px; }
  .nav-actions { gap: 16px; }
  .site-main { padding: 24px 16px 48px; }
  .site-footer {
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    text-align: center;
  }
  .blog-grid { grid-template-columns: 1fr; }
  .article-title { font-size: clamp(28px, 8vw, 40px); }
  .article-content p,
  .article-content ul,
  .article-content ol,
  .article-content blockquote { font-size: 16px; }
  .places-grid { grid-template-columns: 1fr; }
  .migration-timeline::before { left: 14px; }
}

/* ─── MOBILE DRAWER ───────────────────────────────────── */
.nav-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 300;
}

.nav-drawer-overlay.is-open { display: block; }

.nav-drawer {
  position: fixed;
  top: 0; left: 0;
  height: 100%;
  width: 264px;
  background: var(--surface);
  z-index: 301;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  box-shadow: 2px 0 16px rgba(0,0,0,0.08);
}

.nav-drawer.is-open { transform: translateX(0); }

.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--nav-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.nav-drawer-brand {
  font-family: var(--mono, 'IBM Plex Mono', monospace);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.nav-drawer-brand .tilde { color: var(--muted); font-weight: 400; }

.nav-drawer-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}

.nav-drawer-close:hover { color: var(--text); }

.nav-drawer-links {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-drawer-link {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono, 'IBM Plex Mono', monospace);
  font-size: 13.5px;
  text-transform: lowercase;
  color: var(--muted);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.nav-drawer-link:hover {
  color: var(--text);
  background: var(--bg);
}

.nav-drawer-link.is-active {
  color: var(--accent);
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.nav-drawer-link--gh svg { flex-shrink: 0; }
.nav-drawer-link--minor { font-size: 13px; }

.nav-drawer-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* ─── BACK TO TOP ─────────────────────────────────────── */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 100;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, color 0.15s, border-color 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-top:hover {
  color: var(--text);
  border-color: var(--text);
}
