/* ==========================================================================
   Blog JABALAB — estilos de blog/ y blog/articulo/.
   Fuente, tokens, navbar, footer y barra de scroll están en site.css.
   ========================================================================== */

/* ===== BASE DE LAS PÁGINAS DEL BLOG ===== */
body {
  display: flex;
  flex-direction: column;
  line-height: 1.65;
}
main { flex: 1; position: relative; z-index: 1; }
img { max-width: 100%; display: block; }
main a { color: var(--primary-text); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.22;
  background: radial-gradient(circle, var(--primary), transparent 70%);
}
.glow-1 { width: min(520px, 90vw); height: min(520px, 90vw); top: -140px; right: -180px; }
.glow-2 { width: min(380px, 70vw); height: min(380px, 70vw); bottom: 10%; left: -160px; opacity: 0.12; }
[data-theme="dark"] .glow { opacity: 0.14; }

/* Botones redondos de icono (compartir) */
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 1.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.3s, border-color 0.3s;
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }

/* ===== ENCABEZADO DEL BLOG ===== */
.blog-hero {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 4.5rem) var(--gutter) clamp(1.5rem, 3vw, 2.25rem);
  text-align: center;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  border-radius: 50px;
  background: var(--tint);
  border: 1px solid var(--tint-border);
  color: var(--primary-text);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 1.1rem;
}
.blog-hero h1 {
  font-size: clamp(2rem, 1.3rem + 3.2vw, 3.4rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.blog-hero h1 span { color: var(--primary); }
[data-theme="dark"] .blog-hero h1 span { color: #4ade80; }
.blog-hero .lead {
  max-width: 640px;
  margin: 1rem auto 0;
  color: var(--text-secondary);
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.12rem);
}

/* Buscador */
.search {
  position: relative;
  max-width: 620px;
  margin: clamp(1.5rem, 3vw, 2rem) auto 0;
}
.search .svg-icon.search-icon {
  position: absolute;
  left: 1.15rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.05rem;
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 56px;
  padding: 0 3.4rem 0 3rem;
  border-radius: 50px;
  border: 1px solid var(--input-border);
  background: var(--surface-strong);
  color: var(--text-primary);
  font: inherit;
  font-size: 1rem; /* 16px: evita zoom en iOS */
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search input::placeholder { color: var(--text-muted); }
.search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(18, 186, 56, 0.14), var(--shadow); }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear,
.search-spinner {
  position: absolute;
  right: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
}
.search-clear {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
}
.search-clear:hover { color: var(--text-primary); background: var(--tint); }
.search.has-value .search-clear { display: inline-flex; }
.search.is-loading .search-clear { display: none; }
.search.is-loading .search-spinner { display: inline-flex; }
.search-spinner::before {
  content: '';
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid var(--tint-border);
  border-top-color: var(--primary);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.search-hint {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 1.4em;
}
.search-hint strong { color: var(--text-primary); }

/* ===== LISTADO ===== */
.blog-list {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0.5rem var(--gutter) clamp(3rem, 6vw, 5rem);
}
.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1rem, 2.2vw, 1.75rem);
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
.card:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); border-color: var(--tint-border); }
.card:focus-within { border-color: var(--primary); }
.card-cover {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(18, 186, 56, 0.16), rgba(11, 26, 48, 0.08));
}
.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease, opacity 0.4s ease;
  opacity: 0;
}
.card-cover img.is-loaded { opacity: 1; }
.card:hover .card-cover img { transform: scale(1.04); }
/* Sin portada o si falla: marca de agua con el icono del sitio */
.card-cover.no-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url('../img/jabalab-icon.svg') center / 22% no-repeat;
  opacity: 0.35;
}
.card-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.25rem 1.35rem 1.4rem;
  flex: 1;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.9rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.card-meta span { display: inline-flex; align-items: center; gap: 0.35rem; }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 50px;
  background: var(--tint);
  border: 1px solid var(--tint-border);
  color: var(--primary-text);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.card h2,
