@use '../variables'as *;
@use '../mixins'as *;

$list-item-hover-background                    : $component-background-shade;
$list-item-hover-background-dark               : $component-background-shade-active;
$list-item-highlight-background                : $component-background-shade-active;
$list-item-highlight-background-dark           : $component-background-shade-dark-active;
$list-item-highlight-background-accent         : $component-background-accent-shade;
$list-item-highlight-background-accent-dark    : $component-background-accent-dark-shade;
$list-item-highlight-background-secondary      : $component-background-secondary-shade;
$list-item-highlight-background-secondary-dark : $component-background-secondary-dark-shade;
$list-item-highlight-hover-background          : $component-background-shade-active;
$list-item-highlight-hover-background-dark     : $component-background-shade-dark-active;
$list-item-even-background                     : $component-background-shade;
$list-item-even-background-dark                : $component-background-shade-dark;
$list-item-bullet-shade-background             : $component-background-shade-active;
$list-item-bullet-shade-background-dark        : $component-background-shade-dark-active;
$list-item-bullet-size                         : 8px;
$list-item-color                               : $component-color-default;
$list-item-color-dark                          : $component-color-default-dark;
$list-item-active-color-accent                 : $component-background-accent;
$list-item-active-color-secondary              : $component-background-secondary;
$list-item-active-color-accent-dark            : $component-background-accent-dark;
$list-item-active-color-secondary-dark         : $component-background-secondary-dark;
$list-item-inactive-color                      : $component-color-muted;
$list-item-inactive-color-dark                 : $component-color-muted-dark;
$list-transition-time                          : $animation-duration-short;
$list-item-font-weight-bold                    : $text-weight-semi-bold;

@mixin list {
    ul.#{$prefix}-list {
        list-style: none;
        margin    : 0;
        padding   : 0;

        &>li {
            display: block;
            @include component-padding;
            color: $list-item-color;
        }
    }
}

@mixin list-stripped {
    ul.#{$prefix}-list {
        &.#{$prefix}-stripped {
            &>li:nth-child(even) {
                background-color: $list-item-even-background;
            }
        }
    }
}

@mixin list-small {
    ul.#{$prefix}-list {
        &.#{$prefix}-small {
            &>li {
                @include component-padding(small);
            }
        }
    }
}

@mixin list-hover {
    ul.#{$prefix}-list {
        &.#{$prefix}-hover {
            &>li {
                &:hover {
                    background-color: $list-item-hover-background;
                }
            }
        }
    }
}


@mixin list-inline {
    ul.#{$prefix}-list {
        &.#{$prefix}-inline {
            &>li {
                display: inline-block;
            }
        }
    }
}

@mixin list-bullet {
    ul.#{$prefix}-list {
        &.#{$prefix}-bullet {
            &>li {
                padding-left: 2rem;
                position    : relative;

                &:before {
                    content      : "";
                    position     : absolute;
                    border       : 1px solid $list-item-color;
                    border-radius: 50%;
                    width        : $list-item-bullet-size;
                    height       : $list-item-bullet-size;
                    top          : calc(1rem - 2px);
                    left         : 0.5rem;
                }
            }
        }
    }
}

@mixin list-bullet-shade {
    ul.#{$prefix}-list {
        &.#{$prefix}-bullet-shade {
            &>li {
                padding-left: 2rem;
                position    : relative;

                &:before {
                    content         : "";
                    position        : absolute;
                    border          : 1px solid transparent;
                    background-color: $list-item-bullet-shade-background;
                    border-radius   : 50%;
                    width           : $list-item-bullet-size;
                    height          : $list-item-bullet-size;
                    top             : calc(1rem - 2px);
                    left            : 0.5rem;
                }
            }
        }
    }
}

@mixin list-interactive {
    ul.#{$prefix}-list.#{$prefix}-interactive {
        &>li {
            padding: 0px;

            a {
                display: block;
                @include component-padding;
                @include link-decoration($list-item-color);
                @include list-element-interaction($list-item-hover-background);

                &.#{$prefix}-active {
                    background-color: $list-item-highlight-background;
                    font-weight     : $list-item-font-weight-bold;
                }
            }

            &.#{$prefix}-active {
                background-color: $list-item-highlight-background;
                font-weight     : $list-item-font-weight-bold;
            }
        }
    }
}

