/* ============================================================
   IC A11Y PRO — pannello accessibilità completo
   Palette InfoComuni: navy #0b2340 + gold #ffcc33
   Tutti i pulsanti funzionano davvero (vedi ic-a11y-pro.js)
   ============================================================ */

/* =========== Trigger button =========== */
/* Floating fallback (solo se non esiste header slot) */
html .ica-fab,
html.ic-display-kiosk-h .ica-fab,
html.ic-display-kiosk-v .ica-fab {
  position: fixed;
  right: 18px; bottom: 18px;
  z-index: 9999;
  width: 56px !important; height: 56px !important;
  min-height: 56px !important;
  border-radius: 50% !important;
  background: #0b2340;
  border: 2px solid #ffcc33;
  color: #ffcc33;
  display: inline-flex !important; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.25), 0 0 0 4px rgba(255,204,51,.18);
  transition: transform .15s ease, background .2s ease;
  font-family: inherit;
  padding: 0 !important;
  font-size: inherit !important;
}
.ica-fab:hover { transform: scale(1.06); background: #13355c; }
.ica-fab svg { width: 28px !important; height: 28px !important; flex: 0 0 auto; }

/* Inline (nell'header del sito) — più piccolo e si integra */
html .ica-fab.ica-fab--inline,
html.ic-display-kiosk-h .ica-fab.ica-fab--inline,
html.ic-display-kiosk-v .ica-fab.ica-fab--inline {
  position: static;
  width: 40px !important; height: 40px !important;
  min-height: 40px !important;
  border-radius: 999px !important;
  border: 1.5px solid #0b2340 !important;
  background: #fff !important;
  color: #0b2340 !important;
  box-shadow: none !important;
  margin-left: 6px;
  padding: 0 !important;
}
.ica-fab.ica-fab--inline:hover {
  background: #0b2340;
  color: #ffcc33;
  border-color: #ffcc33;
  transform: none;
}
.ica-fab.ica-fab--inline svg { width: 22px !important; height: 22px !important; flex: 0 0 auto; }

/* Inline su header dark (kiosk) */
.kh-tools .ica-fab.ica-fab--inline,
.kv-head .ica-fab.ica-fab--inline {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.18);
  color: #fff;
}
.kh-tools .ica-fab.ica-fab--inline:hover,
.kv-head .ica-fab.ica-fab--inline:hover {
  background: #ffcc33;
  color: #0b2340;
  border-color: #ffcc33;
}

.ica-fab__dot {
  position: absolute; top: 4px; right: 4px;
  width: 8px; height: 8px;
  background: #ffcc33;
  border-radius: 50%;
  box-shadow: 0 0 8px #ffcc33;
  display: none;
}
.ica-fab.has-active .ica-fab__dot { display: block; }
.ica-fab.ica-fab--inline.has-active .ica-fab__dot { top: 2px; right: 2px; }

