@use 'uswds-core' as *;

$step-indicator-current-step-border-width: 3px;
$step-indicator-line-height: 4px;

lg-step-indicator {
  display: block;
  border-bottom: 1px solid color('primary-light');
  box-shadow: 0 2px 2px rgb(0 0 0 / 10%);
  margin-bottom: units(4);
  position: relative;

  @include at-media('tablet') {
    border-bottom: 0;
    box-shadow: none;
  }

  @include at-media-max('tablet') {
    &::before,
    &::after {
      bottom: 0;
      content: '';
      height: 100%;
      position: absolute;
      top: 0;
      width: units(3);
    }

    &::before {
      background: linear-gradient(
        to right,
        rgb(255 255 255 / 100%),
        rgb(255 255 255 / 100%) 17%,
        rgb(255 255 255 / 0%)
      );
      left: 0;
      z-index: 1;
    }

    &::after {
      background: linear-gradient(
        to left,
        rgb(255 255 255 / 100%),
        rgb(255 255 255 / 100%) 17%,
        rgb(255 255 255 / 0%)
      );
      right: 0;
    }
  }
}

.step-indicator__scroller {
  display: flex;
  list-style-type: none;
  margin: 0;
  overflow: scroll;
  padding: units(1) units(3) units(2);
  scrollbar-width: none;

  @include at-media('tablet') {
    overflow: visible;
    padding-left: 0;
    padding-right: 0;
    padding-top: 0;
  }

  &::after {
    content: '';
    flex: 0 0 units(3);

    @include at-media('tablet') {
      content: none;
    }
  }

  &::-webkit-scrollbar {
    display: none;
  }
}

.step-indicator__step {
  flex: 0 0 33.33%;
  font-size: 0.75rem;
  padding: 1.5rem 0.25rem 0;
  position: relative;
  text-align: center;

  // In cases when browser text zoom is very high (i.e. the root font-size has
  // been drastically increased), the step indicator will overflow the viewport
  // by _a lot_. In those cases, 33% of the viewport will not be wide enough to
  // keep the individual steps from crowding each other.
  //
  // This min-width takes effect under those circumstances, keeping individual
  // steps far enough apart to remain legible.
  min-width: 4rem;

  @include at-media('tablet') {
    flex: 1 1 0%;
    min-width: auto;
  }
}

.step-indicator__step::before {
  background-color: color('base-lighter');
  border-radius: 50%;
  content: '';
  height: 1rem;
  left: 50%;
  margin-left: -0.5rem;
  position: absolute;
  top: 0;
  width: 1rem;
}

.step-indicator__step--current::before {
  background-color: color('white');
  border: $step-indicator-current-step-border-width solid color('success');
}

.step-indicator__step--complete::before {
  background-color: color('white');
  background-image: url('/alerts/success.svg');
}

.step-indicator__step:not(:last-child)::after {
  background-color: color('base-lighter');
  content: '';
  height: $step-indicator-line-height;
  left: calc(50% + 0.5rem + #{$step-indicator-line-height});
  margin-top: -0.5 * $step-indicator-line-height;
  position: absolute;
  top: 0.5rem;
  width: calc(100% - 1rem - #{$step-indicator-line-height * 2});
}

.step-indicator__step--complete:not(:last-child)::after {
  background-color: color('success');
}

.step-indicator__step--current .step-indicator__step-title {
  font-weight: bold;
}
