/**
 * Wazzaf Neo - Accessibility Enhancements
 * WCAG 2.1 Level AA Compliance
 * Focus states, keyboard navigation, screen reader support
 */

/* ==========================================================================
   SKIP LINKS
   Hidden by default, visible on keyboard focus
   ========================================================================== */

.neo-skip-links {
  position: absolute;
  top: 0;
  left: 0;
  z-index: var(--neo-z-tooltip);
}

.neo-skip-link {
  position: absolute;
  top: -100px;
  left: var(--neo-space-4);
  padding: var(--neo-space-3) var(--neo-space-6);
  background: var(--neo-indigo-600);
  color: white;
  font-weight: var(--neo-font-semibold);
  text-decoration: none;
  border-radius: var(--neo-radius-base);
  box-shadow: var(--neo-shadow-xl);
  transition: all var(--neo-duration-fast) var(--neo-ease-out);
}

.neo-skip-link:focus {
  top: var(--neo-space-4);
  outline: 3px solid var(--neo-indigo-300);
  outline-offset: 2px;
}

/* ==========================================================================
   FOCUS INDICATORS
   Visible, high-contrast focus states for keyboard navigation
   ========================================================================== */

/* Global focus style */
*:focus {
  outline: 2px solid var(--neo-indigo-500);
  outline-offset: 2px;
}

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

/* Enhanced focus-visible for keyboard users */
*:focus-visible {
  outline: 3px solid var(--neo-indigo-500);
  outline-offset: 3px;
  transition: outline-offset var(--neo-duration-fast) var(--neo-ease-out);
}

/* Button focus states */
.neo-btn:focus-visible {
  outline: 3px solid var(--neo-indigo-400);
  outline-offset: 4px;
  box-shadow: var(--neo-shadow-indigo);
}

.neo-btn-primary:focus-visible {
  outline-color: var(--neo-jade-400);
}

.neo-btn-secondary:focus-visible {
  outline-color: var(--neo-indigo-500);
}

/* Link focus states */
a:focus-visible {
  outline: 2px solid var(--neo-indigo-500);
  outline-offset: 3px;
  background: var(--neo-indigo-50);
  border-radius: var(--neo-radius-sm);
}

/* Input focus states */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--neo-indigo-500);
  outline-offset: 0;
  border-color: var(--neo-indigo-400);
  box-shadow: 0 0 0 3px var(--neo-indigo-100);
}

/* Card focus states (for interactive cards) */
.neo-value-card:focus-visible,
.neo-testimonial-card:focus-visible {
  outline: 3px solid var(--neo-indigo-500);
  outline-offset: 2px;
  transform: translateY(-8px);
  box-shadow: var(--neo-shadow-xl);
}

/* Navigation link focus */
.neo-nav-link:focus-visible {
  outline: 2px solid var(--neo-indigo-500);
  outline-offset: 2px;
  background: var(--neo-indigo-100);
}

/* ==========================================================================
   HIGH CONTRAST MODE SUPPORT
   Respects Windows High Contrast Mode
   ========================================================================== */

@media (prefers-contrast: high) {
  :root {
    --neo-shadow-base: 0 4px 8px -1px rgba(0, 0, 0, 0.3);
    --neo-shadow-md: 0 6px 16px -2px rgba(0, 0, 0, 0.4);
    --neo-shadow-lg: 0 10px 24px -4px rgba(0, 0, 0, 0.5);
  }

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

  .neo-btn {
    border: 2px solid currentColor;
  }

  .neo-text-gradient {
    -webkit-text-fill-color: unset;
    background: none;
    color: var(--neo-indigo-600);
  }
}

