/* A switch is as tall as its row's text with a little room, so a list of
   them sits close, as a form's rows do. It has a 44px touch target wherever
   any coarse pointer exists (RULES §7: a finger, a Pencil, an iPad's
   trackpad). */
.switch_label {
  position: relative;
  display: inline-block;
  flex: 0 0 var(--ui-touch-target);
  width: var(--ui-touch-target);
  height: calc(var(--switch-height) + var(--ui-space-2));
  margin: 0;
  padding: 0;
  cursor: pointer;
  --switch-height: 20px;
  -webkit-tap-highlight-color: rgb(0 0 0 / 0%);
}

table .switch_label {
  --switch-height: 16px;
}

.switch_input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
}

.switch_label::before,
.switch_label::after {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: var(--ui-space-1);
  outline: 0;
  transition: transform var(--ui-duration-feedback) var(--ui-ease-feedback), background-color var(--ui-duration-feedback) var(--ui-ease-feedback);
  content: '';
  transform: translate3d(0, -50%, 0);
}

.switch_label::before {
  width: calc(var(--switch-height) * 1.8 - 1px);
  height: var(--switch-height);
  background-color: var(--color-input-background);
  border-width: 1px;
  border-style: solid;
  border-color: var(--color-input-border);
  border-radius: var(--switch-height);
}

.warn_in_off_state .switch_label::before {
  background-color: var(--color-negative);
}

.switch_label::after {
  width: var(--switch-height);
  height: var(--switch-height);
  background-color: var(--color-input-background);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgb(0 0 0 / 40%);
  transform: translate3d(1px, -50%, 0);
}

.switch_input:checked + .switch_label::before {
  background-color: var(--color-positive);
  border-color: var(--color-positive);
}

.switch_input:checked + .switch_label::after {
  transform: translate3d(80%, -50%, 0);
}

.switch_input:focus-visible + .switch_label {
  border-radius: var(--ui-radius-control);
  outline: 2px solid var(--color-input-focus-border);
  outline-offset: 1px;
}

.switch_input:disabled + .switch_label {
  opacity: 0.5;
  cursor: default;
}

@media (prefers-reduced-motion: reduce) {
  .switch_label::before,
  .switch_label::after {
    transition: none;
  }
}

@media (any-pointer: coarse) {
  .switch_label {
    height: var(--ui-touch-target);
  }
}
