@import "../../globals.ios";
@import "./range";

// iOS Range
// --------------------------------------------------

$range-ios-padding-vertical:                  8px !default;
$range-ios-padding-horizontal:                16px !default;

$range-ios-slider-height:                     42px !default;

$range-ios-hit-width:                         42px !default;
$range-ios-hit-height:                        $range-ios-slider-height !default;

$range-ios-bar-height:                        1px !default;
$range-ios-bar-background-color:              #bdbdbd !default;
$range-ios-bar-active-background-color:       color($colors-ios, primary) !default;

$range-ios-knob-width:                        28px !default;
$range-ios-knob-height:                       $range-ios-knob-width !default;
$range-ios-knob-box-shadow:                   0 3px 1px rgba(0, 0, 0, .1), 0 4px 8px rgba(0, 0, 0, .13), 0 0 0 1px rgba(0, 0, 0, .02) !default;
$range-ios-knob-border-radius:                50% !default;
$range-ios-knob-background-color:             #fff !default;

$range-ios-tick-width:                        $range-ios-bar-height !default;
$range-ios-tick-height:                       8px !default;
$range-ios-tick-border-radius:                0 !default;
$range-ios-tick-background-color:             $range-ios-bar-background-color !default;
$range-ios-tick-active-background-color:      $range-ios-bar-active-background-color !default;

$range-ios-pin-background-color:              transparent !default;
$range-ios-pin-color:                         $text-ios-color !default;
$range-ios-pin-font-size:                     12px !default;
$range-ios-pin-padding:                       8px !default;


ion-range {
  padding: $range-ios-padding-vertical $range-ios-padding-horizontal;
}

[range-left],
[range-right] {
  margin: 0 20px;
}

[range-left] {
  margin-left: 0;
}

[range-right] {
  margin-right: 0;
}

.range-has-pin {
  padding-top: $range-ios-padding-vertical + $range-ios-pin-font-size;
}

.range-slider {
  height: $range-ios-slider-height;
}

.range-bar {
  position: absolute;
  top: ($range-ios-slider-height / 2);
  left: 0;

  width: 100%;
  height: $range-ios-bar-height;

  background: $range-ios-bar-background-color;

  pointer-events: none;
}

.range-pressed .range-bar-active {
  will-change: left, right;
}

.range-pressed .range-knob-handle {
  will-change: left;
}

.range-bar-active {
  bottom: 0;

  width: auto;

  background: $range-ios-bar-active-background-color;
}

.range-knob-handle {
  position: absolute;
  top: ($range-ios-slider-height / 2);
  left: 0%;

  margin-top: -($range-ios-hit-height / 2);
  margin-left: -($range-ios-hit-width / 2);

  width: $range-ios-hit-width;
  height: $range-ios-hit-height;

  text-align: center;
}

.range-knob {
  position: absolute;
  top: ($range-ios-hit-height / 2) - ($range-ios-knob-height / 2) + ($range-ios-bar-height / 2) - .5px;
  left: ($range-ios-hit-width / 2) - ($range-ios-knob-width / 2);

  width: $range-ios-knob-width;
  height: $range-ios-knob-height;

  border-radius: $range-ios-knob-border-radius;

  background: $range-ios-knob-background-color;

  box-shadow: $range-ios-knob-box-shadow;

  pointer-events: none;
}

.range-tick {
  position: absolute;
  top: ($range-ios-hit-height / 2) - ($range-ios-tick-height / 2) + ($range-ios-bar-height / 2);

  margin-left: ($range-ios-tick-width / 2) * -1;

  width: $range-ios-tick-width;
  height: $range-ios-tick-height;

  border-radius: $range-ios-tick-border-radius;

  background: $range-ios-tick-background-color;

  pointer-events: none;
}

.range-tick-active {
  background: $range-ios-tick-active-background-color;
}

.range-pin {
  position: relative;
  top: -20px;
  display: inline-block;

  padding: $range-ios-pin-padding;

  min-width: 28px;

  border-radius: 50px;

  font-size: $range-ios-pin-font-size;

  text-align: center;

  color: $range-ios-pin-color;

  background: $range-ios-pin-background-color;

  transform: translate3d(0, 28px, 0) scale(.01);
  transition: transform 120ms ease;
}

.range-knob-pressed .range-pin {
  transform: translate3d(0, 0, 0) scale(1);
}

// Generate iOS Range Colors
// --------------------------------------------------

@each $color-name, $color-base, $color-contrast in get-colors($colors-ios) {

  ion-range[#{$color-name}] {
    .range-bar-active,
    .range-tick-active {
      background: $color-base;
    }
  }

}
