// Gets the active color's css variable from a variation. Alpha is optional.
// --------------------------------------------------------------------------------------------
// Example usage:
// current-color(base) => var(--lu-color-base)
// current-color(contrast, 0.1) => rgba(var(--lu-color-contrast-rgb), 0.1)
// --------------------------------------------------------------------------------------------
@function current-color($variation, $alpha: null) {
    @if $alpha == null {
        @return var(--lu-color-#{$variation});
    } @else {
        @return rgba(var(--lu-color-#{$variation}-rgb), #{$alpha});
    }
}

// Converts a color to a comma separated rgb.
// --------------------------------------------------------------------------------------------
@function color-to-rgb-list($color) {
    @return #{red($color)},#{green($color)},#{blue($color)};
}

// Gets the specific color's css variable from the name and variation. Alpha/rgb are optional.
// --------------------------------------------------------------------------------------------
// Example usage:
// lu-color(primary, base) => var(--lu-color-primary, #3880ff)
// lu-color(secondary, contrast) => var(--lu-color-secondary-contrast)
// lu-color(primary, base, 0.5) => rgba(var(--lu-color-primary-rgb, 56, 128, 255), 0.5)
// --------------------------------------------------------------------------------------------
@function lu-color($name, $variation, $alpha: null, $rgb: null) {
    $values: map-get($colors, $name);
    $value: map-get($values, $variation);
    $variable: --lu-color-#{$name}-#{$variation};

    @if ($variation == base) {
        $variable: --lu-color-#{$name};
    }

    @if ($alpha) {
        $value: color-to-rgb-list($value);
        @return rgba(var(#{$variable}-rgb, $value), $alpha);
    }
    @if ($rgb) {
        $value: color-to-rgb-list($value);
        $variable: #{$variable}-rgb;
    }

    @return var(#{$variable}, $value);
}

// Mixes a color with black to create its shade.
// --------------------------------------------------------------------------------------------
@function get-color-shade($color) {
    @return mix(#000, $color, 12%);
}

// Mixes a color with white to create its tint.
// --------------------------------------------------------------------------------------------
@function get-color-tint($color) {
    @return mix(#fff, $color, 10%);
}
