/* ==========================================================================
   a11y.css — base accessibile SerpTune (EAA / EN 301 549 / WCAG 2.2 AA, spec §6)
   - contrasto ≥ 4.5:1, focus visibile, reduced motion, no info solo-colore
   ========================================================================== */

:root {
  --text: #1a1a1a;          /* su bianco ≈ 16:1  */
  --muted: #4a4a4a;         /* su bianco ≈ 8.9:1 */
  --bg: #ffffff;
  --accent: #0b5cad;        /* su bianco ≈ 5.5:1 */
  --accent-contrast: #ffffff;
  --error: #b3261e;         /* su bianco ≈ 5.9:1 */
  --success: #0f6b3f;       /* su bianco ≈ 5.3:1 */
  --border: #6b6b6b;        /* bordi campi, contrasto non-testo ≥ 3:1 */
  --focus: #0b5cad;
}

*, *::before, *::after { box-sizing: border-box; }
body { color: var(--text); background: var(--bg); font: 1rem/1.6 system-ui, sans-serif; }

/* --- Skip link (nel layout: <a class="skip-link" href="#main">) ---------- */
.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-contrast);
  padding: .6rem 1rem; z-index: 1000; border-radius: 0 0 4px 0;
}
.skip-link:focus { left: 0; }

/* --- Contenuto solo per 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;
}

/* --- Focus SEMPRE visibile (2.4.7 / 2.4.11) ------------------------------ */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}
/* non rimuovere mai l'outline senza un sostituto visibile */

/* --- Form ---------------------------------------------------------------- */
.field { margin-block: 1.1rem; display: flex; flex-direction: column; gap: .35rem; }
label { font-weight: 600; }
.req { color: var(--error); }          /* asterisco: RIDONDATO da testo "(obbligatorio)" */
.req-word { font-weight: 600; }

input[type="text"], input[type="email"], textarea {
  font: inherit; padding: .55rem .7rem;
  border: 2px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--text); width: 100%; max-width: 40rem;
}
textarea { resize: vertical; }

/* stato di errore: bordo + testo + icona (NON solo colore, 1.4.1) */
[aria-invalid="true"] { border-color: var(--error); }
.error {
  color: var(--error); font-weight: 600; display: flex; align-items: flex-start; gap: .35rem;
}
.error:not([hidden])::before { content: "\2715"; font-weight: 700; } /* ✕ */

.field-hint, .form-hint { color: var(--muted); font-size: .95rem; }

/* honeypot: fuori dal flusso, invisibile a utenti e AT */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* --- Regione di stato ---------------------------------------------------- */
.form-status:empty { display: none; }
.form-status { margin-block: 1rem; padding: .7rem 1rem; border-radius: 6px; font-weight: 600; }
.form-status.is-error   { background: #fce8e6; color: var(--error);   border: 1px solid var(--error); }
.form-status.is-success { background: #e6f4ec; color: var(--success); border: 1px solid var(--success); }

/* --- Bottone ------------------------------------------------------------- */
.btn-primary {
  font: inherit; font-weight: 700; cursor: pointer;
  background: var(--accent); color: var(--accent-contrast);
  border: 2px solid transparent; border-radius: 6px; padding: .6rem 1.3rem;
  transition: background .15s ease;
}
.btn-primary:hover { background: #094a8c; }
.btn-primary[aria-busy="true"] { opacity: .7; cursor: progress; }

/* target touch ≥ 24×24 (2.5.8) */
button, input, textarea, .cf-turnstile { min-height: 44px; }

/* --- Grafici accessibili (spec §6): la <details> tabella dati è l'alternativa */
.chart figure { margin: 0; }
.chart svg { max-width: 100%; height: auto; }
.chart table { border-collapse: collapse; margin-top: .8rem; }
.chart th, .chart td { border: 1px solid var(--border); padding: .35rem .6rem; text-align: left; }
.chart caption { text-align: left; font-weight: 600; margin-bottom: .4rem; }

/* --- Riduzione del movimento (2.3.3) ------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}
