/* ============================================================
   Dentalplus · base.css
   Reset moderado, tipografía base y accesibilidad.
   Cargar después de tokens.css y antes de componentes.css.
   ============================================================ */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

h1, h2, h3, h4, h5, h6 { margin: 0; line-height: var(--alt-apretada); letter-spacing: var(--track-titulo); font-weight: var(--peso-semi); }
h1 { font-size: var(--txt-3xl); }
h2 { font-size: var(--txt-2xl); }
h3 { font-size: var(--txt-xl); }
h4 { font-size: var(--txt-lg); }

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

/* Prosa larga: nota clínica, texto legal, consentimiento */
.prosa { line-height: var(--alt-comoda); max-width: 68ch; }

a { color: var(--primario-texto); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--primario-hover); }

img, svg, video, canvas { display: block; max-width: 100%; }

/* Los íconos heredan el color del texto: nunca se pinta un ícono a mano */
svg { fill: none; stroke: currentColor; }

/* Cifras: siempre tabulares para que las columnas alineen */
.cifra, .num, td.num, input[type="number"], time {
  font-family: var(--fuente-mono);
  font-variant-numeric: tabular-nums;
}

/* ---------- Formularios ---------- */
button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; }

/* En iOS, un input de menos de 16px provoca zoom automático al enfocar */
input, select, textarea { font-size: max(16px, var(--txt-base)); }

/* ---------- Foco ----------
   Nunca se elimina el foco: se sustituye por un anillo derivado del
   color de la clínica, visible sobre cualquier fondo. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid transparent;
  box-shadow: var(--anillo-foco);
  border-radius: var(--r-sm);
}

/* ---------- Accesibilidad ---------- */
.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;
}

.salto-contenido {
  position: absolute;
  left: var(--e-2);
  top: calc(-1 * var(--e-16));
  z-index: var(--z-toast);
  padding: var(--e-3) var(--e-4);
  border-radius: var(--r-md);
  background: var(--color-primario);
  color: var(--texto-sobre-primario);
  font-weight: var(--peso-semi);
  transition: top var(--t-media) var(--curva);
}
.salto-contenido:focus { top: var(--e-2); }

/* Área táctil mínima en todo lo accionable */
button, [role="button"], a.boton, label, summary,
input[type="checkbox"], input[type="radio"] {
  min-height: var(--toque-min);
}
/* Excepción: controles dentro de una fila densa de escritorio,
   donde el objetivo real lo da el padding de la celda */
@media (pointer: fine) {
  .denso button, .denso a.boton { min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

/* Alto contraste del sistema: se respeta y no se pelea con él */
@media (forced-colors: active) {
  .badge, .alerta, .boton { border: 1px solid CanvasText; }
}

/* ── Visibilidad ────────────────────────────────────────────────────────────
   El atributo [hidden] debe ganarle a cualquier display escrito en línea.
   Sin este !important, un elemento con style="display:flex" ignora por completo
   el atributo hidden: el estilo en línea supera la hoja del navegador, y el
   modal nunca se oculta. Aplica a modales, paneles y todo lo que se muestre
   u oculte con JS. */
[hidden] { display: none !important; }
