@use '@/styles/variables' as *;
@use '@/styles/mixins' as *;

.loading {
  @include flex-column-center;
  gap: $spacing-sm;
  color: $primary-color;

  &--sm {
    .loading__spinner {
      width: 20px;
      height: 20px;
    }

    .loading__tip {
      font-size: $font-size-xs;
    }
  }

  &--md {
    .loading__spinner {
      width: 32px;
      height: 32px;
    }

    .loading__tip {
      font-size: $font-size-sm;
    }
  }

  &--lg {
    .loading__spinner {
      width: 48px;
      height: 48px;
    }

    .loading__tip {
      font-size: $font-size-base;
    }
  }

  &__spinner {
    animation: spin 1s linear infinite;

    svg {
      width: 100%;
      height: 100%;
    }

    circle {
      stroke-dasharray: 80, 200;
      stroke-dashoffset: 0;
      animation: dash 1.5s ease-in-out infinite;
    }
  }

  &__tip {
    color: $text-secondary;
  }

  &__fullScreen {
    @include fixed-fill;
    @include flex-center;
    background-color: rgba($card-background, 0.8);
    z-index: $z-index-modal;
  }
}

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

@keyframes dash {
  0% {
    stroke-dasharray: 1, 200;
    stroke-dashoffset: 0;
  }
  50% {
    stroke-dasharray: 90, 200;
    stroke-dashoffset: -35;
  }
  100% {
    stroke-dasharray: 90, 200;
    stroke-dashoffset: -125;
  }
}
