// ┌────────┐
// │ Loader │
// └────────┘
//  ↳ http://esri.github.io/calcite-web/documentation/components/#loader
//  ↳ components → _loader.md

$loader-width: 0.85rem;
$loader-height: 2rem;
$loader-zoom: 0.5rem;
$loader-spacing: 1.25rem;
$loader-speed: 0.8s;
$loader-delay: 0.16s;

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

%loader-styles {
  background: $blue;
  -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: calc(50% - #{$loader-width / 2});
  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;
}

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

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