.card h3 {
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Toda la tarjeta es clicable, pero el enlace real es el título (mejor para lectores de pantalla) */
.card h2 a,
.card h3 a { color: inherit; text-decoration: none; }
.card h2 a::after,
.card h3 a::after { content: ''; position: absolute; inset: 0; z-index: 1; }
.card h2 a:focus-visible,
.card h3 a:focus-visible { outline: none; }
.card p.summary {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.read-more {
  margin-top: auto;
  padding-top: 0.4rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--primary-text);
  font-weight: 600;
  font-size: 0.88rem;
}
.read-more .svg-icon { transition: transform 0.3s; }
.card:hover .read-more .svg-icon { transform: translateX(4px); }

/* Destacado (primera página sin búsqueda): bloque 2×2 con dos tarjetas a su lado.
   1 destacado + 2 + 6 = 9 artículos llenan exactamente 4 filas de 3 columnas. */
.card.featured { grid-column: span 2; grid-row: span 2; }
.card.featured .card-cover { flex: 1; aspect-ratio: auto; min-height: 280px; }
.card.featured .card-body { flex: none; padding: clamp(1.4rem, 2.5vw, 2rem); gap: 0.75rem; }
.card.featured h2 { font-size: clamp(1.35rem, 1.1rem + 0.9vw, 1.8rem); -webkit-line-clamp: 3; }
.card.featured p.summary { -webkit-line-clamp: 3; font-size: 0.98rem; }

/* Esqueletos de carga */
.skeleton { pointer-events: none; }
.skeleton .card-cover,
.skeleton .sk-line {
  background: var(--skeleton);
  position: relative;
  overflow: hidden;
}
.skeleton .card-cover::after,
.skeleton .sk-line::after,
.sk-block::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--skeleton-shine), transparent);
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { display: block; height: 0.85rem; border-radius: 6px; }
.sk-line.w-30 { width: 30%; }
.sk-line.w-60 { width: 60%; }
.sk-line.w-80 { width: 80%; }
.sk-line.w-100 { width: 100%; }
.sk-line.title { height: 1.15rem; }
.sk-block { position: relative; overflow: hidden; background: var(--skeleton); border-radius: 8px; }
.sk-chip { display: block; width: 110px; height: 24px; border-radius: 50px; }
.sk-heading { display: block; width: 90%; height: 2.6rem; margin: 1rem 0 0.6rem; }
.sk-heading.short { width: 60%; margin-top: 0; }
.sk-text { display: block; width: 100%; height: 1rem; margin-top: 1.4rem; }
.sk-text.short { width: 85%; margin-top: 0.6rem; }

