@layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
@layer cinder.components {
  /* ========================================
 * STEPS
 * Wizard step indicator with horizontal and vertical orientations.
 * Uses aria-current="step" for the active step; completed steps render
 * a checkmark icon. No role="progressbar" — steps are navigation, not metering.
 * ======================================== */

  .cinder-steps {
    display: block;
    container-type: inline-size;
    container-name: cinder-steps;
    /* Marker diameter — referenced by the horizontal connector's `top` offset so
     both values stay in sync if the size ever changes. */
    --_marker-size: 1.5rem;
  }

  /* A compact stepper answers to its own container name, so the stacked fallback at the end of this
     file, which queries `cinder-steps`, never matches it. */
  .cinder-steps[data-cinder-narrow-layout='compact'] {
    container-name: cinder-steps-compact;
    /* The drawn size of a narrow row's round target. A literal, not a control-height token: those
       rise to 44px on a coarse pointer, which here grows the hit area only. */
    --_compact-target-size: 2rem;
  }

  /* The current step's label under a compact row; drawn only below 32rem. */
  .cinder-steps__caption {
    display: none;
  }

  /* ----------------------------------------
 * List
 * ---------------------------------------- */

  .cinder-steps__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
  }

  .cinder-steps[data-cinder-orientation='horizontal'] .cinder-steps__list {
    flex-direction: row;
    align-items: flex-start;
  }

  .cinder-steps[data-cinder-orientation='vertical'] .cinder-steps__list {
    flex-direction: column;
    align-items: stretch;
  }

  /* ----------------------------------------
 * Item — horizontal layout
 * Each step is a centered column: marker on top, label/description centered
 * directly beneath it so the three read as one unit. The connector is painted
 * as a line running between this marker's center and the next marker's center
 * (absolutely positioned, behind the markers).
 * ---------------------------------------- */

  .cinder-steps[data-cinder-orientation='horizontal'] .cinder-steps__item {
    flex: 1 1 0;
    /* Equal-width columns even when labels differ in length, so every marker
     sits at the horizontal center of its share of the track. */
    min-width: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .cinder-steps[data-cinder-orientation='horizontal'] .cinder-steps__marker {
    /* Lift the marker above BOTH the connector line (z-index: 0) that passes
       behind it AND the focusable body (z-index: 1) whose box overlaps the
       marker via a negative block-start margin. The body must out-rank the
       connector so its focus ring paints above the line, but it must stay
       below the marker: the body paints LATER in flow and its :hover background
       is opaque (--cinder-surface-hover), so at equal z-index it would occlude
       the marker on hover. z-index: 2 keeps the marker on top in every state. */
    position: relative;
    /* cinder-z-index-local: marker paints above the overlapping body and connector. */
    z-index: 2;
  }

  .cinder-steps[data-cinder-orientation='horizontal'] .cinder-steps__connector {
    position: absolute;
    /* Vertically centered on the marker. Uses --_marker-size so this offset
     stays in sync if the marker diameter is ever changed. */
    top: calc(var(--_marker-size) / 2);
    height: 1px;
    /* Start at this marker's center (50%) and run to the next marker's center.
     This geometry is correct only when every flex item shares the same computed
     width (flex: 1 1 0 with no gap or min-width overrides). If variable-width
     steps are ever needed, revisit this calculation.
     The logical margin follows the inline start in either direction. */
    inset-inline: 0;
    margin-inline-start: 50%;
    width: 100%;
    z-index: 0;
  }

  .cinder-steps[data-cinder-orientation='horizontal'] .cinder-steps__body {
    text-align: center;
    align-items: center;
    max-width: 100%;
  }

  @container cinder-steps (width > 32rem) {
    .cinder-steps[data-cinder-orientation='horizontal'] .cinder-steps__body {
      /* Inset the text inside each column so the marker and connector track stays intact. */
      padding-inline: calc(var(--cinder-space-3) / 2);
    }
  }

  @container cinder-steps-compact (width > 32rem) {
    .cinder-steps[data-cinder-narrow-layout='compact'] .cinder-steps__body {
      padding-inline: calc(var(--cinder-space-3) / 2);
    }
  }

  /* Focus-state geometry for the interactive body in the WIDE horizontal layout.
   * The base reset stretches the focusable <a>/<button> to `inline-size: 100%`,
   * so its :focus-visible ring boxes the entire equal-width column around only
   * the centered label/description — a wide pill with the marker floating
   * detached above it and the connector cutting an empty band. Two coordinated
   * geometry changes make the ring frame the marker + label + description as one
   * centered step unit, with zero net content movement:
   *
   *   1. Shrink the focusable box to its centered content instead of the full
   *      column (`inline-size: auto; align-self: center`), so the ring is a
   *      content-width pill directly beneath the marker rather than a strip.
   *   2. Capture the marker into the box's vertical reach. The marker must stay a
   *      non-interactive sibling ABOVE the body in flow (steps.test.ts asserts
   *      `anchor.contains(marker) === false`), so instead of nesting it we raise
   *      the box's top edge up to the marker's top with a negative block-start
   *      margin, and add an equal block-start padding so the label/description
   *      stay exactly where they were. The body takes `z-index: 1` so its focus
   *      ring paints above the connector, while the marker takes `z-index: 2` so
   *      it stays above the body's overlapping box even when the body's :hover
   *      background is opaque. Net: the ring encloses marker + body as one unit,
   *      the connector (pinned to the marker center) now sits inside the ring's
   *      vertical span, and the visible content y/x position is invariant.
   *
   * The negative margin equals the marker diameter (the in-flow distance from the
   * box's current top to the marker's top); the added padding restores that plus
   * the body's existing space-2 top padding so content does not shift. */
  .cinder-steps[data-cinder-orientation='horizontal']
    .cinder-steps__interactive.cinder-steps__body {
    inline-size: auto;
    max-inline-size: 100%;
    align-self: center;
    margin-block-start: calc(-1 * var(--_marker-size));
    padding-block-start: calc(var(--_marker-size) + var(--cinder-space-2));
    /* Lift the focusable body above the connector line (z-index: 0) so its
       :focus-visible box-shadow ring paints ABOVE the line instead of being
       bisected by it. The marker sits one level higher (z-index: 2) so it is
       never occluded by the body's overlapping box — see the marker rule. */
    position: relative;
    z-index: 1;
  }

  /* ----------------------------------------
 * Item — vertical layout
 * Marker (top of column 1) | Body (column 2, spanning both rows)
 * Connector (below marker in column 1)
 * ---------------------------------------- */

  .cinder-steps[data-cinder-orientation='vertical'] .cinder-steps__item {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto 1fr;
    gap: 0 var(--cinder-space-3);
  }

  .cinder-steps[data-cinder-orientation='vertical'] .cinder-steps__marker {
    grid-column: 1;
    grid-row: 1;
  }

  .cinder-steps[data-cinder-orientation='vertical'] .cinder-steps__connector {
    grid-column: 1;
    grid-row: 2;
    justify-self: center;
    width: 1px;
    min-height: var(--cinder-space-6);
    align-self: stretch;
  }

  .cinder-steps[data-cinder-orientation='vertical'] .cinder-steps__body {
    grid-column: 2;
    grid-row: 1 / span 2;
    padding-block-start: 0;
    padding-bottom: var(--cinder-space-4);
  }

  /* ----------------------------------------
 * Marker — the step circle
 * ---------------------------------------- */

  .cinder-steps__marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--_marker-size);
    height: var(--_marker-size);
    border-radius: var(--cinder-radius-full);
    background: var(--cinder-surface-upcoming-marker);
    flex-shrink: 0;
  }

  [data-cinder-state='complete'] .cinder-steps__marker {
    background: var(--cinder-accent-solid);
    color: var(--cinder-accent-contrast);
  }

  [data-cinder-state='current'] .cinder-steps__marker {
    background: var(--cinder-surface);
    /* Ring uses --cinder-ring-color: the bright fill-accent (L 0.72) is only
       ~1.8:1 against the white marker surface, so the current-step indicator
       would be near-invisible in light mode. */
    box-shadow: 0 0 0 var(--cinder-ring-width) var(--cinder-ring-color);
    color: var(--cinder-accent-text);
  }

  @media (forced-colors: active) {
    [data-cinder-state='current'] .cinder-steps__marker {
      outline: var(--cinder-ring-width) solid ButtonText;
      outline-offset: var(--cinder-ring-width);
      box-shadow: none;
    }
  }

  [data-cinder-state='skipped'] .cinder-steps__marker {
    background: var(--cinder-surface);
    box-shadow: inset 0 0 0 1px var(--cinder-border-muted);
    color: var(--cinder-text-muted);
  }

  @media (forced-colors: active) {
    [data-cinder-state='skipped'] .cinder-steps__marker {
      outline: 1px solid ButtonText;
      box-shadow: none;
    }
  }

  [data-cinder-state='upcoming'] .cinder-steps__marker {
    color: var(--cinder-text-muted);
  }

  .cinder-steps__item[data-cinder-state='unknown'] > .cinder-steps__marker {
    background: transparent;
    color: var(--cinder-text-muted);
  }

  /* ----------------------------------------
 * Check icon and step index number
 * ---------------------------------------- */

  .cinder-steps__check {
    width: 0.875rem;
    height: 0.875rem;
  }

  .cinder-steps__index {
    font-size: var(--cinder-text-xs);
    font-weight: var(--cinder-font-semibold);
    line-height: 1;
  }

  /* ----------------------------------------
 * Body — label and description
 * ---------------------------------------- */

  .cinder-steps__body {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--cinder-space-1);
    padding-top: var(--cinder-space-2);
  }

  /* Inner wrapper rendered by the stepBody snippet — transparent to the parent
   flex layout so the label and description remain direct flex children. */
  .cinder-steps__body-content {
    display: contents;
  }

  /* ----------------------------------------
 * Interactive body — an <a>/<button> occupying the body cell. Resets native
 * chrome so both elements render identically to the static body, then layers
 * a focus ring. The element keeps .cinder-steps__body, so the body's flex
 * layout (position/display/gap) is reused with zero duplication.
 * ---------------------------------------- */

  .cinder-steps__interactive {
    appearance: none;
    border: 0;
    background: transparent;
    margin: 0;
    padding: 0;
    font: inherit;
    text-align: inherit;
    inline-size: 100%;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    border-radius: var(--cinder-radius-sm);
  }

  /* Restore body padding cleared by the reset above. Interactive steps must match
   static step spacing in both orientations. */
  .cinder-steps__interactive.cinder-steps__body {
    padding-top: var(--cinder-space-2);
  }

  .cinder-steps[data-cinder-orientation='vertical'] .cinder-steps__interactive.cinder-steps__body {
    padding-bottom: var(--cinder-space-4);
  }

  @media (hover: hover) {
    .cinder-steps__interactive:hover {
      background: var(--cinder-surface-hover);
    }
  }

  .cinder-steps__interactive:focus-visible {
    outline: var(--cinder-ring-width) solid transparent;
    box-shadow: var(--_cinder-focus-ring-shadow);
  }

  @media (forced-colors: active) {
    .cinder-steps__interactive:focus-visible {
      outline: var(--cinder-ring-width) solid ButtonText;
      outline-offset: 3px;
    }
  }

  .cinder-steps__label {
    font-size: var(--cinder-text-sm);
    font-weight: var(--cinder-font-normal);
    color: var(--cinder-text-default);
    line-height: var(--cinder-leading-tight);
  }

  [data-cinder-state='current'] .cinder-steps__label {
    font-weight: var(--cinder-font-semibold);
  }

  [data-cinder-state='skipped'] .cinder-steps__label,
  [data-cinder-state='upcoming'] .cinder-steps__label {
    color: var(--cinder-text-muted);
  }

  .cinder-steps__description {
    font-size: var(--cinder-text-xs);
    color: var(--cinder-text-muted);
    line-height: var(--cinder-leading-normal);
  }

  /* ----------------------------------------
 * Connector — the line between steps
 * ---------------------------------------- */

  .cinder-steps__connector {
    /* border-muted reads clearly in dark mode where plain --cinder-border is
     near-invisible against --cinder-surface. */
    background: var(--cinder-border-muted);
  }

  .cinder-steps__connector[data-cinder-state='complete'] {
    background: var(--cinder-accent-solid);
  }

  /* ----------------------------------------
 * Visually-hidden text for completed and skipped steps
 * ---------------------------------------- */

  .cinder-steps__sr-only,
  .cinder-steps__sr-only-separator {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
  }

  /* ----------------------------------------
 * Checklist variant
 * Drawn as a grouped list is drawn (COR-2489): the heading and "N of M done" sit above the rows
 * as a Section's heading and action do, with no band and no rule, and the rows are one rounded
 * surface that carries tone, not a border, with separators that start at the text. Each row has a
 * 24px marker, the label and description, and the action at the row's end. Steps complete in any
 * order, so the marker says which are done and which is next: a green check, an accent number, or
 * a neutral number.
 * ---------------------------------------- */

  .cinder-steps[data-cinder-variant='checklist'] {
    min-inline-size: 0;
  }

  .cinder-steps__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--cinder-space-4);
    margin-block-end: var(--cinder-space-3);
  }

  .cinder-steps__heading {
    margin: 0;
    font-size: var(--cinder-text-lg);
    font-weight: var(--cinder-font-semibold);
    line-height: var(--cinder-leading-tight);
    color: var(--cinder-text-default);
  }

  .cinder-steps__progress {
    flex: none;
    font-size: var(--cinder-text-sm);
    color: var(--cinder-text-subtle);
    font-variant-numeric: tabular-nums;
  }

  /* The rows are a grouped list's group: one rounded surface in the raised tone, no border. */
  .cinder-steps[data-cinder-variant='checklist'] .cinder-steps__list {
    flex-direction: column;
    align-items: stretch;
    position: relative;
    overflow: hidden;
    border-radius: var(--cinder-radius-surface);
    background: var(--cinder-surface-raised);
  }

  /* The page hairline, on an overlay that takes no layout in either theme. */
  .cinder-steps[data-cinder-variant='checklist'] .cinder-steps__list::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    border: var(--cinder-border-width) solid var(--_cinder-page-edge);
  }

  /* A row is not filled; its separator is a line under the text that starts where the label does,
   * inset past the marker, as a grouped list row's separator is inset past its leading slot. */
  .cinder-steps[data-cinder-variant='checklist'] .cinder-steps__item {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--cinder-space-3);
    padding-block: var(--cinder-space-3);
    padding-inline: var(--cinder-space-4) var(--cinder-space-3);
  }

  .cinder-steps[data-cinder-variant='checklist'] .cinder-steps__item:not(:last-child)::after {
    content: '';
    position: absolute;
    inset-block-end: 0;
    border-block-end: 1px solid var(--cinder-border-faint);
    margin-inline-start: calc(var(--cinder-space-4) + var(--_marker-size) + var(--cinder-space-3));
    inset-inline: 0;
  }

  .cinder-steps[data-cinder-variant='checklist'] .cinder-steps__body {
    flex: 1;
    min-inline-size: 0;
    padding: 0;
    gap: 0;
  }

  .cinder-steps[data-cinder-variant='checklist'] .cinder-steps__interactive.cinder-steps__body {
    padding: 0;
    inline-size: auto;
  }

  .cinder-steps[data-cinder-variant='checklist'] .cinder-steps__label {
    font-size: var(--cinder-text-base);
    font-weight: var(--cinder-font-semibold);
    line-height: var(--cinder-leading-normal);
    color: var(--cinder-text-default);
  }

  .cinder-steps[data-cinder-variant='checklist']
    [data-cinder-state='complete']
    .cinder-steps__label {
    color: var(--cinder-text-subtle);
  }

  .cinder-steps[data-cinder-variant='checklist'] .cinder-steps__description {
    color: var(--cinder-text-subtle);
  }

  .cinder-steps[data-cinder-variant='checklist']
    [data-cinder-state='complete']
    .cinder-steps__marker {
    background: var(--cinder-status-success-background);
    color: var(--cinder-status-success-text);
  }

  .cinder-steps[data-cinder-variant='checklist']
    [data-cinder-state='current']
    .cinder-steps__marker {
    background: var(--cinder-accent-solid);
    box-shadow: none;
    color: var(--cinder-accent-contrast);
  }

  /* Every open step is a numbered circle that reads as one (owner, 2026-11-19: the upcoming numbers
     floated with no circle on the raised rows): an upcoming marker keeps its ground and draws its
     edge with the control border, which holds 3:1 against the raised surface in both themes. */
  .cinder-steps[data-cinder-variant='checklist']
    [data-cinder-state='upcoming']
    .cinder-steps__marker {
    box-shadow: inset 0 0 0 1px var(--cinder-border-control);
  }

  .cinder-steps[data-cinder-variant='checklist'] .cinder-steps__index {
    font-weight: var(--cinder-font-bold);
  }

  /* The action sits at the row's end and never shrinks; on a narrow container it drops under
   * the text and starts where the text does. */
  .cinder-steps__action {
    display: flex;
    flex: none;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--cinder-space-2);
  }

  @container cinder-steps (max-width: 28rem) {
    .cinder-steps[data-cinder-variant='checklist'] .cinder-steps__item {
      flex-wrap: wrap;
    }

    /* The actions take a line of their own under the text, as a wrapping row from the text's
       leading edge, each button at its own width (COR-2329: buttons the width of the row read as
       page-wide pills). */
    .cinder-steps[data-cinder-variant='checklist'] .cinder-steps__action {
      flex-basis: 100%;
      flex-flow: row wrap;
      justify-content: flex-start;
      padding-inline-start: calc(var(--_marker-size) + var(--cinder-space-3));
    }

    /* A quiet action that leads the wrapped row draws no face at rest, so its words are what the
       eye lines up: it is pulled back by its own inline padding and its 1px transparent border, so
       its text starts on the text edge above it rather than 13px inside it (COR-2489). An outlined
       or filled action keeps its face on the edge. Only a checklist draws actions, so the rule
       names the action row alone and no variant above the Button. */
    .cinder-steps__action
      > .cinder-button:first-child:is(
        .button-variant-ghost,
        .button-variant-ghost-accent,
        .button-variant-ghost-danger
      ):not([data-cinder-icon-only]) {
      margin-inline-start: calc(-1 * (var(--_cinder-steps-action-padding) + 1px));
    }
  }

  /* The inline padding of the Button that leads a checklist action row, by its size, for the
     pull-back above. */
  .cinder-steps__action > .cinder-button {
    --_cinder-steps-action-padding: var(--cinder-button-padding-x-sm);
  }

  .cinder-steps__action > .cinder-button.button-size-extra-small {
    --_cinder-steps-action-padding: var(--cinder-button-padding-x-xs);
  }

  .cinder-steps__action > .cinder-button.button-size-medium {
    --_cinder-steps-action-padding: var(--cinder-button-padding-x-md);
  }

  .cinder-steps__action > .cinder-button.button-size-large {
    --_cinder-steps-action-padding: var(--cinder-button-padding-x-lg);
  }

  /* ----------------------------------------
 * Status variant
 * Progress by step: no card, no numbers. A green check for what is done, a spinner for what is
 * running, a hollow circle for what is waiting, and a dashed ring for unknown outcomes.
 * ---------------------------------------- */

  .cinder-steps[data-cinder-variant='status'] {
    --_marker-size: 1rem;
  }

  .cinder-steps[data-cinder-variant='status'] .cinder-steps__list {
    flex-direction: column;
    align-items: stretch;
    gap: var(--cinder-space-2);
  }

  .cinder-steps[data-cinder-variant='status'] .cinder-steps__item {
    display: flex;
    align-items: center;
    gap: var(--cinder-space-2-5);
  }

  .cinder-steps[data-cinder-variant='status'] .cinder-steps__marker {
    background: transparent;
    box-shadow: none;
  }

  .cinder-steps[data-cinder-variant='status'] [data-cinder-state='complete'] .cinder-steps__marker {
    color: var(--cinder-status-success-text);
  }

  .cinder-steps[data-cinder-variant='status'] [data-cinder-state='current'] .cinder-steps__marker {
    color: var(--cinder-accent-text);
  }

  .cinder-steps[data-cinder-variant='status'] .cinder-steps__body {
    padding: 0;
    gap: 0;
  }

  .cinder-steps[data-cinder-variant='status'] .cinder-steps__label {
    font-size: var(--cinder-text-base);
    line-height: var(--cinder-leading-normal);
    font-weight: var(--cinder-font-normal);
    color: var(--cinder-text-subtle);
  }

  .cinder-steps[data-cinder-variant='status'] [data-cinder-state='complete'] .cinder-steps__label {
    color: var(--cinder-text-muted);
  }

  .cinder-steps[data-cinder-variant='status'] [data-cinder-state='current'] .cinder-steps__label {
    color: var(--cinder-text-default);
    font-weight: var(--cinder-font-normal);
  }

  .cinder-steps__spinner {
    inline-size: 0.875rem;
    block-size: 0.875rem;
    box-sizing: border-box;
    border: 2px solid currentColor;
    border-inline-end-color: transparent;
    border-radius: var(--cinder-radius-full);
    animation: cinder-steps-spin var(--cinder-duration-spin) linear infinite;
  }

  .cinder-steps__pending {
    inline-size: 0.875rem;
    block-size: 0.875rem;
    box-sizing: border-box;
    border: 1.5px solid currentColor;
    border-radius: var(--cinder-radius-full);
  }

  .cinder-steps__unknown {
    inline-size: 0.875rem;
    block-size: 0.875rem;
    box-sizing: border-box;
    border: 1.5px dashed currentColor;
    border-radius: var(--cinder-radius-full);
  }

  @keyframes cinder-steps-spin {
    to {
      transform: rotate(360deg);
    }
  }

  @media (forced-colors: active) {
    .cinder-steps[data-cinder-variant='checklist'] .cinder-steps__list {
      border: 1px solid CanvasText;
    }

    .cinder-steps[data-cinder-variant='checklist']
      .cinder-steps__item:not([data-cinder-state='unknown'])
      > .cinder-steps__marker {
      border: 1px solid CanvasText;
    }
  }

  @container cinder-steps (max-width: 32rem) {
    .cinder-steps[data-cinder-orientation='horizontal'] .cinder-steps__list {
      flex-direction: column;
      align-items: stretch;
    }

    .cinder-steps[data-cinder-orientation='horizontal'] .cinder-steps__item {
      flex: none;
      /* Re-establish the grid the wide layout replaced with a centered flex
       column. Narrow steps read like the vertical orientation: marker in
       column 1, body in column 2, connector running down column 1. */
      display: grid;
      /* Reset align-items from the wide flex-column rule (where it centers
       the flex children horizontally). On a grid container align-items
       would vertically center grid items; stretch is the correct default. */
      align-items: stretch;
      grid-template-columns: auto 1fr;
      grid-template-rows: auto 1fr;
      gap: 0 var(--cinder-space-3);
    }

    .cinder-steps[data-cinder-orientation='horizontal'] .cinder-steps__marker {
      /* Drop the wide layout's stacking context; the marker is back in flow. */
      position: static;
      z-index: auto;
    }

    .cinder-steps[data-cinder-orientation='horizontal'] .cinder-steps__connector {
      /* Undo the wide layout's absolute, behind-the-marker connector and return
       to an in-flow vertical line beneath the marker. */
      position: static;
      top: auto;
      inset-inline: auto;
      z-index: auto;
      grid-column: 1;
      grid-row: 2;
      justify-self: center;
      width: 1px;
      height: auto;
      min-height: var(--cinder-space-6);
      margin-inline-start: 0;
      align-self: stretch;
    }

    .cinder-steps[data-cinder-orientation='horizontal'] .cinder-steps__body {
      /* Left-aligned beside the marker, undoing the wide layout's centering. */
      text-align: start;
      align-items: stretch;
      max-width: none;
      grid-column: 2;
      grid-row: 1 / span 2;
      padding-block-start: 0;
      padding-bottom: var(--cinder-space-4);
    }

    /* Undo the wide layout's marker-capture geometry for the interactive body.
     * That rule (content-width centering + negative block-start margin to pull
     * the focus box up over the marker) only makes sense in the centered flex
     * column. In the narrow grid the marker sits in column 1 and the body in
     * column 2 beside it, so the box must fill its grid cell and stay in flow —
     * otherwise the higher-specificity wide rule's margin/align-self/inline-size
     * would leak in and misplace the body. Reset the block-start padding too so
     * the label content starts on the marker row, matching the vertical layout. */
    .cinder-steps[data-cinder-orientation='horizontal']
      .cinder-steps__interactive.cinder-steps__body {
      inline-size: 100%;
      max-inline-size: none;
      align-self: stretch;
      margin-block-start: 0;
      padding-block-start: 0;
    }
  }

  /* ----------------------------------------
   * Compact narrow layout
   * The wide row stays: markers and connectors in a line, and only the current step's label, on a
   * line of its own under them, where it wraps and is never cut short. Every other label and every
   * description is hidden from the eye and stays in its step's accessible name. The step's link or
   * button becomes a round target centred on the marker, so a tap on the marker follows it. The
   * target takes no layout space: each step stays as tall as its marker. It is drawn between 1.5rem
   * and 2rem across, as its column allows, and the list's padding and the target's inset keep the
   * focus ring inside the component.
   * ---------------------------------------- */
  @container cinder-steps-compact (max-width: 32rem) {
    .cinder-steps[data-cinder-narrow-layout='compact'] .cinder-steps__list {
      /* Above: the target's overhang and its ring. Below: the wide layout's marker-to-label gap. */
      padding-block: calc(
          (var(--_compact-target-size) - var(--_marker-size)) / 2 + var(--cinder-ring-offset) +
            var(--cinder-ring-width)
        )
        var(--cinder-space-2);
    }

    .cinder-steps[data-cinder-narrow-layout='compact'] .cinder-steps__item {
      block-size: var(--_marker-size);
    }

    .cinder-steps[data-cinder-narrow-layout='compact'] .cinder-steps__marker {
      /* The target beneath takes the tap. */
      pointer-events: none;
    }

    .cinder-steps[data-cinder-narrow-layout='compact'] .cinder-steps__item > .cinder-steps__body {
      position: absolute;
      inset-block-start: 50%;
      inset-inline: 0;
      translate: 0 -50%;
      margin: 0 auto;
      padding: 0;
      inline-size: clamp(1.5rem, calc(100% - var(--cinder-space-2)), var(--_compact-target-size));
      max-inline-size: none;
      aspect-ratio: 1;
      min-block-size: 0;
      border-radius: var(--cinder-radius-full);
    }

    /* A coarse pointer reaches 44px through a pseudo-element that takes no layout space, never
       wider than the step's own column, so neighbouring steps do not overlap. */
    @media (any-pointer: coarse) {
      .cinder-steps[data-cinder-narrow-layout='compact'] .cinder-steps__item {
        container-type: inline-size;
      }

      .cinder-steps[data-cinder-narrow-layout='compact']
        .cinder-steps__item
        > .cinder-steps__interactive::after {
        content: '';
        position: absolute;
        inset-block: min(0px, calc((100% - var(--cinder-touch-target-min)) / 2));
        inset-inline: max(
          min(0px, calc((100% - var(--cinder-touch-target-min)) / 2)),
          min(0px, calc((100% - 100cqi) / 2))
        );
      }
    }

    .cinder-steps[data-cinder-narrow-layout='compact'] .cinder-steps__item .cinder-steps__label,
    .cinder-steps[data-cinder-narrow-layout='compact']
      .cinder-steps__item
      .cinder-steps__description {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
    }

    .cinder-steps[data-cinder-narrow-layout='compact'] .cinder-steps__caption {
      display: block;
      text-align: center;
      text-wrap: balance;
      font-size: var(--cinder-text-sm);
      font-weight: var(--cinder-font-semibold);
      line-height: var(--cinder-leading-snug);
      color: var(--cinder-text-default);
      overflow-wrap: anywhere;
    }
  }
}
