@mixin muted {
  opacity: 0.5;
}
@mixin disabled($background: transparent, $color: $disabled) {
  background-color: $background;
  color: $color;
  cursor: not-allowed;
  opacity: $disabled-opacity;
  &:hover,
  &:active,
  &:focus {
    background-color: $background;
    color: $color;
    opacity: $disabled-opacity;
  }
}

@mixin color-stack($bkgd: $body-bkgd) {
  background-color: $bkgd;
  @if lightness($bkgd) < lightness(#888) {
    color: $white-80;
    a {
      color: $white-80;
    }
  }
  @else {
    color: $body-font-color;
  }
}

// UTILITY COLORS
$color-list: primary, success, alert, warning, error;
$color-vars: $brand, $success, $alert, $warning, $error;

@mixin color-management {
  background: $body-font-color;
  @if lightness($body-font-color) > 65% {
    color: $body-font-color;
  }
  @else {
    color: $white;
  }
  @for $i from 1 through length($color-list) {
    // for components that use color vars as props, we find the lightness
    // of the bkgd-color and adjust the font-color accordingly
    &--#{nth($color-list, $i)} {
      background: nth($color-vars, $i);
      @if lightness(nth($color-vars, $i)) > 65% {
        color: $body-font-color;
      }
      @else {
        color: $white;
      }
    }
  }
}

// NAVIGATION COLORS
$navigation-bkgd: $white-0 !default;
$navigation-color: $anchor-color !default;
// hover navigation colors
$navigation-bkgd-hover: $black-06 !default;
$navigation-color-hover: $anchor-color-hover !default;
// onClick navigation colors
$navigation-bkgd-active: $black-10 !default;
$navigation-color-active: $anchor-color-active !default;
// selected state colors are reversed
$navigation-bkgd-selected: $navigation-color !default;
$navigation-color-selected: $anchor-color-inverse !default;
// disabled navigation
$navigation-bkgd-disabled: $navigation-bkgd !default; // will have disabled-opacity
$navigation-color-disabled: $navigation-color !default; // will have disabled-opacity

@mixin navigation-color-mgmt {
  a {
    @include global-transition;
    background-color: $navigation-bkgd;
    color: $navigation-color;
    &:hover {
      background-color: $navigation-bkgd-hover;
      color: $navigation-color-hover;
    }
    &:active,
    &:focus {
      background-color: $navigation-bkgd-active;
      color: $navigation-color-active;
    }
  }
  &[class*='--selected'] a {
    background-color: $navigation-bkgd-selected;
    @if lightness($navigation-bkgd-selected) > 65% {
      color: $body-font-color;
    }
    @else {
      color: $white;
    }
  }
  &[class*='--disabled'] {
    a,
    a:hover,
    a:active,
    a:focus {
      @include disabled($navigation-bkgd-disabled, $navigation-color-disabled);
    }
  }
}

// COMPONENT STATE COLORS
$stateful-item-bkgd: $white-0 !default;
$stateful-item-color: $body-font-color !default;
// hover state colors
$stateful-item-bkgd-hover: $black-06 !default;
$stateful-item-color-hover: $anchor-color !default;
// active state colors
$stateful-item-bkgd-active: $black-10 !default;
$stateful-item-color-active: $anchor-color-active !default;
// selected state colors
$stateful-item-bkgd-selected: $black-10 !default;
$stateful-item-color-selected: $anchor-color-active !default;
// disabled
$stateful-item-bkgd-disabled: $stateful-item-bkgd !default; // will have disabled-opacity
$stateful-item-color-disabled: $stateful-item-color !default; // will have disabled-opacity


@mixin stateful-color-mgmt {
  @include global-transition;
  background: $stateful-item-bkgd;
  color: $stateful-item-color;
  &:hover {
    background: $stateful-item-bkgd-hover;
    color: $stateful-item-color-hover;
  }
  &:active,
  &:focus {
    background: $stateful-item-bkgd-active;
    color: $stateful-item-color-active;
  }
  [class*='--selected'] & {
    background: $stateful-item-bkgd-selected;
    color: $stateful-item-color-selected;
  }
  &[class*='--disabled'] {
    @include disabled($stateful-item-bkgd-disabled, $stateful-item-color-disabled);
    a {
      @include disabled($stateful-item-bkgd-disabled, $stateful-item-color-disabled);
    }
  }
}
