/* kc-v2 v1.5.7 -- stepper */
/* kc-v2 stepper -- linear progress through a multi-step form.
 *
 * Full class contract and conventions: see README.md and kc-v2-base.css.
 *
 * Added in 1.5.0 for the Business License Application (KENT-56), whose Figma frame (node 100:545)
 * is the only mock in the redesign that shows one.
 *
 * 1.5.1 (KENT-44 QA) put it on the Annual and Quarterly returns too. Those had conveyed position
 * with a plain page heading -- "Page 2 of 4" in words -- which told a filer where they were but
 * not what was still ahead of them. Both of those flows are ONE page with a client-side router,
 * so their state is driven by kcV2.setStep() rather than written into each step's markup; see
 * the note on that function.
 *
 * WHAT THIS IS NOT: it is not a tab list and not navigation. The steps are not activatable -- a filer
 * moves between them with the form's own Back/Continue buttons, which run validation on the way. So
 * this renders as an ordered list of plain elements, NOT as links or buttons: a control that looks
 * clickable and is not is worse than no control. If a future flow does allow jumping to a completed
 * step, the marker becomes a <button> and gains its own focus ring; the classes below are shaped so
 * that is additive.
 *
 * ---------------------------------------------------------------------------
 * State hooks
 * ---------------------------------------------------------------------------
 * Current step:   aria-current="step"   -- a real ARIA attribute, per contract rule 4, so the state
 *                                          is announced rather than only drawn.
 * Completed step: .kc-v2-stepper__step--complete
 *                                       -- there is NO ARIA attribute meaning "done", so a modifier
 *                                          class is correct here rather than an invented data-*.
 *                                          The visible check mark carries it for sighted users and
 *                                          .kc-v2-sr-only text carries it for everyone else.
 * Upcoming step:  no attribute, no class -- the default.
 */

.kc-v2-stepper {
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--kc-v2-space-2);
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--kc-v2-font-family);
}

/* Own box-sizing reset, per contract rule 3: no required wrapper root, so each container component
   normalises its own descendants. */
.kc-v2-stepper *,
.kc-v2-stepper *::before,
.kc-v2-stepper *::after {
  box-sizing: border-box;
}

/* `flex: 1 1 auto` plus the connector below is what makes the rail span the row. min-width keeps a
   long label from squeezing a neighbouring step to nothing before the whole list wraps. */
.kc-v2-stepper__step {
  display: flex;
  align-items: center;
  gap: var(--kc-v2-space-2);
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  /* Bare `li` markers are reset on the list, but Community's site.css also sets a text-indent on
     list items, which would offset the marker circle. */
  text-indent: 0;
  list-style: none;
}

/* The connector rail, drawn AFTER every step but the last. A pseudo-element rather than a real
   element so the markup stays one <li> per step -- a screen reader should hear four steps, not four
   steps and three decorative spans.

   `flex: 1 1 auto` on the rail and `flex: 0 0 auto` on the marker/label means the rail absorbs all
   the slack, so the steps sit at even intervals regardless of label length. */
.kc-v2-stepper__step:not(:last-child)::after {
  content: "";
  flex: 1 1 auto;
  min-width: var(--kc-v2-space-4);
  height: 2px;
  margin-inline-start: var(--kc-v2-space-2);
  background-color: var(--kc-v2-ink-300);
}

/* A completed step's trailing rail is filled, so the "how far along am I" read comes from the rail
   as well as the markers. */
.kc-v2-stepper__step--complete:not(:last-child)::after {
  background-color: var(--kc-v2-success-icon);
}

/* ---------------------------------------------------------------------------
 * The marker
 *
 * 28px, not the 24px minimum target size: this is not a target (nothing is activatable), and 28px is
 * what the Figma frame draws. Sized in px rather than em so the circle does not deform if a host
 * page changes the inherited font-size -- which Community's site.css does.
 * ------------------------------------------------------------------------- */
