/* ============================================
   ACCESSIBILITY & LANGUAGE WIDGET
   ============================================ */

/* Floating launcher button - bottom-left corner
   (back-to-top is bottom-right; these don't conflict) */
.a11y-button {
  position: fixed;
  bottom: 28px;
  left: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  border: 2px solid rgba(255,255,255,0.85);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  font-family: inherit;
  padding: 0;
  z-index: 9990;
  box-shadow:
    0 8px 24px rgba(37, 99, 235, 0.55),
    0 0 0 4px rgba(37, 99, 235, 0.16),
    inset 0 2px 6px rgba(255,255,255,0.3);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.a11y-button:hover {
  transform: scale(1.06);
  box-shadow:
    0 12px 32px rgba(37, 99, 235, 0.7),
    0 0 0 4px rgba(37, 99, 235, 0.28),
    inset 0 2px 6px rgba(255,255,255,0.4);
}
.a11y-button:focus-visible {
  outline: 3px solid #ffd700;
  outline-offset: 4px;
}

/* Backdrop */
.a11y-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9995;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s;
}
.a11y-backdrop.open {
  opacity: 1;
  visibility: visible;
}

/* Panel */
.a11y-panel {
  position: fixed;
  bottom: 28px;
  left: 28px;
  width: 360px;
  max-width: calc(100vw - 56px);
  max-height: calc(100vh - 56px);
  background: #ffffff;
  color: #1f2937;
  border-radius: 18px;
  box-shadow:
    0 24px 48px rgba(0,0,0,0.5),
    0 0 0 1px rgba(0,0,0,0.08);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom left;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
  overflow: hidden;
}
.a11y-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.a11y-panel-header {
  padding: 18px 18px 14px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
}
.a11y-panel-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #1f2937;
  margin: 0;
  font-family: 'Georgia', serif;
}
.a11y-panel-close {
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1rem;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
}
.a11y-panel-close:hover { background: #f3f4f6; color: #1f2937; }

.a11y-panel-body {
  padding: 14px 18px 18px;
  overflow-y: auto;
}

.a11y-section { margin-bottom: 18px; }
.a11y-section:last-child { margin-bottom: 0; }

.a11y-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
  margin: 0 0 8px;
}

/* Segmented buttons (language, text size) */
.a11y-segmented {
  display: flex;
  gap: 6px;
  background: #f3f4f6;
  padding: 4px;
  border-radius: 10px;
}
.a11y-seg {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #4b5563;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s ease, color 0.2s ease;
}
.a11y-seg:hover { color: #1f2937; }
.a11y-seg.active {
  background: #ffffff;
  color: #4f46e5;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Toggle rows */
.a11y-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
}
.a11y-toggle:last-child { border-bottom: none; }
.a11y-toggle-label {
  font-size: 0.92rem;
  color: #1f2937;
  font-weight: 500;
}
.a11y-toggle-switch {
  width: 44px;
  height: 24px;
  background: #d1d5db;
  border-radius: 12px;
  position: relative;
  transition: background 0.2s ease;
  flex-shrink: 0;
  cursor: pointer;
}
.a11y-toggle-switch:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}
.a11y-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: left 0.2s ease;
}
.a11y-toggle.on .a11y-toggle-switch {
  background: #4f46e5;
}
.a11y-toggle.on .a11y-toggle-thumb {
  left: 22px;
}

/* Reset button */
.a11y-reset {
  width: 100%;
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #4b5563;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s ease, color 0.2s ease;
}
.a11y-reset:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

.a11y-section-link {
  padding-top: 6px;
  border-top: 1px solid #f3f4f6;
}
.a11y-section-link a {
  color: #4f46e5;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}
.a11y-section-link a:hover {
  text-decoration: underline;
}

/* Mobile */
@media (max-width: 600px) {
  .a11y-button {
    bottom: 20px;
    left: 20px;
    width: 48px;
    height: 48px;
    font-size: 1.45rem;
  }
  .a11y-panel {
    bottom: 20px;
    left: 20px;
    right: 20px;
    width: auto;
    max-width: none;
  }
}

/* ============================================
   APPLIED SETTING EFFECTS
   These classes are added to <html> by a11y.js
   ============================================ */

/* Text Size — uses CSS variables to scale broadly */
html.a11y-text-large {
  font-size: 18px;
}
html.a11y-text-larger {
  font-size: 20px;
}
html.a11y-text-large body,
html.a11y-text-larger body {
  line-height: 1.7;
}

/* High contrast — invert palette, hard borders, strong text */
html.a11y-high-contrast body {
  background: #000000 !important;
}
html.a11y-high-contrast .site-header,
html.a11y-high-contrast .soft-bg,
html.a11y-high-contrast .cta-section,
html.a11y-high-contrast footer,
html.a11y-high-contrast .ladder-step,
html.a11y-high-contrast .card,
html.a11y-high-contrast .stat,
html.a11y-high-contrast .visual-card {
  background: #000000 !important;
  border-color: #ffff00 !important;
}
html.a11y-high-contrast h1,
html.a11y-high-contrast h2,
html.a11y-high-contrast h3,
html.a11y-high-contrast h4,
html.a11y-high-contrast .brand-name,
html.a11y-high-contrast .stat .num,
html.a11y-high-contrast .eyebrow {
  background: none !important;
  -webkit-text-fill-color: #ffff00 !important;
  color: #ffff00 !important;
  text-shadow: none !important;
}
html.a11y-high-contrast p,
html.a11y-high-contrast li,
html.a11y-high-contrast .lead,
html.a11y-high-contrast .brand-sub {
  color: #ffffff !important;
}
html.a11y-high-contrast a {
  color: #00ffff !important;
  text-decoration: underline !important;
}
html.a11y-high-contrast .btn-primary {
  background: #ffff00 !important;
  color: #000000 !important;
  border: 2px solid #ffffff !important;
}
html.a11y-high-contrast .btn-secondary {
  background: transparent !important;
  border: 2px solid #ffffff !important;
  color: #ffffff !important;
}

/* Reduce motion — kill all animations */
html.a11y-reduce-motion *,
html.a11y-reduce-motion *::before,
html.a11y-reduce-motion *::after {
  animation-duration: 0.001s !important;
  animation-delay: 0s !important;
  transition-duration: 0.001s !important;
  transition-delay: 0s !important;
  scroll-behavior: auto !important;
}

/* Dyslexia-friendly font — system fonts known to help readability */
html.a11y-dyslexia-font body,
html.a11y-dyslexia-font h1,
html.a11y-dyslexia-font h2,
html.a11y-dyslexia-font h3,
html.a11y-dyslexia-font h4,
html.a11y-dyslexia-font p,
html.a11y-dyslexia-font a,
html.a11y-dyslexia-font li,
html.a11y-dyslexia-font button,
html.a11y-dyslexia-font input,
html.a11y-dyslexia-font textarea,
html.a11y-dyslexia-font .brand-name,
html.a11y-dyslexia-font .lead {
  font-family: 'Comic Sans MS', 'Trebuchet MS', Verdana, Tahoma, sans-serif !important;
  letter-spacing: 0.03em !important;
  word-spacing: 0.1em !important;
}
html.a11y-dyslexia-font body {
  line-height: 1.7 !important;
}

/* Underline links — make every link visibly underlined */
html.a11y-underline-links a:not(.btn):not(.brand) {
  text-decoration: underline !important;
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
}

/* Highlight focus — bold visible focus ring */
html.a11y-highlight-focus *:focus,
html.a11y-highlight-focus *:focus-visible {
  outline: 3px solid #ffd700 !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 6px rgba(255, 215, 0, 0.25) !important;
}
