<?php

function glowify_wp_dynamic_style() {

	$glowify_wp_custom_css = ''; // define variable before if statements

	wp_enqueue_style('glowify-custom-style', get_template_directory_uri() . '/assets/css/theme-style.css', array(), '1.0.0', 'all' );

	

	// Google Fonts Load

	$body_font_array			=	glowify_wp_option('body_font');
	$heading_font_array	   		=	glowify_wp_option('heading_font');
	$heading_font2_array	    =	glowify_wp_option('heading_font2');
	$heading_font3_array	    =	glowify_wp_option('heading_font3');
	$heading_font4_array	    =	glowify_wp_option('heading_font4');
	$heading_font5_array	    =	glowify_wp_option('heading_font5');
	$heading_font6_array	    =	glowify_wp_option('heading_font6');
	$body_other_font_array	    =	glowify_wp_option('body_other_font');

	

	if(!empty($body_font_array)){

		$glowify_wp_custom_css = '

			body, p,.cs_btn, address,dfn, cite, em, pre, input, textarea, select{

				font-family: '.esc_html($body_font_array['font-family']).', sans-serif; 

				font-weight: '.esc_html($body_font_array['font-weight']).'; 
				
				font-size: '.esc_html($body_font_array['font-size']).'px; 
				
				line-height: '.esc_html($body_font_array['line-height']).'px; 

			}

			:root {
				---secondary-font: "'.esc_html($body_font_array['font-family']).'", sans-serif;
			}


		';

	}

	

	if(!empty($heading_font_array)){

        $glowify_wp_custom_css .= '

       h1,.heading-1{

			font-family: "'.esc_html($heading_font_array['font-family']).'", sans-serif;

			font-weight: '.esc_html($heading_font_array['font-weight']).'

			font-size: '.esc_html($heading_font_array['font-size']).'px; 
			
			line-height: '.esc_html($heading_font_array['line-height']).'px; 

		}

		:root {
			--primary-font: "'.esc_html($heading_font_array['font-family']).'", sans-serif;
		}
			
        h2,.heading-2{

			font-family: "'.esc_html($heading_font2_array['font-family']).'", sans-serif;

			font-weight: '.esc_html($heading_font2_array['font-weight']).';

			font-size: '.esc_html($heading_font2_array['font-size']).'px; 
			
			line-height: '.esc_html($heading_font2_array['line-height']).'px; 

		}

		h3,.heading-3{

			font-family: "'.esc_html($heading_font3_array['font-family']).'", sans-serif;

			font-weight: '.esc_html($heading_font3_array['font-weight']).';

			font-size: '.esc_html($heading_font3_array['font-size']).'px; 
			
			line-height: '.esc_html($heading_font3_array['line-height']).'px; 

		}

		h4,.heading-4{

			font-family: "'.esc_html($heading_font4_array['font-family']).'", sans-serif;

			font-weight: '.esc_html($heading_font4_array['font-weight']).';

			font-size: '.esc_html($heading_font4_array['font-size']).'px; 
			
			line-height: '.esc_html($heading_font4_array['line-height']).'px; 

		}

		h5,.heading-5{

			font-family: "'.esc_html($heading_font5_array['font-family']).'", sans-serif;

			font-weight: '.esc_html($heading_font5_array['font-weight']).';

			font-size: '.esc_html($heading_font5_array['font-size']).'px; 
			
			line-height: '.esc_html($heading_font5_array['line-height']).'px; 

		}

		h6,.heading-6{

			font-family: "'.esc_html($heading_font6_array['font-family']).'", sans-serif ;

			font-weight: '.esc_html($heading_font6_array['font-weight']).';

			font-size: '.esc_html($heading_font6_array['font-size']).'px; 
			
			line-height: '.esc_html($heading_font6_array['line-height']).'px; 

		}

		
		@media (max-width: 1400px) {
		h1,.heading-1 {
			font-size: 60px ;
			line-height: 135% ;
			}
			h2,.heading-2 {
			font-size: 46px ;
			line-height: 135% ;
		}
		h3,.heading-3 {
			font-size: 34px ;
			line-height: 135% ;
		}
		}
		@media (max-width: 991px) {
		h1,.heading-1 {
			font-size: 46px ;
			line-height: 62px ;
			}
		h2,.heading-2 {
			font-size: 40px ;
		}
		h3,.heading-3 {
			font-size: 30px ;
		}
		}
		

		';

	}



	if(!empty($body_other_font_array)){

        $glowify_wp_custom_css .= '

		.cs_hamburger_menu .cs_nav_list > li a,blockquote,.wc-tabs ul li a,.cs_list.cs_style_3  li{

                font-family: "'.esc_html($body_other_font_array['font-family']).'", sans-serif;

                font-weight: '.esc_html($body_other_font_array['font-weight']).'


			}

		';

	}

	

	// Options


	if(!empty($footer_heading_color)) {
		$glowify_wp_custom_css .='
		.cs_footer  .wp-block-heading, .cs_footer  .wp-block-heading,
		.cs_footer  .widget_nav_menu ul li a, .cs_footer  .widget_nav_menu ul li{
			color: '.esc_attr($footer_heading_color).' !important;

		}
		';
	}

	if(!empty($footer_title_color)) {
		$glowify_wp_custom_css .='
		.cs_footer -news-list li .wp-block-latest-posts__post-title, .cs_footer -news-list li a,
		.wp-block-heading.cs_footer -inside-heading{
			color: '.esc_attr($footer_title_color).' !important;

		}
		';
	}

	if(!empty($footer_text_color)) {
		$glowify_wp_custom_css .='
			.cs_footer  p{color: '.esc_attr($footer_text_color).'}
		';

	}

	
	$theme_primary_color	=	glowify_wp_option('theme_primary_color');
	$theme_secondary_color	=	glowify_wp_option('theme_secondary_color');
	$theme_body_color	=	glowify_wp_option('theme_body_color');
	$theme_heading_color	=	glowify_wp_option('theme_heading_color');


	
	// Theme Heading Colors

	if(!empty($theme_primary_color)){

		$glowify_wp_custom_css .='
		:root {
			--accent-color: '.esc_attr($theme_primary_color).' !important;
			--accent-strong: '.esc_attr($theme_secondary_color).' !important;
			--secondary: '.esc_attr($theme_body_color).' !important;
			--primary: '.esc_attr($theme_heading_color).' !important;
			
		}';
	}


	
	$header_font_size	=	glowify_wp_option('header_font_size');
	$header_dropdown_font_size	=	glowify_wp_option('header_dropdown_font_size');
	$overwrite_default_color	=	glowify_wp_option('overwrite_default_color');
	$header_menu_color	=	glowify_wp_option('header_menu_color');
	$header_menu_hover_color	=	glowify_wp_option('header_menu_hover_color');
	$header_menu_dropdown_color	=	glowify_wp_option('header_menu_dropdown_color');
	$header_menu_dropdown_hover_color	=	glowify_wp_option('header_menu_dropdown_hover_color');

	if(!empty($header_font_size)){
		$glowify_wp_custom_css .='
		.header .main-menu li a{
			font-size: '.esc_attr($header_font_size).'px;
		}
		';
	}

	if(!empty($header_dropdown_font_size)){
		$glowify_wp_custom_css .='
		.header .main-menu li ul li a{
			font-size: '.esc_attr($header_dropdown_font_size).'px;
		}
		';
	}

	if  ($overwrite_default_color == true){

		if(!empty($header_menu_color)){
			$glowify_wp_custom_css .='
			.header .main-menu li a{
				color: '.esc_attr($header_menu_color).';
			}
			';
		}
	
		if(!empty($header_menu_hover_color)){
			$glowify_wp_custom_css .='
			.header .main-menu li a:hover{
				color: '.esc_attr($header_menu_hover_color).';
			}
			';
		}
	
		if(!empty($header_menu_dropdown_color)){
			$glowify_wp_custom_css .='
			.header .main-menu li ul li a{
				color: '.esc_attr($header_menu_dropdown_color).';
			}
			';
		}
	
		if(!empty($header_menu_dropdown_hover_color)){
			$glowify_wp_custom_css .='
			.header .main-menu li ul li a:hover{
				color: '.esc_attr($header_menu_dropdown_hover_color).';
			}
			';
		}
	

	}  

	

	wp_add_inline_style('glowify-custom-style', $glowify_wp_custom_css);	

}

add_action('wp_enqueue_scripts', 'glowify_wp_dynamic_style');