// ┌────────┐
// │ Loader │
// └────────┘
//  Adapted from: http://esri.github.io/calcite-web/components/#loader
//  Line 15 is a shortcircuit of functionality found in Calcite-Web
//  Color variables have been changed to $Calcite-*

@mixin loader() {
  display: none;
  position: relative;
  &.is-active {
    display: block;
  }
}

%loader-styles {
  background: $Calcite_Blue_250;
  -webkit-animation: load $loader-speed infinite ease-in-out;
  animation: load $loader-speed infinite ease-in-out;
  width: $loader-width;
  height: $loader-height;
}

%loader-pseudoelements {
  @extend %loader-styles;
  position: absolute;
  top: 0;
  content: '';
}

@mixin loader-bars() {
  @extend %loader-styles;
  text-indent: -9999em;
  margin: auto;
  position: absolute;
  right: 50%;
  font-size: 11px;
  -webkit-animation-delay: $loader-delay;
  animation-delay: $loader-delay;
  &:before{
    @extend %loader-pseudoelements;
    left: -$loader-spacing;
  }
  &:after {
    @extend %loader-pseudoelements;
    left: $loader-spacing;
    -webkit-animation-delay: 2*$loader-delay;
    animation-delay: 2*$loader-delay;
  }
}

@mixin loader-text() {
  text-align: center;
  padding-top: 4rem;
  @extend .avenir-regular !optional;
}

@if $include-loader == true {
  @-webkit-keyframes load {
    0%,
    80%,
    100% {
      box-shadow: 0 0 $Calcite_Blue_250;
      background: $Calcite_Blue_250;
      height: $loader-height;
    }
    40% {
      box-shadow: 0 -1*$loader-zoom $Calcite_Highlight_Blue_350;
      background: $Calcite_Highlight_Blue_350;
      height: $loader-height+$loader-zoom;
    }
  }
  @keyframes load {
    0%,
    80%,
    100% {
      box-shadow: 0 0 $Calcite_Highlight_Blue_350;
      background: $Calcite_Blue_250;
      height: $loader-height;
    }
    40% {
      box-shadow: 0 -1*$loader-zoom $Calcite_Highlight_Blue_350;
      background: $Calcite_Highlight_Blue_350;
      height: $loader-height+$loader-zoom;
    }
  }

  .loader {@include loader();}
    .loader-bars {@include loader-bars();}
    .loader-text {@include loader-text();}

   .ie9 {
    .loader-bars {
      position: inherit;
      background-color: transparent;
      background-image: url('../img/loader-ie9.gif');
      background-position: center top;
      animation: none;
      -webkit-animation-delay: none;
      -webkit-animation: none;
      width: 64px;
      height: 64px;
      &:before, &:after {
        background: none;
        animation: none;
        -webkit-animation: none;
        width: 0px;
        height: 0px;
      }
    }
    .loader-text {
      padding-top: 2rem;
    }
   }
}