@import '@vtmn/css-design-tokens/src/base-colors';
@import '@vtmn/css-design-tokens/src/themes/default';

.vtmn-loader {
  inline-size: rem(32px);
  block-size: rem(32px);
  background-color: #c4000000;
  mask-image: linear-gradient(transparent 50%, white 50%),
    linear-gradient(to right, transparent 50%, white 50%);
  position: relative;
  color: var(--vtmn-semantic-color_content-active);
  animation: rotate 6s infinite;
}

.vtmn-loader::before {
  content: '';
  position: absolute;
  inset: 0;
  border: rem(2px) solid transparent;
  border-top-color: currentcolor;
  border-radius: 50%;
  background-color: transparent;
  animation: rotate-shrink 0.75s infinite linear alternate;
}

.vtmn-loader_size--small.vtmn-loader {
  inline-size: rem(16px);
  block-size: rem(16px);
}

.vtmn-loader_size--small.vtmn-loader::before {
  border-width: rem(1px);
}

.vtmn-loader_size--medium.vtmn-loader {
  inline-size: rem(32px);
  block-size: rem(32px);
}

.vtmn-loader_size--medium.vtmn-loader::before {
  border-width: rem(2px);
}

.vtmn-loader_size--large.vtmn-loader {
  inline-size: rem(64px);
  block-size: rem(64px);
}

.vtmn-loader_size--large.vtmn-loader::before {
  border-width: rem(4px);
}

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

  12.5% {
    transform: rotate(180deg);
    animation-timing-function: linear;
  }

  25% {
    transform: rotate(630deg);
  }

  37.5% {
    transform: rotate(810deg);
    animation-timing-function: linear;
  }

  50% {
    transform: rotate(1260deg);
  }

  62.5% {
    transform: rotate(1440deg);
    animation-timing-function: linear;
  }

  75% {
    transform: rotate(1890deg);
  }

  87.5% {
    transform: rotate(2070deg);
    animation-timing-function: linear;
  }

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

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

  29.4% {
    border-inline-start-color: transparent;
  }

  29.41% {
    border-inline-start-color: currentcolor;
  }

  64.7% {
    border-block-end-color: transparent;
  }

  64.71% {
    border-block-end-color: currentcolor;
  }

  100% {
    border-inline-start-color: currentcolor;
    border-block-end-color: currentcolor;
    transform: rotate(225deg);
  }
}
