/* ============================================================
   InfoComuni · Accessibility & Contrast Pass v1
   ----------------------------------------------------------------
   Allinea il portale alle Linee guida AGID + WCAG 2.1 AA
   - Contrasti testo ≥ 4.5:1 (body) / ≥ 3:1 (large)
   - Focus-visible con outline gold ≥ 3px su tutti gli interattivi
   - Link sotto-lineati nei contenuti (color alone non basta — WCAG 1.4.1)
   - Skip-link visibile al tab
   - Stati hover/active/disabled distinguibili
   Carica DOPO ic-home-polish.css per ridefinire gli stili problematici.
   ============================================================ */

/* ============= 1. PALETTE ACCESSIBILE ============= */
/* Variabili che sostituiscono i token con varianti AA-compliant.
   Il gold #c89b3c ha contrasto 2.6:1 su cream → SOLO per icone/bordi/sfondi.
   Per testo gold serve #8b6914 o più scuro (4.6:1 su cream). */
:root {
  --ic-a11y-text:        #1a1f2c;   /* body — 13.5:1 su cream ✓ */
  --ic-a11y-text-muted:  #49566c;   /* secondary — 6.4:1 su cream ✓ */
  --ic-a11y-text-faint:  #5a6478;   /* tertiary — 5.0:1 su cream ✓ AA */
  --ic-a11y-link:        #0b2340;   /* link default — 14.8:1 ✓ */
  --ic-a11y-link-hover:  #8b6914;   /* link hover — 4.7:1 ✓ */
  --ic-a11y-gold-text:   #8b6914;   /* gold leggibile come testo */
  --ic-a11y-gold-accent: #c89b3c;   /* gold solo per icone/sfondi */
  --ic-a11y-focus:       #ffcc33;   /* focus ring */
  --ic-a11y-focus-dark:  #0b2340;   /* focus ring contorno (su sfondi gialli) */
  --ic-a11y-bg-light:    #fbf9f4;
  --ic-a11y-bg-white:    #ffffff;
}

/* ============= 2. FOCUS VISIBILE OVUNQUE ============= */
:focus { outline: none; }  /* reset stile browser */
:focus-visible {
  outline: 3px solid var(--ic-a11y-focus) !important;
  outline-offset: 2px !important;
  border-radius: 3px;
}
/* Su sfondi gialli/cream il giallo non si vede: doppio bordo */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  box-shadow: 0 0 0 3px var(--ic-a11y-focus), 0 0 0 5px var(--ic-a11y-focus-dark) !important;
}

/* ============= 3. SKIP LINK VISIBILE AL FOCUS ============= */
.skip-link {
  position: absolute !important;
  top: 8px !important;
  left: 8px !important;
  padding: 12px 18px !important;
  background: var(--ic-a11y-link) !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  text-decoration: underline !important;
  border-radius: 4px !important;
  z-index: 100000 !important;
  transform: translateY(-200%);
  transition: transform .2s;
}
.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
}

/* ============= 4. SEARCH BAR CONTRASTO ============= */
/* Dark hero: il placeholder bianco a 0.45 opacity → 2.5:1, scarso.
   Alza l'opacity per arrivare ad almeno 4.5:1. */
body #ic-search-bar input[type="search"]::placeholder {
  color: rgba(255, 255, 255, 0.78) !important;  /* ≥ 4.5:1 su navy */
  font-style: normal !important;
  opacity: 1 !important;
}
html.force-light body #ic-search-bar input[type="search"]::placeholder {
  color: #5a6478 !important;  /* AA su white */
}
/* Caption sotto search */
body #ic-search-bar > div + div {
  color: var(--ic-a11y-text-faint) !important;
}
html.force-dark body #ic-search-bar > div + div {
  color: rgba(255, 255, 255, 0.85) !important;  /* AA su navy */
}

