<?php
function minigolf_custom_header_setup() {
	add_theme_support( 'custom-header', apply_filters( 'minigolf_custom_header_args', array(
		'default-image'      => '',
		'default-text-color' => 'fff',
		'width'              => 2000, 
		'height'             => 200,
		'flex-height'        => true,
		'wp-head-callback'   => 'minigolf_header_style',
	) ) );
}
add_action( 'after_setup_theme', 'minigolf_custom_header_setup' );

if ( ! function_exists( 'minigolf_header_style' ) ) :

function minigolf_header_style() {
	$header_text_color = get_header_textcolor();

	$topheader_logowidth = esc_attr(get_theme_mod('topheader_logowidth','auto'));

	$minigolf_logo_top_padding    = esc_attr(get_theme_mod('minigolf_logo_top_padding','2'));
	$minigolf_logo_left_padding   = esc_attr(get_theme_mod('minigolf_logo_left_padding','2'));
	$minigolf_logo_bottom_padding = esc_attr(get_theme_mod('minigolf_logo_bottom_padding','2'));
	$minigolf_logo_right_padding  = esc_attr(get_theme_mod('minigolf_logo_right_padding','2'));

  	$ourcourses_disable_section = esc_attr(get_theme_mod('ourcourses_disable_section','YES'));
  	$aboutus_disable_section    = esc_attr(get_theme_mod('aboutus_disable_section','YES'));

	$custom_css = "";

	
	// Logo
	$custom_css .= "
	.site-logo img {
		width: {$topheader_logowidth};
		padding-top: {$minigolf_logo_top_padding}px;
		padding-left: {$minigolf_logo_left_padding}px;
		padding-bottom: {$minigolf_logo_bottom_padding}px;
		padding-right: {$minigolf_logo_right_padding}px;
	}
	";

	// Header colors
	$custom_css .= "
	header.site-header .site-title {
		color: " . esc_attr(get_theme_mod('topheader_sitetitlecol')) . ";
	}
	header.site-header .site-logo a {
		text-decoration-color: " . esc_attr(get_theme_mod('topheader_sitetitlecol')) . " !important;
	}
	p.site-description {
		color: " . esc_attr(get_theme_mod('topheader_taglinecol')) . ";
	}
	
	.home .main-header .navbar .navbar-menu ul li a, 
	.main-header .navbar .navbar-menu ul li.dropdown>a::after {
		color: " . esc_attr(get_theme_mod('header_menuscolor')) . ";
	}
	.main-header .navbar .navbar-menu ul li.dropdown .sub-menu a:not(.remove) {
		color: " . esc_attr(get_theme_mod('header_submenutextcolor')) . ";
	}
	.main-header .navbar .navbar-menu ul li.dropdown .sub-menu a {
		background: " . esc_attr(get_theme_mod('header_submenusbgcolor')) . ";
	}
	.main-header .navbar .navbar-menu ul li.dropdown .sub-menu a:not(.remove) {
		border-left-color: " . esc_attr(get_theme_mod('header_submenusbordercolor')) . ";
	}
	.main-header .navbar .navbar-menu ul li.dropdown .sub-menu a:hover {
		background: " . esc_attr(get_theme_mod('header_submenusbghovercolor')) . " !important;
		color: " . esc_attr(get_theme_mod('header_submenustxthovercolor')) . ";
	}
	header .bn-btn a {
		color: " . esc_attr(get_theme_mod('header_btntextcolor')) . ";
	}
	header .bn-btn a {
		background: " . esc_attr(get_theme_mod('header_buttonbg_color')) . ";
	}
	
	";

	// slider
	$custom_css .= "
		.slider-area .sub-title {
			color: " . esc_attr(get_theme_mod('slider_subheadingcolor')) . ";
		}

		.slider-area h2 {
			color: " . esc_attr(get_theme_mod('slider_titlecolor')) . ";
		}

		.slider-area .slide-text p {
			color: " . esc_attr(get_theme_mod('slider_descriptioncolor')) . ";
		}

		.slider-area a.contactus {
			color: " . esc_attr(get_theme_mod('slider_btntxt1color')) . ";
		}

		.slider-area a.contactus {
			background: " . esc_attr(get_theme_mod('slider_btntxt1bgcolor')) . ";
		}

		.slider-area a.contactus:hover {
			color: " . esc_attr(get_theme_mod('slider_btntxthrvcolor')) . ";
		}

		.slider-area a.ReadMore {
			color: " . esc_attr(get_theme_mod('slider_btntxt2color')) . ";
			border-color: " . esc_attr(get_theme_mod('slider_btntxt2color')) . ";
		}

		.slider-area a.ReadMore:hover {
			color: " . esc_attr(get_theme_mod('slider_btn2txthrvcolor')) . ";
			border-color: " . esc_attr(get_theme_mod('slider_btn2txthrvcolor')) . ";
		}
	
	";


	// Our Service
	$custom_css .= "
	#ourcourses-section .subheading span {
		color: " . esc_attr(get_theme_mod('ourcourses_subheadingcolor')) . ";
	}
	#ourcourses-section .subheading .line {
		background: linear-gradient(to right, transparent, " . esc_attr(get_theme_mod('ourcourses_subheadingcolor')) . ");
	}
	#ourcourses-section .subheading .line.right {
		background: linear-gradient(to right, transparent, " . esc_attr(get_theme_mod('ourcourses_subheadingcolor')) . ");
	}
	#ourcourses-section .heading h2 {
		color: " . esc_attr(get_theme_mod('ourcourses_headingcolor')) . ";
	}
	#ourcourses-section h2 span {
		color: " . esc_attr(get_theme_mod('ourcourses_descriptioncolor')) . ";
	}
	#ourcourses-section .course-content h3 {
		color: " . esc_attr(get_theme_mod('ourcourses_boxtitlecolor')) . ";
	}
	#ourcourses-section .course-meta span strong {
		color: " . esc_attr(get_theme_mod('ourcourses_detailsheadingcolor')) . ";
	}
	#ourcourses-section .course-meta {
		color: " . esc_attr(get_theme_mod('ourcourses_detailsdescriptioncolor')) . ";
	}
	#ourcourses-section .course-content p {
		color: " . esc_attr(get_theme_mod('ourcourses_boxdescriptioncolor')) . ";
	}
	#ourcourses-section .course-content h3:after {
		background: linear-gradient(to left, transparent, " . esc_attr(get_theme_mod('ourcourses_boxbordercolor')) . ");
	}
	#ourcourses-section .buttn a {
		color: " . esc_attr(get_theme_mod('ourcourses_learnmorebtncolor')) . ";
	}
	#ourcourses-section .buttn svg {
		border-color: " . esc_attr(get_theme_mod('ourcourses_learnmorebtncolor')) . ";
	}
	#ourcourses-section .course-number {
		color: " . esc_attr(get_theme_mod('ourcourses_imgiconcolor')) . ";
	}
	#ourcourses-section .course-number {
		background: " . esc_attr(get_theme_mod('ourcourses_imgiconbgcolor')) . ";
	}
	#ourcourses-section {
		background: linear-gradient( to bottom right, " . esc_attr(get_theme_mod('ourcourses_bgcolor')) . ", " . esc_attr(get_theme_mod('ourcourses_bgcolor')) . ", " . esc_attr(get_theme_mod('ourcourses_bgcolor')) . " );
	}

	";

	// About us
	$custom_css .= "
	#aboutus-section .aboutus-head h4 {
		color: " . esc_attr(get_theme_mod('aboutus_headsubtitlecolor')) . ";
	}
	#aboutus-section .aboutus-head h4:before {
		background: linear-gradient(to right, transparent, " . esc_attr(get_theme_mod('aboutus_headsubtitlecolor')) . ");
	}
	
	#aboutus-section .aboutus-head h2 {
		color: " . esc_attr(get_theme_mod('aboutus_headtitlecolor')) . ";
	}
	#aboutus-section .abtright p {
		color: " . esc_attr(get_theme_mod('aboutus_headdescriptioncolor')) . ";
	}
	#aboutus-section .abtimg2 .imgtxt, #aboutus-section .abtimg3 .imgtxt {
		color: " . esc_attr(get_theme_mod('aboutus_imageheadingcolor')) . ";
	}
	#aboutus-section .abtimg2 .imgtxt, #aboutus-section .abtimg3 .imgtxt {
		background: " . esc_attr(get_theme_mod('aboutus_imageheadingbgcolor')) . ";
	}
	#aboutus-section .lists h6 {
		color: " . esc_attr(get_theme_mod('aboutus_listheadingcolor')) . ";
	}
	#aboutus-section .lists p {
		color: " . esc_attr(get_theme_mod('aboutus_listdescriptioncolor')) . ";
	}
	#aboutus-section .bttn a svg {
		fill: " . esc_attr(get_theme_mod('aboutus_buttoncolor')) . ";
		border-color: " . esc_attr(get_theme_mod('aboutus_buttoncolor')) . ";
	}
	#aboutus-section .bttn a {
		color: " . esc_attr(get_theme_mod('aboutus_buttoncolor')) . ";
	}
	#aboutus-section .bttn .vb-brd1:after {
		border-color: " . esc_attr(get_theme_mod('aboutus_buttonhvrcolor')) . ";
	}
	#aboutus-section .bttn a:hover svg {
		background: " . esc_attr(get_theme_mod('aboutus_buttonhvrcolor')) . ";
		border-color: " . esc_attr(get_theme_mod('aboutus_buttonhvrcolor')) . ";
	}
	";

	// Footer
	$custom_css .= "
	.footer-area {
		background: " . esc_attr(get_theme_mod('footer_bgcolor')) . ";
	}
	.copy-right p,.copy-right p a {
		color: " . esc_attr(get_theme_mod('footer_copyrightcolor')) . ";
	}
	.copy-right {
		border-color: " . esc_attr(get_theme_mod('footer_copyrightbrdcolor')) . ";
	}
	.footer-area .footer-widget .w-title {
		color: " . esc_attr(get_theme_mod('footer_widgettilecolor')) . ";
	}
	.footer-area .widget_text, .footer-area .widget_text p, .wp-block-latest-comments__comment-excerpt p, 
	.wp-block-latest-comments__comment-date, 
	.has-avatars .wp-block-latest-comments__comment .wp-block-latest-comments__comment-excerpt, 
	.has-avatars .wp-block-latest-comments__comment .wp-block-latest-comments__comment-meta,
	.footer-area .widget_block h1, 
	.footer-area .widget_block h2, 
	.footer-area .widget_block h3, 
	.footer-area .widget_block h4, 
	.footer-area .widget_block h5, 
	.footer-area .widget_block h6,
	.footer-area .footer-widget .widget:not(.widget_social_widget):not(.widget_tag_cloud) li a {
		color: " . esc_attr(get_theme_mod('footer_textcolor')) . ";
	}
	.footer-area li:before, 
	.page-template-home-template .footer-area li:before, 
	.page .footer-area li:before, 
	.single .footer-area li:before {
		color: " . esc_attr(get_theme_mod('footer_iconcolor')) . ";
	}
	.footer-area .footer-widget .widget:not(.widget_social_widget):not(.widget_tag_cloud) li a:hover {
		color: " . esc_attr(get_theme_mod('footer_listhovercolor')) . ";
	}
	.scroll-top i {
		color: " . esc_attr(get_theme_mod('footer_scrolltotopiconcolor')) . ";
	}
	.scroll-top {
		background: " . esc_attr(get_theme_mod('footer_scrolltotopiconbgcolor')) . ";
	}
	.scroll-top:hover {
		background: " . esc_attr(get_theme_mod('footer_scrolltotopiconbghrvcolor')) . ";
	}
	";

	// Header text
	if ( ! display_header_text() ) {
		$custom_css .= "
		.site-title,
		.site-description {
			position: absolute;
			clip: rect(1px,1px,1px,1px);
		}";
	} else {
		$custom_css .= "
		.breadcrumb-section h1, .breadcrumb-list li a, .breadcrumb-list li, breadcrumb-list span{
			color: #{$header_text_color} !important;
		}";
	}

	// Section disable
	if ( $ourcourses_disable_section == 1 ) {
		$custom_css .= "#ourcourses-section { display: none; }";
	} else {
		$custom_css .= "#ourcourses-section { display: block; }";
	}
	if ( $aboutus_disable_section == 1 ) {
		$custom_css .= "#aboutus-section { display: none; }";
	} else {
		$custom_css .= "#aboutus-section { display: block; }";
	}

	// Add inline style
	if ( ! empty( $custom_css ) ) {
		wp_add_inline_style( 'minigolf-style', $custom_css );
	}
}
endif;
add_action( 'wp_enqueue_scripts', 'minigolf_header_style' );
