@import './token.less';

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

  100% {
    transform: rotate(359deg);
  }
}

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

  to {
    transform: rotate(1turn);
  }
}

@keyframes pSpinMove {
  to {
    opacity: 1;
  }
}
@keyframes pRotate {
  to {
    -webkit-transform: rotate(405deg);
    transform: rotate(405deg);
  }
}

.@{ns}-Spinner {
  transform: translateZ(0);
  display: inline-block;
  background-size: 100%;
  transition: ease-out all @animation-duration-3;

  &--icon {
    background: transparent;
    animation: spin 2s linear infinite;
    width: auto;
    height: auto;
  }
  .is-spin {
    animation: spin 2s linear infinite;
  }

  &-overlay {
    position: absolute;
    z-index: 10;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: @spinner-overlay-bg;
    transition: ease-out opacity @animation-duration-3;

    opacity: 0;

    &.in {
      opacity: 1;
    }
  }

  // 当启用 overlay 的时候，应该是居中模式。
  &--overlay {
    position: absolute;
    z-index: 11;
    top: 50%;
    left: 50%;
    transform: translate3d(-50%, -50%, 0);
    text-align: center;
  }

  .p-spin {
    position: static;
    display: inline-block;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    color: var(--primary-color);
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
    list-style: none;
    opacity: 1;
    transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
    font-feature-settings: 'tnum';
  }
  &-tip {
    color: var(--primary-color);
    font-size: @font-size-small;
  }

  .p-spin-dot {
    position: relative;
    display: inline-block;
    font-size: 20px;
    width: 1em;
    height: 1em;
  }

  .p-spin-dot i {
    position: absolute;
    display: block;
    width: 9px;
    height: 9px;
    background-color: var(--primary-color);
    border-radius: 100%;
    transform: scale(0.75);
    transform-origin: 50% 50%;
    opacity: 0.3;
    animation: pSpinMove 1s infinite linear alternate;
  }

  .p-spin-dot i:nth-child(1) {
    top: 0;
    left: 0;
  }

  .p-spin-dot i:nth-child(2) {
    top: 0;
    right: 0;
    animation-delay: 0.4s;
  }

  .p-spin-dot i:nth-child(3) {
    right: 0;
    bottom: 0;
    animation-delay: 0.8s;
  }

  .p-spin-dot i:nth-child(4) {
    bottom: 0;
    left: 0;
    animation-delay: 1.2s;
  }

  .p-spin-dot-spin {
    transform: rotate(45deg);
    animation: pRotate 1.2s infinite linear;
  }

  &--lg {
    .p-spin-dot {
      font-size: 32px;
      i {
        width: 14px;
        height: 14px;
      }
    }
  }

  &--sm {
    .p-spin-dot {
      font-size: 14px;
      i {
        width: 6px;
        height: 6px;
      }
    }
  }
}