/* ============= 5. PROV CARDS (home) — meta leggibile ============= */
body #provPills .prov-pill-wrap > summary.prov-pill {
  color: var(--ic-a11y-text) !important;
  border-color: rgba(11, 35, 64, 0.18) !important;
}
body #provPills .ic-prov-meta {
  color: var(--ic-a11y-text-muted) !important;  /* solid → 6.4:1 ✓ */
  font-size: 11.5px !important;
}
/* Badge count: testo navy solido su beige solido (override -webkit-text-fill-color
   impostato da ic-kiosk-skin.css che altrimenti vincerebbe sul color) */
html body #provPills .prov-pill-wrap > summary.prov-pill > small,
html.force-light body #provPills .prov-pill-wrap > summary.prov-pill > small {
  background: #f3efe5 !important;
  color: var(--ic-a11y-text) !important;
  -webkit-text-fill-color: var(--ic-a11y-text) !important;  /* 13.5:1 ✓ */
  border: 1px solid #d4cbb3 !important;
  font-weight: 700 !important;
  font-family: 'Inter', system-ui, sans-serif !important;
}

/* ============= 6. CARDS "ARGOMENTI" (Cosa cerchi oggi) ============= */
.ic-v3-arg-card,
.ic-v3-arg-card__h,
.ic-v3-arg-card__d {
  color: var(--ic-a11y-text) !important;
}
.ic-v3-arg-card__d {
  color: var(--ic-a11y-text-muted) !important;
  font-size: 14px !important;
  line-height: 1.45 !important;
}

/* ============= 7. LINK SOTTOLINEATI NEI CONTENUTI ============= */
/* WCAG 1.4.1: il colore non è l'unico mezzo per identificare i link.
   Sotto-linea sui link nel corpo testo (non sui menu/card). */
main p a,
main li a,
main .ic-v3-section p a,
.footer-bottom a,
.legal-links a,
.legal-links button.ic-cc-footer-link {
  text-decoration: underline !important;
  text-underline-offset: 2px !important;
  text-decoration-thickness: 1px !important;
}
main p a:hover,
main li a:hover,
.legal-links a:hover,
.legal-links button.ic-cc-footer-link:hover {
  text-decoration-thickness: 2px !important;
}

/* ============= 8. FOOTER LEGGIBILITÀ ============= */
/* Footer scuro: testo bianco a opacity bassa → spesso < 4.5:1. Alza. */
.site-footer-v2,
.site-footer {
  color: rgba(255, 255, 255, 0.92) !important;  /* ≥ 14:1 ✓ */
}
.site-footer-v2 .brand-sub,
.site-footer-v2 .contact-col-title,
.site-footer-v2 .links-group-title,
.site-footer .sf-desc,
.site-footer .sf-net,
.site-footer .links-group-title {
  color: rgba(255, 255, 255, 0.85) !important;
}
.site-footer-v2 a:not(.brand-cta):not(.sf-whatsapp-btn),
.site-footer a:not(.brand-cta):not(.sf-whatsapp-btn) {
  color: rgba(255, 255, 255, 0.88) !important;
}
.site-footer-v2 a:not(.brand-cta):not(.sf-whatsapp-btn):hover,
.site-footer a:not(.brand-cta):not(.sf-whatsapp-btn):hover {
  color: var(--ic-a11y-focus) !important;
}
.site-footer-v2 .legal-links a,
.site-footer-v2 .legal-links .ic-cc-footer-link,
.site-footer .legal-links a,
.site-footer .legal-links .ic-cc-footer-link,
.site-footer-v2 .copyright {
  color: rgba(255, 255, 255, 0.85) !important;
}

/* ============= 9. BOTTONI / CTA ============= */
.brand-cta,
.sf-cta-block a {
  background: var(--ic-a11y-focus) !important;   /* gold pieno */
  color: var(--ic-a11y-link) !important;          /* navy su gold = 12.6:1 ✓ */
  font-weight: 700 !important;
}
.brand-cta:hover,
.sf-cta-block a:hover {
  background: #ffd755 !important;
}

