/* ============================================
   ACCESSIBILITY ENHANCEMENTS
   ============================================ */

/* 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-width: 0;
}

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

/* Skip Navigation Link */
.skip-to-main {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--accent);
  color: white;
  padding: 12px 20px;
  text-decoration: none;
  font-weight: 600;
  z-index: 10001;
  border-radius: 0 0 8px 0;
  transition: top 0.3s ease;
}

.skip-to-main:focus {
  top: 0;
  outline: 3px solid var(--accent-dark);
  outline-offset: 2px;
}

/* Enhanced Focus States */
*:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Keyboard Navigation Indicators */
.keyboard-navigation-active *:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(31, 182, 255, 0.1);
}

/* ARIA Live Regions */
[role="status"],
[role="alert"],
[aria-live] {
  position: relative;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  :root {
    --accent: #0078d4;
    --border: #000000;
  }

  .btn {
    border: 2px solid currentColor;
  }

  .card-dog {
    border: 2px solid var(--border);
  }
}

/* Reduced Motion Support */
@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;
  }
}

/* Touch Target Sizes for Accessibility */
@media (pointer: coarse) {
  button,
  a,
  input[type="button"],
  input[type="submit"],
  input[type="reset"],
  .clickable {
    min-height: 44px;
    min-width: 44px;
  }

  .nav-link {
    min-height: 48px;
    display: flex;
    align-items: center;
  }
}

/* Better Color Contrast for Text */
.text-muted {
  color: var(--muted);
  font-weight: 500;
}

[data-theme="dark"] .text-muted {
  color: #9ca3af;
}

/* ARIA Attributes Styling */
[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

[aria-hidden="true"] {
  display: none !important;
}

[aria-expanded="false"] + * {
  display: none;
}

[aria-expanded="true"] + * {
  display: block;
}

/* Loading State Announcements */
.loading-announcement {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Focus Trap for Modals */
.modal-open {
  overflow: hidden;
}

.modal-open .modal {
  overflow-x: hidden;
  overflow-y: auto;
}

/* Keyboard Navigation Helper */
.keyboard-navigation-helper {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--card);
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  display: none;
  animation: slideInRight 0.3s ease;
}

.keyboard-navigation-helper.show {
  display: block;
}

@keyframes slideInRight {
  from {
    transform: translateX(100px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Better Link Underlines for Accessibility */
a:not(.btn):not(.nav-link) {
  text-decoration-skip-ink: auto;
}

a:not(.btn):not(.nav-link):hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

/* Image Alt Text Fallback */
img:not([alt]) {
  border: 3px solid var(--danger);
  outline: 3px solid var(--danger);
}

/* Form Label Association */
label {
  cursor: pointer;
}

label[for] {
  user-select: none;
}

/* Required Field Indicator */
.required::after {
  content: " *";
  color: var(--danger);
  font-weight: 700;
}

/* Error Message Styling */
.error-message {
  color: var(--danger);
  font-size: 0.875rem;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.error-message::before {
  content: "?";
  font-size: 1rem;
}

/* Success Message Styling */
.success-message {
  color: var(--success);
  font-size: 0.875rem;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.success-message::before {
  content: "?";
  font-size: 1rem;
  font-weight: 700;
}
