/*!
 * # Fomantic-UI - Step
 * https://github.com/fomantic/Fomantic-UI/
 *
 *
 * Released under the MIT license
 * https://opensource.org/licenses/MIT
 *
 */

/*******************************
             Step
*******************************/

/* --------------
   Load Theme
--------------- */

@type: "element";
@element: "step";

@import (multiple) "../../theme.config";

@notCircular: if(@variationStepCircular, e(":not(.circular)"));
@notVertical: if(@variationStepVertical, e(":not(.vertical)"));
@notUnstackable: if(@variationStepUnstackable, e(":not(.unstackable)"));

/*******************************
            Plural
*******************************/

.ui.steps@{notCircular} {
    display: inline-flex;
    flex-direction: row;
    align-items: stretch;
    margin: @stepMargin;
    background: @stepsBackground;
    box-shadow: @stepsBoxShadow;
    line-height: @lineHeight;
    border-radius: @stepsBorderRadius;
    border: @stepsBorder;
}
.ui.steps@{notUnstackable} {
    flex-wrap: wrap;
}

/* First Steps */
.ui.steps:first-child {
    margin-top: 0;
}

/* Last Steps */
.ui.steps:last-child {
    margin-bottom: 0;
}

/*******************************
           Singular
*******************************/

.ui.steps@{notCircular} .step {
    position: relative;
    display: flex;
    flex: 1 0 auto;
    flex-flow: row wrap;
    vertical-align: middle;
    align-items: center;
    justify-content: @justifyContent;
    margin: @verticalMargin @horizontalMargin;
    padding: @verticalPadding @horizontalPadding;
    background: @background;
    color: @textColor;
    box-shadow: @boxShadow;
    border-radius: @borderRadius;
    border: @border;
    border-right: @divider;
    transition: @transition;
}

/* Arrow */
.ui.steps@{notCircular} .step::after {
    display: none;
    position: absolute;
    z-index: 2;
    content: "";
    top: @arrowTopOffset;
    right: @arrowRightOffset;
    background-color: @arrowBackgroundColor;
    width: @arrowSize;
    height: @arrowSize;
    border-style: solid;
    border-color: @borderColor;
    border-width: @arrowBorderWidth;
    transition: @transition;
    transform: translateY(-50%) translateX(50%) rotate(-45deg);
}

/* First Step */
.ui.steps@{notCircular} .step:first-child {
    padding-left: @horizontalPadding;
    border-radius: @stepsBorderRadius 0 0 @stepsBorderRadius;
}

/* Last Step */
.ui.steps@{notCircular} .step:last-child {
    border-radius: 0 @stepsBorderRadius @stepsBorderRadius 0;
    border-right: none;
    margin-right: 0;
}

/* Only Step */
.ui.steps@{notCircular} .step:only-child {
    border-radius: @stepsBorderRadius;
}

/*******************************
            Content
*******************************/

/* Title */
.ui.steps .step .title {
    font-family: @titleFontFamily;
    font-size: @titleFontSize;
    font-weight: @titleFontWeight;
    line-height: @lineHeight;
}
.ui.steps .step > .title {
    width: 100%;
}

/* Description */
.ui.steps .step .description {
    font-weight: @descriptionFontWeight;
    font-size: @descriptionFontSize;
    color: @descriptionColor;
    line-height: @lineHeight;
}
.ui.steps .step > .description {
    width: 100%;
}
.ui.steps .step .title ~ .description {
    margin-top: @descriptionDistance;
}

/* Icon */
.ui.steps .step > i.icon {
    line-height: 1;
    font-size: @iconSize;
    margin: 0 @iconDistance 0 0;
}
.ui.steps .step > i.icon,
.ui.steps .step > i.icon ~ .content {
    display: block;
    flex: 0 1 auto;
    align-self: @iconAlign;
}

/* Horizontal Icon */
.ui.steps@{notVertical} .step > i.icon {
    width: auto;
}

/* Link */
.ui.steps .link.step,
.ui.steps a.step {
    cursor: pointer;
}

/*******************************
            Types
*******************************/

