//
// Copyright 2017 Google Inc. All Rights Reserved.
//
// 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.
//

@import "@material/animation/variables";
@import "@material/theme/mixins";
@import "./variables";

@mixin mdc-checkbox-container-keyframes_(
  $from-stroke-color,
  $to-stroke-color,
  $from-fill-color,
  $to-fill-color,
  $uid) {
  @keyframes mdc-checkbox-fade-in-background-#{$uid} {
    0% {
      @include mdc-theme-prop(border-color, $from-stroke-color);
      @include mdc-theme-prop(background-color, $from-fill-color);
    }

    50% {
      @include mdc-theme-prop(border-color, $to-stroke-color);
      @include mdc-theme-prop(background-color, $to-fill-color);
    }
  }

  @keyframes mdc-checkbox-fade-out-background-#{$uid} {
    0%,
    80% {
      @include mdc-theme-prop(border-color, $to-stroke-color);
      @include mdc-theme-prop(background-color, $to-fill-color);
    }

    100% {
      @include mdc-theme-prop(border-color, $from-stroke-color);
      @include mdc-theme-prop(background-color, $from-fill-color);
    }
  }
}

@keyframes mdc-checkbox-unchecked-checked-checkmark-path {
  0%,
  50% {
    stroke-dashoffset: $mdc-checkbox-mark-path-length_;
  }

  50% {
    animation-timing-function: $mdc-animation-deceleration-curve-timing-function;
  }

  100% {
    stroke-dashoffset: 0;
  }
}

@keyframes mdc-checkbox-unchecked-indeterminate-mixedmark {
  0%,
  68.2% {
    transform: scaleX(0);
  }

  68.2% {
    animation-timing-function: cubic-bezier(0, 0, 0, 1);
  }

  100% {
    transform: scaleX(1);
  }
}

@keyframes mdc-checkbox-checked-unchecked-checkmark-path {
  from {
    animation-timing-function: $mdc-animation-acceleration-curve-timing-function;
    opacity: 1;
    stroke-dashoffset: 0;
  }

  to {
    opacity: 0;
    stroke-dashoffset: $mdc-checkbox-mark-path-length_ * -1;
  }
}

@keyframes mdc-checkbox-checked-indeterminate-checkmark {
  from {
    animation-timing-function: $mdc-animation-deceleration-curve-timing-function;
    transform: rotate(0deg);
    opacity: 1;
  }

  to {
    transform: rotate(45deg);
    opacity: 0;
  }
}

@keyframes mdc-checkbox-indeterminate-checked-checkmark {
  from {
    animation-timing-function: $mdc-checkbox-indeterminate-checked-easing-function_;
    transform: rotate(45deg);
    opacity: 0;
  }

  to {
    transform: rotate(360deg);
    opacity: 1;
  }
}

@keyframes mdc-checkbox-checked-indeterminate-mixedmark {
  from {
    animation-timing-function: mdc-animation-deceleration-curve-timing-function;
    transform: rotate(-45deg);
    opacity: 0;
  }

  to {
    transform: rotate(0deg);
    opacity: 1;
  }
}

@keyframes mdc-checkbox-indeterminate-checked-mixedmark {
  from {
    animation-timing-function: $mdc-checkbox-indeterminate-checked-easing-function_;
    transform: rotate(0deg);
    opacity: 1;
  }

  to {
    transform: rotate(315deg);
    opacity: 0;
  }
}

@keyframes mdc-checkbox-indeterminate-unchecked-mixedmark {
  0% {
    animation-timing-function: linear;
    transform: scaleX(1);
    opacity: 1;
  }

  32.8%,
  100% {
    transform: scaleX(0);
    opacity: 0;
  }
}
