/* ==================== ACCESSIBILITY MODULE ==================== */
/* Inspired by auladeti.com a11y patterns */

/* FAB button — sits above WhatsApp (z-50) and below LGPD (z-[60]) */
.a11y-fab {
  position: fixed;
  bottom: 5.5rem;
  left: 1rem;
  z-index: 55;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  background: #1845c0;
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(29, 85, 241, 0.3);
  transition: transform 0.2s, background 0.2s;
}

/* When LGPD banner is visible, push FAB up to avoid overlap */
body:has(#lgpd-banner:not(.hidden)) .a11y-fab {
  bottom: 8rem;
}

.a11y-fab:hover {
  transform: scale(1.1);
  background: #1237a8;
}

/* Panel — above FAB, responsive width */
.a11y-panel {
  position: fixed;
  bottom: 8.5rem;
  left: 1rem;
  z-index: 55;
  background: white;
  border-radius: 1rem;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  padding: 1.25rem;
  width: 220px;
  max-width: calc(100vw - 2rem);
  display: none;
}

/* When LGPD banner is visible, push panel up too */
body:has(#lgpd-banner:not(.hidden)) .a11y-panel {
  bottom: 11rem;
}

.a11y-panel.open {
  display: block;
}

.a11y-panel h4 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #535e78;
  margin-bottom: 0.75rem;
}

.a11y-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid #eceef2;
  font-size: 0.8125rem;
  color: #343a47;
}

.a11y-option:last-child {
  border-bottom: none;
}

.a11y-toggle {
  position: relative;
  width: 2.5rem;
  height: 1.375rem;
  background: #d5d9e2;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.a11y-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1rem;
  height: 1rem;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.a11y-toggle.active {
  background: #1845c0;
}

.a11y-toggle.active::after {
  transform: translateX(1.125rem);
}

/* ==================== HIGH CONTRAST ==================== */
/* Apply contrast boost only to text-containing elements, not the whole body.
   body-level filter breaks backdrop-filter and darkens already-dark overlays. */
body.a11y-light {
  --contrast-boost: 1.3;
}

body.a11y-light p,
body.a11y-light span,
body.a11y-light h1,
body.a11y-light h2,
body.a11y-light h3,
body.a11y-light h4,
body.a11y-light h5,
body.a11y-light h6,
body.a11y-light li,
body.a11y-light td,
body.a11y-light th,
body.a11y-light label,
body.a11y-light a {
  filter: contrast(var(--contrast-boost));
}

/* ==================== FONT SIZE ==================== */
/* Use clamp to prevent overflow on small screens */
body.a11y-large {
  font-size: clamp(16px, 118%, 22px);
}

/* Scale headings proportionally instead of fixed rem that conflicts with Tailwind responsive */
body.a11y-large h1 { font-size: 1.25em; }
body.a11y-large h2 { font-size: 1.15em; }

/* ==================== SPACING ==================== */
/* Target only text-flow elements, not buttons, flex containers, or fixed elements */
body.a11y-spacing p,
body.a11y-spacing li,
body.a11y-spacing td,
body.a11y-spacing th,
body.a11y-spacing dd,
body.a11y-spacing dt,
body.a11y-spacing label,
body.a11y-spacing span:not(.a11y-toggle *):not([class*="flex"]) {
  letter-spacing: 0.05em;
  word-spacing: 0.1em;
  line-height: 1.8 !important;
}

/* ==================== REDUCED MOTION ==================== */
/* Kill decorative animations but preserve interactive feedback (hover, toggle, accordion) */
body.a11y-no-motion *,
body.a11y-no-motion *::before,
body.a11y-no-motion *::after {
  animation: none !important;
}

/* Reduce transitions to near-instant instead of removing entirely — keeps hover/focus feedback */
body.a11y-no-motion *,
body.a11y-no-motion *::before,
body.a11y-no-motion *::after {
  transition-duration: 0.01ms !important;
}

/* ==================== MOBILE — small screens ==================== */
@media (max-width: 374px) {
  .a11y-panel {
    width: auto;
    right: 1rem;
  }
}
