<?php
/**
 * Vintuna Dynamic Styles
 *
 * @package Vintuna
 */

function vintuna_dynamic_css()
{

    $vintuna_default = vintuna_get_default_theme_options();
    $logo_width_range = get_theme_mod('logo_width_range', $vintuna_default['logo_width_range']);

    $background_color = get_theme_mod('background_color');
    $site_title_font_size = get_theme_mod('site_title_font_size', $vintuna_default['site_title_font_size']);


    echo "<style type='text/css' media='all'>"; ?>

    .site-logo .custom-logo-link{
    max-width:  <?php echo esc_attr($logo_width_range); ?>px;
    }

    @media (min-width: 1200px) {
        .header-titles .site-title,
        .header-titles .custom-logo-name{
        font-size: <?php echo esc_attr($site_title_font_size); ?>px;
        }
    }

    .custom-background .sidr,
    .custom-background .header-searchbar-inner,
    .custom-background .offcanvas-wraper{
    background-color: #<?php echo esc_attr($background_color); ?>;
    }
    <?php echo "</style>";
}

add_action('wp_head', 'vintuna_dynamic_css', 100);

/**
 * Sanitizing Hex color function.
 */
function vintuna_sanitize_hex_color($color)
{

    if ('' === $color)
        return '';
    if (preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color))
        return $color;

}