/**
 * Expert-Level Accessibility CSS
 * WCAG 2.1 AA Compliant Styles
 */

/* Skip to main content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: #000;
  color: #fff;
  padding: 8px 16px;
  text-decoration: none;
  font-weight: 600;
  border-radius: 0 0 4px 4px;
  z-index: 1000;
  transition: top 0.3s ease;
}

.skip-link:focus {
  top: 0;
}

/* Screen reader only content */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Enhanced focus indicators for keyboard navigation */
body.using-keyboard *:focus {
  outline: 3px solid #4A90E2 !important;
  outline-offset: 2px !important;
}

body.using-keyboard button:focus,
body.using-keyboard a:focus,
body.using-keyboard input:focus,
body.using-keyboard textarea:focus,
body.using-keyboard select:focus {
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.3) !important;
}

/* High contrast mode support */
.high-contrast {
  --primary: #0066cc;
  --primary-dark: #004499;
  --secondary: #00aa00;
  --dark: #000000;
  --light: #ffffff;
  --gray: #666666;
}

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

.high-contrast .service-card {
  border: 2px solid #666666;
}

.high-contrast .nav-menu a {
  border: 1px solid transparent;
}

.high-contrast .nav-menu a:focus,
.high-contrast .nav-menu a:hover {
  border-color: currentColor;
}

/* Reduced motion preferences */
.reduced-motion *,
.reduced-motion *::before,
.reduced-motion *::after {
  animation-duration: 0.01s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01s !important;
  scroll-behavior: auto !important;
}

/* Color contrast improvements */
.btn:focus {
  background: linear-gradient(135deg, #8e44ad 0%, #7c3aed 100%);
  transform: translateY(-2px);
}

.service-btn:focus {
  background: #8e44ad;
  color: #ffffff;
}

/* Mobile hamburger menu accessibility */
.hamburger-menu {
  cursor: pointer;
  padding: 10px;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  width: 30px;
  height: 30px;
}

.hamburger-menu span {
  display: block;
  height: 3px;
  width: 100%;
  background: currentColor;
  border-radius: 3px;
  transition: all 0.3s ease;
}

.hamburger-menu[aria-expanded="true"] span:nth-child(1) {
  transform: rotate(-45deg) translate(-5px, 6px);
}

.hamburger-menu[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.hamburger-menu[aria-expanded="true"] span:nth-child(3) {
  transform: rotate(45deg) translate(-5px, -6px);
}

/* Enhanced link states */
a:focus {
  outline: 2px solid #4A90E2;
  outline-offset: 2px;
}

a:focus:not(:focus-visible) {
  outline: none;
}

/* Improved form accessibility */
input:focus,
textarea:focus,
select:focus {
  border-color: #4A90E2;
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

/* Error states with sufficient contrast */
.error {
  border-color: #d63384 !important;
  color: #721c24;
  background-color: #f8d7da;
}

.error:focus {
  box-shadow: 0 0 0 3px rgba(214, 51, 132, 0.2);
}

/* Success states */
.success {
  border-color: #198754 !important;
  color: #0f5132;
  background-color: #d1e7dd;
}

/* Ensure decorative elements are properly handled by assistive technology */
.service-icon svg[aria-hidden="true"],
.feature-icon[aria-hidden="true"] {
  pointer-events: none;
}

/* Loading states accessibility */
.loading {
  position: relative;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Media queries for accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01s !important;
  }
}

@media (prefers-contrast: high) {
  .btn {
    border: 2px solid currentColor;
  }

  .service-card {
    border: 2px solid currentColor;
  }
}

/* Dark mode accessibility */
@media (prefers-color-scheme: dark) {
  .skip-link {
    background: #ffffff;
    color: #000000;
  }
}

/* Accessible list structures */
.benefit-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.benefit-list .benefit-card {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
  position: relative;
}

.benefit-list .benefit-card:focus-within {
  outline: 2px solid #4A90E2;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Ensure proper semantics for screen readers */
.benefit-card h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.benefit-card p {
  margin: 0;
  line-height: 1.6;
}

/* Responsive text sizing for accessibility */
@media (max-width: 768px) {
  .skip-link {
    font-size: 16px;
    padding: 12px 20px;
  }
  
  .benefit-card h3 {
    font-size: 1.1rem;
  }
}
