/* Font base barra — Arial su tutti i container principali */
.acc-toggle,
.acc-panel,
.acc-structure-panel {
  font-family: Arial, Helvetica, sans-serif;
}

/* Bottone toggle fisso sul lato sinistro */
.acc-toggle {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9999;
  width: 52px;
  height: 52px;
  background-color: #1341b0;
  border: none;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
  transition: background-color 0.2s, width 0.2s;
  color: #fff;
}

.acc-toggle:hover,
.acc-toggle:focus-visible {
  background-color: #0f33a0;
  width: 56px;
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
}

.acc-toggle svg {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

/* Pannello laterale */
.acc-panel {
  position: fixed;
  left: 0;
  top: 0;
  height: 100%;
  width: 320px;
  max-width: 90vw;
  background: #fff;
  z-index: 9998;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.acc-panel.is-open {
  transform: translateX(0);
}

/* Intestazione pannello */
.acc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 16px;
  background-color: #1341b0;
  color: #fff;
  flex-shrink: 0;
}

.acc-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.acc-header-left svg {
  width: 40px;
  height: 40px;
  opacity: 0.9;
}

.acc-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.acc-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  transition: background-color 0.15s;
  flex-shrink: 0;
}

.acc-close:hover,
.acc-close:focus-visible {
  background: rgba(255, 255, 255, 0.3);
  outline: 2px solid #fbbf24;
  outline-offset: 2px;
}

/* Corpo scrollabile */
.acc-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.acc-body::-webkit-scrollbar {
  width: 5px;
}

.acc-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Etichette di sezione */
.acc-section-label {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #495768;
  margin: 20px 0 10px;
}

.acc-section-label:first-child {
  margin-top: 4px;
}

/* Griglia bottoni */
.acc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Singolo bottone */
.acc-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 8px 12px;
  background: #f8fafc;
  border: 1.5px solid #94a3b8;
  border-radius: 10px;
  cursor: pointer;
  color: #334155;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  min-height: 82px;
}

.acc-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1341b0;
}

.acc-btn:focus-visible {
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
  background: #eff6ff;
  border-color: #93c5fd;
}

.acc-btn.is-active {
  background: #1341b0;
  border-color: #1341b0;
  color: #fff;
  box-shadow: 0 2px 8px rgba(19, 65, 176, 0.35);
}

.acc-btn.is-active .acc-btn-icon svg {
  stroke: #fff;
}

/* Icona del bottone */
.acc-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: #e2e8f0;
  border-radius: 8px;
  transition: background-color 0.15s;
}

.acc-btn:hover .acc-btn-icon {
  background: #bfdbfe;
}

.acc-btn.is-active .acc-btn-icon {
  background: rgba(255, 255, 255, 0.22);
}

.acc-btn-icon svg {
  width: 20px;
  height: 20px;
  stroke: #475569;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.15s;
}

.acc-btn:hover .acc-btn-icon svg {
  stroke: #1341b0;
}

.acc-btn-label {
  display: block;
  font-size: 0.9375rem;
}

/* Bottone reset in fondo */
.acc-footer {
  padding: 14px 16px 18px;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.acc-reset {
  width: 100%;
  padding: 10px 16px;
  background: #fff;
  border: 1.5px solid #94a3b8;
  border-radius: 8px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: #495768;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.acc-reset:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #dc2626;
}

.acc-reset:focus-visible {
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
}

/* Footer pannello */
.acc-panel-footer {
  background-color: #1341b0;
  padding: 10px 16px;
  text-align: center;
  flex-shrink: 0;
}

@media (max-width: 350px) {
  .acc-panel-footer {
    padding-bottom: 44px;
  }
}

.acc-panel-footer-link {
  color: #fff;
  font-size: 1rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  opacity: 1;
  transition: opacity 0.15s;
}

.acc-panel-footer-link:hover,
.acc-panel-footer-link:focus-visible {
  opacity: 1;
  outline: 2px solid #fbbf24;
  outline-offset: 2px;
  border-radius: 2px;
}

/* Overlay scuro quando il pannello è aperto (mobile) */
.acc-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9997;
}

@media (max-width: 480px) {
  .acc-overlay.is-visible {
    display: block;
  }
}

/* ---- PANNELLO STRUTTURA PAGINA ---- */

.acc-structure-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 10000;
}

.acc-structure-overlay.is-visible {
  display: block;
}

.acc-structure-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  width: 520px;
  max-width: 92vw;
  max-height: 80vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.acc-structure-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.acc-structure-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #1341b0;
  color: #fff;
  border-radius: 12px 12px 0 0;
  flex-shrink: 0;
}

.acc-structure-title {
  font-weight: 700;
  font-size: 1rem;
}

.acc-structure-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s;
}

.acc-structure-close:hover,
.acc-structure-close:focus-visible {
  background: rgba(255, 255, 255, 0.3);
  outline: 2px solid #fbbf24;
  outline-offset: 2px;
}

