//
// 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.
//

@import '../../globals/scss/vars';
@import '../../globals/scss/css--reset';
@import '../../globals/scss/typography';
@import '../../globals/scss/vendor/@carbon/elements/scss/import-once/import-once';
@import '../loading/loading';
@import 'keyframes';

/// Inline loading styles
/// @access private
/// @group inline-loading
@mixin inline-loading {
  .#{$prefix}--inline-loading {
    display: flex;
    width: 100%;
    min-height: 2rem;
    align-items: center;

    .#{$prefix}--loading__svg circle {
      stroke-width: 12;
    }

    .#{$prefix}--loading__stroke {
      stroke-dashoffset: $loading--small__gap;
    }
  }

  .#{$prefix}--inline-loading__text {
    @include type-style('body-short-01');
    color: $text-02;
  }

  .#{$prefix}--inline-loading__animation {
    position: relative;
    width: 2rem;
    height: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .#{$prefix}--inline-loading__checkmark-container {
    fill: $interactive-04;

    // For deprecated older markup
    &.#{$prefix}--inline-loading__svg {
      width: 0.75rem;
      position: absolute;
      top: 0.75rem;
    }

    &[hidden] {
      display: none;
    }
  }

  .#{$prefix}--inline-loading__checkmark {
    fill: none;
    stroke: $interactive-04;
    transform-origin: 50% 50%;
    stroke-width: 1.8;
    stroke-dasharray: 12;
    stroke-dashoffset: 12;
    animation-name: stroke;
    animation-duration: 0.25s;
    animation-fill-mode: forwards;
  }

  .#{$prefix}--inline-loading--error {
    fill: $support-01;
    width: rem(16px);
    height: rem(16px);

    &[hidden] {
      display: none;
    }
  }

  .#{$prefix}--loading--small .#{$prefix}--inline-loading__svg {
    stroke: $interactive-04;
  }
  /* If IE11 Don't show check animation */
  @media screen and (-ms-high-contrast: active),
    screen and (-ms-high-contrast: none) {
    .#{$prefix}--inline-loading__checkmark-container {
      top: 1px;
      right: 0.5rem;
    }

    .#{$prefix}--inline-loading__checkmark {
      animation: none;
      stroke-dashoffset: 0;
      stroke-dasharray: 0;
    }
  }
}

@include exports('inline-loading') {
  @include inline-loading;
}
