// Name:            List
// Description:     Styles for lists
//
// Component:       `ui-list`
//
// Modifiers:       `ui-list-divider`
//                  `ui-list-striped`
//                  `ui-list-bullet`
//                  `ui-list-large`
//
// ========================================================================


// Variables
// ========================================================================

@list-margin-top:                               @global-small-margin;

@list-nested-padding-left:                      @global-gutter;

@list-divider-margin-top:                       @global-small-margin;
@list-divider-border-width:                     @global-border-width;
@list-divider-border:                           @global-border;

@list-striped-padding-vertical:                 @global-small-margin;
@list-striped-padding-horizontal:               @global-small-margin;
@list-striped-background:                       @global-muted-background;

@list-bullet-width:                             (@global-line-height * 1em);
@list-bullet-height:                            @list-bullet-width;
@list-bullet-margin-right:                      @global-small-margin;
@list-bullet-icon-color:                        @global-color;

@list-large-margin-top:                         @global-margin;
@list-large-divider-margin-top:                 @global-margin;
@list-large-striped-padding-vertical:           @global-margin;
@list-large-striped-padding-horizontal:         @global-small-margin;

@internal-list-bullet-image:                    "../../images/backgrounds/list-bullet.svg";


/* ========================================================================
   Component: List
 ========================================================================== */

.ui-list {
    padding: 0;
    list-style: none;
}

/*
 * Micro clearfix
 */

.ui-list > li::before,
.ui-list > li::after {
    content: "";
    display: table;
}

.ui-list > li::after { clear: both; }

/*
 * Remove margin from the last-child
 */

.ui-list > li > :last-child { margin-bottom: 0; }

/*
 * Nested lists
 */

.ui-list ul {
    margin: 0;
    padding-left: @list-nested-padding-left;
    list-style: none;
}

/*
 * Style
 */

.ui-list > li:nth-child(n+2),
.ui-list > li > ul { margin-top: @list-margin-top; }


/* Style modifiers
 ========================================================================== */

/*
 * Divider
 */

.ui-list-divider > li:nth-child(n+2) {
    margin-top: @list-divider-margin-top;
    padding-top: @list-divider-margin-top;
    border-top: @list-divider-border-width solid @list-divider-border;
    .hook-list-divider;
}

/*
 * Striped
 */

.ui-list-striped > li {
    padding: @list-striped-padding-vertical @list-striped-padding-horizontal;
    .hook-list-striped;
}

.ui-list-striped > li:nth-of-type(odd) { background: @list-striped-background; }

.ui-list-striped > li:nth-child(n+2) { margin-top: 0; }

/*
 * Bullet
  * 1. Reset display `table` which causes issues in combination with multi column layouts
 */

.ui-list-bullet > li {
    position: relative;
    padding-left: ~'calc(@{list-bullet-width} + @{list-bullet-margin-right})';
}

.ui-list-bullet > li::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: @list-bullet-width;
    height: @list-bullet-height;
    .svg-fill(@internal-list-bullet-image, "#000", @list-bullet-icon-color);
    background-repeat: no-repeat;
    background-position: 50% 50%;
    /* 1 */
    display: block;
    .hook-list-bullet;
}


/* Size modifier
 ========================================================================== */

.ui-list-large > li:nth-child(n+2),
.ui-list-large > li > ul { margin-top: @list-large-margin-top; }

/*
 * Divider
 */

.ui-list-large.ui-list-divider > li:nth-child(n+2) {
    margin-top: @list-large-divider-margin-top;
    padding-top: @list-large-divider-margin-top;
}

/*
 * Striped
 */

.ui-list-large.ui-list-striped > li {
    padding: @list-large-striped-padding-vertical @list-large-striped-padding-horizontal;
    .hook-list-striped;
}

.ui-list-large.ui-list-striped > li:nth-child(n+2) { margin-top: 0; }


// Hooks
// ========================================================================

.hook-list-misc;

.hook-list-divider() {}
.hook-list-striped() {}
.hook-list-bullet() {}
.hook-list-misc() {}


// Inverse
// ========================================================================

@inverse-list-divider-border:                     @inverse-global-border;
@inverse-list-striped-background:                 @inverse-global-muted-background;
@inverse-list-bullet-icon-color:                  @inverse-global-color;

.hook-inverse() {

    .ui-list-divider > li:nth-child(n+2) {
        border-top-color: @inverse-list-divider-border;
        .hook-inverse-list-divider;
    }

    .ui-list-striped > li {
        .hook-inverse-list-striped;
    }

    .ui-list-striped > li:nth-of-type(odd) { background-color: @inverse-list-striped-background; }

    .ui-list-bullet > li::before {
        .svg-fill(@internal-list-bullet-image, "#000", @inverse-list-bullet-icon-color);
        .hook-inverse-list-bullet;
    }

}

.hook-inverse-list-divider() {}
.hook-inverse-list-striped() {}
.hook-inverse-list-bullet() {}
