<?php
/*
 * print css with cheking value is empty or not
 *
 */
function bestel_print_css( $props = '', $values = array(), $vkey = '', $pre_fix = '', $post_fix = '' ) {
	if ( isset( $values[ $vkey ] ) && ! empty( $values[ $vkey ] ) ) {
		print wp_kses_post( $props . ':' . $pre_fix . $values[ $vkey ] . $post_fix . ";\n" );
	}

}

function bestel_color_brightness( $colourstr, $steps, $darken = false ) {
	$colourstr = str_replace( '#', '', $colourstr );
	$rhex      = substr( $colourstr, 0, 2 );
	$ghex      = substr( $colourstr, 2, 2 );
	$bhex      = substr( $colourstr, 4, 2 );

	$r = hexdec( $rhex );
	$g = hexdec( $ghex );
	$b = hexdec( $bhex );

	if ( $darken ) {
		$steps = $steps * -1;
	}

	$r = max( 0, min( 255, $r + $steps ) );
	$g = max( 0, min( 255, $g + $steps ) );
	$b = max( 0, min( 255, $b + $steps ) );

	$hex  = '#';
	$hex .= str_pad( dechex( $r ), 2, '0', STR_PAD_LEFT );
	$hex .= str_pad( dechex( $g ), 2, '0', STR_PAD_LEFT );
	$hex .= str_pad( dechex( $b ), 2, '0', STR_PAD_LEFT );

	return $hex;
}
function bestel_get_custom_styles() {
	global $bestel_opt;
	$redix_opt_prefix = 'bestel';

	$bestel_colors    = get_theme_mod( 'bestel_colors', array() );
	$bestel_print_css = get_theme_mod( 'bestel_print_css', array() );

	ob_start();

	?>
	body{
		<?php
		if ( isset( $bestel_opt[ $redix_opt_prefix . '-body_typography' ] ) ) {
			bestel_print_css( 'font-family', $bestel_opt[ $redix_opt_prefix . '-body_typography' ], 'font-family' );
			bestel_print_css( 'font-weight', $bestel_opt[ $redix_opt_prefix . '-body_typography' ], 'font-weight' );
			bestel_print_css( 'font-size', $bestel_opt[ $redix_opt_prefix . '-body_typography' ], 'font-size' );
			bestel_print_css( 'line-height', $bestel_opt[ $redix_opt_prefix . '-body_typography' ], 'line-height' );
			bestel_print_css( 'color', $bestel_opt[ $redix_opt_prefix . '-body_typography' ], 'color' );
		}
		?>
	}
 h1,.h1{
		<?php
		if ( isset( $bestel_opt[ $redix_opt_prefix . '-heading-1-typography' ] ) ) {
			bestel_print_css( 'font-family', $bestel_opt[ $redix_opt_prefix . '-heading-1-typography' ], 'font-family' );
			bestel_print_css( 'font-weight', $bestel_opt[ $redix_opt_prefix . '-heading-1-typography' ], 'font-weight' );
			bestel_print_css( 'font-size', $bestel_opt[ $redix_opt_prefix . '-heading-1-typography' ], 'font-size' );
			bestel_print_css( 'line-height', $bestel_opt[ $redix_opt_prefix . '-heading-1-typography' ], 'line-height' );
			bestel_print_css( 'color', $bestel_opt[ $redix_opt_prefix . '-heading-1-typography' ], 'color' );
		}
		?>
	}
	h2,.h2{
		<?php
		if ( isset( $bestel_opt[ $redix_opt_prefix . '-heading-2-typography' ] ) ) {
			bestel_print_css( 'font-family', $bestel_opt[ $redix_opt_prefix . '-heading-2-typography' ], 'font-family' );
			bestel_print_css( 'font-weight', $bestel_opt[ $redix_opt_prefix . '-heading-2-typography' ], 'font-weight' );
			bestel_print_css( 'font-size', $bestel_opt[ $redix_opt_prefix . '-heading-2-typography' ], 'font-size' );
			bestel_print_css( 'line-height', $bestel_opt[ $redix_opt_prefix . '-heading-2-typography' ], 'line-height' );
			bestel_print_css( 'color', $bestel_opt[ $redix_opt_prefix . '-heading-2-typography' ], 'color' );
		}
		?>
	}
	h3{
		<?php
		if ( isset( $bestel_opt[ $redix_opt_prefix . '-heading-3-typography' ] ) ) {
			bestel_print_css( 'font-family', $bestel_opt[ $redix_opt_prefix . '-heading-3-typography' ], 'font-family' );
			bestel_print_css( 'font-weight', $bestel_opt[ $redix_opt_prefix . '-heading-3-typography' ], 'font-weight' );
			bestel_print_css( 'font-size', $bestel_opt[ $redix_opt_prefix . '-heading-3-typography' ], 'font-size' );
			bestel_print_css( 'line-height', $bestel_opt[ $redix_opt_prefix . '-heading-3-typography' ], 'line-height' );
			bestel_print_css( 'color', $bestel_opt[ $redix_opt_prefix . '-heading-3-typography' ], 'color' );
		}
		?>
	}
   h4{
		<?php
		if ( isset( $bestel_opt[ $redix_opt_prefix . '-heading-4-typography' ] ) ) {
			bestel_print_css( 'font-family', $bestel_opt[ $redix_opt_prefix . '-heading-4-typography' ], 'font-family' );
			bestel_print_css( 'font-weight', $bestel_opt[ $redix_opt_prefix . '-heading-4-typography' ], 'font-weight' );
			bestel_print_css( 'font-size', $bestel_opt[ $redix_opt_prefix . '-heading-4-typography' ], 'font-size' );
			bestel_print_css( 'line-height', $bestel_opt[ $redix_opt_prefix . '-heading-4-typography' ], 'line-height' );
			bestel_print_css( 'color', $bestel_opt[ $redix_opt_prefix . '-heading-4-typography' ], 'color' );
		}
		?>
	}
	h5{
		<?php
		if ( isset( $bestel_opt[ $redix_opt_prefix . '-heading-5-typography' ] ) ) {
			bestel_print_css( 'font-family', $bestel_opt[ $redix_opt_prefix . '-heading-5-typography' ], 'font-family' );
			bestel_print_css( 'font-weight', $bestel_opt[ $redix_opt_prefix . '-heading-5-typography' ], 'font-weight' );
			bestel_print_css( 'font-size', $bestel_opt[ $redix_opt_prefix . '-heading-5-typography' ], 'font-size' );
			bestel_print_css( 'line-height', $bestel_opt[ $redix_opt_prefix . '-heading-5-typography' ], 'line-height' );
			bestel_print_css( 'color', $bestel_opt[ $redix_opt_prefix . '-heading-5-typography' ], 'color' );
		}
		?>
	}
	h6{
		<?php
		if ( isset( $bestel_opt[ $redix_opt_prefix . '-heading-6-typography' ] ) ) {
			bestel_print_css( 'font-family', $bestel_opt[ $redix_opt_prefix . '-heading-6-typography' ], 'font-family' );
			bestel_print_css( 'font-weight', $bestel_opt[ $redix_opt_prefix . '-heading-6-typography' ], 'font-weight' );
			bestel_print_css( 'font-size', $bestel_opt[ $redix_opt_prefix . '-heading-6-typography' ], 'font-size' );
			bestel_print_css( 'line-height', $bestel_opt[ $redix_opt_prefix . '-heading-6-typography' ], 'line-height' );
			bestel_print_css( 'color', $bestel_opt[ $redix_opt_prefix . '-heading-6-typography' ], 'color' );
		}
		?>
	}
	.car_repair_services_wc_products_tab.vc_tta.vc_tta-style-classic .vc_tta-tab a{ <?php bestel_print_css( 'font-family', $bestel_opt[ $redix_opt_prefix . '-body_typography' ], 'font-family' ); ?> }
	.widget-title, .title-contact-info, .widgettitle{
	<?php if ( isset( $bestel_opt[ $redix_opt_prefix . '-widget_title_typography' ] ) ) { ?>
		<?php bestel_print_css( 'font-family', $bestel_opt[ $redix_opt_prefix . '-widget_title_typography' ], 'font-family' ); ?>
		<?php bestel_print_css( 'font-weight', $bestel_opt[ $redix_opt_prefix . '-widget_title_typography' ], 'font-weight' ); ?>
		<?php bestel_print_css( 'font-size', $bestel_opt[ $redix_opt_prefix . '-widget_title_typography' ], 'font-size' ); ?>
		<?php bestel_print_css( 'color', $bestel_opt[ $redix_opt_prefix . '-widget_title_typography' ], 'color' ); ?>
	<?php } ?>
	}
	@keyframes pulse {
	0% {
	  transform: scale(1); 
	}
	50% {
	  transform: scale(1.35); 
	}
	100% {
	  transform: scale(1); 
	} 
	}
	<?php

	if ( isset( $bestel_opt['extra_css'] ) ) {
		echo sprintf( __( '%s', 'bestel' ), $bestel_opt['extra_css'] );
	}

	$bestel_custom_css = ob_get_clean();

	return $bestel_custom_css;
}





