/**
 * Accessibility Enhancements
 * Respects user preferences for reduced motion, high contrast, etc.
 */

/* ═══════════════════════════════════════════════════════════════════════════
   REDUCED MOTION
   Respect users who prefer reduced motion (vestibular disorders, motion sensitivity)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    /* Disable all animations */
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;

    /* Disable all transitions */
    transition-duration: 0.01ms !important;

    /* Disable smooth scrolling */
    scroll-behavior: auto !important;
  }

  /* Specifically target transform-based animations */
  [class*="animate-"],
  [class*="transition-"],
  .fade-in,
  .slide-in,
  .zoom-in,
  .modal,
  .dialog,
  .toast,
  .dropdown {
    animation: none !important;
    transition: none !important;
  }

  /* Keep essential visual feedback (very quick) */
  button:active,
  a:active,
  .btn:active {
    transition: background-color 0.05s, color 0.05s !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   HIGH CONTRAST MODE
   Improve readability for users with low vision
   ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-contrast: high) {
  :root {
    --text-main: #000;
    --text-2: #333;
    --bg-main: #fff;
    --bg-surface: #f5f5f5;
    --border: #000;
    --primary: #0000ff;
  }

  [data-theme="dark"] {
    --text-main: #fff;
    --text-2: #ccc;
    --bg-main: #000;
    --bg-surface: #1a1a1a;
    --border: #fff;
    --primary: #66b3ff;
  }

  /* Ensure all interactive elements have clear borders */
  button,
  a,
  input,
  select,
  textarea {
    border: 2px solid currentColor !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   FOCUS VISIBLE (Keyboard Navigation)
   Clear focus indicators for keyboard-only users
   ═══════════════════════════════════════════════════════════════════════════ */

/* Hide focus ring for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* Show clear focus ring for keyboard users */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-2);
}

/* Enhanced focus for interactive elements */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent);
}

/* ═══════════════════════════════════════════════════════════════════════════
   DARK MODE PREFERENCES
   Respect system dark mode preference
   ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
  }
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TRANSPARENT VIDEO (Auto-play preference)
   Disable auto-playing animations if user prefers reduced motion
   ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  video,
  .video-container {
    animation-play-state: paused !important;
  }

  /* Pause GIF-like animations */
  [data-animated] {
    animation-play-state: paused !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SCREEN READER UTILITIES
   ═══════════════════════════════════════════════════════════════════════════ */

/* Visually hidden but accessible to screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Show on focus (skip links) */
.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════════════════════════════════════════ */

@media print {
  /* Hide navigation and non-essential elements */
  .app-sidebar,
  .app-header,
  .app-footer,
  button,
  .modal,
  .toast,
  [aria-hidden="true"] {
    display: none !important;
  }

  /* Ensure text is black on white */
  * {
    color: #000 !important;
    background: #fff !important;
  }

  /* Show link URLs */
  a::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
}
