<?php


function bexplore_custom_styles() {
	/**
	 * Customizer inline style
	 */

	//Fonts

	$custom_css = '';

	$headings_font = get_theme_mod('bexplore_headings_fonts');

	$body_font = get_theme_mod('bexplore_body_fonts');

	if ( $headings_font ) {

		$custom_css .= "h1, h2, h3, h4, h5, h6 { font-family: {$headings_font};}";

	}

	if ( $body_font ) {

		$custom_css .= "body, button, input, select, textarea { font-family: {$body_font};}";

	}

	$headings_font = esc_html(get_theme_mod('bexplore_headings_fonts'));
	$body_font = esc_html(get_theme_mod('bexplore_body_fonts'));

	if( $headings_font ) {
		wp_enqueue_style( 'bexplore-headings-fonts', '//fonts.googleapis.com/css?family='. $headings_font );
	} else {
		wp_enqueue_style( 'bexplore-source-sans', '//fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic');
	}
	if( $body_font ) {
		wp_enqueue_style( 'bexplore-body-fonts', '//fonts.googleapis.com/css?family='. $body_font );
	} else {
		wp_enqueue_style( 'bexplore-source-body', '//fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,400italic,700,600');
	}

	//Theme's Color Scheme

	$be_site_bg_color = get_theme_mod( 'be_site_background_color' );
	$be_default_text_color = get_theme_mod( 'be_default_text_color' );
	$heading_text_color = get_theme_mod( 'heading_text_color' );

	if ( ! empty( $be_site_bg_color ) || ! empty( $be_default_text_color ) || ! empty( $heading_text_color ) ) {

		$custom_css .= ':root {';

		if ( ! empty( $be_site_bg_color ) ) {
			$custom_css .= '--color-base: ' . esc_attr( $be_site_bg_color) . ';';
		}

		if ( ! empty( $be_default_text_color ) ) {
			$custom_css .= '--color-base-text: ' . esc_attr( $be_default_text_color) . ';';
		}

		if ( ! empty( $be_default_text_color ) ) {
			$custom_css .= '--color-base-text: ' . esc_attr( $be_default_text_color) . ';';
		}

		if ( ! empty( $heading_text_color ) ) {
			$custom_css .= '--color-heading-text: ' . esc_attr( $heading_text_color) . ';';
		}

		$custom_css .= '}';
	}

	//Header With BG style
	$header_image = get_theme_mod( 'header_image' );
	$header_bg_clr = get_theme_mod( 'bexplore_header_bg_clr' );
	$header_border_clr = get_theme_mod( 'bexplore_header_border_clr' );
	if ( ! empty( $header_image ) ) {
		$custom_css .= '
					.bexplore-header-area {
						background-image: url(' . esc_url( $header_image ) . ');
						background-repeat: no-repeat; background-size:cover;
					}
				';
	}
	if ( ! empty( $header_bg_clr ) ) {
		$custom_css .= '
					.bexplore-header-area {background-color: ' . esc_attr( $header_bg_clr ) . '; }
				';
	}
	if ( ! empty( $header_border_clr ) ) {
		$custom_css .= '
					.bexplore-header-area {border-bottom-color: ' . esc_attr( $header_border_clr ) . '; }
				';
	}

	//Breadcrumb style
	$breadcrumb_bg_img = get_theme_mod( 'bexplore_breadcrumb_bg_img' );
	$breadcrumb_bg_clr = get_theme_mod( 'bexplore_breadcrumb_bg_clr' );
	$breadcrumb_overlay_bg_clr = get_theme_mod( 'bexplore_breadcrumb_overlay_bg_clr' );
	$breadcrumb_overlay_opacity = get_theme_mod( 'bexplore_breadcrumb_overlay_opacity' );
	$breadcrumb_txt_clr = get_theme_mod( 'bexplore_breadcrumb_txt_clr' );
	$breadcrumb_txt_hvr_clr = get_theme_mod( 'bexplore_breadcrumb_txt_hvr_clr' );
	if ( ! empty( $breadcrumb_bg_img ) ) {
		$custom_css .= '
						.bexplore-breadcrumbs-area {background-image: url(' . esc_url( $breadcrumb_bg_img ) . '); }
					';
	}
	if ( ! empty( $breadcrumb_bg_clr ) ) {
		$custom_css .= '
					.bexplore-breadcrumbs-area {background-color: ' . esc_attr( $breadcrumb_bg_clr ) . '; }
				';
	}
	if ( ! empty( $breadcrumb_overlay_bg_clr ) ) {
		$custom_css .= '
					.bexplore-breadcrumbs-area:after {background-color: ' . esc_attr( $breadcrumb_overlay_bg_clr ) . '; }
				';
	}
	if ( ! empty( $breadcrumb_overlay_opacity ) ) {
		$custom_css .= '
					.bexplore-breadcrumbs-area:after {opacity: ' . esc_attr( $breadcrumb_overlay_opacity ) . '; }
				';
	}
	if ( ! empty( $breadcrumb_txt_clr ) ) {
		$custom_css .= '
					.bexplore-breadcrumbs .bexplore-breadcrumbs-title,
					.bexplore-breadcrumbs li,
					.bexplore-breadcrumbs a {color: ' . esc_attr( $breadcrumb_txt_clr ) . '; }
				';
	}
	if ( ! empty( $breadcrumb_txt_hvr_clr ) ) {
		$custom_css .= '
					.bexplore-breadcrumbs a:hover{color: ' . esc_attr( $breadcrumb_txt_hvr_clr ) . '; }
				';
	}

	//Footer style
	$footer_bg_clr = get_theme_mod( 'bexplore_footer_bg_clr' );

	if ( ! empty( $footer_bg_clr ) ) {
		$custom_css .= '
					footer.bexplore-footer-section {background-color: ' . esc_attr( $footer_bg_clr ) . '; }
				';
	}

	wp_register_style( 'bexplore-css', false );
	wp_enqueue_style( 'bexplore-css' );

	if ( ! empty( $custom_css ) ) {
		wp_add_inline_style( 'bexplore-css', $custom_css );
	}

}

add_action( 'wp_enqueue_scripts', 'bexplore_custom_styles' );
