@use 'variables' as *;
@use 'mixins' as *;
@forward 'variables';
@forward 'mixins';

// Global CSS custom properties for accessibility
:root {
  --color-primary: #2563eb;
  --color-secondary: #60a5fa;
  --color-focus-ring: #2563eb;
  --color-text-aaa-light: #111827;
  --color-text-aaa-dark: #ffffff;
  --box-shadow-hover: rgba(0, 0, 0, 0.15);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-primary: #60a5fa;
    --color-secondary: #93c5fd;
    --color-focus-ring: #60a5fa;
  }
}

// Screen Reader Only Classes - Central Definition
.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;
}

.sr-only-focusable:focus {
  position: static !important;
  width: auto !important;
  height: auto !important;
  padding: 0.5rem !important;
  margin: 0 !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
  background-color: var(--color-primary) !important;
  color: var(--color-text-aaa-dark) !important;
  border: 2px solid var(--color-focus-ring) !important;
  border-radius: 4px !important;
  text-decoration: none !important;
  z-index: 1000 !important;
  outline: 2px solid var(--color-focus-ring) !important;
  outline-offset: 2px !important;
}

// Skip link for accessibility
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--color-primary);
  color: var(--color-text-aaa-dark);
  padding: 8px;
  text-decoration: none;
  z-index: 9999;
  border-radius: 4px;
  font-weight: 500;
  transition: top 0.3s;

  &:focus {
    top: 6px;
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 2px;
  }
}

// Global button placeholder
%button-base {
  @include button-base;
}

// Global card placeholder
%card-base {
  border-radius: $border-radius-md;
  box-shadow: var(--box-shadow-md);
  @include card-hover;
}

// AAA Focus Management
%focus-aaa {
  &:focus {
    outline: 3px solid var(--color-focus-ring);
    outline-offset: 2px;
    border-radius: 4px;
  }
}

// Apply AAA focus to all interactive elements
button,
a,
input,
select,
textarea,
[tabindex]:not([tabindex='-1']) {
  @extend %focus-aaa;
}

// High contrast mode support
@media (prefers-contrast: high) {
  * {
    &:focus {
      outline: 4px solid currentColor !important;
      outline-offset: 2px !important;
    }
  }

  button,
  a {
    border: 2px solid currentColor !important;
  }
}

// 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 size for AAA (minimum 44x44px)
@media (pointer: coarse) {
  button,
  a,
  input,
  select,
  textarea,
  [role='button'] {
    min-height: 44px;
    min-width: 44px;
  }
}

// Responsive mixins (keep existing)
@mixin mobile-only {
  @media (max-width: #{$mobile-breakpoint - 1px}) {
    @content;
  }
}

@mixin desktop-only {
  @media (min-width: $desktop-breakpoint) {
    @content;
  }
}

// Common button base styles
%button-base {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  transition: all 0.3s ease;
  text-decoration: none;

  &:focus {
    outline: none;
  }

  &:active {
    transform: translateY(0);
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
  }
}

// Interactive element hover effects
%hover-lift {
  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--box-shadow-hover);
  }
}

// Clean button reset
%button-reset {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