@mixin list-interactive-theme {
    ul.#{$prefix}-list.#{$prefix}-interactive.#{$prefix}-accent {
        &>li {

            a {
                &.#{$prefix}-active {
                    background-color: $list-item-highlight-background-accent;
                }
            }

            &.#{$prefix}-active {
                background-color: $list-item-highlight-background-accent;
            }
        }
    }

    ul.#{$prefix}-list.#{$prefix}-interactive.#{$prefix}-secondary {
        &>li {

            a {
                &.#{$prefix}-active {
                    background-color: $list-item-highlight-background-secondary;
                }
            }

            &.#{$prefix}-active {
                background-color: $list-item-highlight-background-secondary;
            }
        }
    }
}

@mixin list-interactive-dark {
    @include mode-dark {
        ul.#{$prefix}-list.#{$prefix}-interactive {
            &>li {
                a {
                    color: $list-item-color-dark;
                    @include list-element-interaction($list-item-hover-background-dark);

                    &.#{$prefix}-active {
                        background-color: $list-item-highlight-background-dark;
                    }
                }

                &.#{$prefix}-active {
                    background-color: $list-item-highlight-background-dark;
                }
            }
        }
    }
}

@mixin list-interactive-theme-dark {
    @include mode-dark {
        ul.#{$prefix}-list.#{$prefix}-interactive.#{$prefix}-accent {
            &>li {
                a {
                    &.#{$prefix}-active {
                        background-color: $list-item-highlight-background-accent-dark;
                    }
                }

                &.#{$prefix}-active {
                    background-color: $list-item-highlight-background-accent-dark;
                }
            }
        }

        ul.#{$prefix}-list.#{$prefix}-interactive.#{$prefix}-secondary {
            &>li {

                a {
                    &.#{$prefix}-active {
                        background-color: $list-item-highlight-background-secondary-dark;
                    }
                }

                &.#{$prefix}-active {
                    background-color: $list-item-highlight-background-secondary-dark;
                }
            }
        }
    }
}

@mixin list-interactive-line {
    ul.#{$prefix}-list {
        &.#{$prefix}-interactive-line {
            &>li {
                padding: 0px;

                a {
                    position: relative;
                    display : block;
                    @include component-padding;
                    @include link-decoration($list-item-color);
                    @include list-element-interaction($list-item-hover-background);

                    &:before {
                        content           : "";
                        position          : absolute;
                        width             : 2px;
                        border-radius     : 4px;
                        background-color  : transparent;
                        height            : 100%;
                        left              : 0;
                        top               : 50%;
                        transform         : translateY(-50%) scale(1, 0.4);
                        //transition      : transform $list-transition-time ease-out;
                    }

                    &:focus {
                        font-weight: $text-weight-semi-bold;

                        &:before {
                            background-color: $list-item-inactive-color;
                        }
                    }

                    &.#{$prefix}-active {
                        font-weight: $list-item-font-weight-bold;

                        &:before {
                            background-color: $list-item-color;
                        }

                        &:hover {
                            &:before {
                                transform: translateY(-50%) scale(1, 0.6);
                            }
                        }
                    }
                }

                &.#{$prefix}-active {
                    a {
                        font-weight: $list-item-font-weight-bold;

                        &:before {
                            background-color: $list-item-color;
                        }

                        &:hover {
                            &:before {
                                transform: translateY(-50%) scale(1, 0.6);
                            }
                        }
                    }
                }
            }

            &.#{$prefix}-reverse {
                &>li {
                    a {
                        &:before {
                            left : 100%;
                            right: 0;
                        }
                    }
                }
            }
        }
    }
}

@mixin list-interactive-line-accent {
    ul.#{$prefix}-list.#{$prefix}-interactive-line.#{$prefix}-accent {

        &>li.#{$prefix}-active {
            a {
                &:before {
                    background-color: $list-item-active-color-accent !important;
                }
            }
        }

        &>li>a.#{$prefix}-active {
            &:before {
                background-color: $list-item-active-color-accent !important;
            }
        }
    }
}

