/* ==========================================================================
   Steps — where you are in a multi-step flow (checkout, onboarding, setup).

   <ol class="steps">
     <li class="is-done">Cart</li>
     <li aria-current="step">Shipping</li>
     <li>Payment</li>
   </ol>

   With a second line: <li><span class="step-title">Shipping</span><span class="step-text">Address &amp; method</span></li>
   States: .is-done (✓) · aria-current="step" (current) · .is-error (!) · (nothing) upcoming.
   .steps-vertical · .steps-sm · theme-* · links inside steps work (to go back)
   On phones only the current step's label is shown.
   ========================================================================== */

.steps {
  --mo-step-size: 2rem;
  --mo-step-line: color-mix(in oklab, var(--mo-fg-body) 10%, transparent);
  display: flex;
  padding: 0;
  margin: 0;
  font-size: .875rem;
  list-style: none;
  counter-reset: mo-step;
}
.steps > li {
  position: relative;
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  gap: .125rem;
  align-items: center;
  min-width: 0;
  padding: 0 .25rem;
  color: var(--mo-fg-3);
  text-align: center;
  counter-increment: mo-step;
}
/* The circle: number, ✓ or ! */
.steps > li::before {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: var(--mo-step-size);
  height: var(--mo-step-size);
  margin-bottom: .5rem;
  font-size: .8125rem;
  font-weight: var(--mo-font-weight-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--mo-fg-3);
  content: counter(mo-step);
  background: color-mix(in oklab, var(--mo-fg-body) 7%, transparent);
  border-radius: 50%;
  transition: background-color var(--mo-duration) var(--mo-ease), color var(--mo-duration) var(--mo-ease);
}
/* The line to the next step */
.steps > li:not(:last-child)::after {
  position: absolute;
  top: calc(var(--mo-step-size) / 2 - 1px);
  inset-inline: calc(50% + var(--mo-step-size) / 2 + .375rem) calc(-50% + var(--mo-step-size) / 2 + .375rem);
  height: 2px;
  content: "";
  background: var(--mo-step-line);
  border-radius: 2px;
}
.step-title { font-weight: var(--mo-font-weight-medium); }
.step-text { font-size: .8125rem; color: var(--mo-fg-3); }
.steps > li > a { color: inherit; text-decoration: none; }
.steps > li > a:hover { text-decoration: underline; }

/* Done: ✓ in the soft solid shade, and a colored line onward */
.steps > li.is-done { color: var(--mo-fg-2); }
.steps > li.is-done::before {
  content: "";
  background: var(--mo-accent, var(--mo-theme-accent)) var(--mo-check-mark, var(--mo-theme-accent-mark)) center / 60% no-repeat;
}
.steps > li.is-done::after { background: var(--mo-theme-bg); }
/* Current */
.steps > li[aria-current="step"] { color: var(--mo-fg-body); }
.steps > li[aria-current="step"] .step-title,
.steps > li[aria-current="step"]:not(:has(.step-title)) { font-weight: var(--mo-font-weight-semibold); }
.steps > li[aria-current="step"]::before {
  color: var(--mo-theme-contrast);
  background: var(--mo-theme-bg);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--mo-theme-bg) 35%, transparent);
}
/* Error */
.steps > li.is-error { color: var(--mo-red-fg); }
.steps > li.is-error::before { color: var(--mo-red-contrast); content: "!"; background: var(--mo-red-bg); }

/* Vertical: circles on the side, text next to them (a two-column grid per step) */
.steps-vertical { flex-direction: column; }
.steps-vertical > li {
  display: grid;
  flex: none;
  grid-template-columns: var(--mo-step-size) minmax(0, 1fr);
  gap: .125rem .875rem;
  align-items: start;
  padding: 0 0 1.5rem;
  text-align: start;
}
.steps-vertical > li:last-child { padding-bottom: 0; }
.steps-vertical > li::before { grid-row: 1 / span 2; margin: 0; }
.steps-vertical > li > * { grid-column: 2; }
.steps-vertical > li > :first-child,
.steps-vertical > li:not(:has(> *)) { padding-top: calc((var(--mo-step-size) - 1.4em) / 2); }
.steps-vertical > li:not(:last-child)::after {
  top: calc(var(--mo-step-size) + .375rem);
  bottom: .375rem;
  inset-inline: calc(var(--mo-step-size) / 2 - 1px) auto;
  width: 2px;
  height: auto;
}

.steps-sm { --mo-step-size: 1.5rem; font-size: .8125rem; }
.steps-sm > li::before { font-size: .6875rem; }

/* Phones: only the current step keeps its label */
@media (width < 576px) {
  .steps:not(.steps-vertical) > li:not([aria-current="step"]) > *,
  .steps:not(.steps-vertical) > li:not([aria-current="step"]):not(:has(> *)) { font-size: 0; }
  .steps:not(.steps-vertical) > li::before { font-size: .8125rem; }
  .steps:not(.steps-vertical) .step-text { display: none; }
}
