<?php 

if (!function_exists('newsweek_css_custom')) {

	function newsweek_css_custom() { 

		$css = '';
		$woocommerce = '';

		/* =================== BEGIN BODY STYLE =================== */

		if (newsweek_setting('newsweek_body_font_family')) 
			$css .= "body { font-family:".esc_html(newsweek_google_font_name('newsweek_body_font_family'))."; }";
		
		/* =================== END BODY WIDTH =================== */

		/* =================== BEGIN HEADER IMAGE =================== */

		if ( get_header_image() ) :
				
			$css .= '
				#header { 
					background-image: url('.esc_url(get_header_image()).');
					-webkit-background-size: cover !important;
					-moz-background-size: cover !important;
					-o-background-size: cover !important;
					background-size: cover !important;
					background-position: center;
				}'; 
		
		endif;

		if (newsweek_setting('newsweek_mobile_header_padding')) :

			$css .= '
				@media screen and (min-width : 0px) and (max-width : 600px)  {
					body.home #header { 
						padding-bottom:' . esc_html(newsweek_google_font_name('newsweek_mobile_header_padding')) . 'px;
					}

				}';

		endif;

		if (newsweek_setting('newsweek_tablet_header_padding')) :

			$css .= '
				@media screen and (min-width : 601px) and (max-width : 992px)  {
					body.home #header { 
						padding-bottom:' . esc_html(newsweek_google_font_name('newsweek_tablet_header_padding')) . 'px;
					}
				}';

		endif;

		if (newsweek_setting('newsweek_desktop_header_padding')) :

			$css .= '
				@media screen and (min-width : 992px) {
					body.home #header { 
						padding-bottom:' . esc_html(newsweek_google_font_name('newsweek_desktop_header_padding')) . 'px;
					}
				}';

		endif;

		/* =================== END HEADER IMAGE =================== */

		/* =================== BEGIN HEADER TEXT COLOR =================== */

		if (newsweek_setting('newsweek_header_text_color')) :

			$css .= '
				#header,
				#logo a,
				.header-search a,
				nav.header-menu ul li a,
				.open-modal-sidebar i { color:' . esc_html(newsweek_setting('newsweek_header_text_color')) . '}';
			
			$woocommerce .= '
				.header-cart a.cart-contents,
				.header-cart a span { color:' . esc_html(newsweek_setting('newsweek_header_text_color')) . '}';

		endif;
		
		/* =================== END HEADER TEXT COLOR =================== */

		/* =================== BEGIN LOGO STYLE =================== */

		if (newsweek_setting('newsweek_logo_font_family')) 
			$css .= "#logo a { font-family:".esc_html(newsweek_google_font_name('newsweek_logo_font_family'))."; }";

		if (newsweek_setting('newsweek_logo_font_size')) 
			$css .= "#logo a { font-size:".esc_html(newsweek_setting('newsweek_logo_font_size'))."; }";

		if (newsweek_setting('newsweek_logo_font_weight'))
			$css .= "#logo a { font-weight:" . esc_html(newsweek_setting('newsweek_logo_font_weight')) . ";}"; 
		
		if (newsweek_setting('newsweek_logo_text_transform'))
			$css .= "#logo a { text-transform:" . esc_html(newsweek_setting('newsweek_logo_text_transform')) . ";}"; 

		if (newsweek_setting('newsweek_logo_description_font_family')) 
			$css .= ".head-site-description span { font-family:".esc_html(newsweek_google_font_name('newsweek_logo_description_font_family'))."; }";

		if (newsweek_setting('newsweek_logo_description_font_weight')) 
			$css .= ".head-site-description span { font-weight:" . esc_html(newsweek_setting('newsweek_logo_description_font_weight')) . ";}"; 

		if (newsweek_setting('newsweek_logo_description_font_size')) 
			$css .= ".head-site-description span { font-size:".esc_html(newsweek_setting('newsweek_logo_description_font_size'))."; }";
		
		if (newsweek_setting('newsweek_mobile_logo_description_top_margin')) :

			$css .= '
				@media screen and (min-width : 0px) and (max-width : 599px)  {
					.head-site-description { 
						margin-top:' . esc_html(newsweek_setting('newsweek_mobile_logo_description_top_margin')) . 'px;
					}

				}';

		endif;

		if (newsweek_setting('newsweek_tablet_logo_description_top_margin')) :

			$css .= '
				@media screen and (min-width : 600px) and (max-width : 991px)  {
					.head-site-description { 
						margin-top:' . esc_html(newsweek_setting('newsweek_tablet_logo_description_top_margin')) . 'px;
					}
				}';

		endif;
		
		if (newsweek_setting('newsweek_desktop_logo_description_top_margin')) :

			$css .= '
				@media screen and (min-width : 992px) {
					.head-site-description { 
						margin-top:' . esc_html(newsweek_setting('newsweek_desktop_logo_description_top_margin')) . 'px;
					}
				}';

		endif;

		/* =================== END LOGO STYLE =================== */

		/* =================== BEGIN MAIN MENU STYLE =================== */

		if (newsweek_setting('newsweek_menu_font_family')) 
			$css .= "nav.header-menu ul li a, nav.header-menu ul ul li a { font-family:".esc_html(newsweek_google_font_name('newsweek_menu_font_family'))."; }";
		
		if ( newsweek_setting('newsweek_menu_font_size') )  : 
			$css .= "nav.header-menu ul li a { font-size:".esc_html(newsweek_setting('newsweek_menu_font_size'))."; }"; 
			$css .= "nav.header-menu ul ul li a { font-size:" . ( str_replace("px", "", esc_html(newsweek_setting('newsweek_menu_font_size'))) - 2 ) . "px;}"; 
		endif;
		
		if (newsweek_setting('newsweek_menu_font_weight'))
			$css .= "nav.header-menu ul li a { font-weight:" . esc_html(newsweek_setting('newsweek_menu_font_weight')) . ";}"; 
		
		if (newsweek_setting('newsweek_menu_text_transform'))
			$css .= "nav.header-menu ul li a { text-transform:" . esc_html(newsweek_setting('newsweek_menu_text_transform')) . ";}"; 

		/* =================== END MAIN MENU STYLE =================== */

		/* =================== BEGIN MOBILE MENU STYLE =================== */

		if (newsweek_setting('newsweek_mobile_menu_font_family')) 
			$css .= "nav#mobilemenu ul li a, nav#mobilemenu ul ul li a { font-family:".esc_html(newsweek_google_font_name('newsweek_mobile_menu_font_family'))."; }";

		if ( newsweek_setting('newsweek_mobile_menu_font_size') )  : 
			$css .= "nav#mobilemenu ul li a { font-size:".esc_html(newsweek_setting('newsweek_mobile_menu_font_size'))."; }"; 
			$css .= "nav#mobilemenu ul ul li a { font-size:" . ( str_replace("px", "", esc_html(newsweek_setting('newsweek_mobile_menu_font_size'))) - 2 ) . "px;}"; 
		endif;
		
		if (newsweek_setting('newsweek_mobile_menu_font_weight'))
			$css .= "nav#mobilemenu ul li a { font-weight:" . esc_html(newsweek_setting('newsweek_mobile_menu_font_weight')) . ";}"; 
		
		if (newsweek_setting('newsweek_mobile_menu_text_transform'))
			$css .= "nav#mobilemenu ul li a { text-transform:" . esc_html(newsweek_setting('newsweek_mobile_menu_text_transform')) . ";}"; 
		
		/* =================== END MOBILE MENU =================== */
		
		/* =================== BEGIN CONTENT STYLE =================== */
		
		if ( newsweek_setting('newsweek_content_font_size') ) :
			
			$css .= '
				.post-article a,
				.post-article p,
				.post-article li,
				.post-article address,
				.post-article dd,
				.post-article blockquote,
				.post-article td,
				.post-article th,
				.post-article span,
				.sidebar-area a,
				.sidebar-area p,
				.sidebar-area li,
				.sidebar-area address,
				.sidebar-area dd,
				.sidebar-area blockquote,
				.sidebar-area td,
				.sidebar-area th,
				.sidebar-area span,
				.textwidget { font-size:' . esc_html(newsweek_setting('newsweek_content_font_size')) . '}';
			
		endif;
		
		/* =================== END CONTENT STYLE =================== */
		
		/* =================== START TITLE STYLE =================== */

		if ( newsweek_setting('newsweek_h1_font_size') ) :
		
			$css .=  "
				h1, 
				h1.title, 
				h1.title a, 
				h1.title span { font-size:" . esc_html(newsweek_setting('newsweek_h1_font_size')) . "; }"; 
		
		endif;
		
		if ( newsweek_setting('newsweek_h2_font_size') ) :
		
			$css .=  "
				h2, 
				h2.title, 
				h2.title a, 
				h2.title span { font-size:" . esc_html(newsweek_setting('newsweek_h2_font_size')) . "; }"; 
		
		endif;
		
		if ( newsweek_setting('newsweek_h3_font_size') ) :
		
			$css .=  "
				h3, 
				h3.title, 
				h3.title a, 
				h3.title span { font-size:" . esc_html(newsweek_setting('newsweek_h3_font_size')) . "; }"; 
		
		endif;
		
		if ( newsweek_setting('newsweek_h4_font_size') ) :
		
			$css .=  "
				h4, 
				h4.title, 
				h4.title a, 
				h4.title span { font-size:" . esc_html(newsweek_setting('newsweek_h4_font_size')) . "; }"; 
		
		endif;
		
		if ( newsweek_setting('newsweek_h5_font_size') ) :
		
			$css .=  "
				h5, 
				h5.title, 
				h5.title a, 
				h5.title span { font-size:" . esc_html(newsweek_setting('newsweek_h5_font_size')) . "; }"; 
		
		endif;
		
		if ( newsweek_setting('newsweek_h6_font_size') ) :
		
			$css .=  "
				h6, 
				h6.title, 
				h6.title a, 
				h6.title span { font-size:" . esc_html(newsweek_setting('newsweek_h6_font_size')) . "; }"; 
		
		endif;

		if ( newsweek_setting('newsweek_headlines_font_family') ) :
		
			$css .=  "
	
				h1,
				h2,
				h3,
				h4,
				h5,
				h6,
				h1.title a,
				h2.title a,
				h3.title a,
				h4.title a,
				h5.title a,
				h6.title a,
				h1.title span,
				h2.title span,
				h3.title span,
				h4.title span,
				h5.title span,
				h6.title span { font-family:".esc_html(newsweek_google_font_name('newsweek_headlines_font_family'))."; }"; 
		
		endif;

		if ( newsweek_setting('newsweek_titles_font_weight') ) :
		
			$css .=  "
	
				h1,
				h2,
				h3,
				h4,
				h5,
				h6,
				h1.title a,
				h2.title a,
				h3.title a,
				h4.title a,
				h5.title a,
				h6.title a,
				h1.title span,
				h2.title span,
				h3.title span,
				h4.title span,
				h5.title span,
				h6.title span { font-weight:" . esc_html(newsweek_setting('newsweek_titles_font_weight')) . "; }"; 
		
		endif;
		
		if ( newsweek_setting('newsweek_titles_text_transform') ) :
		
			$css .=  "
	
				h1,
				h2,
				h3,
				h4,
				h5,
				h6,
				h1.title a,
				h2.title a,
				h3.title a,
				h4.title a,
				h5.title a,
				h6.title a { text-transform:" . esc_html(newsweek_setting('newsweek_titles_text_transform')) . "; }"; 
		
		endif;
		
		if ( newsweek_setting('newsweek_h2_font_size') && newsweek_is_woocommerce_active() ) :
		
			$woocommerce .=  "
				.cross-sells h2 span,
				.upsells-products h2 span,
				.related-products h2 span { font-size:" . esc_html(newsweek_setting('newsweek_h2_font_size')) . "; }"; 
		
		endif;

		/* =================== END TITLE STYLE =================== */

		/* =================== BEGIN POST META STYLE =================== */
		
		if ( newsweek_setting('newsweek_postmeta_font_size') ) :
			
			$css .= '
			.post-meta-author ,
			.post-meta-author a,
			.post-meta-date,
			.post-meta-category ,
			.post-meta-category a,
			.post-meta-icon { font-size:' . esc_html(newsweek_setting('newsweek_postmeta_font_size')) . ' !important}';
			
		endif;

		if ( newsweek_setting('newsweek_postmeta_text_transform') ) :
			
			$css .= '
			.post-meta-author ,
			.post-meta-date,
			.post-meta-category ,
			.post-meta-icon { text-transform:' . esc_html(newsweek_setting('newsweek_postmeta_text_transform')) . ' !important}';
			
		endif;

		/* =================== END POST META =================== */

		wp_add_inline_style( 'newsweek-style', $css );
		wp_add_inline_style( 'newsweek-woocommerce', $woocommerce );
		
	}

	add_action('wp_enqueue_scripts', 'newsweek_css_custom');

}

?>