@mixin list-interactive-accent-line-dark {
    @include mode-dark {
        ul.#{$prefix}-list.#{$prefix}-interactive-line.#{$prefix}-accent {

            &>li.#{$prefix}-active {
                a {
                    &:before {
                        background-color: $list-item-active-color-accent !important;
                    }
                }
            }

            &>li>a.#{$prefix}-active {
                &:before {
                    background-color: $list-item-active-color-accent !important;
                }
            }
        }
    }

}

@mixin list-interactive-secondary-line {
    ul.#{$prefix}-list.#{$prefix}-interactive-line.#{$prefix}-secondary {

        &>li.#{$prefix}-active {
            a {
                &:before {
                    background-color: $list-item-active-color-secondary !important;
                }
            }
        }

        &>li>a.#{$prefix}-active {
            &:before {
                background-color: $list-item-active-color-secondary !important;
            }
        }
    }
}

@mixin list-interactive-secondary-line-dark {
    @include mode-dark {
        ul.#{$prefix}-list.#{$prefix}-interactive-line.#{$prefix}-secondary {

            &>li.#{$prefix}-active {
                a {
                    &:before {
                        background-color: $list-item-active-color-secondary !important;
                    }
                }
            }

            &>li>a.#{$prefix}-active {
                &:before {
                    background-color: $list-item-active-color-secondary !important;
                }
            }
        }
    }
}

@mixin list-dark {
    @include mode-dark {
        ul.#{$prefix}-list {
            &>li {
                color: $list-item-color-dark;
            }
        }
    }
}

@mixin list-dark-bullet {
    @include mode-dark {
        ul.#{$prefix}-list {
            &.#{$prefix}-bullet {
                &>li {
                    &:before {
                        border-color: $list-item-color-dark;
                    }
                }
            }
        }
    }
}

@mixin list-dark-bullet-shade {
    @include mode-dark {
        ul.#{$prefix}-list {
            &.#{$prefix}-bullet-shade {
                &>li {
                    &:before {
                        background-color: $list-item-bullet-shade-background-dark;
                    }
                }
            }
        }
    }
}

@mixin list-dark-hover {
    @include mode-dark {
        ul.#{$prefix}-list {
            &.#{$prefix}-hover {
                &>li {
                    &:hover {
                        background-color: $list-item-hover-background-dark;
                    }
                }
            }
        }
    }
}

@mixin list-dark-interactive-line {
    @include mode-dark {
        ul.#{$prefix}-list.#{$prefix}-interactive-line {
            &>li {
                &>a {
                    color: $list-item-color-dark;
                    @include list-element-interaction($list-item-hover-background);

                    &:focus {
                        &:before {
                            background-color: $list-item-inactive-color-dark;
                        }
                    }

                    &.#{$prefix}-active {
                        &:before {
                            background-color: $list-item-color-dark;
                        }
                    }
                }

                &.#{$prefix}-active {
                    a {
                        &:before {
                            background-color: $list-item-color-dark;
                        }
                    }
                }
            }
        }
    }
}

@mixin list-dark-stripped {
    @include mode-dark {
        ul.#{$prefix}-list {
            &.#{$prefix}-stripped {
                &>li:nth-child(even) {
                    background-color: $list-item-even-background-dark;
                }
            }
        }
    }
}

@mixin list-print {
    @include mode-print {
        ul.#{$prefix}-list {
            &>li {
                color: $component-print-color;
            }
        }
    }
}


@mixin list-print-stripped {
    @include mode-print {
        ul.#{$prefix}-list {
            &.#{$prefix}-stripped {
                &>li {
                    background-color: $component-print-background;
                }
            }
        }
    }
}

@mixin list-print-bullet {
    @include mode-print {
        ul.#{$prefix}-list {
            &.#{$prefix}-bullet {
                &>li {
                    &:before {
                        border-color: $component-print-color;
                    }
                }
            }
        }
    }
}

@mixin list-print-bullet-shade {
    @include mode-print {
        ul.#{$prefix}-list {
            &.#{$prefix}-bullet-shade {
                &>li {
                    &:before {
                        border-color    : $component-print-color;
                        background-color: transparent;
                    }
                }
            }
        }
    }
}

