/**
 * BASE — normalización, tipografía y accesibilidad.
 * Todos los valores salen de tokens.css. Aquí no hay ni un número mágico.
 */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;

  /* Reserva el hueco de la barra de desplazamiento siempre. Sin esto, bloquear
     el scroll —al abrir el selector de idioma— hace desaparecer la barra y todo
     el contenido salta unos píxeles: CLS medido de 0.0184 antes de esta línea. */
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  background-color: var(--fondo);
  color: var(--texto);
  font-family: var(--fuente-texto);
  font-size: var(--texto-base);
  font-weight: var(--peso-normal);
  line-height: var(--interlineado-texto);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Ritmo vertical: en vez de márgenes sueltos por elemento, separación entre
   hermanos. Evita el clásico margen colapsado que descuadra las secciones. */
:where(p, ul, ol, dl, blockquote, figure, table, pre) {
  margin-block: 0 var(--espacio-sm);
}

:where(h1, h2, h3, h4, h5, h6) {
  margin-block: 0 var(--espacio-xs);
  font-family: var(--fuente-titulo);
  font-weight: var(--peso-titulo);
  line-height: var(--interlineado-titulo);
  letter-spacing: var(--espaciado-letra-titulo);
  text-wrap: balance;
}

h1 { font-size: var(--texto-3xl); line-height: var(--interlineado-apretado); }
h2 { font-size: var(--texto-2xl); }
h3 { font-size: var(--texto-xl); }
h4 { font-size: var(--texto-lg); }
h5,
h6 { font-size: var(--texto-base); }

p {
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--duracion-rapida) var(--curva);
}

a:hover {
  color: var(--acento-texto);
}

/* Imágenes y multimedia: nunca desbordan y nunca provocan salto de maquetación,
   siempre que el HTML lleve width y height, que es obligatorio en este proyecto. */
:where(img, picture, video, canvas, svg) {
  display: block;
  max-width: 100%;
  height: auto;
}

:where(input, button, textarea, select) {
  font: inherit;
  color: inherit;
}

hr {
  border: 0;
  border-top: 1px solid var(--borde);
  margin-block: var(--espacio-lg);
}

::selection {
  background-color: var(--seleccion-fondo);
  color: var(--seleccion-texto);
}

/* -----------------------------------------------------------------------
 * ACCESIBILIDAD
 * --------------------------------------------------------------------- */

/* Foco visible siempre. Nada de outline:none sin sustituto: sin esto la
   navegación por teclado es imposible de seguir sobre fondo oscuro. */
:focus-visible {
  outline: var(--grosor-foco) solid var(--foco);
  outline-offset: var(--separacion-foco);
  border-radius: var(--radio-sm);
}

/* Enlace de salto al contenido: fuera de pantalla hasta que recibe el foco. */
.salto-contenido {
  position: absolute;
  top: var(--espacio-2xs);
  left: var(--espacio-2xs);
  z-index: var(--capa-aviso);
  padding: var(--espacio-2xs) var(--espacio-sm);
  background-color: var(--acento-2);
  color: var(--fondo);
  font-weight: var(--peso-fuerte);
  text-decoration: none;
  border-radius: var(--radio-md);
  transform: translateY(-200%);
}

.salto-contenido:focus-visible {
  transform: translateY(0);
}

/* Texto solo para lectores de pantalla.
   Se le fuerza la fuente de texto a propósito: un titular que nadie ve no debe
   arrastrar la descarga de la tipografía de titulares. */
.solo-lectores {
  font-family: var(--fuente-texto);
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Respeto a quien ha pedido menos movimiento. No se anula la animación del todo
   (eso puede romper transiciones que comunican estado): se reduce a lo mínimo. */
@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;
    scroll-behavior: auto !important;
  }
}

/* -----------------------------------------------------------------------
 * SVG INLINE
 *
 * Los logos entran en el HTML sin fill propio: heredan currentColor. Los trazos
 * marcados como acento los pinta la variable de marca; el CSS gana sobre el
 * atributo fill del SVG, que se conserva como reserva por si el CSS no carga.
 * --------------------------------------------------------------------- */

.coba-svg {
  display: block;
  width: auto;
  height: 100%;
  fill: currentColor;
}

.coba-svg__acento {
  fill: var(--acento);
}