& when (@variationStepCircular) {
    .ui.circular.steps {
        border: 0;
        border-radius: 0;
        box-shadow: none;

        &@{notVertical} {
            background: transparent;
            border: 0;
            border-radius: 0;
            box-shadow: none;
            position: relative;
            display: flex;
            padding: @circularStepsMargin;
            margin: @circularStepsPadding;

            & .step {
                background: @circularStepColor;
                cursor: default;
                height: @circularStepBorderWidth;
                display: flex;
                flex-wrap: wrap;
                align-items: center;
                flex: 1;
                position: relative;
                margin-left: @circularStepRingSize;

                &::before {
                    left: -@circularStepRingSize;
                }
                &::after {
                    left: @circularStepIconDistance;
                }

                &.completed {
                    background: @circularStepCompletedBackground;
                }
                &.completed::after {
                    left: @circularStepCompletedIconDistance;
                }
                &:last-child {
                    flex: 0;
                }
                & .content {
                    margin-top: @circularStepContentMarginTop;
                    padding: @circularStepContentPadding;
                    &.center.aligned {
                        margin-top: @circularStepContentCenterAlignedMarginTop;
                        & .title {
                            padding: @circularStepContentPadding;
                            margin-left: @circularStepContentCenterAlignedMarginLeft;
                            background: @circularStepContentCenterAlignedBackground;
                        }
                    }
                    &.bottom.aligned {
                        margin-top: @circularStepContentBottomAlignedMarginTop;
                    }
                    &:not(.aligned) .title + .description {
                        margin-top: @circularStepContentDescriptionDistance;
                    }
                }
            }

            & a.step::before,
            & a.step::after,
            & a.step .content,
            & .step.link .content,
            & .step.link::before,
            & .step.link::after {
                cursor: pointer;
            }
        }

        & .step {
            color: inherit;

            &::before {
                content: "";
                border-radius: 50%;
                border: @circularStepBorder;
                height: @circularStepRingSize;
                width: @circularStepRingSize;
                line-height: @circularStepRingSize;
                position: absolute;
            }
            &::after {
                content: "";
                display: block;
                position: absolute;
                border-radius: 50%;
                background: @circularStepColor;
                height: @circularStepIconSize;
                width: @circularStepIconSize;
            }
            &.active {
                &::before {
                    border-color: @circularStepActiveColor;
                }

                &::after {
                    background: @circularStepActiveColor;
                }
                & .title {
                    color: @circularStepActiveColor;
                }
            }
            &.completed {
                &::before {
                    background: @circularStepCompletedBackground;
                    border-color: @circularStepCompletedBackground;
                }
                &::after {
                    background: transparent;
                    content: "\e800";
                    font-family: Step;
                    color: @circularStepCompletedColor;
                    height: auto;
                    line-height: @circularStepCompletedIconLineHeight;
                }
            }
        }
    }
    @supports selector(:has(.f)) {
        .ui.circular.steps@{notVertical} .step:last-child:has(.content) {
            flex: 1;
        }
        .ui.circular.steps@{notVertical} .step:last-child:has(.center.aligned.content) {
            background: none;
        }
    }
}

& when (@variationStepOrdered) {
    /* --------------
         Ordered
    --------------- */

    .ui.ordered.steps {
        counter-reset: ordered;
    }
    .ui.ordered.steps .step::before {
        text-align: center;
        content: counter(ordered);
        align-self: @iconAlign;
        counter-increment: ordered;
        font-family: @orderedFontFamily;
        font-weight: @orderedFontWeight;
    }
    .ui.ordered.steps@{notCircular} .step::before {
        display: block;
        position: static;
        font-size: @iconSize;
        margin-right: @iconDistance;
    }

    & when (@variationStepCircular) {
        .ui.circular.ordered.steps .step {
            &::before {
                line-height: calc(@circularStepRingSize - @circularStepBorderWidth);
            }
            &.completed::before {
                content: "";
            }
            &::after {
                background: transparent;
            }
            &.active::before {
                color: @circularStepActiveColor;
            }
        }
    }

    .ui.ordered.steps .step > * {
        display: block;
        align-self: @iconAlign;
    }
}

