@use 'sass:color';

@mixin create-button-variation($base-col, $base-col-05, $base-col-20, $base-col-30, $base-col-80) {
    border-color: $base-col-80;
    background-color: $base-col-05;
    color: $color-text-dim;

    &:focus, &:hover {
        border-color: $base-col;
        background-color: $base-col-30;
        color: $color-text;
    }

    &:disabled,&[disabled] {
        color: $color-text-inactive;
    }

    &:active {
        background-color: $base-col-20;
        color: $color-text-active;
    }
}

.button {
    @extend %label-md;
    @extend %nav-all;
    @include create-button-variation($color-primary, $color-primary-a5, $color-primary-a20, $color-primary-a30, $color-primary-a80);
    @include trans-colors;

    display: block;
    width: auto;
    height: auto;
    // leave 1dp room for border expansion
    padding: space(24 - 1);
    border-width: $border-width-thickness;

    border-radius: $border-radius-md;

    // Setting it by default for convenience
    &--primary {
        @include create-button-variation($color-primary, $color-primary-a5, $color-primary-a20, $color-primary-a30, $color-primary-a80);
    }

    &--large {
        @extend %label-lg;
    }

    &--secondary {
        @include create-button-variation($color-secondary, $color-secondary-a5, $color-secondary-a20, $color-secondary-a30, $color-secondary-a80);
    }

    &--tertiary {
        @include create-button-variation($color-text, $color-text-a5, $color-text-a20, $color-text-a30, $color-text-a80);
    }

    &--success {
        @include create-button-variation($color-success, $color-success-a5, $color-success-a20, $color-success-a30, $color-success-a80);
    }

    &--danger {
        @include create-button-variation($color-danger, $color-danger-a5, $color-danger-a20, $color-danger-a30, $color-danger-a80);
    }

    &--warning {
        @include create-button-variation($color-warning, $color-warning-a5, $color-warning-a20, $color-warning-a30, $color-warning-a80);
    }

    &:not([disabled]) {
        @extend %nav-all;
        cursor: pointer;
    }

    &:disabled,&[disabled] {
        opacity: 0.5;
    }

    &__label {
        width: auto;
        height: auto;
    }
}
