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

@use "../../config" as *;
@use "../../motion" as *;
@use "../../spacing" as *;
@use "../../theme" as *;
@use "../../utilities/component-reset";
@use "../../utilities/convert";
@use "../../utilities/z-index" as *;
@use "./vars" as *;
@use "./keyframes";
@use "./mixins" as *;

/// Loading styles
/// @access private
/// @group loading

@mixin loading {
  .#{$prefix}--loading {
    @include component-reset.reset;
    @include animation__loading--spin;
    width: $loading-size;
    height: $loading-size;
  }

  // Animation (Spin by default)
  .#{$prefix}--loading__svg {
    fill: transparent;
    stroke: $action-default-fill-primary-default;
    stroke-width: 7;
    stroke-linecap: butt;
    stroke-dasharray: 240;
    stroke-dashoffset: $loading-gap;
    animation: rotate 2s linear infinite;
  }

  @keyframes rotate {
    from {
      transform: rotate(0deg);
    }

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


  .#{$prefix}--loading--stop {
    @include animation__loading--stop;
  }

  .#{$prefix}--loading--small {
    width: 2rem;
    height: 2rem;

    .#{$prefix}--loading__svg {
      stroke: $action-default-fill-primary-default;
    }
  }

  .#{$prefix}--loading--inline {
    width: 1.6rem;
    height: 1.6rem;
  }

  .#{$prefix}--loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 1000ms $standard-easing;
    z-index: z("overlay");
  }

  .#{$prefix}--loading-overlay--stop {
    display: none;
  }
}

@include loading;