@use "../base/color";
@use "../base/var";

$spinner-offset: 187 !default;
$spinner-duration: 1.4s !default;

[part~="wy-progress-circular"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  position: relative;

  width: var(--wy-component-icon-width);
  height: var(--wy-component-icon-height);

  &:not([width]),
  &[width="24"] {
    width: var(--wy-component-icon-width, var.wy-rem(1.5));
  }

  &:not([height]),
  &[height="24"] {
    height: var(--wy-component-icon-height, var.wy-rem(1.5));
  }
}

[part~="wy-progress-circular"][part~="wy-primary"] {
  color: color.token(--wy-primary);
}

[part~="wy-progress-remaining"] {
  fill: none;
  stroke: color.token(--wy-surface-variant);
}

[part~="wy-progress-done"] {
  fill: none;
  stroke: currentColor;
}

[part~="wy-progress-overlay"] {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  margin: auto;
}

// Spinner

[part~="wy-progress-indeterminate-circle"] {
  stroke-dasharray: 1, 100;
  stroke-dashoffset: 0;
  transform-origin: center;
  fill: none !important;
}

[part~="wy-progress-indeterminate"] {
  // add class .wy-spin to animate the spinner (otherwise it will not be visible)
  animation: wy-rotate $spinner-duration linear infinite;
}

[part~="wy-progress-indeterminate"] [part~="wy-progress-indeterminate-circle"] {
  animation: wy-dash $spinner-duration ease-in-out infinite, wy-color ($spinner-duration * 2) ease-in-out infinite;
}

@keyframes wy-rotate {
  100% {
    transform: rotate(360deg);
  }
}

@keyframes wy-dash {
  0% {
    stroke-dasharray: 1, 100;
    stroke-dashoffset: 0;
  }

  50% {
    stroke-dasharray: 44.5, 100;
    stroke-dashoffset: -17.5;
  }

  100% {
    stroke-dasharray: 44.5, 100;
    stroke-dashoffset: -62;
  }
}

@keyframes wy-color {
  0%,
  100% {
    stroke: color.token(--wy-primary);
  }

  25% {
    stroke: color.token(--wy-primary);
  }

  50% {
    stroke: transparent;
  }

  75% {
    stroke: color.token(--wy-primary);
  }
}
