/**
 *
 * @ai-apps/angular v2.152.0 | _slider.scss
 *
 * Copyright 2014, 2023 IBM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0

 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


//
// Copyright IBM Corp. 2016, 2018
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

//-----------------------------
// Slider
//-----------------------------

@import '../../globals/scss/vars';
@import '../../globals/scss/helper-mixins';
@import '../../globals/scss/typography';
@import '../../globals/scss/vendor/@carbon/elements/scss/import-once/import-once';
@import '../form/form';
@import '../text-input/text-input';

/// Slider styles
/// @access private
/// @group slider
@mixin slider {
  .#{$prefix}--slider-container {
    display: flex;
    align-items: center;
    user-select: none;
  }

  .#{$prefix}--slider {
    position: relative;
    width: 100%;
    min-width: rem(200px);
    max-width: rem(640px);
    margin: 0 $carbon--spacing-05;
  }

  .#{$prefix}--slider__range-label {
    @include type-style('code-02');

    color: $text-01;
    white-space: nowrap;

    &:last-of-type {
      margin-right: $carbon--spacing-05;
    }
  }

  .#{$prefix}--slider__track {
    position: absolute;
    width: 100%;
    height: rem(2px);
    background: $ui-03;
    cursor: pointer;
    transform: translate(0%, -50%);
  }

  .#{$prefix}--slider__track:before {
    position: absolute;
    top: rem(-5px);
    left: 50%;
    display: inline-block;
    width: rem(2px);
    height: rem(4px);
    background: $ui-03;
    content: '';
    transform: translate(-50%, 0);
  }

  .#{$prefix}--slider__filled-track {
    position: absolute;
    width: 100%;
    height: rem(2px);
    background: $ui-05;
    pointer-events: none;
    transform: translate(0%, -50%);
    transform-origin: left;
    transition: background $duration--fast-02 motion(standard, productive);
  }

  .#{$prefix}--slider__thumb {
    position: absolute;
    z-index: 3;
    top: 0;
    width: rem(14px);
    height: rem(14px);
    background: $ui-05;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px transparent, inset 0 0 0 2px transparent;
    cursor: pointer;
    outline: none;
    transform: translate(-50%, -50%);
    transition: transform $duration--fast-02 motion(standard, productive),
      background $duration--fast-02 motion(standard, productive),
      box-shadow $duration--fast-02 motion(standard, productive);

    &:hover {
      // 20px / 14px = 1.4286
      transform: translate(-50%, -50%) scale(1.4286);
    }

    &:focus {
      background-color: $interactive-04;
      box-shadow: inset 0 0 0 2px $interactive-04, inset 0 0 0 3px $ui-01;
      // 20px / 14px = 1.4286
      transform: translate(-50%, -50%) scale(1.4286);
    }

    &:active {
      box-shadow: inset 0 0 0 2px $interactive-04;
      transform: translate(-50%, -50%) scale(1.4286);
    }
  }

  .#{$prefix}--slider__input {
    display: none;
  }

  .#{$prefix}--slider-text-input,
  .#{$prefix}-slider-text-input {
    width: auto;
    height: rem(40px);
    -moz-appearance: textfield;
    text-align: center;

    &::-webkit-outer-spin-button,
    &::-webkit-inner-spin-button {
      display: none;
    }
  }

  .#{$prefix}--slider__thumb:focus ~ .#{$prefix}--slider__filled-track {
    background-color: $interactive-04;
  }

  // Disabled state
  .#{$prefix}--label--disabled
    ~ .#{$prefix}--slider-container
    > .#{$prefix}--slider__range-label {
    color: $disabled-02;
  }

  .#{$prefix}--slider--disabled .#{$prefix}--slider__thumb {
    background-color: $ui-03;

    &:hover {
      cursor: not-allowed;
      transform: translate(-50%, -50%);
    }

    &:focus {
      background-color: $ui-03;
      box-shadow: none;
      outline: none;
      transform: translate(-50%, -50%);
    }

    &:active {
      background: $ui-03;
      transform: translate(-50%, -50%);
    }
  }

  .#{$prefix}--slider--disabled .#{$prefix}--slider__track,
  .#{$prefix}--slider--disabled .#{$prefix}--slider__filled-track,
  .#{$prefix}--slider--disabled
    .#{$prefix}--slider__thumb:focus
    ~ .#{$prefix}--slider__filled-track {
    background-color: $ui-03;
    cursor: not-allowed;
  }

  .#{$prefix}--slider--disabled
    ~ .#{$prefix}--form-item
    .#{$prefix}--slider-text-input,
  .#{$prefix}--slider--disabled ~ .#{$prefix}--slider-text-input {
    border: none;
    background-color: $disabled-01;
    color: $disabled-02;
    cursor: not-allowed;
    transition: none;

    &:active,
    &:focus,
    &:hover {
      color: $disabled-02;
      outline: none;
    }
  }

  // Skeleton state
  .#{$prefix}--slider-container.#{$prefix}--skeleton
    .#{$prefix}--slider__range-label {
    @include skeleton;

    width: rem(20px);
    height: rem(12px);
  }

  .#{$prefix}--slider-container.#{$prefix}--skeleton
    .#{$prefix}--slider__track {
    cursor: default;
    pointer-events: none;
  }

  .#{$prefix}--slider-container.#{$prefix}--skeleton
    .#{$prefix}--slider__thumb {
    left: 50%;
    cursor: default;
    pointer-events: none;
  }

  // Windows HCM fix
  /* stylelint-disable */
  .#{$prefix}--slider__thumb {
    @include high-contrast-mode('outline');
  }
  .#{$prefix}--slider__thumb:focus {
    @include high-contrast-mode('focus');
  }
  .#{$prefix}--slider__track {
    @include high-contrast-mode('outline');
  }
  /* stylelint-enable */
}

@include exports('slider') {
  @include slider;
}
