:root {
  --bg: #f4f1ea;
  --surface: #fdfbf7;
  --text: #1f1d1a;
  --muted: #6b6660;
  --line: #d9d4cc;
  --accent: #8c1f1f;
  --chip-text: #6b6660;
  --foco: 2px solid #8c1f1f;
  --sombra: 0 1px 2px rgba(0, 0, 0, 0.08);
}

[data-theme="oscuro"] {
  --bg: #141312;
  --surface: #1d1c1a;
  --text: #ece7df;
  --muted: #9b958c;
  --line: #322f2b;
  --accent: #c96a5e;
  --chip-text: #b8b2a6;
  --foco: 2px solid #c96a5e;
  --sombra: 0 1px 2px rgba(0, 0, 0, 0.5);
}

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

html {
  color-scheme: light;
}

[data-theme="oscuro"] {
  color-scheme: dark;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

:focus-visible {
  outline: var(--foco);
  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;
}

/* Encabezado */

.encabezado {
  padding: 1.5rem 1.25rem 0;
  border-bottom: 1px solid var(--line);
}

.encabezado-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.marca {
  display: block;
  line-height: 0;
}

.marca-logo {
  height: 100px;
  width: auto;
  border-radius: 4px;
}

[data-theme="oscuro"] .marca-logo {
  filter: invert(1);
}

.tema-switch {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 10;
  width: 3.5rem;
  height: 1.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.4375rem;
  flex-shrink: 0;
  box-shadow: var(--sombra);
}

.tema-switch:hover {
  border-color: var(--accent);
}

.tema-switch svg {
  width: 1rem;
  height: 1rem;
  color: var(--muted);
}

.tema-switch svg:first-child {
  color: var(--text);
}

[data-theme="oscuro"] .tema-switch svg:first-child {
  color: var(--muted);
}

[data-theme="oscuro"] .tema-switch svg:last-child {
  color: var(--text);
}

.tema-knob {
  position: absolute;
  left: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.2s ease;
  pointer-events: none;
}

[data-theme="oscuro"] .tema-knob {
  transform: translateY(-50%) translateX(1.75rem);
}

/* Filtros */

.filtros {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filtro {
  font: inherit;
  font-size: 0.875rem;
  padding: 0.375rem 0.875rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

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

.filtro[aria-pressed="true"] {
  color: var(--text);
  border-color: var(--text);
  font-weight: 600;
}

/* Grid */

.grid {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1440px) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Tarjeta */

.tarjeta {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--sombra);
  transition: border-color 0.15s ease;
}

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

.tarjeta-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.tarjeta-foto {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}

.tarjeta-foto img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tarjeta-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 1.25rem;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  line-height: 1;
}

.tarjeta-cuerpo {
  padding: 1rem 1.125rem 1.125rem;
}

.tarjeta-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.chip {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--chip-text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.125rem 0.5rem;
  white-space: nowrap;
  text-decoration: none;
}

a.chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.chip-foto {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1;
  background: var(--surface);
  box-shadow: var(--sombra);
}

.tarjeta-meta time {
  font-size: 0.75rem;
  color: var(--muted);
}

.tarjeta-titulo {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.1875rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin-bottom: 0.375rem;
}

.tarjeta-resumen {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.tarjeta-autor {
  font-size: 0.8125rem;
  font-weight: 600;
}

/* Estados: esqueleto, error, vacío */

.esqueleto {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 320px;
  animation: pulso 1.2s ease-in-out infinite;
}

@keyframes pulso {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

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

.estado h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.estado p {
  font-size: 0.9375rem;
  margin-bottom: 1rem;
}

.reintentar {
  font: inherit;
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

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

/* Artículo */

.articulo {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.articulo-cabecera {
  margin-bottom: 1.5rem;
}

.articulo-titulo {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0.75rem 0 0.5rem;
}

.articulo-resumen {
  font-size: 1.0625rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.articulo-autor {
  font-size: 0.875rem;
  font-weight: 600;
}

.articulo-foto {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}

.articulo-foto img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.articulo-cuerpo {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.125rem;
  line-height: 1.75;
}

.articulo-cuerpo p {
  margin-bottom: 1.25rem;
}

.articulo-cuerpo h2 {
  font-size: 1.375rem;
  margin: 2rem 0 1rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--accent);
  line-height: 1.3;
}

.articulo-cuerpo blockquote {
  margin: 1.5rem 0;
  padding: 0.75rem 1.25rem;
  border-left: 3px solid var(--accent);
  font-style: italic;
  color: var(--muted);
}

.articulo-cuerpo img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1rem 0;
}

.articulo-cuerpo .video {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  margin: 1.5rem 0;
  background: #000;
}

.articulo-cuerpo .video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.articulo-cuerpo a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.articulo-cuerpo a:hover {
  text-decoration-thickness: 2px;
}

.volver {
  display: inline-block;
  margin-top: 2.5rem;
  font: inherit;
  font-size: 0.9375rem;
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

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

/* Pie */

.pie {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 1.5rem 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.8125rem;
}
