@use '../../sass/abstracts/variables' as *;
@use '../../sass/abstracts/typography';

#{$object-prefix}loader {
  color: $black;
  text-shadow: 0 0 0.4rem rgba(255, 255, 255, 0.5);
  white-space: pre-line;
  display: inline-block;
  z-index: 9999;
  text-align: center;
  @include typography.body-large;

  &:not(#{$object-prefix}loader--fullscreen) {
    #{$utilities-prefix}background-color-light-grey & {
      &:before {
        border-color: $white;
        border-top-color: $blue;
      }
      & > div {
        color: $sodra-black;
        text-shadow: none;
      }
    }
  }

  &:before {
    content: '';
    border: 10px solid $light-grey;
    border-top: 10px solid $blue;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    display: block;
    margin: auto;
  }

  &--medium {
    &::before {
      width: 30px;
      height: 30px;
      border-width: 5px;
    }

    #{$object-prefix}loader--absolute {
      margin-left: -0.9375rem;
      margin-top: -0.9375rem;
    }
  }

  &--medium.o-loader--absolute {
    margin-left: -0.9375rem;
    margin-top: -0.9375rem;
  }

  &--hide {
    display: none;
  }

  &--fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    vertical-align: middle;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-direction: column;
    color: #fff;
    text-shadow: none;

    &:before {
      position: absolute;
      margin-top: -70px;
    }

    &:after {
      position: fixed;
      background-color: rgba(0, 0, 0, 0.5);
      content: '';
      display: block;
      z-index: -1;
      left: 0;
      top: 0;
      right: 0;
      bottom: 0;
    }
  }

  &--fixed {
    position: fixed;
    top: 50%;
    left: 50%;
    margin-left: -1.875rem;
    margin-top: -1.875rem;
  }

  &--absolute {
    position: absolute;
    top: 50%;
    left: 50%;
    margin-left: -1.875rem;
    margin-top: -1.875rem;
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
