@use "scss/colors";
@use "scss/variables";

$border-radius: 999px;
$button-width: 100px;
$button-height: 24px;
$knob-width: calc($button-height - variables.$border-thin * 2);

@keyframes candystripe {
  to {
    background-position: 60px 0;
  }
}

.button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0;
  width: $button-width;
  height: $button-height;
  border-radius: $border-radius;
  border: variables.$border-thin solid colors.$grey-200;
  background-color: colors.$grey-100;
  overflow: hidden;
  position: relative;
  cursor: pointer;

  &.checked {
    background-color: colors.$blue;
    align-items: flex-end;
  }

  &:disabled {
    opacity: 0.7;
    cursor: not-allowed;
  }

  .stripe {
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;

    &.loading {
      background-image: linear-gradient(
        -65deg,
        transparent 25%,
        colors.$blue-200 25%,
        colors.$blue-200 50%,
        transparent 50%,
        transparent 75%,
        colors.$blue-200 75%,
        colors.$blue-200 100%
      );
      background-size: 60px 80px;
      background-repeat: repeat-x;
      animation: candystripe 1s linear infinite;

      &.reverse {
        animation-direction: reverse;
      }
    }
  }

  .text {
    text-transform: uppercase;
    position: absolute;
    text-align: center;
    top: 50%;
    left: 50%;
    transform: translate(-35%, -50%);
    font-size: variables.$font-size-sm;
    font-weight: 500;
    color: colors.$grey-500;

    &.checkedText {
      color: colors.$white;
      transform: translate(-70%, -50%);
    }
  }

  .knob {
    border-radius: $border-radius;
    width: $knob-width;
    background: colors.$white;
    flex: 1;
    z-index: 1;
  }
}
