@use "design-system";

$progress-bar-width: calc(100% - 34px); // 100% - (circle size + (circle border size * 2))
$progress-bar-position-left: calc(-50% + 17px); // -50% + ((circle size / 2) + circle border size)

.progressbar {
  counter-reset: step;
  display: flex;
  justify-content: space-between;
  margin: 0 auto;
}

ul.two-steps {
  margin: 0 auto;
}

.progressbar li {
  @include design-system.H7;

  list-style-type: none;
  position: relative;
  text-align: center;
  color: var(--color-text-alternative);
  z-index: 2;
  align-items: center;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.progressbar li::before {
  width: 30px;
  height: 30px;
  content: counter(step);
  counter-increment: step;
  line-height: 30px;
  border: 2px solid var(--color-border-muted);
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  margin: 0 auto 10px auto;
  border-radius: 50%;
  background-color: var(--color-background-default);
}

.progressbar li::after {
  width: $progress-bar-width;
  height: 2px;
  content: '';
  position: absolute;
  background-color: var(--color-background-alternative);
  top: 15px;
  left: $progress-bar-position-left;

  [dir='rtl'] & {
    width: $progress-bar-width;
    height: 2px;
    content: '';
    position: absolute;
    background-color: var(--color-background-alternative);
  }
}

.progressbar li:first-child::after {
  content: none;

  [dir='rtl'] & {
    content: none;
  }
}

.progressbar li.active {
  color: var(--color-primary-default);

  [dir='rtl'] & {
    color: var(--color-primary-default);
  }
}

.progressbar li.active::before {
  border-color: var(--color-primary-default);
  z-index: 1;

  [dir='rtl'] & {
    border-color: var(--color-primary-default);
    z-index: 1;
  }
}

.progressbar li.complete + li::after {
  background-color: var(--color-primary-default);
  z-index: -1;

  [dir='rtl'] & {
    background-color: var(--color-primary-default);
    z-index: -1;
  }
}

.progressbar li.complete::before {
  background-color: var(--color-primary-default);
  color: var(--color-primary-inverse);

  [dir='rtl'] & {
    background-color: var(--color-primary-default);
    color: var(--color-primary-inverse);
  }
}

.progressbar li.two-steps::after {
  height: 2px;
  content: '';
  position: absolute;
  background-color: var(--color-background-alternative);
  top: 15px;
  z-index: -1;

  [dir='rtl'] & {
    width: 180px;
    height: 2px;
    content: '';
    position: absolute;
    background-color: var(--color-background-alternative);
    z-index: -1;
  }
}