.kc-v2-stepper__marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: var(--kc-v2-radius-pill);
  border: 2px solid var(--kc-v2-ink-300);
  background-color: var(--kc-v2-white);
  /* ink-600, not ink-400: ink-400 is 2.92:1 on white and fails 4.5:1. The token file says so
     explicitly and this is exactly the kind of place that trap gets sprung. */
  color: var(--kc-v2-ink-600);
  font-size: var(--kc-v2-small-size);
  font-weight: 700;
  line-height: 1;
  /* Montserrat carries tnum, so the digits in a 1/2/3/4 sequence share a width and the circles do
     not jitter. */
  font-variant-numeric: tabular-nums;
}

.kc-v2-stepper__step[aria-current="step"] > .kc-v2-stepper__marker {
  border-color: var(--kc-v2-blue);
  background-color: var(--kc-v2-blue);
  color: var(--kc-v2-white);
}

.kc-v2-stepper__step--complete > .kc-v2-stepper__marker {
  border-color: var(--kc-v2-success-icon);
  background-color: var(--kc-v2-success-icon);
  color: var(--kc-v2-white);
}

/* ---------------------------------------------------------------------------
 * The label
 * ------------------------------------------------------------------------- */
.kc-v2-stepper__label {
  flex: 0 0 auto;
  min-width: 0;
  /* ink-600 clears 4.5:1 on both white and ink-100, and this component sits on the page ground
     (ink-100) on the Business License pages, not on a card. */
  color: var(--kc-v2-ink-600);
  font-size: var(--kc-v2-small-size);
  font-weight: 600;
  line-height: var(--kc-v2-small-line-height);
  letter-spacing: var(--kc-v2-small-letter-spacing);
}

.kc-v2-stepper__step[aria-current="step"] > .kc-v2-stepper__label {
  color: var(--kc-v2-blue);
  font-weight: 700;
}

.kc-v2-stepper__step--complete > .kc-v2-stepper__label {
  color: var(--kc-v2-success-text);
}

/* ---------------------------------------------------------------------------
 * Narrow viewports
 *
 * Four steps with labels do not fit at 375px. The labels are dropped and the markers stay, so the
 * "step 2 of 4" read survives -- and the CURRENT step keeps its label, because that is the one piece
 * of information the row exists to convey. Nothing is hidden from assistive technology: the labels
 * are still in the DOM and still read, they are only visually collapsed.
 * ------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .kc-v2-stepper {
    gap: var(--kc-v2-space-1);
  }

  .kc-v2-stepper__step:not([aria-current="step"]) > .kc-v2-stepper__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  .kc-v2-stepper__step:not(:last-child)::after {
    min-width: var(--kc-v2-space-2);
    margin-inline-start: var(--kc-v2-space-1);
  }
}

/* ---------------------------------------------------------------------------
 * Forced colors
 *
 * Background fills are dropped by the OS in forced-colors mode, so current/complete would become
 * indistinguishable from upcoming. Border style carries the distinction instead, which survives.
 * ------------------------------------------------------------------------- */
@media (forced-colors: active) {
  .kc-v2-stepper__marker {
    border-color: CanvasText;
    color: CanvasText;
  }

  .kc-v2-stepper__step[aria-current="step"] > .kc-v2-stepper__marker {
    border-width: 4px;
  }

  .kc-v2-stepper__step--complete > .kc-v2-stepper__marker {
    border-style: double;
  }

  .kc-v2-stepper__step:not(:last-child)::after {
    background-color: CanvasText;
    /* forced-colors also drops the fill distinction on the rail; height carries it. */
    height: 1px;
  }

  .kc-v2-stepper__step--complete:not(:last-child)::after {
    height: 3px;
  }
}

/* ---------------------------------------------------------------------------
 * Print
 *
 * A printed application is a record of what was submitted, so which step the browser happened to be
 * on when it was printed is noise. Dropped entirely -- the same call Annual and Quarterly make for
 * their screen-only step guidance.
 * ------------------------------------------------------------------------- */
@media print {
  .kc-v2-stepper {
    display: none;
  }
}

.kc-v2-stepper--spaced {
  margin: var(--kc-v2-space-4) 0 var(--kc-v2-space-5);
}
