/*
 * Accessibility Enhancements
 * High Contrast Mode, Font Size Controls, Enhanced Focus Indicators
 */

/* ==========================================
   HIGH CONTRAST MODE
   ========================================== */
body.high-contrast {
  --color-primary: #000000;
  --color-secondary: #000000;
  --color-accent: #ffff00;
  --color-text: #000000;
  --color-text-light: #000000;
  --color-background: #ffffff;
  --color-background-alt: #ffff00;
  --color-border: #000000;
  --color-success: #000000;
  --color-error: #000000;
  --color-warning: #000000;
}

body.high-contrast {
  background-color: #ffffff;
  color: #000000;
}

body.high-contrast .hero {
  background: #000000;
  color: #ffff00;
}

body.high-contrast .hero-title,
body.high-contrast .hero-subtitle {
  color: #ffff00;
}

body.high-contrast .site-header {
  background-color: #ffffff;
  border-bottom: 3px solid #000000;
}

body.high-contrast .nav-menu a {
  color: #000000;
  border: 2px solid transparent;
}

body.high-contrast .nav-menu a:hover,
body.high-contrast .nav-menu a:focus {
  background-color: #ffff00;
  border-color: #000000;
  color: #000000;
}

body.high-contrast .info-card,
body.high-contrast .culture-item {
  background-color: #ffffff;
  border: 3px solid #000000;
}

body.high-contrast .info-table th {
  background-color: #000000;
  color: #ffff00;
  border: 2px solid #000000;
}

body.high-contrast .info-table td {
  border: 2px solid #000000;
}

body.high-contrast .site-footer {
  background-color: #000000;
  color: #ffff00;
}

body.high-contrast .site-footer a {
  color: #ffff00;
  text-decoration: underline;
}

body.high-contrast .accessibility-toolbar {
  background-color: #000000;
}

body.high-contrast .accessibility-btn {
  background-color: #ffff00;
  color: #000000;
  border: 2px solid #000000;
}

body.high-contrast a {
  color: #0000ff;
  text-decoration: underline;
  font-weight: 700;
}

body.high-contrast a:hover,
body.high-contrast a:focus {
  background-color: #ffff00;
  color: #000000;
}

body.high-contrast .notice,
body.high-contrast .risk-section {
  background-color: #ffff00;
  border: 3px solid #000000;
  color: #000000;
}

body.high-contrast .footer-notices {
  background-color: #333333;
  border: 2px solid #ffff00;
}

/* ==========================================
   FONT SIZE ADJUSTMENTS
   ========================================== */
body.font-size-small {
  font-size: 14px;
}

body.font-size-large {
  font-size: 18px;
}

body.font-size-xlarge {
  font-size: 20px;
}

body.font-size-xxlarge {
  font-size: 22px;
}

/* Adjust specific elements when font size changes */
body.font-size-large .hero-title,
body.font-size-xlarge .hero-title,
body.font-size-xxlarge .hero-title {
  font-size: calc(var(--font-size-4xl) * 1.1);
}

body.font-size-large h2,
body.font-size-xlarge h2,
body.font-size-xxlarge h2 {
  font-size: calc(var(--font-size-3xl) * 1.1);
}

/* ==========================================
   ENHANCED FOCUS INDICATORS
   ========================================== */
:focus-visible {
  outline: 4px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

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

body.high-contrast :focus-visible {
  outline: 4px solid #ffff00;
  outline-offset: 3px;
  background-color: #000000;
  color: #ffff00;
}

/* ==========================================
   KEYBOARD NAVIGATION HELPERS
   ========================================== */
.keyboard-focus-only:focus-visible {
  outline: 4px dashed var(--color-accent);
  outline-offset: 4px;
}

/* Show focus on keyboard navigation, hide on mouse click */
.js-focus-visible :focus:not(.focus-visible) {
  outline: none;
}

/* ==========================================
   SCREEN READER ONLY
   ========================================== */
.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:active,
.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

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

  html {
    scroll-behavior: auto;
  }
}

