@use "../../libs/css/theme" as *;
@use "../../libs/css/mixin" as *;


@include b(loading-icon) {
  align-items: center;
  justify-content: center;
  color: $hy-primary;

  @include e(text) {
    color: $hy-primary;
    font-size: 14px;
    line-height: 20px;
  }

  @include e(spinner) {
    position: relative;
    /* #ifndef APP-NVUE */
    box-sizing: border-box;
    max-width: 100%;
    max-height: 100%;
    animation: hy-rotate 1s linear infinite;
    /* #endif */

    @include m(semicircle) {
      border: 3px solid transparent;
      border-top-color: currentColor;
      border-radius: 50%;
    }

    @include m(circle) {
      border-radius: 50%;
      border: 3px solid #e5e5e5;
      border-top-color: currentColor;
    }

    /* ---- dots: 跳动圆点 ---- */
    @include m(dots) {
      /* #ifndef APP-NVUE */
      animation: none;
      border: none;
      @include flex(row);
      align-items: center;
      justify-content: center;
      gap: 6px;
      /* #endif */
    }

    /* ---- bars: 音波柱 ---- */
    @include m(bars) {
      /* #ifndef APP-NVUE */
      animation: none;
      border: none;
      @include flex(row);
      align-items: center;
      justify-content: center;
      gap: 3px;
      /* #endif */
    }
  }

  @include e(row) {
    @include flex(row);

    @include m(text) {
      margin-left: $hy-border-margin-padding-base;
    }
  }

  @include e(column) {
    @include flex(column);

    @include m(text) {
      margin-top: $hy-border-margin-padding-base;
    }
  }
}

/* #ifndef APP-NVUE */
:host {
  font-size: 0;
  line-height: 1px;
}

@include b(loading-icon) {
  @include e(spinner) {
    @include m(spinner) {
      animation-timing-function: steps(12);
    }
  }

  &__text:empty {
    display: none;
  }

  @include e(vertical, text) {
    color: $hy-text-color--grey;
  }

  @include e(dot) {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    &:before {
      /* #ifndef APP-NVUE */
      display: block;
      /* #endif */
      width: 2px;
      height: 25%;
      margin: 0 auto;
      background-color: currentColor;
      border-radius: 40%;
      content: " ";
    }
  }

  /* ---- dots 模式元素 ---- */
  @include e(dot-item) {
    width: 20%;
    height: 20%;
    border-radius: 50%;
    background-color: currentColor;
    animation: hy-dot-bounce 1.4s ease-in-out infinite both;

    &:nth-child(1) { animation-delay: -0.32s; }
    &:nth-child(2) { animation-delay: -0.16s; }
    &:nth-child(3) { animation-delay: 0s; }
  }

  /* ---- bars 模式元素 ---- */
  @include e(bar-item) {
    width: 18%;
    height: 100%;
    border-radius: 4px;
    background-color: currentColor;
    animation: hy-bar-stretch 1.2s ease-in-out infinite;

    &:nth-child(1) { animation-delay: -1s; }
    &:nth-child(2) { animation-delay: -0.8s; }
    &:nth-child(3) { animation-delay: -0.6s; }
    &:nth-child(4) { animation-delay: -0.4s; }
  }
}

@for $i from 1 through 12 {
  .hy-loading-icon__dot:nth-of-type(#{$i}) {
    transform: rotate($i * 30deg);
    opacity: 1 - 0.0625 * ($i - 1);
  }
}

/* ---- 关键帧 ---- */
@keyframes hy-rotate {
  0% { transform: rotate(0deg); }
  to { transform: rotate(1turn); }
}

@keyframes hy-dot-bounce {
  0%,
  80%,
  100% {
    transform: scale(0.4);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes hy-bar-stretch {
  0%,
  100% {
    transform: scaleY(0.4);
    opacity: 0.4;
  }
  50% {
    transform: scaleY(1);
    opacity: 1;
  }
}

/* #endif */
