/* ============================================================
   ACCESSIBILITY WIDGET  –  Standalone-Modul
   ============================================================ */

/* ---- Toggle-Button (rechts, mittig) ---- */
#a11y-toggle-btn {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 99998;
  width: 48px;
  height: 56px;
  background: #4338CA;
  border: none;
  border-radius: 10px 0 0 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: -2px 0 16px rgba(67, 56, 202, 0.45);
  transition: width 0.2s ease, background 0.2s ease;
  padding: 0;
}
#a11y-toggle-btn:hover,
#a11y-toggle-btn:focus-visible {
  width: 54px;
  background: #312E81;
  outline: none;
}
#a11y-toggle-btn svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  pointer-events: none;
}

/* ---- Backdrop ---- */
#a11y-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99997;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
#a11y-backdrop.a11y-backdrop-open {
  display: block;
}

/* ---- Panel ---- */
#a11y-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 100vw;
  background: #fff;
  z-index: 99999;
  box-shadow: -4px 0 32px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.23, 0.65, 0.74, 1.09);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  color: #111;
}
#a11y-panel.a11y-panel-open {
  transform: translateX(0);
}

/* ---- Panel Header ---- */
#a11y-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  background: #4338CA;
  color: #fff;
  flex-shrink: 0;
}
#a11y-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}
#a11y-panel-title .ph {
  font-size: 18px;
}
#a11y-close-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  padding: 0;
}
#a11y-close-btn:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }
#a11y-close-btn:focus-visible { outline: 2px solid rgba(255,255,255,0.8); outline-offset: 1px; }
#a11y-close-btn .ph { font-size: 18px; }

/* ---- Panel Body ---- */
#a11y-panel-body {
  flex: 1;
  min-height: 0; /* Pflicht bei Flex: ohne das scrollt der Body nicht */
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ---- Sections ---- */
.a11y-section {
  padding: 1rem 1.2rem 0.7rem;
  border-bottom: 1px solid #eee;
}
.a11y-section:last-child { border-bottom: none; }

.a11y-section-title {
  margin: 0 0 0.75rem 0;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #999;
}

