/* ==================== ACCESSIBILITY & UX ENHANCEMENTS ==================== 
   This file overrides theme.css variables for better WCAG AA/AAA contrast.
   It should be loaded AFTER theme.css.
*/

:root {
  /* High contrast text overrides for WCAG AAA compliance */
  --text-dark: #0a0a0a;           /* Darker text for better contrast */
  --text-muted: #444;              /* Better contrast for secondary text */
  
  /* Focus ring colors - high contrast */
  --focus-color: #0a7cff;
  --focus-shadow: rgba(10, 124, 255, 0.25);
}

/* ==================== FOCUS MANAGEMENT ==================== */

/* Remove default focus outline to replace with custom */
button,
select,
input,
textarea,
a {
  outline-offset: 2px;
}

/* High contrast focus indicators */
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: var(--focus-ring);
  box-shadow: var(--focus-shadow);
}

/* Modal focus management */
.modal-close:focus-visible {
  outline: var(--focus-ring);
  border-radius: 4px;
}

/* Ensure all interactive elements have visible focus states */
#country-select:focus {
  outline: none !important;
  border-color: #4F7302 !important;
  box-shadow: 0 0 0 2px rgba(79, 115, 2, 0.15) !important;
}

#top-search input:focus {
  outline: none !important;
  border-color: #4F7302 !important;
  box-shadow: 0 0 0 2px rgba(79, 115, 2, 0.15) !important;
}

#top-search button:focus {
  outline: none !important;
}

#about-btn:focus {
  outline: none !important;
}

/* Top search button improvements */
#top-search button {
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Selection improvements for keyboard navigation */
select:focus,
input:focus {
  border-color: #0a7cff !important;
}

/* ==================== SMOOTH TRANSITIONS ==================== */

/* Enable smooth transitions on interactive elements */
body {
  scroll-behavior: smooth;
}

button,
select,
input,
a,
.modal,
.loading,
#map-iframe {
  transition: all 150ms ease;
  will-change: opacity, transform, box-shadow;
}

/* Fade in/out for map loading */
#map-container {
  transition: opacity 150ms ease;
}

#map-iframe {
  transition: opacity 300ms ease, filter 150ms ease;
  will-change: opacity, filter;
}

/* Smooth loading animation */
@keyframes pulse-fade {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

.loading-text {
  animation: pulse-fade 1.2s ease-in-out infinite;
}

/* Smooth fade in for loaded map */
#map-iframe.loaded {
  opacity: 1;
  filter: saturate(0.85);
}

#map-iframe:not(.loaded) {
  opacity: 0;
}

/* Modal smooth transitions */
.modal {
  transition: opacity var(--transition-normal);
  opacity: 0;
  pointer-events: none;
}

.modal.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  transform: translateY(20px);
  transition: transform var(--transition-normal), opacity var(--transition-normal);
}

.modal.show .modal-content {
  transform: translateY(0);
}

/* Smooth icon transitions */
#top-search button,
#about-btn {
  transition: all var(--transition-fast);
}

#top-search button:hover,
#about-btn:hover {
  transform: translateY(-1px);
}

#top-search button:active,
#about-btn:active {
  transform: translateY(1px);
}

/* ==================== TOUCH TARGET SIZE ==================== */

/* Ensure all interactive elements meet 44x44px minimum */
button {
  min-height: 44px;
  min-width: 44px;
}

select {
  min-height: 44px;
}

input {
  min-height: 44px;
}

#top-search button {
  padding: 10px 14px;
  min-width: 44px;
}

#about-btn {
  padding: 12px 20px;
  min-height: 44px;
}

/* ==================== CONTRAST IMPROVEMENTS ==================== */

/* Enhanced button colors for better contrast */
#top-search button,
#about-btn {
  color: white;
  background: #2a5a00;  /* Darker green for better contrast */
}

#top-search button:hover {
  background: #1a3a00;
  color: white;
}

#about-btn:hover {
  background: #1a3a00;
  color: white;
}

/* Input field improvements */
#top-search input,
#country-select {
  background-color: white;
  color: #0a0a0a;
  border: 2px solid #999;
}

#top-search input::placeholder {
  color: #666;
  opacity: 1;
}

/* ==================== KEYBOARD NAVIGATION ==================== */

/* Skip to main content link (hidden by default, visible on focus) */
.skip-to-main {
  position: absolute;
  top: -40px;
  left: 0;
  background: #0a0a0a;
  color: white;
  padding: 8px;
  z-index: 100;
  text-decoration: none;
  font-weight: 600;
}

.skip-to-main:focus {
  top: 0;
}

/* ==================== REDUCED MOTION ==================== */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==================== HIGH CONTRAST MODE ==================== */

@media (prefers-contrast: more) {
  :root {
    --primary: #003399;
    --primary-dark: #001a66;
    --text-dark: #000;
    --text-muted: #333;
    --border-light: #999;
  }
  
  button,
  select,
  input {
    border-width: 2px;
    font-weight: 600;
  }
}

/* ==================== SCREEN READER VISIBILITY ==================== */

/* Visually hidden but accessible to screen readers */
.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;
}

/* Make sr-only visible on focus (useful for keyboard navigation) */
.sr-only:focus {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  margin: 0;
  clip: auto;
  white-space: normal;
  background: #0a0a0a;
  color: white;
  padding: 8px;
  z-index: 100;
}
