/* ==========================================================================
 switch.css — Toggle-Switch-Primitive (.app-switch)

 Fluent-2-artiger An/Aus-Schalter als reines CSS ueber einer nativen
 Checkbox — voll tastatur- und screenreader-faehig, kein JS-Modul noetig.
 Spec: docs/reference/design-system/modules.md § Switch (Toggle).

 Markup (Label umschliesst Input → Klick auf Track toggelt nativ):
   <label class="app-switch" title="...">
     <input type="checkbox" id="..." aria-label="...">
     <span class="app-switch-track" aria-hidden="true"></span>
   </label>

 Einsatzregel: Switch fuer sofort wirksame An/Aus-Zustaende (Auto-Save,
 z.B. Ruhezeiten in den Benachrichtigungs-Einstellungen); Checkboxen
 (.benachr-cell-check-wrap etc.) bleiben fuer Mehrfach-Auswahl in
 Formularen/Matrizen, die erst mit "Speichern" wirksam werden.
 ========================================================================== */

.app-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  /* Hit-Area >= 36px (Touch), Track bleibt visuell 40x22 */
  min-width: 44px;
  min-height: 36px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Native Checkbox unsichtbar UEBER der ganzen Flaeche: sie selbst ist das
   Touch-Target (native Semantik, ein Klick = ein Toggle, fokussierbar). */
.app-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}

.app-switch-track {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  border-radius: var(--radius-circular);
  background: var(--lod-gray-300);
  border: 1px solid transparent;
  transition: background var(--duration-fast) var(--ease-inout-soft);
}

/* Knopf */
.app-switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-circular);
  background: var(--color-surface);
  box-shadow: var(--shadow-2);
  transition: transform var(--duration-fast) var(--ease-inout-soft);
}

.app-switch input:checked + .app-switch-track {
  background: var(--brand-default);
}
.app-switch input:checked + .app-switch-track::after {
  transform: translateX(18px);
}

.app-switch:hover .app-switch-track {
  background: var(--lod-gray-400);
}
.app-switch:hover input:checked + .app-switch-track {
  background: var(--brand-hover, var(--brand-default));
}

/* Tastatur-Fokus sichtbar auf dem Track (Input selbst ist unsichtbar) */
.app-switch input:focus-visible + .app-switch-track {
  outline: 2px solid var(--brand-default);
  outline-offset: 2px;
}

.app-switch input:disabled + .app-switch-track {
  opacity: 0.45;
  cursor: not-allowed;
}
.app-switch:has(input:disabled) { cursor: not-allowed; }

@media (prefers-reduced-motion: reduce) {
  .app-switch-track,
  .app-switch-track::after { transition: none; }
}
