/**
 * Accessibility (a11y) Styles for Metablox
 * WCAG 2.1 AA Compliance
 */

/* ============================================
   Skip Links
   ============================================ */

.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a2e;
  color: #fff;
  padding: 12px 24px;
  border-radius: 0 0 8px 8px;
  z-index: 100000;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid #f37442;
  outline-offset: 2px;
}

/* ============================================
   Focus Indicators
   ============================================ */

/* Default focus style for all focusable elements */
:focus {
  outline: 2px solid #f37442;
  outline-offset: 2px;
}

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

:focus-visible {
  outline: 3px solid #f37442;
  outline-offset: 2px;
}

/* Button focus states */
button:focus-visible,
[role="button"]:focus-visible,
.btn:focus-visible,
.big-btn:focus-visible {
  outline: 3px solid #f37442;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(243, 116, 66, 0.3);
}

/* Input focus states */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid #f37442;
  outline-offset: 0;
  border-color: #f37442;
}

/* Link focus states */
a:focus-visible {
  outline: 2px solid #f37442;
  outline-offset: 2px;
  border-radius: 2px;
}

/* ============================================
   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;
}

/* Make sr-only content visible when focused (for skip links) */
.sr-only-focusable:focus,
.sr-only-focusable:active {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: inherit;
}

/* ============================================
   High Contrast Mode Support
   ============================================ */

@media (prefers-contrast: high) {
  :focus,
  :focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 3px;
  }

  button,
  .btn,
  a {
    border: 2px solid currentColor;
  }
}

/* ============================================
   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;
  }

  .offline-toast {
    transition: none;
  }
}

/* ============================================
   Navigation Accessibility
   ============================================ */

/* Bottom navigation icons - ensure proper tap targets */
.bottom-nav-icon {
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Menu button touch target */
.menu-btn,
.profile-menu-btn {
  min-width: 44px;
}

/* ============================================
   Form Accessibility
   ============================================ */

/* Error messages */
.error-msg {
  color: #d32f2f;
  font-size: 12px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.error-msg[role="alert"] {
  background: #ffebee;
  padding: 8px 12px;
  border-radius: 4px;
  border-left: 3px solid #d32f2f;
}

/* Valid/success messages */
.valid-msg {
  color: #2e7d32;
  font-size: 12px;
  margin-top: 4px;
}

.valid-msg[role="status"] {
  background: #e8f5e9;
  padding: 8px 12px;
  border-radius: 4px;
  border-left: 3px solid #2e7d32;
}

/* Required field indicator */
.required-field::after {
  content: " *";
  color: #d32f2f;
}

/* Invalid input state */
input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: #d32f2f;
  background-color: #fff5f5;
}

input[aria-invalid="true"]:focus,
textarea[aria-invalid="true"]:focus {
  outline-color: #d32f2f;
  box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.2);
}

/* ============================================
   Color Contrast Adjustments
   ============================================ */

/* Ensure links have sufficient contrast */
a:not([class]) {
  color: #c45628;
  text-decoration: underline;
}

a:not([class]):hover {
  color: #f37442;
}

/* Placeholder text - ensure minimum contrast */
::placeholder {
  color: #6b6b6b;
  opacity: 1;
}

/* Disabled states */
button:disabled,
input:disabled,
select:disabled,
textarea:disabled,
[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================
   Interactive Elements
   ============================================ */

/* Ensure clickable elements look clickable */
[role="button"],
[onclick],
[tabindex="0"] {
  cursor: pointer;
}

/* Remove pointer events from disabled elements */
[aria-disabled="true"] {
  pointer-events: none;
}

/* ============================================
   Modal Accessibility
   ============================================ */

/* Trap focus indicator for modals */
[role="dialog"],
[role="alertdialog"] {
  position: relative;
}

[role="dialog"]:focus,
[role="alertdialog"]:focus {
  outline: none;
}

/* ============================================
   Live Regions
   ============================================ */

/* Toast notifications should be announced */
[role="status"],
[role="alert"],
[aria-live] {
  /* Ensure screen readers announce these */
}

/* Loading indicators */
[aria-busy="true"] {
  cursor: wait;
}

/* ============================================
   Icon Buttons
   ============================================ */

/* Icon-only buttons need proper sizing */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.icon-button:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

.icon-button:focus-visible {
  outline: 3px solid #f37442;
  outline-offset: 2px;
}

/* Material icons in buttons should not be focusable */
.icon-button .material-icons,
.icon-button .material-icons-outlined {
  pointer-events: none;
}
