//
// Component: Button
//
// ========================================================================


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

@button-height:                                 @global-height;
@button-mini-height:                            @global-height-mini;
@button-small-height:                           @global-height-small;
@button-large-height:                           @global-height-large;

@button-line-height:                            @global-height - 2;
@button-mini-line-height:                       @global-height-mini - 2;
@button-small-line-height:                      @global-height-small - 2;
@button-large-line-height:                      @global-height-large - 2;

@button-mini-font-size:                         round((@global-font-size * 0.85)); // 12px / 14px
@button-small-font-size:                        round((@global-font-size * 0.85)); // 12px / 14px
@button-large-font-size:                        round((@global-font-size * 1.14)); // 16px / 18px

@button-padding-horizontal:                     15px;
@button-mini-padding-horizontal:                8px;
@button-small-padding-horizontal:               12px;
@button-large-padding-horizontal:               20px;

@button-background:                             @global-default-background;
@button-color:                                  @global-color;
@button-hover-background:                       @global-default-hover-background;
@button-hover-color:                            @global-color;
@button-active-background:                      @global-default-active-background;
@button-active-color:                           @global-color;

@button-primary-background:                     @global-primary-background;
@button-primary-color:                          @global-contrast-color;
@button-primary-hover-background:               @global-primary-hover-background;
@button-primary-hover-color:                    @global-contrast-color;
@button-primary-active-background:              @global-primary-active-background;
@button-primary-active-color:                   @global-contrast-color;

@button-success-background:                     @global-success-background;
@button-success-color:                          @global-contrast-color;
@button-success-hover-background:               @global-success-hover-background;
@button-success-hover-color:                    @global-contrast-color;
@button-success-active-background:              @global-success-active-background;
@button-success-active-color:                   @global-contrast-color;

@button-danger-background:                      @global-danger-background;
@button-danger-color:                           @global-contrast-color;
@button-danger-hover-background:                @global-danger-hover-background;
@button-danger-hover-color:                     @global-contrast-color;
@button-danger-active-background:               @global-danger-active-background;
@button-danger-active-color:                    @global-contrast-color;

@button-disabled-background:                    @global-default-hover-background;
@button-disabled-color:                         @global-muted-color;

@button-link-color:                             @global-link-color;
@button-link-hover-color:                       @global-link-hover-color;
@button-link-hover-text-decoration:             none;
@button-link-disabled-color:                    @global-muted-color;

//
// New
//

@button-border:                                 rgba(0,0,0,0.1);
@button-hover-border:                           rgba(0,0,0,0.15);


// Component
// ========================================================================

.hook-button() {
    border: 1px solid @button-border;
    border-radius: @global-border-radius;
}

.hook-button-hover() { border-color: @button-hover-border; }

.hook-button-active() { box-shadow: inset 0 1px 5px -1px rgba(0,0,0,0.1); }


// Color modifiers
// ========================================================================

//
// Modifier: `uk-button-primary`
//

.hook-button-primary() { border-color: transparent; }

.hook-button-primary-hover() { border-color: transparent; }

.hook-button-primary-active() {
    border-color: fade(darken(@button-primary-active-background, 15%), 50%);
    box-shadow: inset 0 1px 5px -1px fade(darken(@button-primary-active-background, 15%), 70%);
}

//
// Modifier: `uk-button-success`
//

.hook-button-success() { border-color: transparent; }

.hook-button-success-hover() { border-color: transparent; }

.hook-button-success-active() {
    border-color: fade(darken(@button-success-active-background, 15%), 50%);
    box-shadow: inset 0 1px 5px -1px fade(darken(@button-success-active-background, 15%), 70%);
}

//
// Modifier: `uk-button-danger`
//

.hook-button-danger() { border-color: transparent; }

.hook-button-danger-hover() { border-color: transparent; }

.hook-button-danger-active() {
    border-color: fade(darken(@button-danger-active-background, 20%), 50%);
    box-shadow: inset 0 1px 5px -1px fade(darken(@button-danger-active-background, 20%), 70%);
}


// Disabled state
// ========================================================================

.hook-button-disable() {
    border-color: @button-border;
    box-shadow: none;
}


// Modifier: `uk-button-link`
// ========================================================================

.hook-button-link() { box-shadow: none; }


// Size modifiers
// ========================================================================

.hook-button-large() {}


// Miscellaneous
// ========================================================================

.hook-button-misc() {

    /* Sub-object `uk-button-group`
     ========================================================================== */

    /*
     * Reset border-radius
     */

    .uk-button-group > .uk-button:not(:first-child):not(:last-child),
    .uk-button-group > div:not(:first-child):not(:last-child) .uk-button { border-radius: 0; }

    .uk-button-group > .uk-button:first-child,
    .uk-button-group > div:first-child .uk-button {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
    }

    .uk-button-group > .uk-button:last-child,
    .uk-button-group > div:last-child .uk-button {
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
    }

    /*
     * Collapse border
     */

    .uk-button-group > .uk-button:nth-child(n+2),
    .uk-button-group > div:nth-child(n+2) .uk-button { margin-left: -1px; }

    /*
     * Create position context to superimpose the successor elements border
     * Known issue: If you use an `a` element as button and an icon inside,
     * the active state will not work if you click the icon inside the button
     * Workaround: Just use a `button` or `input` element as button
     */

    .uk-button-group .uk-button:hover,
    .uk-button-group .uk-button:active { position: relative; }

}