//== Variables
@hdeng-alert-default-bg: mix(@hdeng-body-bg-default-color, @hdeng-body-bg-contrast-color);
@hdeng-alert-default-text: @hdeng-body-font-default-color;
@hdeng-alert-default-border: darken(@hdeng-alert-default-bg, 3%);

@hdeng-alert-success-bg: @hdeng-state-success-bg;
@hdeng-alert-success-text: @hdeng-state-success-text;
@hdeng-alert-success-border: @hdeng-state-success-border;

@hdeng-alert-info-bg: @hdeng-state-info-bg;
@hdeng-alert-info-text: @hdeng-state-info-text;
@hdeng-alert-info-border: @hdeng-state-info-border;

@hdeng-alert-warning-bg: @hdeng-state-warning-bg;
@hdeng-alert-warning-text: @hdeng-state-warning-text;
@hdeng-alert-warning-border: @hdeng-state-warning-border;

@hdeng-alert-danger-bg: @hdeng-state-danger-bg;
@hdeng-alert-danger-text: @hdeng-state-danger-text;
@hdeng-alert-danger-border: @hdeng-state-danger-border;

//== Generates
.hdeng-alert-critical-generate() {
    // Silence
}

.hdeng-alert-generate() {
    .alert {
        padding: (@hdeng-content-padding * 0.75);
        margin-bottom: @hdeng-spacing;
        border: 1px solid transparent;
        border-radius: @hdeng-border-radius;

        .hdeng-alert-variant(@hdeng-alert-default-bg, @hdeng-alert-default-border, @hdeng-alert-default-text, @link-color: false);

        a {
            font-weight: bold;
        }

        // Improve alignment and spacing of inner content
        > p,
        > ul {
            margin-bottom: 0;
        }
        > p + p {
            margin-top: floor(@hdeng-spacing / 4);
        }
    }

    // Alternate styles
    .alert--success {
        .hdeng-alert-variant(@hdeng-alert-success-bg, @hdeng-alert-success-border, @hdeng-alert-success-text, @link-color: true);
    }
    .alert--info {
        .hdeng-alert-variant(@hdeng-alert-info-bg, @hdeng-alert-info-border, @hdeng-alert-info-text, @link-color: true);
    }

    .alert--warning {
        .hdeng-alert-variant(@hdeng-alert-warning-bg, @hdeng-alert-warning-border, @hdeng-alert-warning-text, @link-color: true);
    }

    .alert--danger {
        .hdeng-alert-variant(@hdeng-alert-danger-bg, @hdeng-alert-danger-border, @hdeng-alert-danger-text, @link-color: true);
    }
}

.hdeng-alert-variant(@background, @border, @body-color, @link-color: false) {
    background-color: @background;
    border-color: @border;
    color: @body-color;

    hr {
        border-top-color: darken(@border, 5%);
    }
}

.hdeng-alert-variant(@background, @border, @body-color, @link-color: false) when (@link-color) {
    a {
        color: darken(@body-color, 10%);

        &:hover {
            color: darken(@body-color, 20%);
        }
    }
}