/* ---- Profile-Buttons ---- */
.a11y-profiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.a11y-profile-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  background: #f5f5f7;
  border: 1.5px solid #e5e5ea;
  border-radius: 10px;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  color: #333;
  text-align: center;
  line-height: 1.3;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  font-family: Arial, Helvetica, sans-serif;
}
.a11y-profile-btn:hover { border-color: #4338CA; background: #eef0fb; }
.a11y-profile-btn:focus-visible { outline: 2px solid #4338CA; outline-offset: 2px; }
.a11y-profile-btn.a11y-profile-active { border-color: #4338CA; background: #eef0fb; color: #4338CA; }
.a11y-profile-icon { line-height: 1; }
.a11y-profile-icon .ph { font-size: 22px; }

/* ---- Toggle-Zeile ---- */
.a11y-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}
.a11y-row + .a11y-row { border-top: 1px solid #f2f2f2; }
.a11y-row-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #222;
  font-weight: 500;
  cursor: pointer;
}
.a11y-row-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.a11y-row-icon .ph { font-size: 16px; color: #555; }

/* ---- Toggle-Switch ---- */
.a11y-switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.a11y-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.a11y-switch-track {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.2s;
}
.a11y-switch-track::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.a11y-switch input:checked ~ .a11y-switch-track { background: #4338CA; }
.a11y-switch input:checked ~ .a11y-switch-track::before { transform: translateX(18px); }
.a11y-switch input:focus-visible ~ .a11y-switch-track {
  outline: 2px solid #4338CA;
  outline-offset: 2px;
}

/* ---- Schriftgröße-Slider ---- */
.a11y-slider-row { padding: 4px 0 10px; }
.a11y-slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.a11y-slider-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #222;
  font-weight: 500;
}
.a11y-slider-label .a11y-row-icon .ph { font-size: 16px; }
.a11y-fontsize-val {
  font-size: 11px;
  font-weight: 700;
  color: #4338CA;
  background: #eef0fb;
  padding: 2px 9px;
  border-radius: 20px;
}

/* +/- Buttons + Slider in einer Zeile */
.a11y-size-control {
  display: flex;
  align-items: center;
  gap: 8px;
}
.a11y-size-control .a11y-range { flex: 1; }
.a11y-size-btn {
  width: 30px;
  height: 30px;
  border: 1.5px solid #e5e5ea;
  border-radius: 7px;
  background: #f5f5f7;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: #444;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
}
.a11y-size-btn:hover  { border-color: #4338CA; background: #eef0fb; color: #4338CA; }
.a11y-size-btn:disabled { opacity: 0.35; cursor: default; pointer-events: none; }
.a11y-size-btn:focus-visible { outline: 2px solid #4338CA; outline-offset: 2px; }

.a11y-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  background: #e0e0e0;
  border-radius: 5px;
  outline: none;
  cursor: pointer;
}
.a11y-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #4338CA;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(67, 56, 202, 0.45);
}
.a11y-range::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #4338CA;
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px rgba(67, 56, 202, 0.45);
}
.a11y-range:focus-visible { outline: 2px solid #4338CA; outline-offset: 3px; }

.a11y-fontsize-steps {
  display: flex;
  justify-content: space-between;
  padding: 3px 40px 0; /* Links/rechts Abstand für die +/- Buttons */
  color: #bbb;
  line-height: 1;
}
.a11y-fontsize-steps span:nth-child(1) { font-size: 9px; }
.a11y-fontsize-steps span:nth-child(2) { font-size: 11px; }
.a11y-fontsize-steps span:nth-child(3) { font-size: 13px; }
.a11y-fontsize-steps span:nth-child(4) { font-size: 15px; }
.a11y-fontsize-steps span:nth-child(5) { font-size: 18px; }

/* ---- Farb-Buttons ---- */
.a11y-color-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.a11y-color-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  background: #f5f5f7;
  border: 1.5px solid #e5e5ea;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #333;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  font-family: Arial, Helvetica, sans-serif;
  text-align: left;
}
.a11y-color-btn:hover { border-color: #4338CA; background: #eef0fb; }
.a11y-color-btn:focus-visible { outline: 2px solid #4338CA; outline-offset: 2px; }
.a11y-color-btn.a11y-color-active { border-color: #4338CA; background: #eef0fb; color: #4338CA; }
.a11y-color-btn .ph { font-size: 16px; flex-shrink: 0; }

/* ---- Panel Footer ---- */
#a11y-panel-footer {
  padding: 0.9rem 1.2rem;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}
#a11y-reset-btn {
  width: 100%;
  padding: 9px;
  background: transparent;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #777;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  font-family: Arial, Helvetica, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
#a11y-reset-btn:hover { border-color: #c00; color: #c00; }
#a11y-reset-btn:focus-visible { outline: 2px solid #4338CA; outline-offset: 2px; }
#a11y-reset-btn .ph { font-size: 15px; }

/* ============================================================
   BARRIEREFREIHEITS-EFFEKTE (auf <html> angewendet)
   ============================================================ */

html.a11y-line-height    * { line-height: 1.85 !important; }
html.a11y-letter-spacing * { letter-spacing: 0.1em !important; }
html.a11y-word-spacing   * { word-spacing: 0.22em !important; }

/* :not(i) schützt Icon-Fonts (Phosphor, FontAwesome usw.) vor Überschreibung */
html.a11y-dyslexia-font *:not(i) {
  font-family: 'Comic Sans MS', 'Comic Sans', Verdana, sans-serif !important;
}
html.a11y-readable-font *:not(i) {
  font-family: 'Verdana', 'Geneva', 'Tahoma', sans-serif !important;
}

/* Farb-Filter (exklusiv) */
html.a11y-contrast   { filter: contrast(175%) !important; }
html.a11y-inverted   { filter: invert(100%) hue-rotate(180deg) !important; }
html.a11y-grayscale  { filter: grayscale(100%) !important; }
html.a11y-sepia      { filter: sepia(70%) !important; }
html.a11y-desaturate { filter: saturate(20%) !important; }

/* Widget gegen Invert-Effekt gegenfärben */
html.a11y-inverted #a11y-panel,
html.a11y-inverted #a11y-toggle-btn,
html.a11y-inverted #a11y-backdrop {
  filter: invert(100%) hue-rotate(180deg) !important;
}

/* Animationen stoppen */
html.a11y-pause-anim *,
html.a11y-pause-anim *::before,
html.a11y-pause-anim *::after {
  animation-play-state: paused !important;
  transition-duration: 0ms !important;
}

html.a11y-highlight-links a {
  text-decoration: underline !important;
  outline: 2px solid #4338CA !important;
  outline-offset: 2px !important;
  border-radius: 2px;
}
html.a11y-hide-images img,
html.a11y-hide-images picture,
html.a11y-hide-images video,
html.a11y-hide-images figure img { visibility: hidden !important; }

/* Fokus-Ring: wird dynamisch per JS injiziert (nach allen anderen Styles),
   damit er nicht von main.css/plugins.css überschrieben wird. */

html.a11y-big-cursor,
html.a11y-big-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='42'%3E%3Cpath d='M8 5 L30 19 L21.5 21.5 L17 33 Z' fill='%23000000' stroke='%23ffffff' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E") 8 5, auto !important;
}

/* ---- Lesemaske ---- */
#a11y-mask-top,
#a11y-mask-bottom {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.68);
  pointer-events: none;
  z-index: 99996;
}
html.a11y-reading-mask #a11y-mask-top,
html.a11y-reading-mask #a11y-mask-bottom { display: block; }

/* ---- Spotlight ---- */
#a11y-spotlight-el {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99995;
  pointer-events: none;
  background: radial-gradient(
    circle 130px at var(--a11y-mx, 50%) var(--a11y-my, 50%),
    transparent 110px,
    rgba(0, 0, 0, 0.78) 135px
  );
}
html.a11y-spotlight #a11y-spotlight-el { display: block; }

/* Mobile */
@media (max-width: 360px) {
  #a11y-panel { width: 100vw; }
}