/* Estados vacío y error */
.state {
  grid-column: 1 / -1;
  text-align: center;
  padding: clamp(2.5rem, 6vw, 4rem) 1.5rem;
  background: var(--surface);
  border: 1px dashed var(--tint-border);
  border-radius: var(--radius);
}
.state .state-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 1.1rem;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.9rem;
  background: var(--tint);
  color: var(--primary-text);
}
.state.is-error .state-icon { background: rgba(220, 38, 38, 0.08); color: #dc2626; }
.state h2 { font-size: 1.3rem; margin-bottom: 0.4rem; }
.state p { color: var(--text-secondary); max-width: 520px; margin: 0 auto; }
.state .actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; margin-top: 1.4rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 46px;
  padding: 0 1.4rem;
  border-radius: 50px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s, color 0.25s;
}
.btn-primary {
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 6px 20px rgba(18, 186, 56, 0.3);
}
.btn-primary:hover { color: #fff; transform: translateY(-2px); box-shadow: 0 10px 28px rgba(18, 186, 56, 0.42); }
.btn-ghost {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
}
.btn-ghost:hover { color: var(--primary-text); border-color: var(--primary); }

/* Paginación */
.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  margin-top: clamp(2rem, 4vw, 3rem);
}
.pagination[hidden] { display: none; }
.page-btn {
  min-width: 44px;
  height: 44px;
  padding: 0 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.page-btn:hover:not(:disabled):not([aria-current]) { border-color: var(--primary); color: var(--primary-text); }
.page-btn[aria-current="page"] {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: transparent;
  color: #fff;
  cursor: default;
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-gap { color: var(--text-muted); padding: 0 0.25rem; }
.page-summary {
  width: 100%;
  text-align: center;
  margin-top: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ===== ARTÍCULO ===== */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--primary), #4ade80);
  z-index: 200;
}
.article-wrap {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 2.5rem) var(--gutter) clamp(3rem, 6vw, 5rem);
}
.breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1.25rem; }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.breadcrumb li { display: inline-flex; align-items: center; gap: 0.35rem; min-width: 0; }
.breadcrumb li + li::before { content: '›'; color: var(--text-muted); }
.breadcrumb a { color: var(--text-secondary); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary-text); text-decoration: underline; }
.breadcrumb [aria-current] {
  color: var(--text-primary);
  max-width: 40ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.article-header { max-width: 820px; }
.article-header h1 {
  font-size: clamp(1.9rem, 1.3rem + 2.6vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0.75rem 0 1rem;
  text-wrap: balance;
}
.article-header .lead {
  font-size: clamp(1.02rem, 0.98rem + 0.3vw, 1.18rem);
  color: var(--text-secondary);
  line-height: 1.7;
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1.25rem;
  margin-top: 1.25rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.article-meta span { display: inline-flex; align-items: center; gap: 0.4rem; }
.article-meta .svg-icon { color: var(--primary); }

.share { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; }
.share-label { font-size: 0.82rem; color: var(--text-muted); margin-right: 0.2rem; }
.share .icon-btn { width: 40px; height: 40px; font-size: 1rem; }
.share .icon-btn.is-done { color: #fff; background: var(--primary); border-color: var(--primary); }

.article-cover {
  margin: clamp(1.5rem, 3vw, 2.25rem) 0 0;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 21 / 9;
  background: linear-gradient(135deg, rgba(18, 186, 56, 0.16), rgba(11, 26, 48, 0.08));
  box-shadow: var(--shadow);
}
.article-cover img { width: 100%; height: 100%; object-fit: cover; }

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: clamp(2rem, 4vw, 3.5rem);
  align-items: start;
  margin-top: clamp(1.75rem, 4vw, 2.75rem);
}
.article-layout.no-toc { grid-template-columns: minmax(0, 1fr); }

.article-aside { position: sticky; top: calc(var(--nav-h) + 1.25rem); display: grid; gap: 1rem; }
.toc,
.aside-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem 1rem;
  box-shadow: var(--shadow);
}
.toc-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.toc ol { list-style: none; max-height: 52vh; overflow-y: auto; }
.toc a {
  display: block;
  padding: 0.38rem 0.6rem;
  border-left: 2px solid transparent;
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.86rem;
  line-height: 1.4;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.toc li.level-3 a { padding-left: 1.4rem; font-size: 0.82rem; }
.toc a:hover { color: var(--text-primary); background: var(--tint); }
.toc a.active { color: var(--primary-text); border-left-color: var(--primary); background: var(--tint); font-weight: 600; }
.aside-card h2 { font-size: 0.98rem; margin-bottom: 0.35rem; }
.aside-card p { font-size: 0.86rem; color: var(--text-secondary); margin-bottom: 0.85rem; }
.aside-card .btn { width: 100%; min-height: 42px; font-size: 0.86rem; }

/* Tipografía del contenido */
.prose { font-size: clamp(1rem, 0.97rem + 0.2vw, 1.08rem); line-height: 1.8; color: var(--text-secondary); max-width: 72ch; }
.prose > * + * { margin-top: 1.1em; }
.prose h2,
.prose h3,
.prose h4 { color: var(--text-primary); line-height: 1.3; scroll-margin-top: calc(var(--nav-h) + 1.25rem); }
.prose h2 { font-size: 1.55em; margin-top: 2em; padding-bottom: 0.35em; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 1.25em; margin-top: 1.7em; }
.prose h4 { font-size: 1.08em; margin-top: 1.5em; }
.prose strong { color: var(--text-primary); }
.prose a { color: var(--primary-text); font-weight: 500; }
.prose ul,
.prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 0.4em; }
.prose li::marker { color: var(--primary); }
.prose blockquote {
  margin-left: 0;
  padding: 0.9em 1.2em;
  border-left: 4px solid var(--primary);
  background: var(--tint);
  border-radius: 0 12px 12px 0;
  color: var(--text-primary);
}
.prose hr { border: none; height: 1px; background: var(--border); margin: 2.2em 0; }
.prose img { border-radius: 14px; margin-left: auto; margin-right: auto; box-shadow: var(--shadow); height: auto; }
.prose figure figcaption { text-align: center; font-size: 0.85em; color: var(--text-muted); margin-top: 0.5em; }
.prose code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.88em;
  padding: 0.15em 0.4em;
  border-radius: 6px;
  background: var(--tint);
  color: var(--text-primary);
}
.prose pre {
  overflow-x: auto;
  padding: 1em 1.2em;
  border-radius: 12px;
  background: #0b1a30;
  color: #e6edf3;
  font-size: 0.88em;
  line-height: 1.6;
}
.prose pre code { background: none; padding: 0; color: inherit; }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.92em; display: block; overflow-x: auto; }
.prose th,
.prose td { padding: 0.6em 0.8em; border: 1px solid var(--border); text-align: left; }
.prose th { background: var(--tint); color: var(--text-primary); }

