/* Perkalate Accessibility Styles - WCAG 2.1 AA Compliant */

/* Skip to content link - must be first focusable element */
.a11y-skip {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 10000;
  background: #8b5cf6;
  color: #fff;
  padding: 12px 24px;
  border-radius: 0 0 12px 12px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s ease;
  border: 2px solid transparent;
}
.a11y-skip:focus {
  top: 0;
  outline: none;
  border-color: #fff;
}

/* Skip to navigation link */
.a11y-skip-nav {
  position: absolute;
  top: -100px;
  left: 160px;
  z-index: 10000;
  background: #6d28d9;
  color: #fff;
  padding: 12px 24px;
  border-radius: 0 0 12px 12px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s ease;
  border: 2px solid transparent;
}
.a11y-skip-nav:focus {
  top: 0;
  outline: none;
  border-color: #fff;
}

/* Focus-visible styles — keyboard users only */
*:focus-visible {
  outline: 2px solid #a78bfa;
  outline-offset: 2px;
  border-radius: 4px;
}

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

/* Nav items focus */
.nav-item:focus-visible {
  outline-offset: -2px;
  border-radius: 8px;
}

/* Cards focus */
.brand-card:focus-visible,
.reward-card:focus-visible {
  outline-offset: -1px;
  border-radius: 16px;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.5);
}

/* Buttons focus */
.reward-btn:focus-visible,
.filter-tab:focus-visible,
.brand-chip:focus-visible {
  outline: 2px solid #a78bfa;
  outline-offset: 2px;
}

/* Modal close button focus */
.pass-close-x:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Hidden live region */
.a11y-live {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Improved contrast for muted text — bump from 0.4 to 0.55 */
.text-muted-a11y,
.reward-expires,
.pass-count,
.brand-value[style*="text-muted"],
.page-subtitle {
  color: rgba(255, 255, 255, 0.55) !important;
}

/* Respect 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;
  }
  .status-dot {
    animation: none !important;
  }
}

/* Minimum touch target size (44x44px) */
.nav-item {
  min-height: 44px;
  min-width: 44px;
}

.reward-btn,
.filter-tab {
  min-height: 44px;
}

.brand-chip {
  min-width: 48px;
  min-height: 48px;
}

.pass-close-x {
  min-width: 44px;
  min-height: 44px;
}

/* Info button sizing */
.info-btn {
  min-width: 44px;
  min-height: 44px;
}

/* Enhanced contrast for better readability */
.a11y-high-contrast .text-muted,
.a11y-high-contrast .page-subtitle,
.a11y-high-contrast .reward-expires,
.a11y-high-contrast .pass-count {
  color: rgba(255, 255, 255, 0.8) !important;
}

/* Error and success states */
.a11y-error {
  color: #ef4444 !important;
  border-color: #ef4444 !important;
}
.a11y-success {
  color: #10b981 !important;
  border-color: #10b981 !important;
}

/* Loading states - screen reader friendly */
.a11y-loading::after {
  content: " (loading)";
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Form labels - ensure proper association */
.a11y-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: block;
}

/* Required field indicators */
.a11y-required::after {
  content: " *";
  color: #ef4444;
  font-weight: 600;
}

/* Modal focus management */
.modal-active {
  overflow: hidden;
}
.modal-active * {
  /* Disable all interactive elements outside modal */
  pointer-events: none;
}
.modal-active .modal,
.modal-active .modal * {
  /* Re-enable inside modal */
  pointer-events: auto;
}

/* Keyboard-only focus indicators */
.a11y-keyboard-focus:focus-visible {
  outline: 3px solid #a78bfa;
  outline-offset: 2px;
  border-radius: 4px;
  box-shadow: 0 0 0 1px #8b5cf6;
}

/* Screen reader only text */
.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;
}

/* When screen reader content becomes visible */
.sr-only:focus {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: inherit;
  border: inherit;
}

/* Improved button states */
button:disabled,
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Link states */
a:hover {
  text-decoration: underline;
}
a:focus-visible {
  outline: 2px solid #a78bfa;
  outline-offset: 2px;
  border-radius: 2px;
}

/* Enhanced search input */
.search-box[aria-expanded="true"] + .search-results {
  display: block;
}

/* Status announcements */
.status-announcement {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Progressive enhancement for JavaScript-disabled users */
.no-js .js-only {
  display: none !important;
}

.no-js .no-js-fallback {
  display: block !important;
}

/* High contrast mode support */
@media (forced-colors: active) {
  .brand-card,
  .reward-card {
    border: 2px solid ButtonText;
  }
  .nav-item.active {
    border-bottom: 2px solid Highlight;
  }
  .filter-tab.active {
    border: 2px solid Highlight;
  }
  .a11y-skip,
  .a11y-skip-nav {
    background: ButtonFace;
    color: ButtonText;
    border-color: ButtonText;
  }
  
  /* Ensure icons are visible */
  .nav-item i,
  .brand-logo img {
    opacity: 1;
    filter: none;
  }
}

/* Print styles for better accessibility */
@media print {
  .nav-item,
  .fixed-header,
  .bottom-nav {
    display: none;
  }
  
  .content {
    padding: 0;
  }
  
  a[href]:after {
    content: " (" attr(href) ")";
    font-size: 90%;
    color: #666;
  }
}
