/* =========================
   Switch
========================= */

@use "../kit-deps" as *;

.switch {
  display: inline-flex;
  align-items: center;
  gap: $space-2;
  cursor: pointer;
  font-size: 15px;
  color: $neutral-900;

  input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
    padding: 0;
    margin: 0;
  }

  .switch-control {
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 9999px;
    background-color: $neutral-300;
    position: relative;
    transition: background-color $motion-base $motion-ease;

    &::after {
      content: "";
      position: absolute;
      top: 2px;
      left: 2px;
      width: 20px;
      height: 20px;
      border-radius: 50%;
      background-color: $neutral-0;
      box-shadow: 0 1px 3px rgba($neutral-900, 0.16);
      transition: transform $motion-base $motion-ease;
    }
  }

  &:hover .switch-control {
    background-color: $neutral-400;
  }

  input[type="checkbox"]:focus-visible + .switch-control {
    @include focus_ring;
  }

  input[type="checkbox"]:checked + .switch-control {
    background-color: $mint-600;

    &::after {
      transform: translateX(20px);
    }
  }

  input[type="checkbox"]:disabled + .switch-control {
    background-color: $neutral-200;
    cursor: not-allowed;
  }

  input[type="checkbox"]:checked:disabled + .switch-control {
    background-color: $neutral-400;
  }

  input[type="checkbox"]:disabled ~ .switch-label {
    color: $neutral-500;
    cursor: not-allowed;
  }

  .switch-label {
    font-weight: $font-weight-medium;
    line-height: 1.25;
  }
}
