// All-caps `RGBA()` function used because of this Sass bug: https://github.com/sass/node-sass/issues/2251
@if $enable-bootstrap-compatibility {
  @each $color, $value in map-remove($utilities-bg-colors, "black", "white", "body") {
    // OUDS mod: Force colors to have a good rendering
    $text-bg-color: var(--#{$prefix}color-content-default);
    @if index(("danger"), #{$color}) {
      $text-bg-color: var(--#{$prefix}color-content-on-status-negative-emphasized);
    } @else if index(("dark"), #{$color}) {
      $text-bg-color: var(--#{$prefix}color-content-inverse);
    } @else if index(("success"), #{$color}) {
      $text-bg-color: var(--#{$prefix}color-content-on-status-positive-emphasized);
    } @else if index(("info", "warning"), #{$color}) {
      $text-bg-color: var(--#{$prefix}color-content-on-status-#{$color}-emphasized);
    }
    // End mod

    .text-bg-#{$color} {
      color: $text-bg-color if($enable-important-utilities, !important, null); // OUDS mod: instead of `color-contrast($value)`
      background-color: if($value, $value, var(--#{$prefix}color-bg-#{$color})) if($enable-important-utilities, !important, null); // OUDS mod: instead of `RGBA(var(--#{$prefix}#{$color}-rgb), var(--#{$prefix}bg-opacity, 1))`
    }
  }
}

@each $color, $value in $ouds-backgrounds-with-color {
  $text-bg-color: null;

  @if index(("always-black"), #{$color}) {
    $text-bg-color: var(--#{$prefix}color-always-on-black);
  } @else if index(("always-white"), #{$color}) {
    $text-bg-color: var(--#{$prefix}color-always-on-white);
  } @else {
    $text-bg-color: var(--#{$prefix}color-content-on-#{str-replace($color, "surface-")});
  }

  .bg-#{$color} {
    --#{$prefix}color-local: #{$text-bg-color};
    color: var(--#{$prefix}color-local);
  }
}

@each $color, $value in $ouds-backgrounds-without-color {
  .bg-#{$color} {
    --#{$prefix}color-local: initial;
  }
}
