/* ==========================================================================
   Backgrounds extends and mixins
   ========================================================================== */

@mixin bg($name, $hex) {
    &--#{$name} {
        background-color: $hex;

        @if color-contrast($hex, $black) < 8 {
            color: $white;

            a {
                color: $black;

                &:hover,
                &:focus,
                &:active {
                    color: scale-color($hex, $lightness: -40%);
                }
            }
        }
    }
}

/* ==========================================================================
   Backgrounds
   ========================================================================== */

.bg {
    @each $color, $hex in $foundation-palette {
        @include bg($color, $hex);
    }

    @include bg( 'primary', get-color(primary) );
    @include bg( 'secondary', get-color(secondary) );
    @include bg( 'light-gray', $light-gray );
    @include bg( 'medium-gray', $medium-gray );
    @include bg( 'dark-gray', $dark-gray );
}