/* ============================================================
   RESET & BASE — v1.0
   Normalizza comportamenti browser senza distruggere tutto.
   ============================================================ */


/* ------------------------------------------------------------
   1. BOX MODEL
   Tutti gli elementi usano border-box: padding e border
   sono inclusi nella larghezza dichiarata, non aggiunti.
   ------------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}


/* ------------------------------------------------------------
   2. ROOT & BODY
   ------------------------------------------------------------ */
html {
  /* Previene zoom automatico su iOS quando si foca un input */
  -webkit-text-size-adjust: 100%;
  /* Scroll più fluido per anchor links */
  scroll-behavior: smooth;
}

body {
  margin: 0;
  line-height: 1.5;
  /* Migliora rendering font su webkit */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/* ------------------------------------------------------------
   3. TIPOGRAFIA — reset elementi semantici
   ------------------------------------------------------------ */

/* Titoli: rimuove margini browser, dimensione ereditata dal CSS */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
}

/* Paragrafi e testi */
p {
  margin: 0;
}

/* Rimuove stili di default da strong/b (li ri-applicheremo con classi) */
b, strong {
  font-weight: bolder;
}

/* Small, sub, sup */
small {
  font-size: 80%;
}

sub, sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}
sub { bottom: -0.25em; }
sup { top: -0.5em; }

/* Link: rimuove underline di default, colore ereditato */
a {
  color: inherit;
  text-decoration: none;
}

/* Abbreviazioni */
abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

/* Codice: font monospace normalizzato */
code, kbd, samp, pre {
  font-family: ui-monospace, 'Courier New', monospace;
  font-size: 1em;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* Blockquote e citazioni */
blockquote, figure {
  margin: 0;
}

/* hr: linea sottile e controllata */
hr {
  border: none;
  border-top: 1px solid currentColor;
  height: 0;
  margin: 0;
  opacity: 0.2;
}


/* ------------------------------------------------------------
   4. LISTE
   Rimuove bullet/numeri e spaziature di default.
   Si ri-applicano esplicitamente dove servono con classi.
   ------------------------------------------------------------ */
ul, ol {
  list-style: none;
  margin: 0;
  padding: 0;
}


/* ------------------------------------------------------------
   5. IMMAGINI E MEDIA
   ------------------------------------------------------------ */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
  border-style: none; /* IE compat */
}

/* SVG inline: non eredita colori strani */
svg {
  overflow: hidden;
}


/* ------------------------------------------------------------
   6. FORM ELEMENTS
   I form hanno comportamenti browser molto difformi.
   ------------------------------------------------------------ */
button,
input,
optgroup,
select,
textarea {
  font-family: inherit;
  font-size: 100%;
  line-height: 1.5;
  margin: 0;
  /* Rimuove stili nativi dove possibile */
  -webkit-appearance: none;
  appearance: none;
}

button,
[type="button"],
[type="reset"],
[type="submit"] {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  /* fix cursor su iOS */
  -webkit-appearance: button;
}

button:disabled,
[disabled] {
  cursor: not-allowed;
}

textarea {
  resize: vertical; /* solo verticale, non diagonale */
  overflow: auto;
}

/* Rimuove outline di default (va ri-aggiunto con focus-visible) */
:focus {
  outline: none;
}

/* Focus accessibile: visibile solo con tastiera/screen reader */
:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Checkbox e radio: dimensioni coerenti */
[type="checkbox"],
[type="radio"] {
  -webkit-appearance: auto;
  appearance: auto;
  padding: 0;
}

/* Rimuove frecce dagli input numerici */
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
  height: auto;
}

/* Search input */
[type="search"] {
  -webkit-appearance: textfield;
  outline-offset: -2px;
}
[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

/* File input */
::-webkit-file-upload-button {
  -webkit-appearance: button;
  font: inherit;
}

/* Select */
select {
  background-color: transparent;
}

/* Fieldset e legend */
fieldset {
  margin: 0;
  padding: 0;
  border: none;
}

legend {
  padding: 0;
}


/* ------------------------------------------------------------
   7. TABELLE
   ------------------------------------------------------------ */
table {
  border-collapse: collapse;
  border-spacing: 0;
}

th {
  text-align: left;
  font-weight: inherit;
}

td, th {
  padding: 0;
  vertical-align: top;
}


/* ------------------------------------------------------------
   8. ACCESSIBILITÀ E UTILITÀ
   ------------------------------------------------------------ */

/* Elementi nascosti visivamente ma accessibili agli screen reader */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Riduce animazioni per chi lo preferisce */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}