/* Llamada a la acción al final del artículo */
.article-cta {
  margin-top: clamp(2.5rem, 5vw, 3.5rem);
  padding: clamp(1.5rem, 3.5vw, 2.25rem);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(18, 186, 56, 0.14), rgba(18, 186, 56, 0.04));
  border: 1px solid var(--tint-border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  max-width: 72ch;
}
.article-cta h2 { font-size: 1.25rem; margin-bottom: 0.25rem; }
.article-cta p { color: var(--text-secondary); font-size: 0.95rem; }
.article-cta .actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.article-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 72ch;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.related { margin-top: clamp(3rem, 6vw, 4.5rem); }
.related-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.related-head h2 { font-size: clamp(1.35rem, 1.15rem + 0.8vw, 1.75rem); }
.related-head a { font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 0.35rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Tablet: destacado horizontal a lo ancho; 1 + 8 = 9 llena 5 filas de 2 */
  .card.featured { grid-row: auto; flex-direction: row; }
  .card.featured .card-cover { flex: 1.1; min-height: 260px; }
  .card.featured .card-body { flex: 1; justify-content: center; }
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .article-aside { position: static; order: -1; }
  .article-aside .aside-card { display: none; }
  .toc ol { max-height: none; }
}
@media (max-width: 720px) {
  .cards { grid-template-columns: minmax(0, 1fr); }
  .card.featured { grid-column: auto; flex-direction: column; }
  .card.featured .card-cover { aspect-ratio: 16 / 9; min-height: 0; flex: none; }
  .card.featured .card-body { flex: 1; }
  .article-cover { aspect-ratio: 16 / 9; }
  .page-btn.num:not([aria-current]) { display: none; }   /* en celular: solo ‹ actual › */
  .page-gap { display: none; }
}
@media (hover: none) {
  .card:hover,
  .btn:hover,
  .nav-cta:hover { transform: none; }
  .card:hover .card-cover img { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
@media print {
  .navbar, .glow, .progress, .share, .article-aside, .article-cta, .related, .footer, .skip-link { display: none !important; }
  .article-layout { display: block; }
  .prose { max-width: none; color: #000; }
  body { background: #fff; color: #000; }
}