& when (@variationStepVertical) {
    /* --------------
        Vertical
    --------------- */

    .ui.vertical.steps@{notCircular} {
        display: inline-flex;
        flex-direction: column;
        overflow: visible;
    }
    .ui.vertical.steps@{notCircular} .step {
        justify-content: flex-start;
        border-radius: @borderRadius;
        padding: @verticalPadding @horizontalPadding;
        border-right: none;
        border-bottom: @verticalDivider;
    }
    .ui.vertical.steps@{notCircular} .step:first-child {
        padding: @verticalPadding @horizontalPadding;
        border-radius: @stepsBorderRadius @stepsBorderRadius 0 0;
    }
    .ui.vertical.steps@{notCircular} .step:last-child {
        border-bottom: none;
        border-radius: 0 0 @stepsBorderRadius @stepsBorderRadius;
    }
    .ui.vertical.steps@{notCircular} .step:only-child {
        border-radius: @stepsBorderRadius;
    }

    /* Arrow */
    .ui.vertical.steps@{notCircular} .step::after {
        top: @verticalArrowTopOffset;
        right: @verticalArrowRightOffset;
        border-width: @verticalArrowBorderWidth;
        display: @verticalArrowDisplay;
    }
    .ui.right.vertical.steps@{notCircular} .step::after {
        border-width: @verticalLeftArrowBorderWidth;
        left: @verticalLeftArrowLeftOffset;
        right: @verticalLeftArrowRightOffset;
        transform: translateY(-50%) translateX(-50%) rotate(-45deg);
    }

    .ui.vertical.steps@{notCircular} .active.step::after {
        display: @verticalActiveArrowDisplay;
    }
    .ui.vertical.steps@{notCircular} .step:last-child::after {
        display: @verticalLastArrowDisplay;
    }
    .ui.vertical.steps@{notCircular} .active.step:last-child::after {
        display: @verticalActiveLastArrowDisplay;
    }

    /* Circular Step */
    & when (@variationStepCircular) {
        .ui.circular.vertical.steps {
            display: inline-flex;
            flex-flow: column wrap;
            align-items: flex-start;

            & .step {
                position: relative;
                width: 100%;

                &::before {
                    left: 0;
                    top: 0;
                }

                &::after {
                    left: @verticalCircularStepIconDistance;
                    top: @verticalCircularStepIconDistance;
                }

                & .content {
                    padding-left: @verticalCircularStepContentPadding;
                }

                &:not(:last-child) {
                    padding-bottom: @verticalCircularStepPadding;

                    & .content::before {
                        content: "";
                        position: absolute;
                        border-left: @circularStepBorder;
                        top: @circularStepRingSize;
                        bottom: 0;
                        left: @verticalCircularStepLineDistance;
                    }
                }

                &.completed .content::before {
                    border-color: @circularStepCompletedBackground;
                }

                &.completed::before {
                    background: @circularStepCompletedBackground;
                    border-color: @circularStepCompletedBackground;
                }
                &.completed::after {
                    top: @verticalCircularStepCompletedIconDistance;
                }
            }
        }
    }
}

/* ---------------
    Responsive
---------------- */

/* Mobile (Default) */
@media only screen and (max-width: (@largestMobileScreen)) {
    .ui.steps@{notUnstackable}@{notCircular} {
        display: inline-flex;
        overflow: visible;
        flex-direction: column;
    }
    .ui.steps@{notUnstackable}@{notCircular} .step {
        width: 100% !important;
        flex-direction: column;
        border-radius: @borderRadius;
        padding: @verticalPadding @horizontalPadding;
        border-right: none;
        border-bottom: @stepsBorder;
    }
    .ui.steps@{notUnstackable}@{notCircular} .step:first-child {
        padding: @verticalPadding @horizontalPadding;
        border-radius: @stepsBorderRadius @stepsBorderRadius 0 0;
    }
    .ui.steps@{notUnstackable}@{notCircular} .step:last-child {
        border-radius: 0 0 @stepsBorderRadius @stepsBorderRadius;
        border-bottom: none;
    }

    /* Arrow */
    .ui.steps@{notUnstackable}@{notCircular} .step::after {
        top: unset;
        bottom: -@arrowSize;
        right: 50%;
        transform: translateY(-50%) translateX(50%) rotate(45deg);
    }
    & when (@variationStepVertical) {
        .ui.vertical.steps@{notCircular} .active.step:last-child::after {
            display: none;
        }
    }

    /* Content */
    .ui.steps@{notUnstackable}@{notCircular} .step .content {
        text-align: center;
    }

    /* Icon */
    .ui.steps@{notUnstackable}@{notCircular} .step > i.icon,
    .ui.ordered.steps@{notUnstackable}@{notCircular} .step::before {
        margin: 0 0 @mobileIconDistance 0;
    }
}

