/* ============================================
   InfluenceHub – Mobile filters toggle a11y
   - WCAG AA contrast for .filters-toggle and
     .filters-toggle-chevron in both light and dark mode.
   - prefers-reduced-motion guard: disables the
     expand/collapse chevron rotation, hover/focus
     transforms and any pulse/scale animation on the
     toggle so users who prefer reduced motion are not
     exposed to motion.
   - 44px minimum touch target (WCAG 2.5.5) for mobile
     users on the toggle.
   - Focus-visible ring for keyboard users.
   - Forced-colors (Windows High Contrast) support.
   ============================================ */

/* ---------- Base: 44px minimum touch target ---------- */

.filters-toggle {
  /* WCAG 2.5.5 – minimum 44x44px touch target for mobile users */
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 1;
}

/* ---------- Light mode contrast (WCAG AA) ----------
   Light mode:
     - toggle surface: #ffffff
     - toggle text: #334155 on #ffffff = 10.9:1 (passes AA)
     - hover text: #6d28d9 on #ffffff = 8.4:1 (passes AA)
     - chevron: #475569 on #ffffff = 7.5:1 (passes AA)
*/

.filters-toggle {
  color: #334155 !important;
  background-color: #ffffff !important;
  border-color: #e2e8f0 !important;
}

.filters-toggle:hover {
  color: #6d28d9 !important;
  border-color: #c4b5fd !important;
}

.filters-toggle-chevron {
  color: #475569 !important;
}

.filters-toggle:hover .filters-toggle-chevron {
  color: #6d28d9 !important;
}

/* ---------- Dark mode contrast (WCAG AA) ----------
   Dark mode:
     - toggle surface: #0f172a
     - toggle text: #e2e8f0 on #0f172a = 12.4:1 (passes AA)
     - hover text: #c4b5fd on #0f172a = 9.6:1 (passes AA)
     - chevron: #cbd5e1 on #0f172a = 11.6:1 (passes AA)
*/

.dark .filters-toggle {
  color: #e2e8f0 !important;
  background-color: #0f172a !important;
  border-color: #334155 !important;
}

.dark .filters-toggle:hover {
  color: #c4b5fd !important;
  border-color: #8b5cf6 !important;
}

.dark .filters-toggle-chevron {
  color: #cbd5e1 !important;
}

.dark .filters-toggle:hover .filters-toggle-chevron {
  color: #c4b5fd !important;
}

/* ---------- Focus-visible ring (keyboard) ---------- */

.filters-toggle:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
  box-shadow:
    0 0 0 2px #ffffff,
    0 0 0 6px rgba(124, 58, 237, 0.35);
}

.dark .filters-toggle:focus-visible {
  outline-color: #c4b5fd;
  box-shadow:
    0 0 0 2px #0f172a,
    0 0 0 6px rgba(196, 181, 253, 0.45);
}

/* ---------- Fallback for browsers without :focus-visible ---------- */

@supports not selector(:focus-visible) {
  .filters-toggle:focus {
    outline: 2px solid #7c3aed;
    outline-offset: 2px;
    box-shadow:
      0 0 0 2px #ffffff,
      0 0 0 6px rgba(124, 58, 237, 0.35);
  }

  .dark .filters-toggle:focus {
    outline-color: #c4b5fd;
    box-shadow:
      0 0 0 2px #0f172a,
      0 0 0 6px rgba(196, 181, 253, 0.45);
  }
}

/* ---------- Small screens: keep the 44px target ---------- */

@media (max-width: 480px) {
  .filters-toggle {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ---------- prefers-reduced-motion guard ----------
   The filters toggle rotates its chevron when expanded and may
   animate on hover/focus. Users who prefer reduced motion should
   see state changes instantly, with no motion. */

@media (prefers-reduced-motion: reduce) {
  .filters-toggle,
  .filters-toggle-chevron {
    transition: none !important;
    animation: none !important;
    transform: none !important;
    scroll-behavior: auto !important;
  }

  /* Neutralise any hover/focus/active transform on the toggle */
  .filters-toggle:hover,
  .filters-toggle:focus,
  .filters-toggle:focus-visible,
  .filters-toggle:active {
    transform: none !important;
    transition: none !important;
  }

  /* The chevron must not rotate or animate when the panel expands */
  .filters-toggle-chevron,
  .filters-toggle[aria-expanded="true"] .filters-toggle-chevron,
  .filters-toggle[aria-expanded="false"] .filters-toggle-chevron {
    transform: none !important;
    transition: none !important;
    animation: none !important;
  }

  /* Icons inside the toggle must not animate either */
  .filters-toggle i,
  .filters-toggle svg {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }

  /* Disable any pulse/scale animation on the toggle */
  .filters-toggle,
  .filters-toggle::before,
  .filters-toggle::after {
    animation: none !important;
    transform: none !important;
  }

  /* Keep the focus ring visible but static (no animated halo) */
  .filters-toggle:focus-visible {
    box-shadow:
      0 0 0 2px #ffffff,
      0 0 0 6px rgba(124, 58, 237, 0.35) !important;
  }

  .dark .filters-toggle:focus-visible {
    box-shadow:
      0 0 0 2px #0f172a,
      0 0 0 6px rgba(196, 181, 253, 0.45) !important;
  }
}

/* ---------- Forced colors (Windows High Contrast) ---------- */

@media (forced-colors: active) {
  .filters-toggle {
    border: 1px solid CanvasText;
    color: CanvasText;
    background: Canvas;
  }

  .filters-toggle:hover {
    background: Highlight;
    color: HighlightText;
  }

  .filters-toggle-chevron {
    color: CanvasText;
  }

  .filters-toggle:hover .filters-toggle-chevron {
    color: HighlightText;
  }

  .filters-toggle:focus-visible,
  .filters-toggle:focus {
    outline: 2px solid Highlight;
    outline-offset: 2px;
    box-shadow: none;
    background: Highlight;
    color: HighlightText;
  }
}
