/**
 *  Button
 *
 *  @author Björn Hase, Tentakelfabrik
 *  @license http://opensource.org/licenses/MIT The MIT License
 *  @link https://github.com/tentakelfabrik/plain-ui
 *
 */

/**
 *
 *
 */
@mixin button-color($name)
{
    &--#{$name} {
        border-color: var(--#{$name});

        &:hover {
            background-color: var(--#{$name});
        }

        &:focus, &:active {
            outline: 2px solid var(--#{$name});
        }
    }
}

/**
 *
 *
 */
@mixin button-outline-color($name, $color)
{
    &--#{$name}.button--outline {
        &:hover {
            border-color: $color;
        }
    }
}

.button {
    appearance: none;
    position: relative;

    display: inline-flex;
    align-items: center;
    text-decoration: none;

    font-family: var(--font-family);
    font-size: 1rem;

    border: 1px solid var(--border);
    background-color: var(--background-contrast);
    color: var(--text);

    border-radius: $border-radius;
    transition: background-color 0.1s;

    margin: $margin;
    
    padding: 0 1.3rem;
    min-height: 2.8rem;
    width: 100%;

    @include media-sm() {
        width: auto;
    }

    &--small {
        font-size: 0.8rem;
    }

    &:hover, &--selected {
        cursor: pointer;
        text-decoration: none;
        color: white;
        background-color: var(--active);
    }

    &:focus, &:active {
        outline: 1px solid var(--active);
    }

    &:disabled {
        opacity: 0.5;

        &:hover {
            cursor: not-allowed;
            border: 1px solid var(--border);
            background-color: var(--background-contrast);
            color: var(--border);
        }
    }

    &--transparent {
        margin: 0;
        padding: 0;
        border: none;
        background: transparent;
        border-radius: 0;

        &:focus, &:active {
            outline: none;
        }
    }

    @include button-color('danger');
    @include button-color('info');
    @include button-color('warning');
    @include button-color('success');

    &--outline {
        background-color: transparent;

        &:hover {
            color: var(--border);
            border-color: lighten($color__primary, 40%);
            background-color: transparent;
        }
    }

    @include button-outline-color('danger', lighten($color__danger, 20%));
    @include button-outline-color('info', lighten($color__info, 20%));
    @include button-outline-color('warning', lighten($color__warning, 20%));
    @include button-outline-color('success', lighten($color__success, 20%));
}