/* Base: reinicio, tipografía, foco, movimiento (diseño §6.2, §6.3). */

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

html {
  background: var(--fondo);
  scrollbar-color: var(--borde-fuerte) transparent;
  scrollbar-width: thin;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--alto-barra) + var(--e-4));
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--fondo);
  color: var(--texto-2);
  font: 400 13px/20px var(--fuente);
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--acento-sutil); color: var(--texto-1); }

h1, h2, h3, h4, p, ul, ol, dl, dd, figure, pre { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
:disabled { cursor: not-allowed; }
[hidden] { display: none !important; }

a { color: var(--acento); text-decoration: none; }
a:hover { color: var(--acento-fuerte); text-decoration: underline; text-underline-offset: 2px; }

/* Tipografía (§6.2): jerarquía por color antes que por tamaño o peso. */
h1, .t-h1 { font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -0.019em; color: var(--texto-1); text-wrap: balance; }
h2, .t-h2 { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -0.014em; color: var(--texto-1); text-wrap: balance; }
h3, .t-h3 { font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: -0.011em; color: var(--texto-1); }
.t-ui { font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: -0.006em; }
.prosa { font-size: 14px; line-height: 22px; font-weight: 400; letter-spacing: 0; text-wrap: pretty; }
.t-pequeno { font-size: 12px; line-height: 16px; letter-spacing: 0; }
.t-micro, .etiqueta-micro {
  font-size: 11px; line-height: 16px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--texto-3); font-feature-settings: "case";
}
.mono, code, pre, kbd.mono {
  font-family: var(--fuente-mono); font-size: 12px; line-height: 16px; font-weight: 400; letter-spacing: 0;
}
code { color: var(--texto-1); }
.num, time, table { font-variant-numeric: tabular-nums; }
.num { text-align: right; }
.texto-1 { color: var(--texto-1); }
.texto-2 { color: var(--texto-2); }
.texto-3 { color: var(--texto-3); }
.truncar { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* Foco visible en todo lo interactivo (§6.1). */
:focus-visible { outline: 2px solid var(--anillo-foco); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
/* Encabezados y contenedores que solo reciben foco por programa: sin anillo. */
:is(h1, h2, h3, main, section, div)[tabindex="-1"]:focus { outline: none; }

/* Áreas de toque (§6.1). */
@media (pointer: coarse) {
  :is(button, .boton, .chip, [role="option"]) { min-height: 40px; }
}

.visualmente-oculto {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* Movimiento (§6.3): una sola guarda global. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* Transiciones de vista (§6.3). Nunca se funden dos textos: lo viejo se apaga en 60 ms y recién al final entra lo
   nuevo (un fundido cruzado deja dos títulos encimados a mitad de camino). Total 180 ms. Firefox no tiene tipos:
   la dirección va en <html data-nav> (adelante | atras | lado | pestana). */
#contenido { view-transition-name: contenido; }
/* El panel se captura aparte solo al cambiar de pestaña; en una navegación completa va dentro de `contenido`. */
html[data-nav="pestana"] .panel-tanda { view-transition-name: panel; }

/* El armazón (la barra superior) cambia sin animación; sus grupos no se mueven ni se estiran. */
::view-transition-old(root) { animation: none; opacity: 0; }
::view-transition-new(root) { animation: none; }
::view-transition-group(root), ::view-transition-group(contenido), ::view-transition-group(panel) { animation: none; }

::view-transition-old(contenido), ::view-transition-old(panel) {
  animation: vt-salir 60ms ease-out both;
}
::view-transition-new(contenido), ::view-transition-new(panel) {
  animation: vt-entrar 130ms var(--curva-salida) 50ms both;
}
html[data-nav="adelante"]::view-transition-new(contenido) { animation-name: vt-entrar-adelante; }
html[data-nav="atras"]::view-transition-new(contenido) { animation-name: vt-entrar-atras; }
/* Cambio de pestaña: el marco no cambia (solo la pestaña marcada), así que se cambia de golpe; anima el panel. */
html[data-nav="pestana"]::view-transition-old(contenido) { animation: none; opacity: 0; }
html[data-nav="pestana"]::view-transition-new(contenido) { animation: none; }

@keyframes vt-salir { to { opacity: 0; } }
@keyframes vt-entrar { from { opacity: 0; } }
@keyframes vt-entrar-adelante { from { opacity: 0; transform: translateX(12px); } }
@keyframes vt-entrar-atras { from { opacity: 0; transform: translateX(-12px); } }