/* ==========================================================================
   SCREEN READER ONLY CONTENT
   Visually hidden but available 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;
}

/* Make sr-only content visible on focus (for skip links) */
.sr-only:focus,
.sr-only:active {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

.sr-only-focusable:not(:focus):not(:focus-within) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ==========================================================================
   KEYBOARD NAVIGATION HELPERS
   ========================================================================== */

/* Visible focus indicator for keyboard users */
.keyboard-nav *:focus {
  outline: 3px solid var(--neo-indigo-500);
  outline-offset: 3px;
}

/* Tab order indicator (for testing) */
[tabindex]:not([tabindex="-1"]) {
  position: relative;
}

/* ==========================================================================
   ARIA LIVE REGIONS
   For dynamic content announcements
   ========================================================================== */

.neo-live-region {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ==========================================================================
   FORM ACCESSIBILITY
   ========================================================================== */

/* Required field indicator */
.neo-form-required::after {
  content: '*';
  color: var(--neo-error);
  margin-left: var(--neo-space-1);
  font-weight: var(--neo-font-bold);
}

/* Error message styling */
.neo-form-error {
  display: flex;
  align-items: center;
  gap: var(--neo-space-2);
  padding: var(--neo-space-3) var(--neo-space-4);
  background: var(--neo-error-light);
  border: 1px solid var(--neo-error);
  border-radius: var(--neo-radius-base);
  color: var(--neo-error);
  font-size: var(--neo-text-sm);
  margin-top: var(--neo-space-2);
}

.neo-form-error::before {
  content: '⚠️';
  font-size: var(--neo-text-base);
}

/* Success message styling */
.neo-form-success {
  display: flex;
  align-items: center;
  gap: var(--neo-space-2);
  padding: var(--neo-space-3) var(--neo-space-4);
  background: var(--neo-success-light);
  border: 1px solid var(--neo-success);
  border-radius: var(--neo-radius-base);
  color: var(--neo-gray-900);
  font-size: var(--neo-text-sm);
  margin-top: var(--neo-space-2);
}

.neo-form-success::before {
  content: '✓';
  color: var(--neo-success);
  font-weight: var(--neo-font-bold);
}

/* Invalid input styling */
input:invalid:not(:placeholder-shown),
textarea:invalid:not(:placeholder-shown) {
  border-color: var(--neo-error);
  background: var(--neo-error-light);
}

input:invalid:not(:placeholder-shown):focus,
textarea:invalid:not(:placeholder-shown):focus {
  outline-color: var(--neo-error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* ==========================================================================
   MODAL / DIALOG ACCESSIBILITY
   ========================================================================== */

.neo-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: var(--neo-z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--neo-space-6);
}

.neo-modal {
  background: white;
  border-radius: var(--neo-radius-lg);
  box-shadow: var(--neo-shadow-2xl);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  z-index: var(--neo-z-modal);
}

.neo-modal:focus {
  outline: none;
}

.neo-modal-close {
  position: absolute;
  top: var(--neo-space-4);
  right: var(--neo-space-4);
  width: 40px;
  height: 40px;
  border-radius: var(--neo-radius-full);
  background: var(--neo-gray-100);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--neo-duration-fast) var(--neo-ease-out);
}

.neo-modal-close:hover {
  background: var(--neo-gray-200);
  transform: scale(1.1);
}

.neo-modal-close:focus-visible {
  outline: 3px solid var(--neo-indigo-500);
  outline-offset: 2px;
}

/* Disable scroll when modal is open */
body.neo-modal-open {
  overflow: hidden;
}

/* ==========================================================================
   TOOLTIP ACCESSIBILITY
   ========================================================================== */

.neo-tooltip {
  position: relative;
  display: inline-block;
}

.neo-tooltip-content {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: var(--neo-space-2) var(--neo-space-3);
  background: var(--neo-gray-900);
  color: white;
  font-size: var(--neo-text-sm);
  border-radius: var(--neo-radius-base);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all var(--neo-duration-fast) var(--neo-ease-out);
  z-index: var(--neo-z-tooltip);
}

.neo-tooltip:hover .neo-tooltip-content,
.neo-tooltip:focus-within .neo-tooltip-content {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* ==========================================================================
   REDUCED TRANSPARENCY (for users who prefer)
   ========================================================================== */

@media (prefers-reduced-transparency) {
  .neo-glass-bg,
  .neo-nav-inner,
  .neo-value-card,
  .neo-testimonial-card {
    backdrop-filter: none;
    background: white;
  }

  .neo-modal-overlay {
    background: rgba(0, 0, 0, 0.9);
  }
}

/* ==========================================================================
   PRINT STYLES (Accessibility for printing)
   ========================================================================== */

@media print {
  /* Hide non-essential elements */
  .neo-nav,
  .neo-skip-links,
  .neo-hero-search,
  .neo-btn,
  .neo-modal-overlay {
    display: none !important;
  }

  /* Ensure text is readable */
  body {
    font-size: 12pt;
    line-height: 1.5;
    color: #000;
    background: #fff;
  }

  /* Show link URLs */
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 10pt;
    color: #666;
  }

  /* Avoid page breaks inside elements */
  .neo-value-card,
  .neo-testimonial-card,
  .neo-story-step {
    page-break-inside: avoid;
  }
}

/* ==========================================================================
   COLOR BLIND SAFE PATTERNS
   Uses shape + color to convey information
   ========================================================================== */

.neo-status-success::before {
  content: '✓ ';
}

.neo-status-error::before {
  content: '✗ ';
}

.neo-status-warning::before {
  content: '⚠ ';
}

.neo-status-info::before {
  content: 'ℹ ';
}

/* ==========================================================================
   FORCED COLORS MODE (Windows High Contrast)
   ========================================================================== */

@media (forced-colors: active) {
  .neo-btn {
    border: 2px solid;
  }

  .neo-text-gradient {
    -webkit-text-fill-color: unset;
    background: none;
    color: LinkText;
  }

  *:focus-visible {
    outline: 3px solid Highlight;
  }
}

/* ==========================================================================
   TOUCH TARGET SIZES (Minimum 44x44px for WCAG compliance)
   ========================================================================== */

@media (pointer: coarse) {
  /* Mobile/touch devices */
  .neo-btn,
  .neo-nav-link,
  .neo-nav-hamburger {
    min-height: 44px;
    min-width: 44px;
  }

  .neo-nav-link {
    padding: var(--neo-space-3) var(--neo-space-4);
  }
}
