<?php
/**
 * Dynamic CSS
 */
function crt_builder_with_elementor_dynamic_css() {

	$crt_builder_with_elementor_header_font           = get_theme_mod( 'crt_builder_with_elementor_header_font', 'Fira Sans' );
	$crt_builder_with_elementor_body_font             = get_theme_mod( 'crt_builder_with_elementor_body_font', 'Merriweather' );
	$crt_builder_with_elementor_site_title_font       = get_theme_mod( 'crt_builder_with_elementor_site_title_font', 'Fira Sans' );
	$crt_builder_with_elementor_site_description_font = get_theme_mod( 'crt_builder_with_elementor_site_description_font', 'Roboto' );
	$crt_builder_with_elementor_homepage_type         = get_theme_mod( 'crt_manage_general_homepage_options');
	$crt_builder_with_elementor_border_item_space     = get_theme_mod( 'crt_manage_general_homepage_border_item_space', 'large' );
	$crt_builder_with_elementor_border_item_color     = get_theme_mod( 'crt_manage_general_homepage_border_item_color', '#000' );

    $space = '1.5rem';
    if($crt_builder_with_elementor_homepage_type == 'home-border-item') {
        if($crt_builder_with_elementor_border_item_space == 'large') {
            $space = '3rem';
        } elseif($crt_builder_with_elementor_border_item_space == 'small') {
            $space = '2rem';
        }
    }
    $crt_builder_with_elementor_custom_css = '';

	$crt_builder_with_elementor_custom_css .= '
    /* Color */
    :root {
		--header-text-color: ' . '#' . esc_attr( get_header_textcolor() ) . ';
    }
    ';

	$crt_builder_with_elementor_custom_css .= '
    /* Typograhpy */
    :root {
        --font-heading: "' . esc_attr( $crt_builder_with_elementor_header_font ) . '", serif;
        --font-main: -apple-system, BlinkMacSystemFont,"' . esc_attr( $crt_builder_with_elementor_body_font ) . '", "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    }

    body,
	button, input, select, optgroup, textarea {
        font-family: "' . esc_attr( $crt_builder_with_elementor_body_font ) . '", serif;
	}

	.site-title a {
        font-family: "' . esc_attr( $crt_builder_with_elementor_site_title_font ) . '", serif;
	}
    
	.site-description {
        font-family: "' . esc_attr( $crt_builder_with_elementor_site_description_font ) . '", serif;
	}
	.home-border-item {
	    --primary-custom-border-color: '.esc_attr( $crt_builder_with_elementor_border_item_color ).';
	}
	.home-border-item .row {
        --bs-gutter-x: '.esc_attr( $space ).';
    }
    ';

	wp_add_inline_style( 'crt-builder-with-elementor-inline-style', $crt_builder_with_elementor_custom_css );

}
add_action( 'wp_enqueue_scripts', 'crt_builder_with_elementor_dynamic_css', 99 );
