/*
 * stepper.css — where a person is in a task of steps: completing a job.
 *
 * <ol class="app-stepper" role="list" aria-label="Fortschritt">
 *   <li class="app-step" data-state="done | current | todo" aria-current="step (current only)">
 *     <span class="app-step-marker" aria-hidden="true">[icon: check | the number]</span>
 *     <span class="app-step-label">Material</span>
 *     <span class="app-step-state">erledigt</span>
 *   </li>
 * </ol>
 *
 * The steps share the width, joined by a line. A done step's state is read out but not shown
 * (the check says it); the current step is aria-current. Below a region of 560 only the current
 * step keeps its label, at its own width: the markers still show where in the task it is.
 */
@layer components {
    .app-stepper {
        display: flex;
        align-items: center;
        gap: var(--app-space-steps);
        min-inline-size: 0;
    }

    .app-step {
        display: flex;
        flex: 1 1 0;
        align-items: center;
        gap: var(--app-space-steps);
        min-inline-size: 0;
        color: var(--app-color-text-muted);
        font-size: var(--app-text-body-size);
        line-height: var(--app-text-body-leading);
    }

    .app-step:last-child {
        flex: none;
    }

    .app-step:not(:last-child)::after {
        content: "";
        flex: 1 1 0;
        min-inline-size: var(--app-space-steps);
        block-size: var(--app-border-width-strong);
        border-radius: var(--app-radius-round);
        background: var(--app-color-line);
    }

    .app-step[data-state="done"]::after {
        background: var(--app-color-accent);
    }

    .app-step-marker {
        display: inline-flex;
        flex: none;
        align-items: center;
        justify-content: center;
        inline-size: var(--app-marker-size);
        block-size: var(--app-marker-size);
        border-radius: var(--app-radius-round);
        box-shadow: inset 0 0 0 var(--app-border-width) var(--app-color-line-control);
        font-size: var(--app-text-count-size);
        font-variant-numeric: tabular-nums;
        font-weight: var(--app-text-chip-weight);
        line-height: var(--app-text-help-leading);
    }

    .app-step[data-state="done"] .app-step-marker {
        background: var(--app-color-accent-soft);
        color: var(--app-color-accent-text);
        box-shadow: none;
    }

    .app-step[data-state="current"] .app-step-marker {
        background: var(--app-color-accent);
        color: var(--app-color-text-on-accent);
        box-shadow: none;
    }

    .app-step-label {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-step[data-state="current"] .app-step-label {
        color: var(--app-color-text);
        font-weight: var(--app-text-strong-weight);
    }

    /* Read out, not shown. */
    .app-step-state {
        position: absolute;
        inline-size: var(--app-border-width);
        block-size: var(--app-border-width);
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .app-step-state:empty {
        display: none;
    }

    @container app-region (width < 560px) {
        .app-step:not([data-state="current"]) .app-step-label {
            display: none;
        }

        /* The others never get narrower than their marker and a short line. */
        .app-step:not([data-state="current"]) {
            flex: 0 1 auto;
            min-inline-size: auto;
        }

        .app-step:not([data-state="current"], :last-child) {
            flex: 1 1 0;
        }

        /* The one label shown starts at its own width; the lines share what is left, and it
           shortens only when nothing else can. */
        .app-step[data-state="current"]:not(:last-child) {
            flex: 1 1 auto;
        }

        .app-step[data-state="current"]:last-child {
            flex: 0 1 auto;
        }
    }

    /* Forced colours (a Windows contrast theme): shadows and backgrounds are gone, so frames
       are outlines and a chosen state is the system highlight. */
    @media (forced-colors: active) {
        .app-step-marker {
            outline: var(--app-border-width) solid var(--app-color-forced-line);
            outline-offset: calc(-1 * var(--app-border-width));
        }
        .app-step[data-state="current"] .app-step-marker {
            forced-color-adjust: none;
            background: var(--app-color-forced-current);
            color: var(--app-color-forced-current-text);
        }
    }
}
