/* base.css — Óptica Croma
   Reset mínimo, tipografía base, foco, utilidades y contenedor.
   Solo usa variables de tokens.css (cargar tokens.css antes). Fuente de verdad: docs/DESIGN.md */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--color-canvas);
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  letter-spacing: var(--tracking-normal);
  text-align: left;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

/* El pie queda abajo aunque el contenido de la página sea corto (privacidad, créditos, portal) */
body {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}

body > main {
  flex: 1 0 auto;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

p,
ul,
ol,
dl,
figure,
blockquote {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

/* ---- Títulos (DESIGN.md sección 3) ---- */
h1,
h2,
h3,
h4,
.text-display,
.text-h1,
.text-h2,
.text-h3 {
  margin: 0;
  color: var(--color-ink);
  text-wrap: balance;
}

.text-display {
  font-size: var(--text-display);
  font-weight: var(--fw-extrabold);
  line-height: var(--lh-display);
  letter-spacing: var(--tracking-display);
}

h1,
.text-h1 {
  font-size: var(--text-h1);
  font-weight: var(--fw-extrabold);
  line-height: var(--lh-heading);
  letter-spacing: var(--tracking-heading);
}

h2,
.text-h2 {
  font-size: var(--text-h2);
  font-weight: var(--fw-bold);
  line-height: var(--lh-heading);
  letter-spacing: var(--tracking-heading);
}

h3,
.text-h3 {
  font-size: var(--text-h3);
  font-weight: var(--fw-bold);
  line-height: var(--lh-snug);
  letter-spacing: var(--tracking-normal);
}

h4 {
  font-size: var(--text-small);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-small);
}

.text-lead {
  font-size: var(--text-lead);
  line-height: var(--lh-body);
}

.text-small {
  font-size: var(--text-small);
  line-height: var(--lh-small);
}

.text-caption {
  font-size: var(--text-caption);
  font-weight: var(--fw-medium);
  line-height: var(--lh-caption);
  color: var(--color-ink-3);
}

.text-muted {
  color: var(--color-ink-2);
}

.num {
  font-variant-numeric: tabular-nums;
}

p,
li {
  max-width: var(--measure);
}

/* ---- Enlaces ---- */
a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: var(--space-1);
}

/* ---- Foco visible (DESIGN.md secciones 6 y 8) ---- */
:focus-visible {
  outline: var(--focus-ring) solid var(--color-focus);
  outline-offset: var(--focus-offset);
}

.on-dark :focus-visible,
.panel-dark :focus-visible {
  outline-color: var(--color-focus-on-dark);
}

/* ---- Utilidades de accesibilidad ---- */
.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill);
  background: var(--color-action);
  color: var(--color-action-text);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(0);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Sprite de íconos en línea (partes/iconos.php): no ocupa lugar. Lo incluyen todas las páginas, así que
   la regla vive acá y no en hero.css (que solo carga la portada). */
.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ---- Contenedor y ritmo vertical ---- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  padding-block: var(--section-gap);
}

.stack > * + * {
  margin-top: var(--space-4);
}

.stack-lg > * + * {
  margin-top: var(--space-6);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

/* ---- Movimiento reducido (DESIGN.md sección 5) ---- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
