/* ============================================================
   ZUNQIO · Reset moderno + tipografía base + accesibilidad
   ============================================================ */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--navbar-h) + var(--sp-4));
  -moz-tab-size: 2;
  tab-size: 2;
}

body {
  min-height: var(--vh-dyn);
  background-color: var(--bg-root);
  background-image: var(--gradient-hero);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  font-weight: var(--fw-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-synthesis-weight: none;
  overflow-x: hidden;
  transition: background-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
}

body.is-scroll-locked {
  overflow: hidden;
  touch-action: none;
}

/* ---------- Tipografía ---------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: -0.022em;
  color: var(--text-primary);
  text-wrap: balance;
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }

p { text-wrap: pretty; }

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}

a.link {
  color: var(--text-brand);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--text-brand) 45%, transparent);
}
a.link:hover { text-decoration-color: currentColor; }

strong, b { font-weight: var(--fw-semibold); color: var(--text-primary); }
small { font-size: var(--fs-xs); }

ul, ol { list-style: none; }
ul.bullets { list-style: disc; padding-left: 1.25em; }
ul.bullets li { margin-bottom: var(--sp-2); color: var(--text-secondary); }

code, kbd, pre { font-family: var(--font-mono); font-size: 0.92em; }

kbd {
  display: inline-block;
  min-width: 1.9em;
  padding: 0.15em 0.5em;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-xs);
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-align: center;
  line-height: 1.5;
}

hr {
  border: 0;
  height: 1px;
  background: var(--border-subtle);
  margin: var(--sp-6) 0;
}

/* ---------- Media ---------- */
img, svg, video, canvas, picture {
  display: block;
  max-width: 100%;
}
img { height: auto; border-style: none; }
img[data-broken="true"] { visibility: hidden; }

/* ---------- Formularios ---------- */
button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
}
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; }
textarea { resize: vertical; }

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

::placeholder { color: var(--text-faint); opacity: 1; }

/* ---------- Selección ---------- */
::selection {
  background: color-mix(in srgb, var(--brand-500) 45%, transparent);
  color: #fff;
}

/* ---------- Foco visible (accesibilidad) ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--brand-400);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ---------- Barras de scroll ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

/* ---------- Utilidades de accesibilidad ---------- */
.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;
}

.skip-link {
  position: fixed;
  top: var(--sp-3);
  left: 50%;
  translate: -50% -200%;
  z-index: var(--z-max);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-pill);
  background: var(--brand-500);
  color: #fff;
  font-weight: var(--fw-semibold);
  box-shadow: var(--shadow-lg);
  transition: translate var(--dur-base) var(--ease-spring);
}
.skip-link:focus-visible { translate: -50% 0; }

/* ---------- Utilidades genéricas ---------- */
.text-gradient {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.no-scrollbar { scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.hidden { display: none !important; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.gap-8 { gap: var(--sp-8); }
.grow { flex: 1 1 auto; min-width: 0; }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
/* Lo mismo si se elige «Movimiento: reducido» en ZUNQIO (core/prefs.js pone
   data-motion="reduce"). Antes esa opción sólo paraba los cosméticos: los
   esqueletos de carga, las entradas y los pulsos seguían moviéndose. */
:root[data-motion="reduce"] { scroll-behavior: auto; }
:root[data-motion="reduce"] *,
:root[data-motion="reduce"] *::before,
:root[data-motion="reduce"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* ---------- Impresión ---------- */
@media print {
  body { background: #fff; color: #000; }
  .app-navbar, .app-sidebar, .app-footer, .ad-banner { display: none !important; }
}

/* ---------- Contenido sin JavaScript ----------
   Lo que hay dentro de <noscript> lo escribe tools/build-seo.mjs con los
   datos reales de cada página: el mismo título, la misma descripción y los
   mismos enlaces que pinta la aplicación. Sin estas reglas se vería como
   texto suelto sobre el fondo, pegado al borde de la pantalla. */
.noscript-fallback {
  max-width: 72ch;
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-5) var(--sp-10);
  line-height: 1.7;
}
.noscript-fallback h1 { font-size: var(--fs-3xl); margin-bottom: var(--sp-4); }
.noscript-fallback h2 { font-size: var(--fs-xl); margin: var(--sp-8) 0 var(--sp-3); }
.noscript-fallback h3 { font-size: var(--fs-base); margin: var(--sp-5) 0 var(--sp-2); }
.noscript-fallback p { margin-bottom: var(--sp-4); color: var(--text-secondary); }
.noscript-fallback ul { margin: 0 0 var(--sp-4) var(--sp-6); }
.noscript-fallback li { margin-bottom: var(--sp-2); color: var(--text-secondary); }
.noscript-fallback a { color: var(--text-brand); }

/* El texto de cada página también va escrito dentro de <main data-prerender>
   (lo genera tools/build-seo.mjs). Se ve hasta que arranca la aplicación y
   ésta pone la vista real en su lugar. Los enlaces de abajo son los del pie,
   que la aplicación pinta con JavaScript. */
.prerender__nav {
  max-width: 72ch;
  margin: var(--sp-8) auto 0;
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--fs-sm);
}
.prerender__nav a { color: var(--text-brand); }
