/**
 * MojoLeague - Accessibility CSS
 * Barrierefreiheits-Styles nach WCAG 2.1 AA
 * 
 * Features:
 * - Schriftgrößen-Steuerung (4 Stufen)
 * - Legasthenie-freundliche Schriftart
 * - Fokus-Indikatoren für Tastatur-Navigation
 * - High-Contrast-Modus
 * - Skip-Links
 */

/* ============================================
   BASE STYLES & VARIABLES
   ============================================ */
:root {
  /* Schriftgrößen-Variablen (Standard: medium) */
  --font-size-base: 1rem;
  --font-size-h1: 3rem;
  --font-size-h2: 1.5rem;
  --font-size-body: 1.125rem;
  --font-size-small: 0.875rem;
  
  /* Farbvariablen für Kontrast */
  --color-text: #1a1a1a;
  --color-text-muted: #4a4a4a;
  --color-focus: #736357;
  --color-focus-ring: rgba(115, 99, 87, 0.4);
  
  /* Transition */
  --transition-speed: 0.3s;
}

/* ============================================
   SKIP LINK (Für Screenreader & Tastatur)
   ============================================ */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-text);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  font-weight: 500;
  z-index: 10000;
  border-radius: 0 0 4px 0;
  transition: top 0.3s;
}

.skip-link:focus {
  top: 0;
}

/* ============================================
   SCHriftgrößEN-STEUERUNG
   ============================================ */

/* Small - 14px Base */
[data-font-size="small"] {
  --font-size-base: 0.875rem;
  --font-size-h1: 2.5rem;
  --font-size-h2: 1.25rem;
  --font-size-body: 1rem;
  --font-size-small: 0.75rem;
}

/* Medium - 16px Base (Default) */
[data-font-size="medium"] {
  --font-size-base: 1rem;
  --font-size-h1: 3rem;
  --font-size-h2: 1.5rem;
  --font-size-body: 1.125rem;
  --font-size-small: 0.875rem;
}

/* Large - 20px Base */
[data-font-size="large"] {
  --font-size-base: 1.25rem;
  --font-size-h1: 3.5rem;
  --font-size-h2: 1.75rem;
  --font-size-body: 1.375rem;
  --font-size-small: 1rem;
}

/* XLarge - 24px Base */
[data-font-size="xlarge"] {
  --font-size-base: 1.5rem;
  --font-size-h1: 4rem;
  --font-size-h2: 2rem;
  --font-size-body: 1.625rem;
  --font-size-small: 1.125rem;
}

/* Anwendung der Schriftgrößen */
[data-font-size] {
  font-size: var(--font-size-base);
}

[data-font-size] h1 {
  font-size: var(--font-size-h1);
}

[data-font-size] h2 {
  font-size: var(--font-size-h2);
}

[data-font-size] p,
[data-font-size] label {
  font-size: var(--font-size-body);
}

[data-font-size] .text-sm {
  font-size: var(--font-size-small);
}

/* Smooth Transition bei Größenänderung */
[data-font-size] * {
  transition: font-size var(--transition-speed) ease;
}

/* ============================================
   LEGASTHENIE-MODUS
   ============================================ */
.font-dyslexic {
  font-family: 'OpenDyslexic', sans-serif !important;
}

.font-dyslexic * {
  font-family: 'OpenDyslexic', sans-serif !important;
  line-height: 1.8 !important;
  letter-spacing: 0.05em !important;
  word-spacing: 0.1em !important;
}

/* Bessere Lesbarkeit im Legasthenie-Modus */
.font-dyslexic p {
  max-width: 70ch;
}

.font-dyslexic h1,
.font-dyslexic h2 {
  font-weight: 600;
}

/* ============================================
   BARRIEREFREIHEITS-PANEL
   ============================================ */
.accessibility-panel {
  background: #ffffff;
  border-bottom: 1px solid #e5e0db;
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Accessibility Buttons */
.a11y-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border: 2px solid #e5e0db;
  border-radius: 6px;
  background: #ffffff;
  color: #4a4a4a;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.a11y-btn:hover {
  border-color: #736357;
  color: #736357;
}

