@import "../variables/variables";
@import "../mixins/private/token-mixins";

$progress-stepper-min-width: 80px;
$progress-stepper-large-min-width: 120px;
/* Shortcut private variables */
$_progress-stepper-active-gradient: var(
        --progress-stepper-active-color,
        var(--color-background-information)
    )
    50%;
$_progress-stepper-upcoming-gradient: var(
        --progress-stepper-upcoming-color,
        var(--color-background-disabled)
    )
    50%;

.progress-stepper__items {
    align-items: flex-start;
    display: flex;
}

.progress-stepper__item {
    align-items: center;
    display: flex;
    flex-direction: column;
    width: 32px;
}

hr.progress-stepper__separator {
    @include background-color-token(
        progress-stepper-active-color,
        color-background-information
    );

    border: 0 none;
    border-radius: 2px;
    flex: 1;
    height: 4px;
    margin: 0;
    min-width: $progress-stepper-min-width;
    position: relative;
    top: 10px;
}

.progress-stepper__text {
    font-size: var(--font-size-default);
    justify-self: center;
    margin-top: 8px;
    text-align: center;
    width: $progress-stepper-min-width;
}

.progress-stepper__text h2,
.progress-stepper__text h3,
.progress-stepper__text h4,
.progress-stepper__text h5,
.progress-stepper__text h6 {
    @include color-token(progress-stepper-text-color, color-foreground-primary);

    font-size: var(--font-size-default);
    font-weight: normal;
}

.progress-stepper__items--upcoming .progress-stepper__text h2,
.progress-stepper__items--upcoming .progress-stepper__text h3,
.progress-stepper__items--upcoming .progress-stepper__text h4,
.progress-stepper__items--upcoming .progress-stepper__text h5,
.progress-stepper__items--upcoming .progress-stepper__text h6 {
    @include color-token(
        progress-stepper-text-light-color,
        color-foreground-secondary
    );
}

.progress-stepper__item[aria-current] .progress-stepper__text h2,
.progress-stepper__item[aria-current] .progress-stepper__text h3,
.progress-stepper__item[aria-current] .progress-stepper__text h4,
.progress-stepper__item[aria-current] .progress-stepper__text h5,
.progress-stepper__item[aria-current] .progress-stepper__text h6 {
    font-weight: bold;
}

.progress-stepper__item[aria-current]
    ~ .progress-stepper__item
    .progress-stepper__text
    h2,
.progress-stepper__item[aria-current]
    ~ .progress-stepper__item
    .progress-stepper__text
    h3,
.progress-stepper__item[aria-current]
    ~ .progress-stepper__item
    .progress-stepper__text
    h4,
.progress-stepper__item[aria-current]
    ~ .progress-stepper__item
    .progress-stepper__text
    h5,
.progress-stepper__item[aria-current]
    ~ .progress-stepper__item
    .progress-stepper__text
    h6 {
    @include color-token(
        progress-stepper-text-light-color,
        color-foreground-secondary
    );
}

.progress-stepper__text p {
    @include color-token(
        progress-stepper-text-light-color,
        color-foreground-secondary
    );
}

.progress-stepper__icon {
    height: 24px;
    margin: auto;
    width: 24px;
}

.progress-stepper__items--upcoming hr.progress-stepper__separator,
.progress-stepper__item[aria-current] ~ hr.progress-stepper__separator {
    @include background-color-token(
        progress-stepper-upcoming-color,
        color-background-disabled
    );

    background-image: none;
}

.progress-stepper__item[aria-current] + hr.progress-stepper__separator {
    background-image: linear-gradient(
        90deg,
        $_progress-stepper-active-gradient,
        $_progress-stepper-upcoming-gradient
    );
}

.progress-stepper__item--attention[aria-current]
    ~ hr.progress-stepper__separator {
    @include background-color-token(
        progress-stepper-upcoming-color,
        color-background-disabled
    );

    background-image: none;
}

.progress-stepper__text > * {
    margin: 0;
}

.progress-stepper {
    overflow: auto;
    padding: var(--spacing-200) 0;
}

.progress-stepper__item:first-child .progress-stepper__text {
    align-self: flex-start;
    margin-inline-start: var(--spacing-50);
    text-align: left;
}

.progress-stepper__item:last-child .progress-stepper__text {
    align-self: flex-end;
    margin-inline-end: var(--spacing-50);
    text-align: right;
}

.progress-stepper--vertical .progress-stepper__item {
    align-items: flex-start;
    flex-direction: row;
    height: 24px;
    width: auto;
}

.progress-stepper--vertical
    .progress-stepper__item[aria-current]
    + hr.progress-stepper__separator {
    background: linear-gradient(
        180deg,
        $_progress-stepper-active-gradient,
        $_progress-stepper-upcoming-gradient
    );
}

.progress-stepper--vertical
    .progress-stepper__item--attention[aria-current]
    ~ hr.progress-stepper__separator {
    @include background-color-token(
        progress-stepper-upcoming-color,
        color-background-disabled
    );

    background-image: none;
}

.progress-stepper--vertical .progress-stepper__items {
    display: block;
}

.progress-stepper--vertical .progress-stepper__item .progress-stepper__text {
    align-self: center;
    margin-inline-start: var(--spacing-200);
    margin-top: 0;
    text-align: left;
    white-space: nowrap;
    width: auto;
}

.progress-stepper--vertical .progress-stepper__icon {
    display: inline-block;
    height: 24px;
    margin: inherit;
    width: 24px;
}

.progress-stepper--vertical .progress-stepper__separator {
    display: inline-block;
    flex: inherit;
    height: 51px;
    margin-bottom: 12px;
    margin-left: 10px;
    margin-top: -4px;
    min-width: inherit;
    width: 4px;
}

[dir="rtl"] {
    .progress-stepper__item:first-child .progress-stepper__text {
        text-align: right;
    }

    /* stylelint-disable no-descending-specificity */
    .progress-stepper__item[aria-current] + hr.progress-stepper__separator {
        background-image: linear-gradient(
            90deg,
            $_progress-stepper-upcoming-gradient,
            $_progress-stepper-active-gradient
        );
    }

    .progress-stepper--vertical
        .progress-stepper__item[aria-current]
        + hr.progress-stepper__separator {
        background: linear-gradient(
            180deg,
            $_progress-stepper-active-gradient,
            $_progress-stepper-upcoming-gradient
        );
    }

    .progress-stepper--vertical
        .progress-stepper__items--current
        .progress-stepper__item[aria-current]
        ~ hr.progress-stepper__separator {
        @include background-color-token(
            progress-stepper-upcoming-color,
            color-background-disabled
        );

        background-image: none;
    }

    .progress-stepper__item:last-child .progress-stepper__text {
        text-align: left;
    }

    .progress-stepper--vertical
        .progress-stepper__item
        .progress-stepper__text {
        text-align: right;
    }

    .progress-stepper--vertical .progress-stepper__separator {
        margin-left: inherit;
        margin-right: 11px;
    }
}

@media (min-width: $_screen-size-SM) {
    hr.progress-stepper__separator {
        min-width: $progress-stepper-large-min-width;
    }

    .progress-stepper__text {
        width: $progress-stepper-large-min-width;
    }
}
