/* ============================================================
   BASE · Reset moderno + estrategia de NITIDEZ tipográfica
   ============================================================ */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
  text-size-adjust: 100%;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: var(--weight-regular);
  letter-spacing: var(--tracking-body);

  /* ── NITIDEZ SOBRE BLANCO ──────────────────────────────
     Texto oscuro sobre fondo claro: se DEJA el renderizado
     subpíxel del sistema (el más nítido). NO se fuerza
     -webkit-font-smoothing: antialiased aquí, porque adelgaza
     el trazo y reduce la percepción de definición.          */
  text-rendering: optimizeLegibility;
  font-synthesis-weight: none;
  font-optical-sizing: auto;
  font-variant-numeric: tabular-nums lining-nums;
}

/* ── NITIDEZ SOBRE OSCURO ────────────────────────────────
   Blanco sobre navy sí "sangra" (halo). Ahí, y solo ahí,
   se activa el suavizado en escala de grises y se baja
   medio peso para compensar el engrosamiento óptico.      */
.on-dark, .section--invert, [data-surface="invert"] {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg, video, canvas { display: block; max-width: 100%; height: auto; }
/* Solo se hereda el color de relleno cuando el SVG no declara el suyo.
   Una regla global pisaba el fill="none" de los iconos de trazo (las reglas
   CSS ganan a los atributos de presentación) y los rellenaba por completo. */
svg:not([fill]) { fill: currentColor; }

h1, h2, h3, h4, h5, h6 { margin: 0; text-wrap: balance; }
p, ul, ol, dl, figure, blockquote, pre { margin: 0; }
p { text-wrap: pretty; }

h1 { font-family: var(--font-display); font-size: var(--fs-h1);
     line-height: var(--lh-tight); letter-spacing: var(--tracking-display);
     font-weight: var(--weight-bold); color: var(--ink-strong); }
h2 { font-family: var(--font-display); font-size: var(--fs-h2);
     line-height: var(--lh-snug); letter-spacing: var(--tracking-head);
     font-weight: var(--weight-bold); color: var(--ink-strong); }
h3 { font-size: var(--fs-h3); line-height: var(--lh-snug);
     letter-spacing: var(--tracking-head); font-weight: var(--weight-semi); }
h4 { font-size: var(--fs-h4); line-height: 1.35;
     font-weight: var(--weight-semi); }

a { color: var(--navy-600); text-decoration: none;
    text-underline-offset: 0.22em; text-decoration-thickness: 1.5px; }
a:hover { color: var(--accent-ink); text-decoration: underline; }
.on-dark a, .section--invert a { color: var(--ink-invert); }
.on-dark a:hover, .section--invert a:hover { color: var(--accent-on-dark); }

strong, b { font-weight: var(--weight-semi); color: var(--ink-strong); }
.on-dark strong, .section--invert strong { color: var(--white); }

small { font-size: var(--fs-sm); }

ul, ol { padding-left: 1.15em; }
li + li { margin-top: var(--sp-2); }
li::marker { color: var(--accent); }

code, kbd, pre, samp { font-family: var(--font-mono); font-size: 0.9em; }
code { background: var(--navy-050); border: var(--border);
       border-radius: var(--r-xs); padding: 0.12em 0.4em; color: var(--navy-800); }

hr { border: 0; border-top: var(--border); margin: var(--sp-8) 0; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }

::selection { background: var(--selection-bg); color: var(--ink-strong); }
.on-dark ::selection, .section--invert ::selection {
  background: var(--accent-on-dark); color: var(--navy-950); }

/* ── FOCO VISIBLE: obligatorio y con contraste ─────────── */
:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
.on-dark :focus-visible, .section--invert :focus-visible {
  outline-color: var(--white);
}
:focus:not(:focus-visible) { outline: none; }

/* ── Utilidades de accesibilidad ───────────────────────── */
.visually-hidden {
  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;
}
.skip-link {
  position: absolute; top: 0; left: var(--sp-4);
  transform: translateY(-120%);
  background: var(--navy-700); color: var(--white);
  padding: var(--sp-3) var(--sp-5); border-radius: 0 0 var(--r-md) var(--r-md);
  z-index: var(--z-toast); font-weight: var(--weight-semi);
  transition: transform var(--dur-base) var(--ease-out);
}
.skip-link:focus { transform: translateY(0); }

/* ── Contraste alto del sistema operativo ──────────────── */
@media (prefers-contrast: more) {
  :root {
    --ink-muted:  #2C3E5C;
    --ink-subtle: #3A4C6B;
    --line: #9FB0C9;
    --line-strong: #6B7C97;
  }
  .btn, .card, .chip { border-width: 2px; }
}

/* ── Impresión ─────────────────────────────────────────── */
@media print {
  .site-header, .site-footer, .adaptive-bar, .btn { display: none !important; }
  body { color: #000; font-size: 11pt; }
  a::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555; }
}
