/// Returns the color value for a given color name and group.
///
/// @param {String} $hue - The color's hue.
/// @param {String} $value - The darkness/lightness of the color. Defaults to base.
/// @param {Color} $for-background - The background color on which this color will
/// appear. Applies a multiply filter to ensure appropriate contrast.
/// @return {Color} The color value.

@function color($hue, $value: base, $for-background: null) {
  $fetched-color: map-get(map-get($color-palette-data, $hue), $value);

  @if map-has-key($color-palette-data, $fetched-color) {
    $fetched-color: map-get(map-get($color-palette-data, $fetched-color), $value);
  }

  @if $for-background != null {
    $fetched-color: color-multiply($fetched-color, $for-background);
  }

  @if type-of($fetched-color) == color {
    @return $fetched-color;
  } @else {
    @error 'Color `#{$hue} - #{$value}` not found. Available colors: #{available-names($color-palette-data)}';
  }
}


/// Darkens the foreground color by the background color. This is the same as the
/// “multiply” filter in graphics apps.
///
/// @param {Color} $foreground - The color to darken.
/// @param {Color} $background - The background to base darkening on.
/// @return {Color} The modified color.

@function color-multiply($foreground, $background: null) {
  @if $background == null {
    $background: #ffffff;
  }

  @return $foreground * $background / 255;
}

// stylelint-enable color-no-hex, function-max-empty-lines, value-list-max-empty-lines