/* Progress meter (only used in core for setup panels)
   ========================================================================== */

/**
 * Progress meter lists.
 *
 * Utilizes CSS counters to increment the progress steps, more info -
 * https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Lists_and_Counters/Using_CSS_counters
 *
 * Example HTML:
 *
 * <aside class="progress-meter">
 *     <ol>
 *         <li class="active"><strong>Item 1</strong></li>
 *         <li>Item 2</li>
 *         <li>Item 3</li>
 *     </ol>
 * </aside>
 */

.progress-meter {
    ol {
        margin-bottom: 0;
        padding: 0;
        list-style: none;
        text-align: center;
        counter-reset: step; // set up name of increment on parent
    }

    li {
        @include gradient-linear($color-gradient-from, $color-gradient-to);

        display: inline-block;
        position: relative;
        margin: 0 1em 1em 0;
        padding: 1em 1em 1em 4em;
        border-top: 1px solid $color-border-light;
        border-right: 1px solid $color-border-extra-light;
        border-bottom: 1px solid $color-border-dark;
        border-left: 1px solid $color-border-extra-light;

        // highlight the currently active step

        &.active {
            @include gradient-linear($color-accent-gradient-from, $color-accent-gradient-to);

            border: 1px solid $color-accent-gradient-to;
            border-bottom-color: darken($color-accent-gradient-to, 6%);
        }

        // numerical indication of step

        &::before {
            content: counter(step); // write out value of the increment
            position: absolute;
            z-index: 2;
            top: 0.4375em; // 7px / 16px
            left: 0.6875em; // 12px / 16px
            width: 1.375em; // 22px / 16px
            padding: 0.25em; // 4px / 16px
            border: 1px solid $color-background;
            border-radius: 50%;
            background-color: $color-border;
            font-size: 1.230769230769231rem; // 16px / 13px
            font-weight: bold;
            text-align: center;
            counter-increment: step; // increment the step on each occurance of this (pseudo) element
        }

        // arrows at right-hand side of boxes

        &::after {
            @include hide-text;

            content: "\2192";
            display: block;
            position: absolute;
            z-index: 2;
            top: -1px;
            left: 100%;
            width: 0;
            height: 0;
            border: 0 solid transparent;
            border-width: 1.5em 0 1.5em 0.75em;
            border-left-color: $color-border;
            font-size: 16px;
        }
    }

    strong {
        font-weight: normal;
    }
}

@include dark-mode {
    .progress-meter li {
        border-top: 1px solid $dark-color-border-light;
        border-right: 1px solid $dark-color-border-extra-light;
        border-bottom: 1px solid $dark-color-border-dark;
        border-left: 1px solid $dark-color-border-extra-light;
        color: $dark-color-text-inverse;

        // numerical indication of step

        &::before {
            border: 1px solid $dark-color-background;
            background: $dark-color-border;
            color: $dark-color-text;
        }

        // arrows at right-hand side of boxes

        &::after {
            border-left-color: $dark-color-border;
        }
    }
}

/**
 * Swap margin/padding/numerical/arrow positions in RTL languages.
 */

[dir="rtl"] .progress-meter {
    ol {
        padding: 0;
    }

    li {
        margin: 0 0 1em 1em;
        padding: 1em 4em 1em 1em;

        &::before {
            right: 0.6875em; // 12px / 16px
            left: auto;
        }

        &::after {
            content: "\2190";
            right: 100%;
            left: auto;
            border: 0 solid transparent;
            border-width: 1.5em 0.75em 1.5em 0;
            border-right-color: $color-border;
        }
    }
}

@include dark-mode {
    [dir="rtl"] .progress-meter li::after {
        border-right-color: $dark-color-border;
    }
}
