// Bootstrap overrides for `bootstrap/scss/_functions.scss`

// Color contrast
// DH Customization: Add support for dh-color variables
@function color-yiq(
  $color,
  $dark: var(--dh-color-contrast-dark),
  $light: var(--dh-color-contrast-light)
) {
  // if $color is a hex color, use the default color-yiq function
  @if type-of($color) == 'color' {
    $r: red($color);
    $g: green($color);
    $b: blue($color);

    $yiq: (($r * 299) + ($g * 587) + ($b * 114)) * 0.001;

    @if $yiq >= $yiq-contrasted-threshold {
      @return $dark;
    } @else {
      @return $light;
    }
  }

  $contrast-color: var(
    --dh-color-#{$color}-contrast,
    var(--dh-color-contrast-light)
  );

  @return $contrast-color;
}
