<?php
/**
* Loads all the components related to customizer 
*
* @since Blogto 1.0.0
*/
require get_parent_theme_file_path( '/modules/customizer/framework/customizer.php' );
require get_parent_theme_file_path( '/modules/customizer/panels/panels.php' );
require get_parent_theme_file_path( '/modules/customizer/sections/sections.php' );

require get_parent_theme_file_path( '/modules/customizer/settings/general.php' );
require get_parent_theme_file_path( '/modules/customizer/settings/frontpage.php' );
require get_parent_theme_file_path( '/modules/customizer/defaults/defaults.php' );


function blogto_modify_default_settings( $wp_customize ){

	$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
	$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
	$wp_customize->get_setting( 'background_color' )->transport = 'postMessage';
	$wp_customize->get_control( 'background_color' )->label = esc_html__( 'Background', 'blogto' );
}
add_action( 'blogto_customize_register', 'blogto_modify_default_settings' );

function blogto_default_styles(){
	
	$site_title_color           = blogto_get_option( 'site_title_color' );
	$site_tagline_color         = blogto_get_option( 'site_tagline_color' );
	$primary_color              = blogto_get_option( 'site_primary_color' );

	$slider_control             = blogto_get_option( 'slider_control' );

	$callback_bg                = blogto_get_callback_banner_url();
	
	?>
	<style type="text/css">
		.offcanvas-menu-open .kt-offcanvas-overlay {
		    position: fixed;
		    width: 100%;
		    height: 100%;
		    background: rgba(0, 0, 0, 0.7);
		    opacity: 1;
		    z-index: 9;
		    top: 0px;
		}

		.kt-offcanvas-overlay {
		    width: 0;
		    height: 0;
		    opacity: 0;
		    transition: opacity 0.5s;
		}

		<?php if( !blogto_get_option( 'enable_alternate_header' ) ): ?>
			.site-header .row {
				align-items: center;
				display: -webkit-box;
				display: -webkit-flex;
				display:    -moz-flex;
				display:     -ms-flex;
				display:         flex;
			}
		<?php endif; ?>
		
		.masonry-grid.wrap-post-list {
			width: 100% !important;
		}

		<?php if( !$slider_control ): ?>
			.block-slider .controls, .block-slider .owl-pager{
				opacity: 0;
			}
		<?php endif; ?>

		.block-callback {
		   background-image: url(<?php echo esc_url( $callback_bg ); ?> );
		 }

		/*======================================*/
		/* Site title */
		/*======================================*/
		.site-header .site-branding .site-title,
		.site-header .site-branding .site-title a {
			color: <?php echo esc_attr( $site_title_color ); ?>;
		} 

		/*======================================*/
		/* Tagline title */
		/*======================================*/
		.site-header .site-branding .site-description {
			color: <?php echo esc_attr( $site_tagline_color ); ?>;
		}

		/*======================================*/
		/* Primary color */
		/*======================================*/

		/*======================================*/
		/* Background Primary color */
		/*======================================*/
		#go-top span:hover, #go-top span:focus, #go-top span:active, .page-numbers.current,
		.searchform .search-button, .button-primary, .wrap-detail-page .contact-form-section input[type="submit"], .wrap-detail-page .kt-contact-form-area .form-group input.form-control[type="submit"], .block-grid .post-content .post-content-inner span.cat a, .block-grid .post-content .post-content-inner .button-container .post-footer-detail .post-format-outer > span span, .comments-area .comment-respond .comment-form .submit, .wrap-detail-page form input[type="submit"], .widget.widget_mc4wp_form_widget input[type="submit"] {
			background-color: <?php echo esc_attr( $primary_color ); ?>
		}

		/*======================================*/
		/* Primary border color */
		/*======================================*/
		#go-top span:hover, #go-top span:focus, #go-top span:active,
		.main-navigation ul ul, .page-numbers.current,
		.searchform .search-button, .button-primary, .wrap-detail-page .contact-form-section input[type="submit"], .wrap-detail-page .kt-contact-form-area .form-group input.form-control[type="submit"], .comments-area .comment-respond .comment-form .submit, .wrap-detail-page form input[type="submit"], .widget.widget_mc4wp_form_widget input[type="submit"] {
			border-color: <?php echo esc_attr( $primary_color ); ?>
		}

	</style>
	<?php
}
add_action( 'wp_head', 'blogto_default_styles' );

/**
* Load customizer preview js file
*/
function blogto_customize_preview_js() {
	wp_enqueue_script( 'blogto-customize-preview', get_theme_file_uri( '/assets/js/customizer/customize-preview.js' ), array( 'jquery', 'customize-preview'), '1.0', true );
}
add_action( 'customize_preview_init', 'blogto_customize_preview_js' );