.navds-stepper {
  --navds-stepper-circle-size: 1.75rem;
  --navds-stepper-border-width: 2px;
  --navds-stepper-line-length: 1rem;

  color: var(--ac-stepper-text, var(--a-surface-action));
  font-weight: 600;
  line-height: 1;
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.navds-stepper--horizontal {
  display: flex;
  align-items: flex-start;
  text-align: center;
}

.navds-stepper__item {
  display: grid;
  grid-template-rows:
    [line-1] auto [step-start] var(--navds-stepper-circle-size)
    [line-2 step-end] auto;
  grid-template-columns: var(--navds-stepper-circle-size) auto;
  justify-items: flex-start;
  gap: 0.5rem;
}

.navds-stepper__line {
  background-color: var(--ac-stepper-line, var(--a-border-default));
  width: var(--navds-stepper-border-width);
  height: 100%;
  min-height: var(--navds-stepper-line-length);
  justify-self: center;
  grid-column: 1;
}

.navds-stepper__step--behind.navds-stepper__step--completed + .navds-stepper__line {
  background-color: var(--ac-stepper-line-completed, var(--a-border-selected));
}

.navds-stepper__item--behind.navds-stepper__item--completed + .navds-stepper__item > .navds-stepper__line--1 {
  background-color: var(--ac-stepper-line-completed, var(--a-border-selected));
}

.navds-stepper__line--1 {
  grid-row: line-1;
  display: none;
}

.navds-stepper__line--2 {
  grid-row: line-2;
}

:where(.navds-stepper__item:last-of-type) .navds-stepper__line--2 {
  display: none;
}

.navds-stepper__step {
  grid-row: 2 / -1;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: [circle] var(--navds-stepper-circle-size) [content] auto;
  gap: var(--a-spacing-2);
  justify-content: flex-start;
  text-decoration: none;
  cursor: pointer;
  padding: var(--navds-stepper-border-width);
  margin: calc(var(--navds-stepper-border-width) * -1) calc(var(--navds-stepper-border-width) * -1) 1.75rem;
}

.navds-stepper__item:last-child .navds-stepper__step {
  margin-bottom: 0;
}

@media (forced-colors: active) {
  .navds-stepper__step {
    background-color: ButtonFace;
    color: ButtonText;
  }

  .navds-stepper__circle.navds-stepper__circle {
    border: 0;
  }

  .navds-stepper__step .navds-stepper__circle {
    forced-color-adjust: none;
    background-color: ButtonText;
    border-color: ButtonText;
    color: ButtonFace;
  }

  .navds-stepper__step.navds-stepper__step:focus-visible {
    box-shadow: none;
    outline: 2px solid highlight;
    outline-offset: 2px;
  }

  .navds-stepper__step.navds-stepper__step--active .navds-stepper__circle {
    forced-color-adjust: none;
    background-color: highlight;
    border-color: highlighttext;
    color: highlighttext;
  }

  .navds-stepper__line {
    background-color: ButtonText;
  }
}

button.navds-stepper__step {
  appearance: none;
  border: none;
  background-color: transparent;
  font: inherit;
  color: inherit;
  text-align: inherit;
}

.navds-stepper__step--non-interactive {
  color: var(--ac-stepper-non-interactive, var(--a-text-subtle));
  cursor: default;
}

:where(.navds-stepper__step):focus-visible {
  outline: none;
  box-shadow: var(--a-shadow-focus);
  isolation: isolate;
}

@supports not selector(:focus-visible) {
  .navds-stepper__step:focus {
    outline: none;
    box-shadow: var(--a-shadow-focus);
    isolation: isolate;
  }
}

.navds-stepper__circle {
  grid-column: circle;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: var(--navds-stepper-circle-size);
  height: var(--navds-stepper-circle-size);
  border: var(--navds-stepper-border-width) solid currentColor;
  border-radius: var(--a-border-radius-full);
  line-height: 1;
}

.navds-stepper__circle--success {
  border: none;
  background: none;
  font-size: 1.75rem;
  color: var(--a-text-on-action);
  background-color: var(--ac-stepper-text, var(--a-surface-action));
}

.navds-stepper__content {
  min-width: fit-content;
  line-height: 1.5;
  grid-column: content;
  padding-top: 0.035rem;
}

/* Horizontal */
:where(.navds-stepper--horizontal) .navds-stepper__item {
  flex: 1 1 100%;
  grid-template-columns:
    [line-1-start] 1fr [step-start] auto [line-1-end] var(--navds-stepper-circle-size)
    [line-2-start] auto [step-end] 1fr [line-2-end];
  grid-template-rows: var(--navds-stepper-circle-size) auto;
}

:where(.navds-stepper--horizontal) .navds-stepper__line {
  height: var(--navds-stepper-border-width);
  width: 100%;
  min-height: auto;
  grid-row: 1;
  display: block;
  align-self: center;
}

:where(.navds-stepper--horizontal) .navds-stepper__line--1 {
  grid-column: line-1;
}

:where(.navds-stepper--horizontal) .navds-stepper__line--2 {
  grid-column: line-2;
}

:where(.navds-stepper--horizontal .navds-stepper__item:first-of-type) .navds-stepper__line--1,
:where(.navds-stepper--horizontal .navds-stepper__item:last-of-type) .navds-stepper__line--2 {
  visibility: hidden;
}

:where(.navds-stepper--horizontal) .navds-stepper__step {
  grid-row: 1 / -1;
  grid-column: step;
  display: grid;
  grid-template-rows: [circle] var(--navds-stepper-circle-size) [content] auto;
  grid-template-columns:
    [content-start] auto [circle] var(--navds-stepper-circle-size)
    [content-end] auto;
  place-items: center center;
  margin-bottom: 0;
}

:where(.navds-stepper--horizontal) .navds-stepper__circle {
  grid-row: circle;
  grid-column: 2;
}

:where(.navds-stepper--horizontal) .navds-stepper__content {
  grid-row: content;
  grid-column: 1 / -1;
  max-width: 24ch;
}

/* Active step */
:where(.navds-stepper__step--active) .navds-stepper__content {
  color: var(--ac-stepper-active, var(--a-text-action-selected));
}

.navds-stepper__step:hover:where(:not(.navds-stepper__step--non-interactive)) {
  color: var(--ac-stepper-hover-active, var(--a-text-action-hover));
}

:where(.navds-stepper__step:hover) .navds-stepper__content {
  text-decoration: underline;
}

:where(.navds-stepper__step--non-interactive:hover, .navds-stepper__step--active:hover) .navds-stepper__content {
  text-decoration: none;
}

:where(.navds-stepper__step--active) .navds-stepper__circle {
  background-color: var(--ac-stepper-active-bg, var(--a-surface-action-selected));
  border-color: var(--ac-stepper-active-border, var(--a-border-action-selected));
  color: var(--ac-stepper-active-text, var(--a-text-on-action));
}

:where(.navds-stepper__step:not(.navds-stepper__step--active):hover) .navds-stepper__circle {
  background-color: var(--ac-stepper-hover-bg, var(--a-surface-action-subtle-hover));
}

:where(.navds-stepper__step:not(.navds-stepper__step--active):hover) .navds-stepper__circle--success {
  background-color: var(--ac-stepper-text, var(--a-surface-action-hover));
}

/* Non-interactive */
:where(.navds-stepper__step--non-interactive.navds-stepper__step--active) .navds-stepper__content {
  color: var(--ac-stepper-non-interactive-active, var(--a-text-default));
}

.navds-stepper__step--non-interactive.navds-stepper__step--behind.navds-stepper__step--completed + .navds-stepper__line {
  background-color: var(--ac-stepper-non-interactive-line-completed, var(--a-border-strong));
}

.navds-stepper__item--non-interactive.navds-stepper__item--behind.navds-stepper__item--completed
  + .navds-stepper__item
  > .navds-stepper__line--1 {
  background-color: var(--ac-stepper-non-interactive-line-completed, var(--a-border-strong));
}

:where(.navds-stepper__step--non-interactive.navds-stepper__step--active) .navds-stepper__circle {
  background-color: var(--ac-stepper-non-interactive-active-bg, var(--a-surface-inverted));
  border-color: var(--ac-stepper-non-interactive-active-border, var(--a-surface-inverted));
  color: var(--ac-stepper-non-interactive-active-text, var(--a-text-on-inverted));
}

:where(.navds-stepper__step--non-interactive:hover) .navds-stepper__circle {
  background-color: transparent;
}

:where(.navds-stepper__step--non-interactive.navds-stepper__step--active:hover) .navds-stepper__circle {
  background-color: var(--ac-stepper-non-interactive-active-bg, var(--a-surface-inverted));
}

:where(.navds-stepper__step--completed.navds-stepper__step--active) .navds-stepper__circle {
  background-color: inherit;
  color: var(--ac-stepper-active-completed, var(--a-text-action-selected));
}

:where(.navds-stepper__step--completed.navds-stepper__step--active) .navds-stepper__circle--success {
  color: var(--a-text-on-action);
  background-color: var(--ac-stepper-active-completed, var(--a-surface-action-selected));
}

:where(.navds-stepper__step--non-interactive, .navds-stepper__step--non-interactive:hover) .navds-stepper__circle--success {
  color: var(--a-text-on-inverted);
  background-color: var(--ac-stepper-non-interactive-completed-bg, var(--a-surface-neutral));
}

:where(.navds-stepper__step--non-interactive.navds-stepper__step--active) .navds-stepper__circle--success {
  color: var(--a-text-on-inverted);
  background-color: var(--ac-stepper-non-interactive-active-completed, var(--a-surface-inverted));
}

:where(.navds-stepper__step--completed.navds-stepper__step--active.navds-stepper__step--non-interactive) .navds-stepper__circle {
  color: var(--ac-stepper-non-interactive-active-completed, var(--a-text-default));
}

:where(.navds-stepper__step--completed.navds-stepper__step--active.navds-stepper__step--non-interactive)
  .navds-stepper__circle--success {
  color: var(--ac-stepper-non-interactive-active-completed, var(--a-text-on-inverted));
}
