/* Velotecla · Base: reset ligero, tipografía y utilidades */

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

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

/* El atributo hidden siempre gana, aunque el elemento tenga display propio. */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-block-size: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  line-height: 1.5;
  /* Si la fuente aún no cargó, la de respaldo ocupa el mismo alto de letra (sin saltos) */
  font-size-adjust: from-font;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s, color .3s;
}

/* Grano de papel sobre todo el fondo (no intercepta clics) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background-image: var(--grain);
  opacity: .035;
}

a { color: var(--accent); text-underline-offset: 3px; }

button, select, textarea { font: inherit; color: inherit; }

::selection { background: var(--accent); color: var(--bg); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  vertical-align: -3px;
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
}

/* Etiqueta pequeña (nombres de métricas, títulos de sección): texto normal, sin mayúsculas
   espaciadas, que se leen como plantilla. */
.eyebrow {
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
}

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

/* "Saltar al contenido": invisible hasta que se llega con Tab; no mueve nada al aparecer */
.skip-link {
  position: fixed;
  inset-block-start: 12px;
  inset-inline-start: 12px;
  z-index: 200;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  text-decoration: none;
}

/* Botón principal = una tecla: canto inferior con profundidad y se hunde al pulsarla.
   (Es el objeto de la marca; por eso no es un rectángulo plano genérico.) */
.btn {
  --depth: 4px;
  --edge: color-mix(in srgb, var(--accent) 52%, #000);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: var(--bg);
  border: 0;
  border-radius: 8px;
  padding: 10px 18px 11px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 var(--depth) 0 var(--edge), inset 0 1px 0 rgb(255 255 255 / .35);
  transition: transform .07s ease-out, box-shadow .07s ease-out, filter .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.05); }
/* Foco del botón principal: anillo suave en vez de un segundo borde de color */
.btn:focus-visible { outline: 2px solid color-mix(in srgb, var(--text) 35%, transparent); outline-offset: 5px; }
.btn:active:not(:disabled) { transform: translateY(var(--depth)); box-shadow: 0 0 0 var(--edge), inset 0 1px 0 rgb(255 255 255 / .2); }

/* Opciones de la barra de modos */
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  padding: 6px 2px;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s;
}
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { color: var(--accent); }
.chip[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  left: 2px; right: 2px; bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}
.select-wrap select {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 4px 2px;
  color: var(--muted);
  cursor: pointer;
}
.select-wrap select:hover { color: var(--text); }
.select-wrap select option { background: var(--surface); color: var(--text); }

/* Modo enfoque: atenúa la interfaz mientras escribes.
   Los anuncios NO llevan .dimmable: nunca se atenúan (política de AdSense). */
.dimmable { transition: opacity .6s var(--ease); }
/* Atenuación suave: queda en segundo plano, pero se sigue viendo (no parece apagada) */
body.is-focus .dimmable { opacity: .4; }
body.is-focus .dimmable:hover { opacity: 1; }

/* Alto contraste de Windows: el navegador impone sus colores, así que los estados que
   dependen solo del color (tecla activa, opción elegida) reciben también un borde o subrayado. */
@media (forced-colors: active) {
  .btn { border: 1px solid ButtonText; }
  .chip[aria-pressed="true"] { text-decoration: underline; text-underline-offset: 4px; }
  .chip[aria-pressed="true"]::after { background: Highlight; }
}

/* Al pasar de una página a otra (por ejemplo, entre lecciones) el cambio es un fundido
   suave en vez de un salto. Navegadores sin soporte simplemente cambian de página como siempre. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-group(root) { animation-duration: .2s; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}
