//
// 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/@rocketsoftware/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;
    align-items: center;
    width: 100%;
    min-height: 2rem;

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

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

  .#{$prefix}--inline-loading__text {
    @include type-style('label-01');

    color: $text-02;
  }

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

  .#{$prefix}--inline-loading__checkmark-container {
    fill: $support-02;

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

    &[hidden] {
      display: none;
    }
  }

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

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

    &[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;
}
