// Color scheme - utilities

@mixin generate-utilities($color, $value) {
  $color-rgb: to-rgb($value);
  $important: null;

  @if $enable-important-utilities {
    $important: !important;
  }

  &.text-bg-#{$color},
  .text-bg-#{$color} {
    color: color-contrast($value) $important;
    background-color: RGBA($color-rgb, var(--#{$prefix}bg-opacity, 1))
      $important;
  }

  &.bg-#{$color},
  .bg-#{$color} {
    --bs-bg-opacity: 1;
    background-color: rgba(
      var(--bs-#{$color}-rgb),
      var(--bs-bg-opacity)
    ) !important;
  }

  .link-#{$color} {
    color: $value !important; // stylelint-disable-line declaration-no-important

    @if $link-shade-percentage != 0 {
      &:hover,
      &:focus {
        @if color-contrast($value) == $color-contrast-light {
          color: shade-color(
            $value,
            $link-shade-percentage
          ) !important; // stylelint-disable-line declaration-no-important
        } @else {
          color: tint-color(
            $value,
            $link-shade-percentage
          ) !important; // stylelint-disable-line declaration-no-important
        }
      }
    }
  }
  @if $color == "primary" {
    .icon--primary {
      color: $value;
    }
  }
}
