/**
 * LUMAVINE.AI - WCAG 2.1 AA ACCESSIBILITY ENHANCEMENTS
 * Comprehensive accessibility improvements for full WCAG 2.1 AA compliance
 */

/* =====================================================
   FOCUS INDICATORS (2.4.7 Focus Visible)
   ===================================================== */

/* Enhanced focus indicators with 3:1 contrast ratio */
*:focus-visible {
  outline: 3px solid #a78bfa;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Specific focus styles for interactive elements */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[role="link"]:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #a78bfa;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.2);
}

/* Dark background focus indicators */
.dark-bg *:focus-visible,
[data-theme="dark"] *:focus-visible {
  outline-color: #00d4ff;
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.2);
}

/* =====================================================
   COLOR CONTRAST (1.4.3 Contrast Minimum)
   ===================================================== */

/* Ensure minimum 4.5:1 contrast for normal text */
.text-primary {
  color: #f4f7fa;
}

.text-secondary {
  color: #c4cbd4;
}

.text-muted {
  color: #8891a0;
}

/* Large text (18pt+) can be 3:1 */
h1,
h2,
h3,
.text-large {
  color: #ffffff;
}

/* Link contrast */
a {
  color: #5eead4;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: #2dd4bf;
  text-decoration-thickness: 2px;
}

/* Button contrast */
.btn-primary {
  background: #2dd4bf;
  color: #000000;
  font-weight: 600;
}

.btn-secondary {
  background: #a78bfa;
  color: #000000;
  font-weight: 600;
}

/* =====================================================
   TEXT ALTERNATIVES (1.1.1 Non-text Content)
   ===================================================== */

/* Decorative images */
img[alt=""],
img[role="presentation"] {
  pointer-events: none;
}

/* Icon-only buttons require aria-label */
button:not([aria-label]):not([aria-labelledby]):empty::before,
a[role="button"]:not([aria-label]):not([aria-labelledby]):empty::before {
  content: "⚠️ Missing aria-label";
  position: absolute;
  background: red;
  color: white;
  padding: 2px 4px;
  font-size: 10px;
  z-index: 9999;
}

/* =====================================================
   KEYBOARD NAVIGATION (2.1.1 Keyboard, 2.1.2 No Keyboard Trap)
   ===================================================== */

/* Skip to main content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #2dd4bf;
  color: #000000;
  padding: 8px 16px;
  text-decoration: none;
  font-weight: 600;
  z-index: 10000;
  border-radius: 0 0 4px 0;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid #a78bfa;
  outline-offset: 2px;
}

/* Ensure all interactive elements are keyboard accessible */
[onclick]:not(button):not(a):not([tabindex]) {
  cursor: pointer;
  tabindex: 0;
}

/* Visual indication for keyboard navigation */
body.using-keyboard *:focus {
  outline: 3px solid #a78bfa;
  outline-offset: 2px;
}

/* =====================================================
   TIMING (2.2.1 Timing Adjustable)
   ===================================================== */

/* Pause button for auto-playing content */
.auto-play-control {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  border: 2px solid #2dd4bf;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  z-index: 1000;
  font-weight: 600;
}

.auto-play-control:focus-visible {
  outline: 3px solid #a78bfa;
  outline-offset: 2px;
}

/* =====================================================
   SEIZURES (2.3.1 Three Flashes or Below Threshold)
   ===================================================== */

/* Reduce animation for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  /* Disable parallax effects */
  [data-parallax] {
    transform: none !important;
  }
}

/* =====================================================
   NAVIGABLE (2.4 Series)
   ===================================================== */

/* Bypass blocks (2.4.1) - Skip links */
.skip-nav {
  display: flex;
  gap: 8px;
  position: absolute;
  top: -100px;
  left: 0;
  z-index: 10000;
}

.skip-nav a:focus {
  top: 0;
  position: relative;
}

/* Page titled (2.4.2) - Ensure all pages have descriptive titles */
title:empty::after {
  content: "⚠️ Page title is required";
}

/* Focus order (2.4.3) - Logical tab order */
[tabindex]:not([tabindex="-1"]):not([tabindex="0"]) {
  /* Warning: Custom tabindex values can disrupt logical tab order */
  outline: 2px dashed orange;
}

/* Link purpose (2.4.4) - Descriptive link text */
a:empty::before {
  content: "⚠️ Empty link";
  color: red;
}

/* Headings and labels (2.4.6) - Descriptive headings */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 0.5em;
}

/* =====================================================
   READABLE (3.1 Series)
   ===================================================== */

/* Language of page (3.1.1) - Set in HTML lang attribute */
html:not([lang])::before {
  content: "⚠️ HTML lang attribute is required";
  display: block;
  background: red;
  color: white;
  padding: 8px;
  text-align: center;
}

