/* ==========================================================================
   Base global: reset, tipografía, enlaces, foco y utilidades
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 12px);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh);
  letter-spacing: var(--letter);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}
img {
  height: auto;
}
/* Tamaño por defecto de los iconos cuando el contexto no define otro. */
svg.icon:not([width]) {
  width: 20px;
  height: 20px;
  flex: none;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 var(--sp-3);
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-wrap: balance;
}
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

p {
  margin: 0 0 var(--sp-3);
  text-wrap: pretty;
}

a {
  color: var(--brand-text);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}
a:hover {
  color: var(--brand-strong);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--sp-6) 0;
}

code,
kbd,
pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
}
kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.78em;
  line-height: 1.5;
}

::selection {
  background: color-mix(in srgb, var(--brand) 28%, transparent);
}

/* Foco visible y consistente para navegación con teclado */
:focus {
  outline: none;
}
:focus-visible {
  outline: 2.5px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -100px;
  z-index: 1000;
  padding: var(--sp-3) var(--sp-4);
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--r-sm);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--dur-2) var(--ease);
}
.skip-link:focus {
  top: var(--sp-4);
  color: var(--bg);
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

/* Barras de desplazamiento discretas */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: content-box;
}

/* Utilidades */
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.strong { font-weight: 700; }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.center { text-align: center; }
.right { text-align: right; }
.display { font-family: var(--font-display); }
.tabular { font-variant-numeric: tabular-nums; }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--sp-2); }
.row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mb-4 { margin-bottom: var(--sp-4); }
.w-full { width: 100%; }

/* Contenido Markdown (respuestas de IA, notas) */
.prose {
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.prose > :last-child { margin-bottom: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { margin-top: var(--sp-5); }
.prose h1 { font-size: var(--fs-xl); }
.prose h2 { font-size: var(--fs-lg); }
.prose h3 { font-size: var(--fs-md); }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 var(--sp-3); }
.prose li { margin-bottom: 0.3em; }
.prose code {
  padding: 0.12em 0.4em;
  background: var(--surface-2);
  border-radius: 6px;
}
.prose pre {
  overflow-x: auto;
  padding: var(--sp-4);
  background: #1d241d;
  color: #e8f5e9;
  border-radius: var(--r-md);
  margin: 0 0 var(--sp-3);
}
.prose pre code { background: none; padding: 0; color: inherit; }
.prose blockquote {
  margin: 0 0 var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  border-left: 3px solid var(--brand);
  background: var(--brand-soft);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.prose table { border-collapse: collapse; margin-bottom: var(--sp-3); display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
