function stachestack_background_css()
{
    $sections = stachestack_customizer_fields();
    echo '<style>';
    foreach ($sections as $section) {
        $fields = $section['fields'];
        foreach ($fields as $field => $args) {
            $value = get_theme_mod($field);
            if ('background' == $args['type']) {
                // Generic style for all "background" settings
                if (isset($args['style']) && !empty($args['style'])) {
                    echo $args['style'] . ' {
						background: ' . $value . ';
					}';
                }
                // Additional styles for the content background setting
                if ('body_bg' == $field) {
                    $bg_brightness = StacheStack_Color::get_brightness($value);
                    // Set an "accent" color depending on the background's brightness
                    if ($bg_brightness > 120) {
                        $accent = StacheStack_Color::adjust_brightness($value, -20);
                        $border = StacheStack_Color::adjust_brightness($value, -30);
                    } else {
                        $accent = StacheStack_Color::adjust_brightness($value, 20);
                        $border = StacheStack_Color::adjust_brightness($value, 30);
                    }
                    // Use lumosity difference to find a text color with great readability
                    if (StacheStack_Color::lumosity_difference($value, '#ffffff') > 5) {
                        $text = '#ffffff';
                    } elseif (StacheStack_Color::lumosity_difference($value, '#222222') > 5) {
                        $text = '#222222';
                    }
                    echo '.well {
						background: ' . $accent . ';
						border-color: ' . $border . ';
					}
					body, h1, h2, h3, h4, h5, h6 {
						color: ' . $text . ';
					}';
                }
            } elseif ('color' == $args['type']) {
                // Generic style for all "color" settings
                if (isset($args['style']) && !empty($args['style'])) {
                    echo $args['style'] . ' {
						color: ' . $value . ';
					}';
                }
                // Additional styles per setting
                if ('color_brand_primary' == $field) {
                    $brightness = StacheStack_Color::get_brightness($value);
                    if ($brightness < 195) {
                        $border = StacheStack_Color::adjust_brightness($value, -20);
                        $text_c = '#fff';
                    } else {
                        $border = StacheStack_Color::adjust_brightness($value, 20);
                        $text_c = '#333';
                    }
                    echo '.btn.btn-primary {
						background-color: ' . $value . ';
						border-color: ' . $border . ';
						color: ' . $text_c . ';
					}';
                }
            }
        }
    }
    echo '</style>';
}
function stachestack_adjust_brightness($hex, $steps)
{
    _stachestack_deprecated_function(__FUNCTION__, '3.2', 'StacheStack_Color::adjust_brightness()');
    return StacheStack_Color::adjust_brightness($hex, $steps);
}