/// Scales a color to be lighter if it's light, or darker if it's dark. Use this function to tint a color appropriate to its lightness.
///
/// @param {Color} $color - Color to scale.
/// @param {Percentage} $scale [5%] - Amount to scale up or down.
/// @param {Percentage} $threshold [40%] - Threshold of lightness to check against.
///
/// @returns {Color} A scaled color.
@function smart-scale($color, $scale: 5%, $threshold: 40%) {
    @if lightness($color) > $threshold {
        $scale: -$scale;
    }
    @return scale-color($color, $lightness: $scale);
}


@function foreground($color, $yes: $black, $no: $white, $threshold: 60%) {
    @if $color == transparent {
        $color: $body-background;
    }
    @if (lightness($color) > $threshold) {
        @return $yes;
    } @else {
        @return $no;
    }
}