/*******************************
             States
*******************************/

/* Link Hover */
.ui.steps@{notCircular} .link.step:hover::after,
.ui.steps@{notCircular} .link.step:hover,
.ui.steps@{notCircular} a.step:hover::after,
.ui.steps@{notCircular} a.step:hover {
    background: @hoverBackground;
    color: @hoverColor;
}

/* Link Down */
.ui.steps@{notCircular} .link.step:active::after,
.ui.steps@{notCircular} .link.step:active,
.ui.steps@{notCircular} a.step:active::after,
.ui.steps@{notCircular} a.step:active {
    background: @downBackground;
    color: @downColor;
}

/* Active */
.ui.steps@{notCircular} .step.active {
    cursor: auto;
    background: @activeBackground;
}
.ui.steps@{notCircular} .step.active::after {
    background: @activeBackground;
}
.ui.steps@{notCircular} .step.active .title {
    color: @activeColor;
}
.ui.ordered.steps .step.active::before,
.ui.steps .active.step i.icon {
    color: @activeIconColor;
}

/* Active Arrow */
.ui.steps@{notCircular} .step::after {
    display: @arrowDisplay;
}
.ui.steps@{notCircular} .active.step::after {
    display: @activeArrowDisplay;
}
.ui.steps@{notCircular} .step:last-child::after {
    display: @lastArrowDisplay;
}
.ui.steps@{notCircular} .active.step:last-child::after {
    display: @activeLastArrowDisplay;
}

/* Active Hover */
.ui.steps@{notCircular} .link.active.step:hover::after,
.ui.steps@{notCircular} .link.active.step:hover,
.ui.steps@{notCircular} a.active.step:hover::after,
.ui.steps@{notCircular} a.active.step:hover {
    cursor: pointer;
    background: @activeHoverBackground;
    color: @activeHoverColor;
}

/* Completed */
.ui.steps .step.completed > i.icon::before,
.ui.ordered.steps .step.completed::before {
    color: @completedColor;
}

& when (@variationStepDisabled) {
    /* Disabled */
    .ui.steps@{notCircular} .disabled.step {
        cursor: auto;
        background: @disabledBackground;
        pointer-events: none;
    }
    .ui.steps@{notCircular} .disabled.step,
    .ui.steps@{notCircular} .disabled.step .title,
    .ui.steps@{notCircular} .disabled.step .description {
        color: @disabledColor;
    }
    .ui.steps@{notCircular} .disabled.step::after {
        background: @disabledBackground;
    }
    & when (@variationStepCircular) {
        .ui.circular.steps .disabled.step {
            cursor: auto;
            opacity: @circularStepDisabledItemOpacity;
            pointer-events: none;

            &::before,
            &::after {
                cursor: auto;
            }
        }
    }
}

/*******************************
           Variations
*******************************/

& when (@variationStepStackable) {
    /* --------------
       Stackable
    --------------- */

    /* Tablet Or Below */
    @media only screen and (max-width: @largestTabletScreen) {
        .ui[class*="tablet stackable"].steps@{notCircular} {
            display: inline-flex;
            overflow: visible;
            flex-direction: column;
        }

        /* Steps */
        .ui[class*="tablet stackable"].steps@{notCircular} .step {
            flex-direction: column;
            border-radius: @borderRadius;
            padding: @verticalPadding @horizontalPadding;
            border-right: none;
            border-bottom: @stepsBorder;
        }
        .ui[class*="tablet stackable"].steps@{notCircular} .step:first-child {
            padding: @verticalPadding @horizontalPadding;
            border-radius: @stepsBorderRadius @stepsBorderRadius 0 0;
        }
        .ui[class*="tablet stackable"].steps@{notCircular} .step:last-child {
            border-radius: 0 0 @stepsBorderRadius @stepsBorderRadius;
            border-bottom: none;
        }

        /* Arrow */
        .ui[class*="tablet stackable"].steps@{notCircular} .step::after {
            top: unset;
            bottom: -@arrowSize;
            right: 50%;
            transform: translateY(-50%) translateX(50%) rotate(45deg);
        }

        /* Content */
        .ui[class*="tablet stackable"].steps@{notCircular} .step .content {
            text-align: center;
        }

        /* Icon */
        .ui[class*="tablet stackable"].steps .step > i.icon,
        .ui[class*="tablet stackable"].ordered.steps .step::before {
            margin: 0 0 @mobileIconDistance 0;
        }
    }
}

