/* ═══════════════════════════════════════════════════════════════════════
   BASE — reinicio, tipografía y accesibilidad.
   ═══════════════════════════════════════════════════════════════════════ */

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

  html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + var(--space-s));
    -webkit-tap-highlight-color: transparent;
  }

  @media (prefers-reduced-motion: reduce) {
    html {
      scroll-behavior: auto;
    }
  }

  body {
    min-height: 100svh;
    background: var(--soot);
    color: var(--bone);
    font-family: var(--font-ui);
    font-size: var(--step-0);
    line-height: 1.6;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
  }

  /* ── Textura de fondo ────────────────────────────────────────────────
     Una luz de sodio arriba y un grano fino encima: da profundidad sin
     pedir ni una sola imagen al servidor. */
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: var(--z-grain);
    pointer-events: none;
    background:
      radial-gradient(
        120% 70% at 50% -10%,
        color-mix(in oklab, var(--sodium) 9%, transparent),
        transparent 60%
      ),
      repeating-linear-gradient(
        0deg,
        rgb(255 255 255 / 0.014) 0 1px,
        transparent 1px 3px
      );
    mix-blend-mode: screen;
  }

  /* ── Titulares ───────────────────────────────────────────────────── */
  h1,
  h2,
  h3,
  h4 {
    font-family: var(--font-display);
    font-weight: 900;
    line-height: 0.95;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    text-wrap: balance;
  }

  h1 {
    font-size: var(--step-4);
  }
  h2 {
    font-size: var(--step-3);
  }
  h3 {
    font-size: var(--step-2);
  }
  h4 {
    font-size: var(--step-1);
  }

  p {
    text-wrap: pretty;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  /* Enlaces dentro de texto corrido: subrayado claro y legible. */
  .prose a,
  a.link {
    color: var(--sodium);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: color var(--dur-fast);
  }
  .prose a:hover,
  a.link:hover {
    color: var(--sodium-hi);
  }

  ul,
  ol {
    list-style: none;
  }
  .prose ul,
  .prose ol {
    list-style: revert;
    padding-left: 1.35em;
  }
  .prose li + li {
    margin-top: 0.35em;
  }
  .prose > * + * {
    margin-top: var(--space-s);
  }
  .prose h2,
  .prose h3 {
    margin-top: var(--space-l);
  }

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

  button,
  input,
  select,
  textarea {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
  }
  button {
    cursor: pointer;
  }

  strong,
  b {
    font-weight: 700;
    color: var(--bone);
  }

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

  kbd {
    display: inline-block;
    padding: 0.15em 0.45em;
    border: 1px solid var(--edge-hi);
    border-bottom-width: 2px;
    border-radius: var(--radius);
    background: var(--pitch);
    color: var(--bone);
    font-size: 0.8em;
    line-height: 1.4;
    white-space: nowrap;
  }

  hr {
    height: 1px;
    border: 0;
    background: var(--edge);
  }

  /* ── Foco: siempre visible, nunca tapado ─────────────────────────── */
  :focus-visible {
    outline: 2px solid var(--sodium);
    outline-offset: 3px;
    border-radius: var(--radius);
  }
  :focus:not(:focus-visible) {
    outline: none;
  }

  /* ── Selección ───────────────────────────────────────────────────── */
  ::selection {
    background: var(--sodium);
    color: var(--void);
  }

  /* ── Barra de desplazamiento ─────────────────────────────────────── */
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--edge-hi) transparent;
  }
  ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }
  ::-webkit-scrollbar-track {
    background: var(--void);
  }
  ::-webkit-scrollbar-thumb {
    background: var(--edge);
    border: 2px solid var(--void);
  }
  ::-webkit-scrollbar-thumb:hover {
    background: var(--edge-hi);
  }

  /* ── Transición entre páginas (navegadores que la soportan) ──────── */
  @view-transition {
    navigation: auto;
  }
}

@layer utilities {
  /* Sólo para lectores de pantalla. */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  /* Salta al contenido: aparece al tabular. */
  .skip-link {
    position: absolute;
    top: var(--space-2xs);
    left: var(--space-2xs);
    z-index: calc(var(--z-header) + 1);
    padding: var(--space-2xs) var(--space-s);
    background: var(--sodium);
    color: var(--void);
    font-weight: 700;
    transform: translateY(-200%);
    transition: transform var(--dur) var(--ease-out);
  }
  .skip-link:focus {
    transform: none;
  }

  .stack > * + * {
    margin-top: var(--flow, var(--space-s));
  }
  .center-text {
    text-align: center;
  }
  [hidden] {
    display: none !important;
  }
}