.acc-structure-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.acc-structure-body::-webkit-scrollbar { width: 5px; }
.acc-structure-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.acc-structure-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
  text-align: left;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.9rem;
  color: #1a1a1a;
  line-height: 1.4;
  transition: background-color 0.15s, border-color 0.15s;
  width: 100%;
}

.acc-structure-item:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}

.acc-structure-item:focus-visible {
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
}

.acc-structure-badge {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: #1341b0;
  color: #fff;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.acc-structure-text {
  flex: 1;
}

.acc-structure-empty {
  text-align: center;
  color: #94a3b8;
  padding: 32px 16px;
  font-size: 0.9rem;
}

/* ---- FUNZIONALITÀ ---- */

/* Evidenzia link */
html.acc-highlight-links a {
  background: #ffff00 !important;
  color: #000000 !important;
  text-decoration: underline !important;
  outline: 2px solid #000000 !important;
  padding: 1px 4px !important;
  border-radius: 2px !important;
}

/* Maschera di lettura */
.acc-reading-mask {
  display: none;
  position: fixed;
  left: 0;
  width: 100%;
  height: 120px;
  background: transparent;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  border-top: 3px solid #1341b0;
  border-bottom: 3px solid #1341b0;
  z-index: 9996;
  pointer-events: none;
}

.acc-reading-mask.is-active {
  display: block;
}

/* Guida alla lettura */
.acc-reading-guide {
  display: none;
  position: fixed;
  left: 0;
  width: 100%;
  height: 5px;
  background: #000;
  z-index: 9996;
  pointer-events: none;
}

.acc-reading-guide.is-active {
  display: block;
}

/* Pausa animazioni CSS */
html.acc-pause-anim *,
html.acc-pause-anim *::before,
html.acc-pause-anim *::after {
  animation-play-state: paused !important;
}

/* Nascondi immagini (solo tag img, le bg-image vengono lasciate intatte) */
html.acc-hide-images img { visibility: hidden; }

/* Contrasto e scala di grigi: gestiti via html.style.filter in JS (combinabili) */

/* Allineamento testo */
html.acc-align-left  body,
html.acc-align-left  body *:not(.acc-panel, .acc-panel *, .acc-toggle, .acc-toggle *, .acc-structure-panel, .acc-structure-panel *) {
  text-align: left !important;
}
html.acc-align-center body,
html.acc-align-center body *:not(.acc-panel, .acc-panel *, .acc-toggle, .acc-toggle *, .acc-structure-panel, .acc-structure-panel *) {
  text-align: center !important;
}
html.acc-align-right body,
html.acc-align-right body *:not(.acc-panel, .acc-panel *, .acc-toggle, .acc-toggle *, .acc-structure-panel, .acc-structure-panel *) {
  text-align: right !important;
}

/* Dimensione testo - 3 livelli (agisce sul font-size di :root, scala tutto ciò che usa rem) */
html.acc-text-1 { font-size: 112% !important; }
html.acc-text-2 { font-size: 125% !important; }
html.acc-text-3 { font-size: 140% !important; }
/* Regole px-based (es. p,a,label,span{font-size:14px}) ignorano il root: forziamo 1rem sugli elementi di testo.
   :not() esclude tutto ciò che è dentro la barra di accessibilità stessa. */
html[class*="acc-text-"] body,
html[class*="acc-text-"] body :is(p, a, label, span, li, td, th, small, strong, b, i, em):not(
  .acc-panel *,
  .acc-toggle *,
  .acc-structure-panel *,
  .acc-overlay *
) { font-size: 1rem !important; }

/* Interlinea - 3 livelli */
html.acc-lh-1 body, html.acc-lh-1 body * { line-height: 2.0 !important; }
html.acc-lh-2 body, html.acc-lh-2 body * { line-height: 2.4 !important; }
html.acc-lh-3 body, html.acc-lh-3 body * { line-height: 2.8 !important; }

/* Spaziatura lettere - 3 livelli */
html.acc-ls-1 body, html.acc-ls-1 body * { letter-spacing: 0.1em !important; }
html.acc-ls-2 body, html.acc-ls-2 body * { letter-spacing: 0.2em !important; }
html.acc-ls-3 body, html.acc-ls-3 body * { letter-spacing: 0.3em !important; }

/* Carattere leggibile - Arial */
html.acc-readable,
html.acc-readable body,
html.acc-readable * {
  font-family: Arial, Helvetica, sans-serif !important;
}

/* Cursore grande bianco */
html.acc-cursor-white,
html.acc-cursor-white * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 32 32'%3E%3Cpath d='M2 2 L2 26 L8 20 L12 28 L16 26.5 L12 19 L20 19 Z' fill='white' stroke='black' stroke-width='2' stroke-linejoin='round' stroke-linecap='round'/%3E%3C/svg%3E") 3 3, auto !important;
}

/* Cursore grande nero */
html.acc-cursor-black,
html.acc-cursor-black * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 32 32'%3E%3Cpath d='M2 2 L2 26 L8 20 L12 28 L16 26.5 L12 19 L20 19 Z' fill='black' stroke='white' stroke-width='2' stroke-linejoin='round' stroke-linecap='round'/%3E%3C/svg%3E") 3 3, auto !important;
}