& when (@variationStepFluid) {
    /* --------------
          Fluid
    --------------- */

    /* Fluid */
    .ui.fluid.steps {
        display: flex;
        width: 100%;
    }
}

& when (@variationStepAttached) {
    /* --------------
        Attached
    --------------- */

    /* Top */
    .ui.attached.steps@{notCircular} {
        width: @attachedWidth !important;
        margin: 0 @attachedHorizontalOffset @attachedVerticalOffset;
        max-width: @attachedWidth;
        border-radius: @stepsBorderRadius @stepsBorderRadius 0 0;
    }
    .ui.attached.steps@{notCircular} .step:first-child {
        border-radius: @stepsBorderRadius 0 0 0;
    }
    .ui.attached.steps@{notCircular} .step:last-child {
        border-radius: 0 @stepsBorderRadius 0 0;
    }

    /* Bottom */
    .ui.bottom.attached.steps@{notCircular} {
        margin: @attachedVerticalOffset @attachedHorizontalOffset 0;
        border-radius: 0 0 @stepsBorderRadius @stepsBorderRadius;
    }
    .ui.bottom.attached.steps@{notCircular} .step:first-child {
        border-radius: 0 0 0 @stepsBorderRadius;
    }
    .ui.bottom.attached.steps@{notCircular} .step:last-child {
        border-radius: 0 0 @stepsBorderRadius 0;
    }
}

& when (@variationStepEqualWidth) {
    /* -------------------
        Evenly Divided
    -------------------- */

    .ui.one.steps,
    .ui.two.steps,
    .ui.three.steps,
    .ui.four.steps,
    .ui.five.steps,
    .ui.six.steps,
    .ui.seven.steps,
    .ui.eight.steps {
        width: 100%;
    }
    .ui.one.steps > .step,
    .ui.two.steps > .step,
    .ui.three.steps > .step,
    .ui.four.steps > .step,
    .ui.five.steps > .step,
    .ui.six.steps > .step,
    .ui.seven.steps > .step,
    .ui.eight.steps > .step {
        flex-wrap: nowrap;
    }
    .ui.one.steps > .step {
        width: 100%;
    }
    .ui.two.steps > .step {
        width: 50%;
    }
    .ui.three.steps > .step {
        width: 33.333%;
    }
    .ui.four.steps > .step {
        width: 25%;
    }
    .ui.five.steps > .step {
        width: 20%;
    }
    .ui.six.steps > .step {
        width: 16.666%;
    }
    .ui.seven.steps > .step {
        width: 14.285%;
    }
    .ui.eight.steps > .step {
        width: 12.5%;
    }
}

/* -------------------
       Sizes
-------------------- */

.ui.steps .step,
.ui.step {
    font-size: @medium;
}
& when not (@variationStepSizes = false) {
    each(@variationStepSizes, {
        @s: @@value;
        .ui.@{value}.steps .step,
        .ui.@{value}.step {
            font-size: @s;
        }
        & when (@variationStepCircular) {
            .ui.@{value}.circular.steps@{notVertical} {
                margin: @s 0;
                padding: @s 0;
            }
        }
    });
}