/* =========== Overlay & panel =========== */
.ica-overlay {
  position: fixed; inset: 0;
  background: rgba(6,24,45,.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000000;
  opacity: 0; pointer-events: none;
  transition: opacity .3s ease;
}
.ica-overlay.is-open { opacity: 1; pointer-events: auto; }

.ica-panel {
  position: fixed;
  top: 0; right: 0;
  width: min(420px, 100%);
  height: 100vh; height: 100dvh;
  background: #fbf9f4;
  z-index: 1000001;
  transform: translateX(100%);
  transition: transform .35s cubic-bezier(.16,1,.3,1);
  display: flex; flex-direction: column;
  font-family: 'Inter', system-ui, sans-serif;
  color: #0b1220;
  box-shadow: -12px 0 40px rgba(0,0,0,.25);
}
.ica-panel.is-open { transform: translateX(0); }

/* === HEADER === */
.ica-head {
  position: relative;
  background: linear-gradient(135deg, #0b2340 0%, #06182d 100%);
  color: #fff;
  padding: 18px 18px 0;
}
.ica-head__topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding-bottom: 14px;
}
html .ica-head__icon-btn,
html.ic-display-kiosk-h .ica-head__icon-btn,
html.ic-display-kiosk-v .ica-head__icon-btn {
  width: 36px !important; height: 36px !important;
  min-height: 36px !important;
  background: transparent;
  border: 1px solid rgba(255,204,51,.4);
  border-radius: 8px;
  color: #ffcc33;
  cursor: pointer;
  display: inline-flex !important; align-items: center; justify-content: center;
  padding: 0 !important;
  transition: all .15s ease;
  font-size: inherit !important;
}
.ica-head__icon-btn:hover { background: rgba(255,204,51,.12); border-color: #ffcc33; }
.ica-head__icon-btn svg { width: 18px !important; height: 18px !important; flex: 0 0 auto; }

.ica-head__lang {
  padding: 6px 14px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,204,51,.3);
  border-radius: 999px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}

html .ica-head__close,
html.ic-display-kiosk-h .ica-head__close,
html.ic-display-kiosk-v .ica-head__close {
  width: 36px !important; height: 36px !important;
  min-height: 36px !important;
  background: rgba(255,255,255,.08);
  border: 0;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 22px !important;
  display: inline-flex !important; align-items: center; justify-content: center;
  padding: 0 !important;
  line-height: 1;
  transition: background .15s ease;
}
.ica-head__close:hover { background: rgba(220,38,38,.7); }

.ica-head__title {
  /* 2026-05-21 — Allineato a UserWay-style: pill bianca trasparente su barra blu scuro,
     contorno bianco, testo bianco. Resta il blu scuro brand (#0b2340) come base. */
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  background: transparent;
  color: #fff;
  padding: 10px 32px;
  border: 1.5px solid rgba(255,255,255,.75);
  border-radius: 10px;
  font-family: 'Oswald', system-ui, sans-serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .04em;
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
  background-color: #0b2340;
}

/* === BODY (scrollable) === */
.ica-body {
  flex: 1;
  overflow-y: auto;
  padding: 30px 18px 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(11,35,64,.3) transparent;
}
.ica-body::-webkit-scrollbar { width: 6px; }
.ica-body::-webkit-scrollbar-thumb { background: rgba(11,35,64,.3); border-radius: 999px; }

/* === SECTION === */
.ica-sec {
  margin-bottom: 18px;
  background: #fff;
  border: 1px solid rgba(11,35,64,.08);
  border-radius: 12px;
  overflow: hidden;
}
.ica-sec__head {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: 'Oswald', system-ui, sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: #0b2340;
  text-align: left;
}
.ica-sec__head:hover { background: rgba(255,204,51,.08); }
.ica-sec__chev {
  width: 26px; height: 26px;
  background: #0b2340;
  color: #ffcc33;
  border-radius: 6px;
  display: grid; place-items: center;
  font-size: 16px;
  line-height: 1;
}
.ica-sec[data-open="true"] .ica-sec__chev::before { content: '−'; }
.ica-sec[data-open="false"] .ica-sec__chev::before { content: '+'; }
.ica-sec__body {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 12px 14px;
}
.ica-sec[data-open="false"] .ica-sec__body { display: none; }

/* === TILE (button toggle) ===
   2026-05-21 — Dimensioni e stato attivo allineati al riferimento UserWay-style:
   tile più alta (110), icona più grande (34), label più leggibile (12),
   stato attivo come outline blu scuro spesso (non fill completo) + tick blu scuro
   in alto a destra. Brand colors mantenuti (blu scuro #0b2340 + giallo #ffcc33). */
.ica-tile {
  background: #fff;
  border: 1.5px solid rgba(11,35,64,.12);
  border-radius: 10px;
  padding: 16px 8px 12px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center;
  transition: all .15s ease;
  font-family: inherit;
  color: #0b2340;
  min-height: 110px;
  position: relative;
}
.ica-tile:hover { border-color: #0b2340; background: rgba(11,35,64,.04); }
.ica-tile__icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  color: #0b2340;
}
.ica-tile__icon svg { width: 30px; height: 30px; }
.ica-tile__lbl {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  color: #0b2340;
  letter-spacing: .01em;
}
.ica-tile.is-on {
  background: #fff;
  border-color: #0b2340;
  border-width: 2px;
  box-shadow: 0 0 0 3px rgba(11,35,64,.10);
}
.ica-tile.is-on .ica-tile__icon,
.ica-tile.is-on .ica-tile__lbl { color: #0b2340; }
.ica-tile.is-on::after {
  content: '✓';
  position: absolute;
  top: 6px; right: 8px;
  width: 18px; height: 18px;
  display: grid; place-items: center;
  background: #0b2340;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* Device tiles (Modalità di visione) */
.ica-sec__body--devices {
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 10px;
}
.ica-tile--device {
  text-decoration: none;
  min-height: 92px;
  padding: 12px 8px;
}
.ica-tile--device .ica-tile__sub {
  font-size: 10px;
  color: #4a5568;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: .04em;
  margin-top: 2px;
}
.ica-tile--device:hover .ica-tile__sub {
  color: #4a5568;
}
.ica-tile--device.is-on .ica-tile__sub {
  color: rgba(255,204,51,.7);
}

/* === Visualizzazione dropdown (Sprint 11 — 03/05/2026) === */
/* 2026-05-21 — Override: la sezione Visualizzazione NON deve essere grid 3-col
   (eredita .ica-sec__body grid). Forza display block + padding orizzontale
   coerente con le altre sezioni, e il select prende 100% della larghezza. */
.ica-sec__body--viz {
  display: block !important;
  padding: 4px 12px 14px !important;
}
.ica-viz-select-wrap { position: relative; width: 100%; }
.ica-viz-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  width: 100%;
  padding: 13px 40px 13px 14px;
  border: 1.5px solid #C8C2B0;
  border-radius: 10px;
  background: #fff;
  color: #0E2F4A;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.ica-viz-select:hover { border-color: #FFCC33; background: #fffbeb; }
.ica-viz-select:focus-visible { outline: 2px solid #FFCC33; outline-offset: 2px; border-color: #FFCC33; }
.ica-viz-select option { background: #fff; color: #0E2F4A; padding: 8px; font-weight: 500; }
.ica-viz-chev {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: #C89B3C; pointer-events: none;
}

/* === COLOR PICKER (sezione custom color) === */
.ica-cp {
  margin: 8px 12px 14px;
  padding: 14px;
  border: 1px dashed rgba(11,35,64,.18);
  border-radius: 10px;
  background: #fbf9f4;
}
.ica-cp__head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.ica-cp__head-icon {
  width: 30px; height: 30px;
  background: #0b2340;
  color: #ffcc33;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 16px;
}
.ica-cp__head-text strong { display: block; font-size: 13px; color: #0b2340; }
.ica-cp__head-text small { display: block; font-size: 11px; color: #4a5568; }

.ica-cp__targets { display: flex; gap: 6px; margin-bottom: 12px; }
.ica-cp__target {
  flex: 1;
  padding: 8px;
  background: #fff;
  border: 1.5px solid rgba(11,35,64,.10);
  border-radius: 8px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: #0b2340;
  transition: all .15s ease;
}
.ica-cp__target.is-on { background: #0b2340; color: #ffcc33; border-color: #ffcc33; }

.ica-cp__bar {
  width: 100%;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(90deg,
    #ff0000 0%, #ff00ff 16%, #0000ff 32%, #00ffff 48%,
    #00ff00 64%, #ffff00 80%, #ff8800 88%, #000 100%);
  border: 0;
  cursor: pointer;
  position: relative;
  -webkit-appearance: none;
}
.ica-cp__bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #0b2340;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.ica-cp__bar::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #0b2340;
  cursor: pointer;
}

.ica-cp__reset {
  margin-top: 10px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid rgba(11,35,64,.18);
  border-radius: 999px;
  color: #0b2340;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.ica-cp__reset:hover { background: #0b2340; color: #ffcc33; border-color: #ffcc33; }

/* === FONT SIZE (slider) === */
.ica-fs {
  margin: 8px 12px 14px;
  padding: 14px;
  border: 1px dashed rgba(11,35,64,.18);
  border-radius: 10px;
  background: #fbf9f4;
}
.ica-fs__head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.ica-fs__head-icon {
  width: 30px; height: 30px;
  background: #0b2340;
  color: #ffcc33;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 14px;
  font-weight: 700;
}
.ica-fs__head-text strong { display: block; font-size: 13px; color: #0b2340; }
.ica-fs__head-text small { display: block; font-size: 11px; color: #4a5568; }

.ica-fs__tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.ica-fs__tab {
  flex: 1;
  padding: 7px 6px;
  background: #fff;
  border: 1.5px solid rgba(11,35,64,.10);
  border-radius: 999px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: #0b2340;
  transition: all .15s ease;
}
.ica-fs__tab.is-on { background: #0b2340; color: #ffcc33; border-color: #ffcc33; }

.ica-fs__slider-row { display: flex; align-items: center; gap: 10px; }
.ica-fs__btn {
  width: 32px; height: 32px;
  background: #0b2340;
  color: #ffcc33;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  display: grid; place-items: center;
}
.ica-fs__btn:hover { background: #ffcc33; color: #0b2340; }
.ica-fs__bar {
  flex: 1;
  -webkit-appearance: none;
  height: 8px;
  background: linear-gradient(90deg, rgba(11,35,64,.18) 0%, rgba(11,35,64,.18) 100%);
  border-radius: 999px;
  cursor: pointer;
}
.ica-fs__bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #ffcc33;
  border: 3px solid #0b2340;
  cursor: pointer;
}
.ica-fs__bar::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #ffcc33;
  border: 3px solid #0b2340;
  cursor: pointer;
}
.ica-fs__val { font: 700 13px 'JetBrains Mono', monospace; color: #0b2340; min-width: 36px; text-align: center; }

/* === FOOTER === */
.ica-foot {
  display: flex; justify-content: space-around;
  padding: 14px 12px;
  background: linear-gradient(135deg, #0b2340 0%, #06182d 100%);
  color: #fff;
  border-top: 1px solid rgba(255,204,51,.2);
}
.ica-foot__btn {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
}
.ica-foot__btn:hover { background: rgba(255,204,51,.16); color: #ffcc33; }
.ica-foot__btn--primary {
  background: #ffcc33;
  color: #0b2340;
  padding: 8px 16px;
  border-radius: 999px;
}
.ica-foot__btn--primary:hover { background: #fff; color: #0b2340; }

/* ============================================================
   GLOBAL CSS APPLIED BASED ON A11Y STATE (toggled on <html>)
   ============================================================ */

/* Visione: Monocromatico */
html.a11y-mono, html.a11y-mono * { filter: grayscale(1) !important; }

/* Visione: Saturazione bassa */
html.a11y-sat-low { filter: saturate(.5); }
html.a11y-sat-low body { filter: saturate(.5); }

/* Visione: Saturazione alta */
html.a11y-sat-high { filter: saturate(2); }
html.a11y-sat-high body { filter: saturate(2); }

/* Visione: Dark high contrast */
html.a11y-hc-dark, html.a11y-hc-dark body {
  background: #000 !important;
  color: #ffeb3b !important;
}
html.a11y-hc-dark *, html.a11y-hc-dark *::before, html.a11y-hc-dark *::after {
  background-color: #000 !important;
  color: #ffeb3b !important;
  border-color: #ffeb3b !important;
}
html.a11y-hc-dark a { color: #4dd0e1 !important; text-decoration: underline !important; }
html.a11y-hc-dark img, html.a11y-hc-dark video { filter: grayscale(1) contrast(1.5) !important; }

/* Visione: Bright high contrast */
html.a11y-hc-bright, html.a11y-hc-bright body {
  background: #fff !important;
  color: #000 !important;
}
html.a11y-hc-bright *, html.a11y-hc-bright *::before, html.a11y-hc-bright *::after {
  background-color: #fff !important;
  color: #000 !important;
  border-color: #000 !important;
}
html.a11y-hc-bright a { color: #1a0dab !important; text-decoration: underline !important; }

/* Visione: Contrast Mode (text-shadow + bordi) */
html.a11y-contrast-mode body {
  filter: contrast(1.4);
}

/* Navigazione: keyboard nav (focus outline) */
html.a11y-keyboard-nav *:focus-visible,
html.a11y-keyboard-nav *:focus {
  outline: 3px solid #ffcc33 !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 6px rgba(255,204,51,.4) !important;
}

/* Navigazione: smart-nav (skip link visibile) */
html.a11y-smart-nav .ica-skip-bar {
  position: fixed; top: 0; left: 0; right: 0;
  background: #0b2340;
  border-bottom: 2px solid #ffcc33;
  display: flex;
  z-index: 9998;
  padding: 8px;
  gap: 8px;
}
html:not(.a11y-smart-nav) .ica-skip-bar { display: none; }
.ica-skip-bar a {
  flex: 1;
  padding: 8px 12px;
  background: rgba(255,204,51,.15);
  border: 1px solid #ffcc33;
  border-radius: 6px;
  color: #ffcc33;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.ica-skip-bar a:hover, .ica-skip-bar a:focus {
  background: #ffcc33; color: #0b2340;
}

/* Navigazione: voice / text-reader / screen-reader / mousegrid feedback toast */
.ica-toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  background: #0b2340;
  color: #ffcc33;
  border: 2px solid #ffcc33;
  padding: 14px 22px;
  border-radius: 999px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  z-index: 10002;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.ica-toast.is-on { opacity: 1; }

/* Mousegrid overlay */
.ica-mousegrid {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9997;
  background-image:
    linear-gradient(to right, rgba(255,204,51,.4) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,204,51,.4) 1px, transparent 1px);
  background-size: 12.5% 12.5%;
  display: none;
}
html.a11y-mousegrid .ica-mousegrid { display: block; }
html.a11y-mousegrid .ica-mousegrid::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(to right, rgba(11,35,64,.6) 2px, transparent 2px),
    linear-gradient(to bottom, rgba(11,35,64,.6) 2px, transparent 2px);
  background-size: 25% 25%;
}

/* Content: line spacing */
html.a11y-line-spacing,
html.a11y-line-spacing * { line-height: 2 !important; }

/* Content: word spacing */
html.a11y-word-spacing,
html.a11y-word-spacing * { word-spacing: .25em !important; }

/* Content: letter spacing */
html.a11y-letter-spacing,
html.a11y-letter-spacing * { letter-spacing: .12em !important; }

/* Content: dyslexia font */
html.a11y-dyslexia,
html.a11y-dyslexia * {
  font-family: 'OpenDyslexic', 'Comic Sans MS', 'Lexend', 'Atkinson Hyperlegible', system-ui, sans-serif !important;
  font-weight: 500 !important;
}

/* Content: font-size scale (5 livelli) */
html.a11y-fs-1 { font-size: 18px; }
html.a11y-fs-2 { font-size: 20px; }
html.a11y-fs-3 { font-size: 22px; }
html.a11y-fs-4 { font-size: 25px; }

/* Custom color overrides (set via CSS variables from JS) */
html.a11y-cc-bg body { background-color: var(--ica-cc-bg, transparent) !important; }
html.a11y-cc-headings h1, html.a11y-cc-headings h2,
html.a11y-cc-headings h3, html.a11y-cc-headings h4 {
  color: var(--ica-cc-heading, inherit) !important;
}
html.a11y-cc-content p, html.a11y-cc-content li, html.a11y-cc-content span:not([class*="badge"]):not([class*="tag"]) {
  color: var(--ica-cc-text, inherit) !important;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .ica-panel, .ica-overlay { transition: none; }
}
