/* =============================================================================
   ANAJUSTRA Acessibilidade — Framework standalone
   Inclua este arquivo + acessibilidade.js em qualquer site HTML/CSS/JS puro.
   ============================================================================= */

/* ---------- Variáveis (customize aqui para casar com a marca do seu site) ---------- */
:root {
  --a11y-cor-primaria: #375e9e;       /* cor do botão flutuante e ativos */
  --a11y-cor-primaria-hover: #4c76ba;
  --a11y-cor-texto: #1a2947;
  --a11y-cor-texto-secundario: #6b7280;
  --a11y-cor-fundo: #ffffff;
  --a11y-cor-fundo-sutil: #f5f7fb;
  --a11y-cor-borda: #e5e7eb;
  --a11y-cor-ativa-bg: rgba(55, 94, 158, 0.10);
  --a11y-cor-ativa-borda: rgba(55, 94, 158, 0.40);
  --a11y-sombra: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* ---------- Botão flutuante ---------- */
.a11y-botao-flutuante {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 99990;
  background: var(--a11y-cor-primaria);
  color: #fff;
  border: 0;
  border-radius: 12px 0 0 12px;
  padding: 12px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: background-color 0.2s, opacity 0.2s;
  line-height: 0;
}
.a11y-botao-flutuante:hover { background: var(--a11y-cor-primaria-hover); }
.a11y-botao-flutuante:focus-visible {
  outline: 3px solid var(--a11y-cor-primaria-hover);
  outline-offset: 2px;
}
.a11y-botao-flutuante.a11y-oculto {
  opacity: 0;
  pointer-events: none;
}
.a11y-botao-flutuante svg { width: 24px; height: 24px; }

/* ---------- Overlay + Painel ---------- */
.a11y-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99991;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.a11y-overlay.a11y-aberto {
  opacity: 1;
  pointer-events: auto;
}

.a11y-painel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 100vw;
  background: var(--a11y-cor-fundo);
  color: var(--a11y-cor-texto);
  z-index: 99992;
  box-shadow: var(--a11y-sombra);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.a11y-painel.a11y-aberto { transform: translateX(0); }

.a11y-painel-cabecalho {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--a11y-cor-borda);
}
.a11y-painel-cabecalho .a11y-avatar {
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  background: var(--a11y-cor-ativa-bg);
  color: var(--a11y-cor-primaria);
  display: flex;
  align-items: center;
  justify-content: center;
}
.a11y-painel-cabecalho h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--a11y-cor-texto);
}
.a11y-painel-cabecalho p {
  margin: 0;
  font-size: 11px;
  color: var(--a11y-cor-texto-secundario);
}
.a11y-painel-fechar {
  margin-left: auto;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 6px;
  color: var(--a11y-cor-texto-secundario);
  border-radius: 6px;
}
.a11y-painel-fechar:hover {
  background: var(--a11y-cor-fundo-sutil);
  color: var(--a11y-cor-texto);
}

.a11y-painel-conteudo {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.a11y-grade {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.a11y-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 8px;
  border: 1px solid var(--a11y-cor-borda);
  border-radius: 12px;
  background: var(--a11y-cor-fundo);
  color: var(--a11y-cor-texto);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s, background-color 0.15s;
}
.a11y-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}
.a11y-card.a11y-ativa {
  background: var(--a11y-cor-ativa-bg);
  border-color: var(--a11y-cor-ativa-borda);
  color: var(--a11y-cor-primaria);
}
.a11y-card svg { width: 20px; height: 20px; }
.a11y-card-badge {
  display: inline-block;
  background: var(--a11y-cor-primaria);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.a11y-painel-rodape {
  padding: 12px 20px 20px;
  border-top: 1px solid var(--a11y-cor-borda);
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--a11y-cor-fundo-sutil);
}
.a11y-botao {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--a11y-cor-borda);
  background: var(--a11y-cor-fundo);
  color: var(--a11y-cor-texto);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.a11y-botao:hover { background: var(--a11y-cor-fundo-sutil); }
.a11y-botao-fantasma { border-color: transparent; background: transparent; }
.a11y-rodape-nota {
  font-size: 10px;
  text-align: center;
  color: var(--a11y-cor-texto-secundario);
  margin: 6px 0 0;
}
.a11y-rodape-credito {
  font-size: 10px;
  text-align: center;
  color: var(--a11y-cor-primaria);
  margin: 2px 0 0;
  padding-top: 6px;
  border-top: 1px dashed var(--a11y-cor-borda);
  letter-spacing: 0.02em;
}
.a11y-rodape-credito strong { font-weight: 700; }

/* ---------- Barra de leitura (overlay segue o mouse) ---------- */
.a11y-leitura-sombra {
  position: fixed;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.45);
  pointer-events: none;
  z-index: 99998;
}
.a11y-leitura-corredor {
  position: fixed;
  left: 0;
  right: 0;
  border-top: 2px solid var(--a11y-cor-primaria);
  border-bottom: 2px solid var(--a11y-cor-primaria);
  pointer-events: none;
  z-index: 99999;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.3);
}

/* =============================================================================
   REGRAS GLOBAIS — reagem às classes / data-attributes do <html>.
   ============================================================================= */

