/*
 * Base: fuente, reset, elementos HTML, foco, selección, barras de desplazamiento.
 * Sin valores literales de color, sombra, radio, duración ni tamaño de fuente (ver tokens.css).
 */

/* Inter variable autoalojada (OFL), eje wght 100–900. Fuera de @layer: @font-face no se ordena */
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter/inter-latin-wght-normal.woff2') format('woff2-variations'),
       url('../fonts/inter/inter-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
                 U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
                 U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter/inter-latin-ext-wght-normal.woff2') format('woff2-variations'),
       url('../fonts/inter/inter-latin-ext-wght-normal.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF,
                 U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; tab-size: 4; }
  body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ol, ul, fieldset, legend, pre { margin: 0; }
  ol[class], ul[class] { list-style: none; padding: 0; }
  fieldset { border: 0; padding: 0; min-width: 0; }
  legend { padding: 0; }
  img, svg, video, canvas, picture { display: block; max-width: 100%; }
  img, video { height: auto; }
  input, button, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
  button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
  button:disabled { cursor: not-allowed; }
  a { color: inherit; }
  table { border-collapse: collapse; border-spacing: 0; }
  textarea { resize: vertical; }
  dialog { padding: 0; border: 0; color: inherit; max-width: none; max-height: none; }
  summary { cursor: pointer; }
  summary::-webkit-details-marker { display: none; }
  hr { border: 0; height: 0; margin: 0; }
  [tabindex="-1"]:focus:not(:focus-visible) { outline: none; }
}

@layer base {
  html {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    color: var(--text-primary);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'calt' 1;
    text-rendering: optimizeLegibility;
    scroll-padding-top: calc(var(--topbar-h) + var(--sp-6));
  }

  @media (prefers-reduced-motion: no-preference) {
    html:focus-within { scroll-behavior: smooth; }
  }

  body {
    min-height: 100vh;
    min-height: 100dvh;
    font: var(--type-body);
    color: var(--text-primary);
    background: var(--bg);
    overflow-wrap: break-word;
  }

  h1, h2, h3, h4 { text-wrap: balance; color: var(--text-primary); }
  h1 { font: var(--type-h1); letter-spacing: var(--tr-2xl); }
  h2 { font: var(--type-h2); letter-spacing: var(--tr-xl); }
  h3 { font: var(--type-h3); letter-spacing: var(--tr-lg); }
  h4 { font: var(--type-h4); letter-spacing: var(--tr-md); }
  p, li, dd, figcaption, .c-field__help, .c-empty__text { text-wrap: pretty; }

  strong, b { font-weight: var(--fw-semibold); }
  small { font-size: var(--fs-xs); line-height: var(--lh-xs); }

  a { text-decoration-thickness: 1px; text-underline-offset: 2px; }

  code, kbd, samp, pre { font-family: var(--font-mono); }

  /* Teclas: fondo sutil, borde inferior de 2 px, mono pequeña (§6.39) */
  kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--kbd-h);
    height: var(--kbd-h);
    padding: 0 var(--sp-1-5);
    font: var(--fw-medium) var(--fs-2xs)/1 var(--font-mono);
    letter-spacing: var(--tr-2xs);
    color: var(--text-secondary);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: var(--r-xs);
    white-space: nowrap;
  }

  mark {
    color: inherit;
    background: var(--warning-subtle);
    box-shadow: var(--mark-underline);
    border-radius: var(--r-xs);
    padding: 0 var(--sp-px);
  }

  ::selection { background: var(--selection); color: var(--text-primary); }

  /* Foco: el mismo anillo en todo. Nunca outline:none sin reemplazo */
  :focus-visible {
    outline: 2px solid transparent;
    outline-offset: 2px;
    box-shadow: var(--focus-ring);
    border-radius: var(--r-xs);
  }
  /* Una fila de tabla enfocada (la primera fila nueva de «Ver más»): en un <tr> el box-shadow no se pinta */
  tr:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; box-shadow: none; }
  /* Modo de alto contraste de Windows: el box-shadow no se pinta, el outline sí */
  @media (forced-colors: active) {
    :focus-visible, tr:focus-visible { outline: 2px solid CanvasText; }
  }

  /* Iconos del sprite Lucide: heredan el color del texto */
  .icon {
    width: var(--icon-md);
    height: var(--icon-md);
    flex: none;
    stroke-width: var(--icon-stroke);
    vertical-align: -0.2em;
    display: inline-block;
  }

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

  ::marker { color: var(--text-tertiary); }

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

  hr { border-top: 1px solid var(--border-subtle); }

  /* Contenedores con scroll interno no arrastran la página */
  dialog { overscroll-behavior: contain; }
}
