// Name:            Accordion
// Description:     Component to create accordions
//
// Component:       `uk-accordion`
//
// Sub-objects:     `uk-accordion-title`
//                  `uk-accordion-content`
//
// Modifiers:       `uk-accordion-default`
//
// States:          `uk-open`
//
// ========================================================================


// Variables
// ========================================================================

@accordion-default-item-margin-top:             @global-margin;

@accordion-default-title-gap:                   15px;
@accordion-default-title-font-size:             @global-medium-font-size;
@accordion-default-title-line-height:           1.4;
@accordion-default-title-color:                 @global-emphasis-color;
@accordion-default-title-hover-color:           @global-color;

@accordion-default-content-margin-top:          @global-margin;


/* ========================================================================
   Component: Accordion
 ========================================================================== */

.uk-accordion {
    padding: 0;
    list-style: none;
    .hook-accordion();
}

.uk-accordion-title { display: block; }

.uk-accordion-content { display: flow-root; }

/*
 * Remove margin from the last-child
 */

.uk-accordion-content > :last-child { margin-bottom: 0; }


/* Default modifier
 ========================================================================== */

/*
 * Item
 */

.uk-accordion-default > * {
    .hook-accordion-default-item();
}

.uk-accordion-default > :nth-child(n+2) { margin-top: @accordion-default-item-margin-top; }

/* Active */
.uk-accordion-default > .uk-open {
    .hook-accordion-default-item-active();
}

/*
 * Title
 */

/*
* 1. Center content vertically, e.g. an icon
* 2. Imitate white space gap when using flexbox
* 3. Reset link
 */

.uk-accordion-default .uk-accordion-title {
    /* 1 */
    display: flex;
    align-items: center;
    /* 2 */
    column-gap: @accordion-default-title-gap;
    /* 3 */
    font-size: @accordion-default-title-font-size;
    line-height: @accordion-default-title-line-height;
    color: @accordion-default-title-color;
    .hook-accordion-default-title();
}

/* Hover */
.uk-accordion-default .uk-accordion-title:hover {
    color: @accordion-default-title-hover-color;
    text-decoration: none;
    .hook-accordion-default-title-hover();
}

/* Active */
.uk-accordion-default > .uk-open .uk-accordion-title {
    .hook-accordion-default-title-active();
}

/*
 * Icon
 */

.uk-accordion-default .uk-accordion-icon {
    flex: none;
    margin-left: auto;
    .hook-accordion-default-icon();
}

/*
 * Content
 */

.uk-accordion-default .uk-accordion-content {
    margin-top: @accordion-default-content-margin-top;
    .hook-accordion-default-content();
}


// Hooks
// ========================================================================

.hook-accordion-misc();

.hook-accordion() {}
.hook-accordion-default-item() {}
.hook-accordion-default-item-active() {}
.hook-accordion-default-title() {}
.hook-accordion-default-title-hover() {}
.hook-accordion-default-title-active() {}
.hook-accordion-default-icon() {}
.hook-accordion-default-content() {}
.hook-accordion-misc() {}


// Inverse
// ========================================================================

@inverse-accordion-default-title-color:             @inverse-global-emphasis-color;
@inverse-accordion-default-title-hover-color:       @inverse-global-color;

.hook-inverse() {

    .uk-accordion-default > * {
        .hook-inverse-accordion-default-item();
    }

    .uk-accordion-default > .uk-open {
        .hook-inverse-accordion-default-item-active();
    }

    .uk-accordion-default .uk-accordion-title {
        color: @inverse-accordion-default-title-color;
        .hook-inverse-accordion-default-title();
    }

    .uk-accordion-default .uk-accordion-title:hover {
        color: @inverse-accordion-default-title-hover-color;
        .hook-inverse-accordion-default-title-hover();
    }

    .uk-accordion-default .uk-accordion-title:active {
        .hook-inverse-accordion-default-title-active();
    }

    .uk-accordion-default .uk-accordion-icon {
        .hook-inverse-accordion-default-icon();
    }

    .uk-accordion-default .uk-accordion-content {
        .hook-inverse-accordion-default-content();
    }

}

.hook-inverse-accordion-default-item() {}
.hook-inverse-accordion-default-item-active() {}
.hook-inverse-accordion-default-title() {}
.hook-inverse-accordion-default-title-hover() {}
.hook-inverse-accordion-default-title-active() {}
.hook-inverse-accordion-default-icon() {}
.hook-inverse-accordion-default-content() {}