/* Language of parts (3.1.2) - Use lang attribute for different languages */
[lang]:not([lang=""]) {
  font-style: inherit;
}

/* =====================================================
   PREDICTABLE (3.2 Series)
   ===================================================== */

/* On focus (3.2.1) - No context changes on focus */
input:focus,
select:focus,
textarea:focus {
  /* Ensure focus does not trigger unexpected behavior */
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* On input (3.2.2) - No automatic context changes */
input[type="checkbox"],
input[type="radio"] {
  cursor: pointer;
}

/* Consistent navigation (3.2.3) - Navigation in same relative order */
nav[role="navigation"],
header nav {
  position: relative;
}

/* =====================================================
   INPUT ASSISTANCE (3.3 Series)
   ===================================================== */

/* Error identification (3.3.1) */
input:invalid,
select:invalid,
textarea:invalid {
  border: 2px solid #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.error-message {
  color: #ef4444;
  font-size: 0.875rem;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.error-message::before {
  content: "⚠️";
}

/* Labels or instructions (3.3.2) */
input:not([aria-label]):not([aria-labelledby]):not([placeholder]),
select:not([aria-label]):not([aria-labelledby]),
textarea:not([aria-label]):not([aria-labelledby]):not([placeholder]) {
  outline: 2px dashed orange;
}

label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Error suggestion (3.3.3) */
.error-suggestion {
  background: rgba(239, 68, 68, 0.1);
  border-left: 4px solid #ef4444;
  padding: 12px;
  margin-top: 8px;
  border-radius: 4px;
}

/* =====================================================
   COMPATIBLE (4.1 Series)
   ===================================================== */

/* Parsing (4.1.1) - Valid HTML */
/* Name, role, value (4.1.2) - ARIA attributes */

[role="button"]:not(button):not([tabindex]) {
  tabindex: 0;
}

[role="link"]:not(a):not([tabindex]) {
  tabindex: 0;
}

/* Status messages (4.1.3) */
[role="status"],
[role="alert"],
[aria-live] {
  position: relative;
}

[role="alert"] {
  background: rgba(239, 68, 68, 0.1);
  border: 2px solid #ef4444;
  padding: 12px;
  border-radius: 8px;
  margin: 8px 0;
}

[role="status"] {
  background: rgba(45, 212, 191, 0.1);
  border: 2px solid #2dd4bf;
  padding: 12px;
  border-radius: 8px;
  margin: 8px 0;
}

/* =====================================================
   ARIA LIVE REGIONS
   ===================================================== */

[aria-live="polite"],
[aria-live="assertive"] {
  position: relative;
}

.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;
}

.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* =====================================================
   FORM CONTROLS
   ===================================================== */

/* Enhanced form control styling */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="number"],
select,
textarea {
  display: block;
  width: 100%;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 16px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: 3px solid #a78bfa;
  outline-offset: 2px;
  border-color: #2dd4bf;
  background: rgba(255, 255, 255, 0.08);
}

/* Checkbox and radio button sizing */
input[type="checkbox"],
input[type="radio"] {
  width: 20px;
  height: 20px;
  margin-right: 8px;
  cursor: pointer;
}

/* Required field indicator */
input:required,
select:required,
textarea:required {
  border-left-width: 4px;
  border-left-color: #2dd4bf;
}

/* =====================================================
   TOUCH TARGET SIZING (2.5.5 Target Size)
   ===================================================== */

/* Minimum 44x44px touch targets */
button,
a,
input[type="button"],
input[type="submit"],
input[type="checkbox"],
input[type="radio"],
select,
[role="button"],
[role="link"],
.clickable {
  min-height: 44px;
  min-width: 44px;
}

/* Spacing between touch targets */
button + button,
a + a,
[role="button"] + [role="button"] {
  margin-left: 8px;
}

/* =====================================================
   HIGH CONTRAST MODE
   ===================================================== */

@media (prefers-contrast: high) {
  * {
    border-color: currentColor !important;
  }

  button,
  a {
    border: 2px solid currentColor;
  }

  :focus-visible {
    outline-width: 4px;
    outline-offset: 4px;
  }
}

/* =====================================================
   DARK MODE SUPPORT
   ===================================================== */

@media (prefers-color-scheme: dark) {
  .text-primary {
    color: #f4f7fa;
  }

  .text-secondary {
    color: #c4cbd4;
  }

  a {
    color: #5eead4;
  }

  input,
  select,
  textarea {
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.2);
    color: #f4f7fa;
  }
}

/* =====================================================
   PRINT ACCESSIBILITY
   ===================================================== */

@media print {
  /* Ensure sufficient contrast in print */
  * {
    color: #000000 !important;
    background: #ffffff !important;
  }

  a {
    text-decoration: underline;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }
}