.a11y-btn:focus {
  outline: none;
  border-color: #736357;
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

.a11y-btn.active {
  background: #736357;
  border-color: #736357;
  color: white;
}

/* Toggle Switch für Legasthenie */
.a11y-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.toggle-track {
  position: relative;
  width: 48px;
  height: 24px;
  background: #e5e0db;
  border-radius: 12px;
  transition: background 0.3s ease;
}

.a11y-toggle[aria-checked="true"] .toggle-track {
  background: #736357;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.a11y-toggle[aria-checked="true"] .toggle-thumb {
  transform: translateX(24px);
}

.a11y-toggle:focus {
  outline: none;
}

.a11y-toggle:focus .toggle-track {
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

/* ============================================
   FOKUS-INDIKATOREN (Tastatur-Navigation)
   ============================================ */
*:focus {
  outline: none;
}

*:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* Spezielle Fokus-Styles für verschiedene Elemente */
a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: 4px;
}

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

/* ============================================
   FORMULAR-STYLES (Barrierefrei)
   ============================================ */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--color-text);
}

.form-group input[type="email"],
.form-group input[type="text"],
.form-group input[type="password"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #e5e0db;
  border-radius: 0.5rem;
  background: white;
  color: var(--color-text);
  font-size: var(--font-size-body);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
  border-color: var(--color-focus);
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

.form-group input[aria-invalid="true"] {
  border-color: #dc2626;
  background-color: #fef2f2;
}

.form-group input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

/* Fehlermeldungen */
.error-message {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #dc2626;
  font-size: var(--font-size-small);
  margin-top: 0.5rem;
}

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

.error-message.hidden {
  display: none;
}

/* Erfolgsmeldungen */
.form-status {
  padding: 1rem;
  border-radius: 0.5rem;
  font-weight: 500;
}

.form-status.hidden {
  display: none;
}

/* ============================================
   RADIO BUTTONS & CHECKBOXES (Barrierefrei)
   ============================================ */
input[type="radio"],
input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  cursor: pointer;
}

input[type="radio"]:focus-visible,
input[type="checkbox"]:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* ============================================
   SOCIAL MEDIA LINKS
   ============================================ */
.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  color: #736357;
  background: white;
  border: 2px solid #e5e0db;
  border-radius: 0.75rem;
  transition: all 0.2s ease;
}

.social-link:hover {
  background: #f5f0eb;
  border-color: #736357;
  transform: translateY(-2px);
}

.social-link:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-color: var(--color-focus);
}

/* ============================================
   SCREENREADER ONLY (sr-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: 0;
}

/* ============================================
   REDUCED MOTION (Respektiere Benutzereinstellungen)
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  [data-font-size] * {
    transition: none !important;
  }
}

/* ============================================
   HIGH CONTRAST MODE (Windows)
   ============================================ */
@media (prefers-contrast: high) {
  :root {
    --color-text: #000000;
    --color-focus: #000000;
    --color-focus-ring: rgba(0, 0, 0, 0.5);
  }
  
  .a11y-btn {
    border-width: 3px;
  }
  
  .form-group input {
    border-width: 3px;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  .accessibility-panel,
  .skip-link {
    display: none !important;
  }
  
  body {
    background: white !important;
    color: black !important;
    font-size: 12pt !important;
  }
  
  a {
    text-decoration: underline;
    color: black !important;
  }
  
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 10pt;
  }
}

/* ============================================
   MOBILE ANPASSUNGEN
   ============================================ */
@media (max-width: 640px) {
  .accessibility-panel {
    padding: 0.5rem 0;
  }
  
  .a11y-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
  }
  
  .toggle-track {
    width: 44px;
    height: 22px;
  }
  
  .toggle-thumb {
    width: 18px;
    height: 18px;
  }
  
  .a11y-toggle[aria-checked="true"] .toggle-thumb {
    transform: translateX(22px);
  }
}

/* ============================================
   COLLAPSIBLE ACCESSIBILITY PANEL (Mobile)
   ============================================ */

/* Panel Toggle Button */
#a11y-panel-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 0;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: #6B6B6B;
  transition: color 0.2s ease;
}

#a11y-panel-toggle:hover {
  color: #736357;
}

#a11y-panel-toggle:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: 4px;
}

#a11y-panel-toggle[aria-expanded="true"] #a11y-chevron {
  transform: rotate(180deg);
}

/* Panel Content */
#a11y-panel-content {
  transition: all 0.3s ease;
}

#a11y-panel-content.hidden {
  display: none;
}

/* Desktop: Always show panel */
@media (min-width: 768px) {
  #a11y-panel-toggle {
    display: none;
  }

  #a11y-panel-content {
    display: block !important;
  }
}

/* Mobile: Collapsed by default */
@media (max-width: 767px) {
  #a11y-panel-content:not(.expanded) {
    display: none;
  }

  /* Größere Touch-Targets auf Mobile */
  .a11y-btn-compact {
    min-width: 44px;
    min-height: 44px;
    font-size: 14px;
  }

  .a11y-toggle-compact {
    min-height: 44px;
    padding: 0.5rem;
  }
}
