@import (reference) "../less/utilities";

.transition-stroke-fill {
  transition: stroke @timingPromptly;
  transition: fill @timingPromptly;
}

.pathColor(@color) {
  path {
    stroke: transparent;
    fill: @color;
  }
}

.Switch {
  .flexbox();
  position: relative;
  width: 4rem;
  height: 2rem;
  touch-action: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  outline: none;
  font-size: initial;
  padding: 0;
  text-align: justify;
  background-color: @neutral_gray;
  border: @size_3xs solid @neutral_gray;
  border-radius: @size_2xs;
  cursor: pointer;
  transition: background-color @timingPromptly;
  transition: box-shadow @timingPromptly;
}

.Switch:focus {
  box-shadow: 0 0 0 0.375rem rgba(128, 157, 255, 0.5);
}

.Switch.Switch--checked {
  background-color: @alert_green_tint_2;
  border: @size_3xs solid @alert_green_tint_2;
}

.Switch:hover:not([disabled]).Switch--checked {
  border: @size_3xs solid @alert_green_shade_1;
}

.Switch:hover:not([disabled]) {
  border: @size_3xs solid @neutral_dark_gray;
}

.Switch--checkedIcon {
  .transition-stroke-fill();
  .pathColor(@neutral_black);
  width: 0.875rem;
  height: 0.688rem;
  pointer-events: none;
  position: relative;
  left: 0.375rem;
  overflow: visible;
}

.Switch--uncheckedIcon {
  .transition-stroke-fill();
  .pathColor(@neutral_black);
  width: 0.625rem;
  height: 0.625rem;
  pointer-events: none;
  position: relative;
  right: 0.438rem;
  overflow: visible;
}

.Switch[disabled] {
  cursor: not-allowed;
  background-color: @neutral_silver;
  border: @size_3xs solid @neutral_silver;

  .Switch--checkedIcon {
    .pathColor(@neutral_gray;);
  }

  .Switch--uncheckedIcon {
    .pathColor(@neutral_gray;);
  }
}

.Switch--handle {
  outline: none;
  width: 1.813rem;
  height: 1.375rem;
  transform: translateX(@size_3xs);
  background-color: transparent;
  background-color: @neutral_white;
  cursor: pointer;
  display: inline-block;
  border-radius: @size_3xs;
  position: absolute;
  top: 0.188em;
  transition: background-color 0.25s, transform 0.25s, box-shadow 0.15s;
}

.Switch--handle.Switch--checked {
  transform: translateX(1.813em);
}

.Switch--handle.Switch--disabled {
  cursor: not-allowed;
}

.Switch--handleGripLeft {
  margin-left: @size_xs;
  margin-top: 0.32rem;
  width: 0.32rem;
  height: @size_s;
  display: inline-block;
  border-left: @size_4xs solid #d6d7de;
  border-right: @size_4xs solid #d6d7de;
}

.Switch--handleGripRight {
  width: 0.32rem;
  height: @size_s;
  display: inline-block;
  border-right: @size_4xs solid #d6d7de;
}

.Switch--iconContainer {
  height: 100%;
}
