/* Accessibility Enhancements for Mobile */

/* Focus management */
.btn:focus-visible,
.nav a:focus-visible,
.mobile-menu-btn:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

/* Skip links for mobile */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--brand);
  color: white;
  padding: 8px;
  text-decoration: none;
  border-radius: 4px;
  z-index: 1000;
}

.skip-link:focus {
  top: 6px;
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --text: #ffffff;
    --muted: #cccccc;
    --border: #666666;
  }
  
  .btn {
    border: 2px solid currentColor;
  }
  
  .card {
    border: 2px solid var(--border);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .btn,
  .card,
  .nav a {
    transition: none;
  }
  
  .hero__image img {
    transition: none;
  }
}

/* Touch target size compliance */
@media (max-width: 960px) {
  .btn,
  .nav a,
  .mobile-menu-btn,
  input[type="button"],
  input[type="submit"],
  button {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Ensure touch targets are accessible */
  .nav a {
    padding: 12px 16px;
  }
  
  .mobile-menu-btn {
    padding: 12px;
  }
}

/* Focus indicators for touch devices */
.touch-device .btn:focus,
.touch-device .nav a:focus,
.touch-device .mobile-menu-btn:focus {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ARIA live regions for dynamic content */
.aria-live {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Error message accessibility */
.error {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.3);
  padding: 12px;
  border-radius: 8px;
  margin: 8px 0;
}

.error[aria-live="polite"] {
  /* Ensure screen readers announce errors */
}

/* Success message accessibility */
.success {
  color: #51cf66;
  background: rgba(81, 207, 102, 0.1);
  border: 1px solid rgba(81, 207, 102, 0.3);
  padding: 12px;
  border-radius: 8px;
  margin: 8px 0;
}

/* Form field accessibility */
.field label {
  font-weight: 600;
  margin-bottom: 6px;
  display: block;
}

.field input:invalid {
  border-color: #ff6b6b;
}

.field input:valid {
  border-color: #51cf66;
}

/* Required field indicators */
.required::after {
  content: " *";
  color: #ff6b6b;
}

/* Loading state accessibility */
.loading {
  position: relative;
}

.loading::after {
  content: "در حال بارگذاری...";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
}

/* Mobile navigation accessibility */
.nav[aria-expanded="true"] {
  /* Ensure screen readers know menu is open */
}

.mobile-menu-btn[aria-expanded="true"] {
  /* Ensure screen readers know button state */
}

/* Image accessibility */
img:not([alt]) {
  border: 2px dashed #ff6b6b;
}

/* Link accessibility */
a:not([href]) {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Button accessibility */
button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Mobile-specific accessibility improvements */
@media (max-width: 960px) {
  /* Larger touch targets */
  .btn,
  .nav a,
  .mobile-menu-btn {
    min-height: 48px;
    min-width: 48px;
  }
  
  /* Better spacing for touch */
  .nav a {
    margin: 4px 0;
  }
  
  /* Improved focus indicators */
  .btn:focus,
  .nav a:focus {
    outline: 3px solid var(--brand);
    outline-offset: 3px;
  }
}

/* Voice control support */
@media (prefers-reduced-motion: no-preference) {
  .btn:hover,
  .nav a:hover {
    transform: translateY(-1px);
  }
}

/* Keyboard navigation improvements */
.btn:focus,
.nav a:focus,
.mobile-menu-btn:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

/* Mobile screen reader optimizations */
@media (max-width: 960px) {
  .sr-only-mobile {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}
