/* ==========================================================================
   Ergosetup · 2-base.css
   Normalización, tipografía y primitivas de maquetación.
   ========================================================================== */

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

/* El atributo hidden SIEMPRE gana. Sin esto, cualquier elemento cuya clase
   fije "display" (p. ej. .tarjeta-producto { display: flex }) pisa el
   "display: none" que el navegador aplica por defecto a [hidden], porque
   ambas reglas tienen la misma especificidad y la hoja de estilos del sitio
   carga despues que la del navegador. Esto rompia los filtros del
   comparador: el atributo se ponia, pero la tarjeta se seguia mostrando. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--alto-cabecera) + var(--e-4));
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--fuente-texto);
  font-size: var(--t-md);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;             /* el body nunca hace scroll horizontal */
}

/* --- Titulares ---------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--fuente-titulo);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 var(--e-4);
  color: var(--ink);
  text-wrap: balance;
}
h1 { font-size: var(--t-3xl); letter-spacing: -0.03em; }
h2 { font-size: var(--t-2xl); }
h3 { font-size: var(--t-xl); }
h4 { font-size: var(--t-lg); }

p { margin: 0 0 var(--e-4); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand-hover); }

strong { font-weight: 650; color: var(--ink); }
small  { font-size: var(--t-sm); }

ul, ol { margin: 0 0 var(--e-4); padding-left: 1.35em; }
li { margin-bottom: var(--e-2); }

img { max-width: 100%; height: auto; display: block; }

hr { border: 0; border-top: 1px solid var(--line); margin: var(--e-7) 0; }

/* --- Accesibilidad ------------------------------------------------------ */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

.solo-lectores {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.saltar-a-contenido {
  position: absolute; left: var(--e-4); top: -100px; z-index: 200;
  background: var(--brand); color: #fff; padding: var(--e-3) var(--e-5);
  border-radius: var(--r-md); font-weight: 600; text-decoration: none;
  transition: top var(--transicion);
}
.saltar-a-contenido:focus { top: var(--e-4); color: #fff; }

/* --- Primitivas de maquetación ------------------------------------------ */
.contenedor {
  width: 100%;
  max-width: var(--ancho-max);
  margin-inline: auto;
  padding-inline: var(--e-5);
}
@media (max-width: 640px) { .contenedor { padding-inline: var(--e-4); } }

.contenedor-texto { max-width: var(--ancho-texto); }

.seccion       { padding-block: var(--e-8); }
.seccion-ligera{ padding-block: var(--e-7); }
.seccion--alt  { background: var(--surface-2); }

/* Rejilla automática reutilizable: se adapta sola al ancho disponible.
   El max-width de los hijos es importante: con auto-fit, una rejilla con un
   solo elemento lo estira a todo el contenedor y una categoría con un único
   producto acababa mostrando una tarjeta gigante. El tope lo evita sin
   afectar a las rejillas de tres o más elementos. */
.rejilla {
  display: grid;
  gap: var(--e-5);
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
}
.rejilla > * { max-width: 100%; }
@media (min-width: 760px) {
  .rejilla > * { max-width: 420px; }
}
.rejilla--2 { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }
@media (min-width: 760px) {
  .rejilla--2 > * { max-width: 480px; }
}

/* Cualquier contenido ancho (tablas, código) scrollea dentro de su caja */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* --- Cabecera de sección reutilizable ----------------------------------- */
.cabecera-seccion { margin-bottom: var(--e-6); max-width: 62ch; }
.cabecera-seccion .antetitulo {
  display: inline-flex; align-items: center; gap: var(--e-2);
  font-family: var(--fuente-titulo);
  font-size: var(--t-xs); font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--brand); margin-bottom: var(--e-3);
}
.cabecera-seccion .antetitulo::before {
  content: ""; width: 22px; height: 2px; background: var(--brand); border-radius: 2px;
}
.cabecera-seccion h2 { margin-bottom: var(--e-3); }
.cabecera-seccion p { color: var(--ink-2); font-size: var(--t-md); }

/* --- Utilidades --------------------------------------------------------- */
.texto-secundario { color: var(--ink-2); }
.texto-terciario  { color: var(--ink-3); font-size: var(--t-sm); }
.centrado { text-align: center; margin-inline: auto; }
.sin-margen-final > *:last-child { margin-bottom: 0; }
