/* ============================================
   InfluenceHub – Auth form a11y
   - WCAG AA contrast for .auth-input, .auth-error
     and .auth-mode-btn in both light and dark mode.
   - prefers-reduced-motion guard: disables the
     focus/hover transitions and any pulse/scale
     animation on the auth form controls so users
     who prefer reduced motion are not exposed to
     motion.
   - 44px minimum touch targets for the auth mode
     buttons and inputs (WCAG 2.5.5).
   - Focus-visible rings for keyboard users.
   - Forced-colors (Windows High Contrast) support.
   ============================================ */

/* ---------- Auth input – base contrast (WCAG AA) ----------
   Light mode:
     - input surface: #ffffff
     - input text: #0f172a on #ffffff = 17.9:1 (passes AA)
     - placeholder: #64748b on #ffffff = 4.8:1 (passes AA)
     - border: #cbd5e1 (visible against white)
   Dark mode:
     - input surface: #0f172a
     - input text: #f1f5f9 on #0f172a = 15.9:1 (passes AA)
     - placeholder: #94a3b8 on #0f172a = 7.4:1 (passes AA)
     - border: #334155 (visible against slate-900)
*/

.auth-input {
  color: #0f172a !important;
  background-color: #ffffff !important;
  border-color: #cbd5e1 !important;
}

.auth-input::placeholder {
  color: #64748b !important;
  opacity: 1;
}

.dark .auth-input {
  color: #f1f5f9 !important;
  background-color: #0f172a !important;
  border-color: #334155 !important;
}

.dark .auth-input::placeholder {
  color: #94a3b8 !important;
  opacity: 1;
}

/* Invalid state – keep the rose border but ensure the text stays
   readable against the tinted surface. */
.auth-input[aria-invalid="true"] {
  border-color: #e11d48 !important;
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.12) !important;
}

.dark .auth-input[aria-invalid="true"] {
  border-color: #fb7185 !important;
  box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.2) !important;
}

/* ---------- Auth error message – base contrast (WCAG AA) ----------
   Light mode:
     - error text: #be123c on #ffffff = 6.9:1 (passes AA)
   Dark mode:
     - error text: #fda4af on #0f172a = 8.9:1 (passes AA)
*/

.auth-error {
  color: #be123c !important;
  font-weight: 500;
}

.dark .auth-error {
  color: #fda4af !important;
}

/* ---------- Auth mode button – base contrast (WCAG AA) ----------
   Light mode (inactive):
     - button text: #475569 on #f1f5f9 = 7.5:1 (passes AA)
   Light mode (active):
     - button text: #ffffff on #7c3aed = 5.9:1 (passes AA)
   Dark mode (inactive):
     - button text: #cbd5e1 on #1e293b = 9.6:1 (passes AA)
   Dark mode (active):
     - button text: #ffffff on #7c3aed = 5.9:1 (passes AA)
*/

.auth-mode-btn {
  color: #475569 !important;
  background-color: transparent !important;
}

.auth-mode-btn:hover {
  color: #6d28d9 !important;
}

.auth-mode-btn.auth-mode-active {
  color: #ffffff !important;
  background-color: #7c3aed !important;
}

.dark .auth-mode-btn {
  color: #cbd5e1 !important;
}

.dark .auth-mode-btn:hover {
  color: #c4b5fd !important;
}

.dark .auth-mode-btn.auth-mode-active {
  color: #ffffff !important;
  background-color: #7c3aed !important;
}

/* ---------- 44px minimum touch targets ---------- */

.auth-input,
.auth-mode-btn {
  /* WCAG 2.5.5 – minimum 44x44px touch target for mobile users */
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

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

.auth-input:focus-visible,
.auth-mode-btn:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.25);
}

.dark .auth-input:focus-visible,
.dark .auth-mode-btn:focus-visible {
  outline-color: #c4b5fd;
  box-shadow: 0 0 0 4px rgba(196, 181, 253, 0.35);
}

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

@supports not selector(:focus-visible) {
  .auth-input:focus,
  .auth-mode-btn:focus {
    outline: 2px solid #7c3aed;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.25);
  }

  .dark .auth-input:focus,
  .dark .auth-mode-btn:focus {
    outline-color: #c4b5fd;
    box-shadow: 0 0 0 4px rgba(196, 181, 253, 0.35);
  }
}

/* ---------- prefers-reduced-motion guard ----------
   The auth inputs and mode buttons may animate on focus/hover
   (border color, box-shadow, background). Users who prefer
   reduced motion should see state changes instantly, with no
   motion. */

@media (prefers-reduced-motion: reduce) {
  .auth-input,
  .auth-error,
  .auth-mode-btn {
    transition: none !important;
    animation: none !important;
    transform: none !important;
    scroll-behavior: auto !important;
  }

  /* Neutralise any hover/focus/active transform on the controls */
  .auth-input:hover,
  .auth-input:focus,
  .auth-input:focus-visible,
  .auth-input:active,
  .auth-mode-btn:hover,
  .auth-mode-btn:focus,
  .auth-mode-btn:focus-visible,
  .auth-mode-btn:active {
    transform: none !important;
    transition: none !important;
  }

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

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

  /* Keep the focus ring visible but static (no animated halo) */
  .auth-input:focus-visible,
  .auth-mode-btn:focus-visible {
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.25) !important;
  }

  .dark .auth-input:focus-visible,
  .dark .auth-mode-btn:focus-visible {
    box-shadow: 0 0 0 4px rgba(196, 181, 253, 0.35) !important;
  }
}

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

@media (forced-colors: active) {
  .auth-input {
    background: Canvas !important;
    color: CanvasText !important;
    border: 1px solid CanvasText !important;
  }

  .auth-input::placeholder {
    color: GrayText !important;
  }

  .auth-input[aria-invalid="true"] {
    border: 2px solid Mark !important;
    box-shadow: none !important;
  }

  .auth-error {
    color: CanvasText !important;
  }

  .auth-mode-btn {
    background: Canvas !important;
    color: CanvasText !important;
    border: 1px solid CanvasText !important;
  }

  .auth-mode-btn.auth-mode-active {
    background: Highlight !important;
    color: HighlightText !important;
    border-color: HighlightText !important;
  }

  .auth-input:focus-visible,
  .auth-input:focus,
  .auth-mode-btn:focus-visible,
  .auth-mode-btn:focus {
    outline: 2px solid Highlight;
    outline-offset: 2px;
    box-shadow: none !important;
  }
}
