/*
 * base.css — reset moderno, tipografia, link, focus, utilità minime.
 * Dichiara qui, una sola volta, l'ordine dei layer del design system.
 */

@layer tokens, base, components, pages;

@layer base {
  @font-face {
    font-family: "Inter Variable";
    src: url("../vendor/fonts/inter/InterVariable.2bf3d951bf9d.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
  }

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

  * {
    margin: 0;
  }

  /* `hidden` deve vincere su qualunque `display` dei componenti:
     !important in un layer precedente prevale anche sui layer successivi. */
  [hidden]:not([hidden="until-found"]) {
    display: none !important;
  }

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

  html,
  body {
    height: 100%;
  }

  body {
    font-family: var(--font-sans);
    font-size: var(--fs-16);
    line-height: var(--lh-normal);
    color: var(--color-text);
    background: var(--color-bg);
    overflow-x: hidden; /* mai scroll orizzontale di pagina */
  }

  img,
  picture,
  svg {
    display: block;
    max-width: 100%;
  }

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

  button {
    background: none;
    border: none;
    cursor: pointer;
  }

  button:disabled {
    cursor: not-allowed;
  }

  table {
    border-collapse: collapse;
  }

  fieldset {
    border: none;
    padding: 0;
    min-width: 0;
  }

  legend {
    padding: 0;
  }

  /* ---- Tipografia ---- */
  h1,
  h2,
  h3 {
    font-weight: var(--fw-semibold);
    line-height: var(--lh-tight);
    color: var(--color-text);
  }

  h1 {
    font-size: var(--fs-32);
  }

  h2 {
    font-size: var(--fs-24);
  }

  h3 {
    font-size: var(--fs-20);
  }

  small {
    font-size: var(--fs-14);
  }

  /* ---- Link ---- */
  a {
    color: var(--color-accent-text);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
  }

  a:hover {
    text-decoration-thickness: 2px;
  }

  /* ---- Focus visibile: mai coperto, offset netto, contrasto verificato
   * nei due temi in tokens.css (--color-focus-ring). ---- */
  :focus {
    outline: none;
  }

  :focus-visible {
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 2px;
    border-radius: var(--radius-control);
  }

  /* ---- Skip link ---- */
  .skip-link {
    position: absolute;
    top: 0;
    left: 0;
    z-index: var(--z-toast);
    padding: var(--space-2) var(--space-4);
    background: var(--color-surface);
    color: var(--color-text);
    border: 2px solid var(--color-accent);
    border-radius: 0 0 var(--radius-control) 0;
    transform: translateY(-100%);
    transition: transform var(--motion-fast) var(--ease-standard);
  }

  .skip-link:focus-visible {
    transform: translateY(0);
  }

  /* ---- Utilità minime ---- */
  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .tabular-nums {
    font-variant-numeric: var(--numeric-variant);
  }

  .visible-scrollbar {
    scrollbar-gutter: stable;
  }
}
