/**
 * Accessibility Widget – shop&food
 * Eigenentwicklung, keine externen Abhängigkeiten
 */

/* ─── Gemeinsame Floating-Button-Basis ────────────────────── */
/* Gilt für den Accessibility-Toggle UND den CookieYes-Revisit-
   Button — beide erscheinen unten rechts, gleich gross, gleicher
   Hover-Effekt. */

:root {
  --a11y-btn-size: 68px;             /* 56px × 1.2 = 67.2 → 68px */
  --a11y-bottom:   var(--space-6);   /* 24px */
  --a11y-right:    var(--space-6);   /* 24px */
}

/* ─── Toggle-Button ──────────────────────────────────────── */

.a11y-toggle {
  position: fixed;
  bottom: var(--a11y-bottom);
  right: var(--a11y-right);
  left: auto;
  z-index: 9000;
  width: var(--a11y-btn-size);
  height: var(--a11y-btn-size);
  border-radius: 50%;
  background-color: var(--color-black);
  color: var(--color-cream);
  border: 2px solid var(--color-cream);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
  transition: background-color 0.22s ease, transform 0.22s ease, border-color 0.22s ease;
  padding: 0;
}

.a11y-toggle:hover {
  background-color: var(--color-red);
  border-color: var(--color-red);
  transform: scale(1.1);
}

.a11y-toggle:focus-visible {
  outline: 3px solid var(--color-cream);
  outline-offset: 3px;
}

.a11y-toggle svg {
  pointer-events: none;
}

/* ─── Tooltip «Barrierefreiheit» (Fähnchen nach links) ────── */

.a11y-toggle::before {
  content: 'Barrierefreiheit';
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) translateX(6px);
  background-color: var(--color-black);
  color: var(--color-cream);
  font-family: var(--font-body, 'Mona Sans', Arial, sans-serif);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  padding: 7px 14px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 1;
}

/* Pfeil zeigt nach rechts (Richtung Button) */
.a11y-toggle::after {
  content: '';
  position: absolute;
  right: calc(100% + 4px);
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-left-color: var(--color-black);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.a11y-toggle:hover::before {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.a11y-toggle:hover::after {
  opacity: 1;
}

/* ─── Panel ──────────────────────────────────────────────── */

.a11y-panel {
  position: fixed;
  bottom: calc(var(--a11y-bottom) + var(--a11y-btn-size) + var(--space-2));
  right: var(--a11y-right);
  left: auto;
  z-index: 9001;
  width: 240px;
  background-color: var(--color-black);
  color: var(--color-cream);
  border: 1px solid rgba(255, 251, 187, 0.25);
  border-radius: var(--radius-md, 12px);
  padding: var(--space-5, 20px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);

  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.a11y-panel.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.a11y-panel__title {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  margin-bottom: var(--space-4);
  color: var(--color-cream);
  opacity: 0.7;
}

/* ─── Option-Rows ─────────────────────────────────────────── */

.a11y-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
  border-bottom: 1px solid rgba(255, 251, 187, 0.12);
}

.a11y-option:last-child {
  border-bottom: none;
}

.a11y-option__label {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-cream);
  line-height: var(--leading-normal);
}

/* ─── 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-color: rgba(255, 251, 187, 0.2);
  border-radius: 11px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.a11y-switch__track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background-color: var(--color-cream);
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.a11y-switch input:checked + .a11y-switch__track {
  background-color: var(--color-red);
}

.a11y-switch input:checked + .a11y-switch__track::after {
  transform: translateX(18px);
}

.a11y-switch input:focus-visible + .a11y-switch__track {
  outline: 2px solid var(--color-cream);
  outline-offset: 2px;
}

/* ─── Schriftgrösse-Stepper ──────────────────────────────── */

.a11y-stepper {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.a11y-stepper__btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 251, 187, 0.4);
  background: transparent;
  color: var(--color-cream);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
  padding: 0;
}

.a11y-stepper__btn:hover {
  background-color: rgba(255, 251, 187, 0.15);
}

.a11y-stepper__btn:focus-visible {
  outline: 2px solid var(--color-cream);
  outline-offset: 2px;
}

.a11y-stepper__value {
  font-size: var(--text-sm);
  min-width: 24px;
  text-align: center;
  color: var(--color-cream);
}

/* ─── Reset-Link ─────────────────────────────────────────── */

.a11y-reset {
  display: block;
  text-align: center;
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  color: rgba(255, 251, 187, 0.5);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  padding: 0;
  transition: color 0.15s ease;
}

.a11y-reset:hover {
  color: var(--color-cream);
}

/* ─── Body/HTML-Klassen (JS setzt diese) ────────────────── */
/* Klassen werden früh auf <html> gesetzt (vor DOMContentLoaded)
   und nach Aufbau des Widgets auf <body> übertragen. */

/* Grössere Schrift (+2 Stufen pro Klick, max 3×) */
:is(html, body).a11y-text-1 { font-size: 106%; }
:is(html, body).a11y-text-2 { font-size: 112%; }
:is(html, body).a11y-text-3 { font-size: 120%; }

/* Hoher Kontrast */
:is(html, body).a11y-contrast {
  filter: contrast(1.25) saturate(0);
}

/* Animationen aus */
:is(html, body).a11y-no-motion *,
:is(html, body).a11y-no-motion *::before,
:is(html, body).a11y-no-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

/* ─── Reduced-Motion: Widget selbst anpassen ──────────────── */

@media (prefers-reduced-motion: reduce) {
  .a11y-toggle,
  .a11y-panel,
  .a11y-switch__track,
  .a11y-switch__track::after,
  .a11y-stepper__btn {
    transition: none;
  }
}