/* ==========================================
   PREFERS COLOR SCHEME
   ========================================== */
@media (prefers-color-scheme: dark) {
  /* Optionally enable dark mode based on system preference */
  /* This can be expanded if dark mode is desired */
}

/* ==========================================
   TOUCH TARGET SIZE
   Minimum 44x44px for WCAG 2.1 AAA compliance
   ========================================== */
button:not(.accessibility-btn),
a:not(.accessibility-btn),
input[type="checkbox"],
input[type="radio"],
select {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-menu a {
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* Mobile adjustments for accessibility toolbar */
@media (max-width: 768px) {
  .accessibility-btn {
    min-height: 36px;
    min-width: 36px;
  }
}

/* ==========================================
   HOVER STATES FOR ACCESSIBILITY
   ========================================== */
.interactive-element:hover,
.interactive-element:focus {
  cursor: pointer;
  transform: scale(1.02);
  transition: transform 0.2s ease-in-out;
}

/* ==========================================
   ARIA LIVE REGIONS STYLING
   ========================================== */
[aria-live="polite"],
[aria-live="assertive"] {
  position: relative;
}

.aria-notification {
  padding: 1rem;
  border-radius: 4px;
  margin: 1rem 0;
  border-left: 4px solid;
}

.aria-notification.success {
  background-color: #d1fae5;
  border-color: #059669;
  color: #065f46;
}

.aria-notification.error {
  background-color: #fee2e2;
  border-color: #dc2626;
  color: #991b1b;
}

.aria-notification.warning {
  background-color: #fef3c7;
  border-color: #d97706;
  color: #78350f;
}

.aria-notification.info {
  background-color: #dbeafe;
  border-color: #3b82f6;
  color: #1e40af;
}

/* ==========================================
   TABLE ACCESSIBILITY
   ========================================== */
table:focus {
  outline: 3px solid var(--color-accent);
  outline-offset: 4px;
}

th[scope="col"],
th[scope="row"] {
  font-weight: 700;
}

/* ==========================================
   FORM ACCESSIBILITY
   ========================================== */
label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--color-text);
}

input:required,
select:required,
textarea:required {
  border-left: 4px solid var(--color-accent);
}

.form-error {
  color: var(--color-error);
  font-size: 0.875rem;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-error::before {
  content: "⚠";
  font-size: 1.25rem;
}

/* ==========================================
   SKIP LINKS ENHANCEMENT
   ========================================== */
.skip-link:focus {
  clip: auto;
  height: auto;
  overflow: visible;
  position: absolute;
  width: auto;
  top: 1rem;
  left: 1rem;
  z-index: 10000;
  padding: 1rem 1.5rem;
  background-color: var(--color-primary);
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
  border-radius: 4px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* ==========================================
   LOADING STATES
   ========================================== */
[aria-busy="true"] {
  cursor: wait;
  opacity: 0.6;
  pointer-events: none;
}

/* ==========================================
   DISABLED STATES
   ========================================== */
[aria-disabled="true"],
:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ==========================================
   ENHANCED LINK INDICATORS
   ========================================== */
a[target="_blank"]::after {
  content: " ↗";
  font-size: 0.8em;
  vertical-align: super;
}

a[href^="mailto:"]::before {
  content: "✉ ";
}

a[href^="tel:"]::before {
  content: "☎ ";
}

/* ==========================================
   RESPONSIVE TEXT
   ========================================== */
@media (max-width: 768px) {
  body {
    font-size: 16px;
    line-height: 1.7;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.75rem;
  }

  h3 {
    font-size: 1.5rem;
  }
}

/* ==========================================
   PRINT ACCESSIBILITY
   ========================================== */
@media print {
  body.high-contrast {
    background: white;
    color: black;
  }

  a {
    text-decoration: underline;
    color: black;
  }

  a[href^="http"]:after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }
}