& when (@variationStepInverted) {
    /* --------------
        Inverted
    --------------- */

    .ui.inverted.steps@{notCircular} {
        border: 1px solid @solidWhiteBorderColor;
    }

    .ui.inverted.steps@{notCircular} .step {
        color: @invertedTextColor;
        background: @black;
        border-color: @solidWhiteBorderColor;
    }

    .ui.inverted.steps@{notCircular} .step::after {
        background-color: @black;
        border-color: @solidWhiteBorderColor;
    }

    .ui.inverted.steps .step .description {
        color: @invertedTextColor;
    }

    /* Active */
    .ui.inverted.steps@{notCircular} .step.active,
    .ui.inverted.steps@{notCircular} .step.active::after {
        background: @invertedActiveBackground;
    }
    .ui.inverted.ordered.steps@{notCircular} .step.active::before,
    .ui.inverted.steps@{notCircular} .active.step i.icon {
        color: @invertedSelectedTextColor;
    }

    & when (@variationStepDisabled) {
        /* Disabled */
        .ui.inverted.steps@{notCircular} .disabled.step,
        .ui.inverted.steps@{notCircular} .disabled.step::after {
            background: @invertedDisabledBackground;
        }
        .ui.inverted.steps@{notCircular} .disabled.step,
        .ui.inverted.steps@{notCircular} .disabled.step .title,
        .ui.inverted.steps@{notCircular} .disabled.step .description {
            color: @invertedDisabledTextColor;
        }
    }

    /* Link Hover */
    .ui.inverted.steps@{notCircular} .link.step:hover::after,
    .ui.inverted.steps@{notCircular} .link.step:hover,
    .ui.inverted.steps@{notCircular} a.step:hover::after,
    .ui.inverted.steps@{notCircular} a.step:hover {
        background: @invertedHoverBackground;
        color: @invertedHoveredTextColor;
    }

    /* Link Down */
    .ui.inverted.steps@{notCircular} .link.step:active::after,
    .ui.inverted.steps@{notCircular} .link.step:active,
    .ui.inverted.steps@{notCircular} a.step:active::after,
    .ui.inverted.steps@{notCircular} a.step:active {
        background: @invertedActiveHoverBackground;
        color: @invertedPressedTextColor;
    }
    & when (@variationStepCircular) {
        /* Circular Step */
        .ui.inverted.circular.steps {
            & .step .content {
                color: @invertedTextColor;
            }

            &@{notVertical} {
                & .step:not(.completed) {
                    background: @invertedTextColor;
                }
                & .step:not(.active, .completed)::before {
                    border-color: @invertedTextColor;
                }
                & .step .center.aligned.content .title {
                    background: @invertedCircularStepContentCenterAlignedBackground;
                }
            }
            &:not(.ordered) .step:not(.active, .completed)::after {
                background: @invertedTextColor;
            }

            & when (@variationStepVertical) {
                &.vertical {
                    & .step:not(.active, .completed)::before {
                        border-color: @invertedTextColor;
                    }
                    & .step:not(.completed) .content::before {
                        background: @invertedTextColor;
                    }
                }
            }
        }
    }
}

& when (@variationStepCircular) and not (@variationStepColors = false) {
    each(@variationStepColors, {
        @variation: @value;
        @color: @colors[@@variation][color];

        .ui.ui.circular.steps .step.@{variation} {
            &::before {
                border-color: @color;
            }
            &::after {
                background: @color;
            }
        }
        .ui.ui.@{variation}.circular.steps .step, .ui.ui.ui.circular.steps .step.@{variation} {
            &.active::before {
                border-color: @color;
            }
            &.active::after {
                background: @color;
            }
            &.completed::before {
                background: @color;
                border-color: @color;
            }
        }
        .ui.ui.@{variation}.circular.steps@{notVertical} .step, .ui.ui.ui.circular.steps@{notVertical} .step.@{variation} {
            &.completed {
                background: @color;
            }
        }
        .ui.ui.circular.steps@{notVertical} .step.@{variation} {
            background: @color;
        }
        .ui.ui.@{variation}.circular.steps .step, .ui.ui.ui.circular.steps .step.@{variation} {
            &.active .content .title {
                color: @color;
            }
        }
        & when (@variationStepVertical) {
            .ui.ui.vertical.circular.steps .step.completed.@{variation} .content::before {
                border-color: @color;
            }
            .ui.ui.@{variation}.vertical.circular.steps .step, .ui.ui.vertical.circular.steps .step.@{variation} {
                &.completed .content::before {
                    border-color: @color;
                }
            }
        }

        & when (@variationStepOrdered) {
            .ui.ui.@{variation}.circular.ordered.steps .step, .ui.ui.circular.ordered.steps .step.@{variation} {
                &::after {
                    background: transparent;
                }
                &.active::before {
                    color: @color;
                }
            }
        }
    });
}

// stylelint-disable no-invalid-position-at-import-rule
@import (multiple, optional) "../../overrides.less";