@mixin list-interactive-line-print {
    @include mode-print {
        ul.#{$prefix}-list {

            &.#{$prefix}-interactive-line,
            &.#{$prefix}-interactive-line.#{$prefix}-accent,
            &.#{$prefix}-interactive-line.#{$prefix}-secondary {
                &>li {
                    &.#{$prefix}-active {
                        a {
                            &:before {
                                background-color: $component-print-color;
                            }
                        }
                    }
                }

                &>li>a.#{$prefix}-active {
                    &:before {
                        background-color: $component-print-color;
                    }
                }
            }
        }
    }
}

@mixin list-interactive-print {
    @include mode-print {
        ul.#{$prefix}-list {

            &.#{$prefix}-interactive,
            &.#{$prefix}-interactive.#{$prefix}-accent,
            &.#{$prefix}-interactive.#{$prefix}-secondary {

                &>li {
                    &>a {
                        &.#{$prefix}-active {
                            background-color: $list-item-highlight-background;
                        }
                    }

                    &.#{$prefix}-active {
                        background-color: $list-item-highlight-background;
                    }
                }
            }
        }
    }
}

@mixin list-no-transitions {
    body:not(.#{$prefix}-no-transitions) {
        .#{$prefix}-list {
            &.#{$prefix}-interactive {
                .#{$prefix}-active {
                    a {
                        &:before {
                            transition: transform $list-transition-time ease-out;
                        }
                    }
                }

                a.#{$prefix}-active {
                    &:before {
                        transition: transform $list-transition-time ease-out;
                    }
                }
            }
        }
    }
}

@mixin definitions($options: ()) {
    @include list();

    @if(not-option-disabled($options, 'dark')) {
        @include list-dark();
    }

    @if(not-option-disabled($options, 'print')) {
        @include list-print();
    }

    @if(not-option-disabled($options, 'interactive')) {
        @include list-interactive();

        @if(not-option-disabled($options, 'theme')) {
            @include list-interactive-theme();
        }

        @if(not-option-disabled($options, 'dark')) {
            @include list-interactive-dark();

            @if(not-option-disabled($options, 'theme')) {
                @include list-interactive-theme-dark();
            }
        }

        @if(not-option-disabled($options, 'print')) {
            @include list-interactive-print();
        }
    }

    @if(not-option-disabled($options, 'interactive-line')) {
        @include list-interactive-line();

        @if(not-option-disabled($options, 'theme')) {
            @include list-interactive-line-accent();
            @include list-interactive-secondary-line();

        }

        @if(not-option-disabled($options, 'dark')) {
            @include list-dark-interactive-line();

            @if(not-option-disabled($options, 'theme')) {
                @include list-interactive-accent-line-dark();
                @include list-interactive-secondary-line-dark();
            }
        }

        @if(not-option-disabled($options, 'print')) {
            @include list-interactive-line-print()
        }
    }

    @if(not-option-disabled($options, 'bullet')) {
        @include list-bullet();

        @if(not-option-disabled($options, 'dark')) {
            @include list-dark-bullet();
        }

        @if(not-option-disabled($options, 'print')) {
            @include list-print-bullet();
        }
    }

    @if(not-option-disabled($options, 'bullet-shade')) {
        @include list-bullet-shade();

        @if(not-option-disabled($options, 'dark')) {
            @include list-dark-bullet-shade();
        }

        @if(not-option-disabled($options, 'print')) {
            @include list-print-bullet-shade();
        }
    }

    @if(not-option-disabled($options, 'hover')) {
        @include list-hover();

        @if(not-option-disabled($options, 'dark')) {
            @include list-dark-hover();
        }
    }

    @if(not-option-disabled($options, 'small')) {
        @include list-small();
    }

    @if(not-option-disabled($options, 'inline')) {
        @include list-inline();
    }

    @if(not-option-disabled($options, 'stripped')) {
        @include list-stripped();

        @if(not-option-disabled($options, 'dark')) {
            @include list-dark-stripped();
        }

        @if(not-option-disabled($options, 'print')) {
            @include list-print-stripped();
        }
    }




}