/* Vanthi Eventos — widget de acessibilidade (WCAG 2.1 AA) */

:root {
  --accessibility-primary: #be185d;
  --accessibility-primary-hover: #9d174d;
  --accessibility-icon: var(--color-white, #ffffff);
  --accessibility-focus: var(--color-accent, #f25d9c);
  --a11y-fab-z: 2147483646;
  --a11y-panel-z: 2147483647;
}

/* —— Filtros só em blocos de 1º nível (nunca html/body) —— */
html.a11y-grayscale #header-placeholder,
html.a11y-grayscale main,
html.a11y-grayscale #footer-placeholder {
  filter: grayscale(100%);
}

html.a11y-cb-protanopia #header-placeholder,
html.a11y-cb-protanopia main,
html.a11y-cb-protanopia #footer-placeholder {
  filter: url("#a11y-protanopia");
}

html.a11y-cb-deuteranopia #header-placeholder,
html.a11y-cb-deuteranopia main,
html.a11y-cb-deuteranopia #footer-placeholder {
  filter: url("#a11y-deuteranopia");
}

html.a11y-cb-tritanopia #header-placeholder,
html.a11y-cb-tritanopia main,
html.a11y-cb-tritanopia #footer-placeholder {
  filter: url("#a11y-tritanopia");
}

/* —— Escala de texto (html) —— */
html.a11y-text-sm {
  font-size: 87.5%;
}

html.a11y-text-lg {
  font-size: 112.5%;
}

html.a11y-text-xl {
  font-size: 125%;
}

/* —— Alto contraste —— */
html.a11y-high-contrast {
  --color-black: #000000;
  --color-black-light: #0d0d0d;
  --color-white: #ffffff;
  --color-white-off: #ffffff;
  --color-gray-300: #e8e8e8;
  --color-gray-500: #cccccc;
  --color-accent: #ff8ec4;
  --color-accent-hover: #7af0ff;
  --color-accent-rgb: 255, 142, 196;
}

html.a11y-high-contrast body {
  background-color: #000000;
  color: #ffffff;
}

html.a11y-high-contrast .header {
  background-color: #000000;
  border-bottom: 2px solid #ffffff;
}

/* —— Links destacados —— */
html.a11y-highlight-links a:not(.a11y-fab):not(.a11y-panel-close) {
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 3px !important;
  outline: 1px dashed currentColor;
  outline-offset: 2px;
}

/* —— Espaçamento —— */
html.a11y-line-spacing body {
  line-height: 1.85 !important;
}

html.a11y-letter-spacing body {
  letter-spacing: 0.06em !important;
}

html.a11y-word-spacing body {
  word-spacing: 0.16em !important;
}

/* —— Fonte acessível —— */
html.a11y-accessible-font body {
  font-family: "Atkinson Hyperlegible", var(--font-primary, Inter, sans-serif) !important;
}

/* —— Reduzir animações (classe + prefs) —— */
html.a11y-reduce-motion *,
html.a11y-reduce-motion *::before,
html.a11y-reduce-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* —— Cursor ampliado (somente ponteiro fino) —— */
@media (hover: hover) and (pointer: fine) {
  html.a11y-large-cursor,
  html.a11y-large-cursor * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' stroke='%23fff' stroke-width='1' d='M4 4l7 18 2.5-7.5L21 12z'/%3E%3C/svg%3E") 4 4, auto !important;
  }
}

/* —— Utilitários —— */
.a11y-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;
}

/* —— FAB —— */
.a11y-fab {
  position: fixed;
  left: max(1rem, env(safe-area-inset-left, 0px));
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  z-index: var(--a11y-fab-z);
  width: clamp(2.875rem, 11vw, 3.35rem);
  height: clamp(2.875rem, 11vw, 3.35rem);
  min-width: 44px;
  min-height: 44px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accessibility-primary);
  color: var(--accessibility-icon);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.a11y-fab:hover {
  background-color: var(--accessibility-primary-hover);
}

.a11y-fab:focus-visible {
  outline: 3px solid var(--accessibility-focus);
  outline-offset: 3px;
}

.a11y-fab svg {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
}

/* —— Painel —— */
.a11y-panel {
  position: fixed;
  left: max(1rem, env(safe-area-inset-left, 0px));
  bottom: calc(max(1rem, env(safe-area-inset-bottom, 0px)) + clamp(2.875rem, 11vw, 3.35rem) + 0.75rem);
  z-index: var(--a11y-panel-z);
  width: min(92vw, 20rem);
  max-height: 70vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #ffffff;
  color: #1a1a1a;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  padding: 1rem 1rem 1.25rem;
}

.a11y-panel[hidden] {
  display: none !important;
}

.a11y-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e0e0e0;
}

.a11y-panel-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
  color: #0a0a0a;
}

.a11y-panel-close {
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: transparent;
  color: #333;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.a11y-panel-close:focus-visible,
.a11y-btn:focus-visible {
  outline: 3px solid var(--accessibility-focus);
  outline-offset: 2px;
}

.a11y-section {
  margin-bottom: 1rem;
}

.a11y-section-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: #0a0a0a;
}

.a11y-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.a11y-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 2px solid #444;
  border-radius: 8px;
  background: #f5f5f5;
  color: #1a1a1a;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  flex: 1 1 auto;
  text-align: center;
}

/* Duas colunas mantêm o painel compacto sem reduzir alvos de toque. */
.a11y-btn-row .a11y-btn {
  flex: 0 0 calc(50% - 0.25rem);
  width: calc(50% - 0.25rem);
}

/* O X é visualmente menor, mas preserva alvo mínimo de teclado/toque. */
.a11y-panel-header .a11y-panel-close {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 0.875rem;
}

.a11y-radio-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.a11y-btn:hover:not(:disabled) {
  background: #ebebeb;
}

.a11y-btn[aria-pressed="true"],
.a11y-btn.is-active {
  background: var(--accessibility-primary);
  border-color: var(--accessibility-primary-hover);
  color: #ffffff;
}

.a11y-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.a11y-radio-group[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

.a11y-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (pointer: coarse) {
  .a11y-hide-coarse {
    display: none !important;
  }
}

/* VLibras — lado oposto ao FAB (direita) */
[vw-access-button],
div[vw-access-button] {
  left: auto !important;
  right: max(1rem, env(safe-area-inset-right, 0px)) !important;
  bottom: max(5.5rem, calc(env(safe-area-inset-bottom, 0px) + 4rem)) !important;
}

@media (max-width: 768px) {
  [vw-access-button],
  div[vw-access-button] {
    bottom: max(6.5rem, calc(env(safe-area-inset-bottom, 0px) + 5rem)) !important;
  }
}