/* ============= 10. TARGET TOUCH (≥ 44x44 px — WCAG 2.5.5) ============= */
.bottom-nav__item,
.ic-appbar__item,
nav a,
.legal-links a,
.legal-links button.ic-cc-footer-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.legal-links a,
.legal-links button.ic-cc-footer-link {
  padding: 10px 8px !important;
}

/* ============= 11. ARIA / DECORATIVE ============= */
/* Icone decorative: mai contenuto significativo nelle pseudo */
[aria-hidden="true"] { pointer-events: none; }

/* ============= 12. PREFERS-REDUCED-MOTION ============= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============= 13. TOPBAR · 11 lingue + accessibilità ============= */
.ic-v3-topbar__nav {
  display: flex !important;
  align-items: center !important;
  gap: 16px !important;
}
.ic-v3-topbar__langs {
  display: flex !important;
  align-items: center !important;
  gap: 0 !important;
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}
.ic-v3-topbar__langs li { margin: 0 !important; padding: 0 !important; list-style: none !important; }
.ic-v3-topbar__langs button {
  background: transparent !important;
  border: none !important;
  color: rgba(255, 255, 255, 0.78) !important;
  font: inherit !important;
  font-size: 11.5px !important;
  font-weight: 600 !important;
  letter-spacing: 0.06em !important;
  padding: 4px 8px !important;
  margin: 0 !important;
  cursor: pointer !important;
  border-radius: 3px !important;
  transition: color .15s, background .15s !important;
  min-height: auto !important;
  line-height: 1.4 !important;
  text-transform: uppercase !important;
}
.ic-v3-topbar__langs li + li button {
  border-left: 1px solid rgba(255, 255, 255, 0.18) !important;
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
}
.ic-v3-topbar__langs li:has(+ li) button {
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
}
.ic-v3-topbar__langs button:hover {
  color: var(--ic-a11y-focus) !important;
  background: rgba(255, 204, 51, 0.10) !important;
}
.ic-v3-topbar__langs button[aria-current="true"] {
  color: var(--ic-a11y-focus) !important;
  background: rgba(255, 204, 51, 0.16) !important;
  font-weight: 800 !important;
}
.ic-v3-topbar__a11y {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  color: rgba(255, 255, 255, 0.92) !important;
  text-decoration: none !important;
  padding: 4px 12px !important;
  border-left: 1px solid rgba(255, 255, 255, 0.25) !important;
  font-weight: 600 !important;
  font-size: 11.5px !important;
  letter-spacing: 0.04em !important;
  line-height: 1.4 !important;
  text-transform: uppercase !important;
}
.ic-v3-topbar__a11y::after { content: "Accessibilità"; }
.ic-v3-topbar__a11y svg { width: 16px !important; height: 16px !important; flex-shrink: 0 !important; }
.ic-v3-topbar__a11y:hover { color: var(--ic-a11y-focus) !important; }
@media (max-width: 640px) {
  .ic-v3-topbar__a11y::after { display: none; }
  .ic-v3-topbar__a11y { padding: 4px 8px !important; }
}

@media (max-width: 900px) {
  .ic-v3-topbar__langs button { padding: 4px 6px !important; font-size: 10.5px !important; }
}
@media (max-width: 640px) {
  /* Su mobile: mostra solo 4 lingue principali + accessibilità per non rompere il layout */
  .ic-v3-topbar__langs li:nth-child(n+5) { display: none !important; }
}

/* ============= 14. PREFERS-CONTRAST: MORE ============= */
@media (prefers-contrast: more) {
  body #provPills .prov-pill-wrap > summary.prov-pill {
    border-width: 2px !important;
    border-color: var(--ic-a11y-link) !important;
  }
  body #provPills .ic-prov-meta {
    color: var(--ic-a11y-text) !important;
  }
  main p a, main li a {
    text-decoration-thickness: 2px !important;
  }
}
