@import 'transitions';

@mixin range($bg, $fg, $fg-medium, $primary) {
  input[type='range'] {
    -webkit-appearance: none;
    margin: 0;
    width: 100%;
    background: $bg;
  }

  input[type='range']:focus {
    outline: none;
  }

  input[type='range']::-webkit-slider-runnable-track {
    width: 100%;
    height: 0.25rem;
    background: $fg-medium;
    border: 0;
  }

  input[type='range']::-webkit-slider-thumb {
    height: 1rem;
    width: 0.3rem;
    margin-top: -0.375rem;
    background: $fg;
    -webkit-appearance: none;
    border: 0;
    border-radius: 0.1rem;
    box-shadow: 0 0 0 1px $bg;
    transition: transform $fast $ease, background $fast $ease;

    &:active,
    &:focus,
    &:hover {
      background: $primary;
    }
  }

  input[type='range']:hover::-webkit-slider-thumb {
    background: $primary;
  }

  input[type='range']:disabled::-webkit-slider-thumb {
    background: $fg-medium;
    cursor: not-allowed;
  }

  input[type='range']::-moz-range-track {
    width: 100%;
    height: 1rem;
    border: 0;
    background: $fg-medium;
    box-shadow: inset 0 0.375rem 0 0 $bg, inset 0 -0.375rem 0 0 $bg;
  }

  input[type='range']::-moz-range-thumb {
    border: 0;
    height: 1rem;
    width: 0.25rem;
    background: $fg;
    border-radius: 0.1rem;
    box-shadow: 0 0 0 1px $bg;
    transition: transform $fast $ease, background $fast $ease;

    &:active,
    &:focus,
    &:hover {
      background: $primary;
    }
  }

  input[type='range']:hover::-moz-range-thumb {
    background: $primary;
  }

  input[type='range']:disabled::-moz-range-thumb {
    background: $fg-medium;
    cursor: not-allowed;
  }

  input[type='range']::-ms-track {
    width: 100%;
    height: 0.25rem;
    background: transparent;
    border-color: transparent;
    color: transparent;
    border: 0;
  }

  input[type='range']::-ms-fill-lower {
    background: $fg-medium;
  }

  input[type='range']::-ms-fill-upper {
    background: $fg-medium;
  }

  input[type='range']::-ms-thumb {
    border: 0;
    height: 2rem;
    width: 0.25rem;
    background: $fg;
    border-radius: 0.1rem;
    box-shadow: 0 0 0 1px $bg;
    transition: transform $fast $ease, background $fast $ease;

    &:active,
    &:focus,
    &:hover {
      background: $primary;
    }
  }

  input[type='range']:hover::-ms-thumb {
    background: $primary;
  }

  input[type='range']:disabled::-ms-thumb {
    background: $fg-medium;
    cursor: not-allowed;
  }
}