/* Contraste + — fundo preto e texto branco em toda a página */
html.a11y-contraste,
html.a11y-contraste body {
  background: #000 !important;
  color: #fff !important;
}
html.a11y-contraste body *:not([class*="a11y-"]) {
  background-color: #000 !important;
  background-image: none !important;
  color: #fff !important;
  border-color: #fff !important;
}
html.a11y-contraste body a:not([class*="a11y-"]) {
  color: #ffeb3b !important;
  text-decoration: underline !important;
}
html.a11y-contraste body img,
html.a11y-contraste body video { filter: grayscale(0.2) contrast(1.1); }

/* O próprio widget mantém aparência legível */
html.a11y-contraste .a11y-botao-flutuante {
  background-color: #1e40af !important;
  color: #fff !important;
  border: 2px solid #fff !important;
}
html.a11y-contraste .a11y-painel,
html.a11y-contraste .a11y-painel * {
  background-color: #fff !important;
  color: #000 !important;
  border-color: #000 !important;
}
html.a11y-contraste .a11y-card.a11y-ativa {
  background: #000 !important;
  color: #fff !important;
}

/* Links destacados */
html.a11y-links-destacados a {
  text-decoration: underline !important;
  background-color: #fff3a0 !important;
  color: #000 !important;
  padding: 0 2px;
  border-radius: 2px;
}

/* Texto maior (3 níveis) — usamos `zoom` no body para funcionar também
   em sites que fixam font-size em px (CSS rem/% não escalaria esses). O
   widget é compensado para manter seu próprio tamanho. */
html[data-a11y-texto="1"] body { zoom: 1.10; }
html[data-a11y-texto="2"] body { zoom: 1.20; }
html[data-a11y-texto="3"] body { zoom: 1.30; }
html[data-a11y-texto="1"] .a11y-botao-flutuante,
html[data-a11y-texto="1"] .a11y-overlay,
html[data-a11y-texto="1"] .a11y-painel { zoom: calc(1 / 1.10); }
html[data-a11y-texto="2"] .a11y-botao-flutuante,
html[data-a11y-texto="2"] .a11y-overlay,
html[data-a11y-texto="2"] .a11y-painel { zoom: calc(1 / 1.20); }
html[data-a11y-texto="3"] .a11y-botao-flutuante,
html[data-a11y-texto="3"] .a11y-overlay,
html[data-a11y-texto="3"] .a11y-painel { zoom: calc(1 / 1.30); }

/* Espaçamento de texto (3 níveis) */
html[data-a11y-espacamento="1"] body { letter-spacing: 0.05em; word-spacing: 0.08em; }
html[data-a11y-espacamento="2"] body { letter-spacing: 0.10em; word-spacing: 0.16em; }
html[data-a11y-espacamento="3"] body { letter-spacing: 0.15em; word-spacing: 0.24em; }

/* Parar animações */
html.a11y-sem-animacao *,
html.a11y-sem-animacao *::before,
html.a11y-sem-animacao *::after {
  animation-duration: 0s !important;
  animation-delay: 0s !important;
  transition-duration: 0s !important;
  transition-delay: 0s !important;
  scroll-behavior: auto !important;
}

/* Ocultar imagens */
html.a11y-sem-imagens img,
html.a11y-sem-imagens picture,
html.a11y-sem-imagens video,
html.a11y-sem-imagens svg:not(.a11y-manter) {
  visibility: hidden !important;
}

/* Dislexia amigável */
html.a11y-dislexia body {
  font-family: "OpenDyslexic", "Atkinson Hyperlegible", Verdana, Arial, sans-serif !important;
  letter-spacing: 0.04em;
  line-height: 1.7;
}

/* Cursor grande */
html.a11y-cursor-grande,
html.a11y-cursor-grande * {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'><path d='M6 2 L6 40 L18 28 L26 44 L32 42 L24 26 L38 26 Z' fill='black' stroke='white' stroke-width='2'/></svg>") 6 2, auto !important;
}

/* Altura da linha (3 níveis) */
html[data-a11y-altura="1"] body { line-height: 1.6; }
html[data-a11y-altura="2"] body { line-height: 1.9; }
html[data-a11y-altura="3"] body { line-height: 2.2; }

/* Alinhamento de texto */
html[data-a11y-alinhamento="esquerda"] p,
html[data-a11y-alinhamento="esquerda"] li,
html[data-a11y-alinhamento="esquerda"] span { text-align: left !important; }
html[data-a11y-alinhamento="centro"] p,
html[data-a11y-alinhamento="centro"] li,
html[data-a11y-alinhamento="centro"] span { text-align: center !important; }
html[data-a11y-alinhamento="direita"] p,
html[data-a11y-alinhamento="direita"] li,
html[data-a11y-alinhamento="direita"] span { text-align: right !important; }
html[data-a11y-alinhamento="justificado"] p,
html[data-a11y-alinhamento="justificado"] li { text-align: justify !important; }

/* Saturação */
html[data-a11y-saturacao="1"] body { filter: saturate(1.6); }
html[data-a11y-saturacao="2"] body { filter: saturate(0.5); }
html[data-a11y-saturacao="3"] body { filter: grayscale(1); }
