/* ====== Variables y base ====== */
:root {
  --bg: #eeeedd;
  --text: #222222;
  --muted: #666666;
  --primary: #2277ee;
  --surface: #dddddd;
  --border: #eeeeee;
  --button: #dddddd;
  --buttonfocus: #eef4ff;

  --max-content: 1200px;
  --page-padding: 16px;
  --gap: 16px;
  --radius: 12px;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);

  --menu-height: 40px;
}

/* Reset mínimo y mejor render */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  line-height: 1.55;

  /* Sticky footer: body a pantalla completa y columna */
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

/* ====== Menú fijo arriba ====== */
/* Contenedor del menú con sticky */
#menu-container {
  position: sticky;
  top: 0;
  z-index: 1000;
}

#menu {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  height: var(--menu-height);

  /* layout interno */
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 var(--page-padding);
  overflow-x: auto;
  /* por si hay muchos enlaces en móvil */
}

/* Enlaces del menú */
#menu a {
  text-decoration: none;
  color: var(--text);
  padding: 4px 4px;
  border-radius: 8px;
  white-space: nowrap;
  background: var(--button);
  font-size: 0.9rem;
  transition: background-color .2s ease, color .2s ease;
}

#menu a:hover,
#menu a:focus-visible {
  background: var(--buttonfocus);
  color: var(--primary);
  outline: none;
}

/* Indicador de página activa */
#menu a.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.menu-img {
  width: auto;
  height: 24px;
}

/* ====== Contenido principal ====== */
#contenido {
  /* que el contenido empuje el footer hacia abajo */
  flex: 1 0 auto;

  max-width: var(--max-content);
  margin: 0 auto;
  padding: 20px var(--page-padding);

  /* evita que el header sticky tape el primer contenido al hacer anchor/scroll */
  scroll-margin-top: calc(var(--menu-height) + 12px);
}

/* Separación inicial bajo el menú */
#contenido>h2:first-child {
  margin-top: 12px;
  margin-bottom: 16px;
}

/* Tipografía */
h2 {
  margin: 6px 0 4px;
  font-size: 1.60rem;
}

h3 {
  margin: 6px 0 4px;
  font-size: 1.00rem;
}

h4 {
  margin: 8px 0 4px;
  font-size: 1.00rem;
  color: var(--text);
}

p {
  margin: 0;
  color: var(--muted);
  font-size: 0.90rem;
}

.articulo-img {
  width: 300px;
  /* Ancho fijo para las imágenes */
  height: auto;
  /* Mantiene la relación de aspecto */
  display: block;
  margin: 5px auto;
  /* Centra las imágenes */
}

/* ====== Rejilla de items ====== */
.cajas {
  display: grid;
  gap: var(--gap);
  /* columnas automáticas; ajusta 240px si quieres tarjetas + anchas/estrechas */
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-items: stretch;
}

/* Tarjeta */
.item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 160px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  /*max-width: 300px;*/
}

.item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Imagen de tarjeta */
.item-img {
  width: 100%;
  height: 160px;
  /* altura consistente */
  object-fit: cover;
  /* recorte elegante */
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}

/* Clase para ofuscación anti-spam */
.anti-spam {
  display: none !important;
}

/* ====== Footer siempre al final ====== */
#footer {
  margin-top: auto;
  /* clave para sticky footer */
  background: var(--surface);
  border-top: 1px solid var(--border);
}

#footer {
  display: block;
  width: 100%;
  margin: 0 auto;
  padding: 2px var(--page-padding);
  color: var(--muted);
  font-size: 0.95rem;
}

.footer-img {
  height: 12px;
  vertical-align: middle;
}

/* ====== Responsivo ====== */
@media (max-width: 900px) {
  :root {
    --menu-height: 52px;
  }

  .cajas {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

@media (max-width: 600px) {
  :root {
    --page-padding: 14px;
    --gap: 14px;
  }

  #menu {
    gap: 8px;
  }

  .item-img {
    height: 140px;
  }
}

@media (max-width: 420px) {
  .cajas {
    grid-template-columns: 1fr;
    /* una columna en móviles muy estrechos */
  }
}

/* ====== Modo oscuro opcional ====== */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111122;
    --text: #eeeeee;
    --muted: #bbbbbb;
    --surface: #222222;
    --border: #223344;
    --button: #223333;
    --primary: #66aaff;
    --buttonfocus: #110800;
    --shadow: none;
  }

  #menu a:hover,
  #menu a:focus-visible {
    background: var(--buttonfocus);
    color: var(--primary);
  }
}

/* ====== Detalles de accesibilidad (opcional pero recomendado) ====== */
#menu a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}