<?php
/**
 * The header for our theme
 *
 * This is the template that displays all of the <head> section and everything up until <div id="content">
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package Code_Manas
 */

?>
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
	<meta charset="<?php bloginfo( 'charset' ); ?>">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="profile" href="https://gmpg.org/xfn/11">

	<?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>

<?php 
if ( function_exists( 'wp_body_open' ) ) {
    wp_body_open();
} else {
    do_action( 'wp_body_open' );
}
?>

<div id="page" class="hfeed site">
	<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'code-manas' ); ?></a>

	<header id="masthead" class="site-header">
		<div class="menu-overlay"></div>
		<div class="container">
			<div class="site-branding">
				<?php the_custom_logo(); ?>
				<div id="site-identity">
					<?php if ( is_front_page() && is_home() ) : ?>
						<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
						<?php
					else :
						?>
						<p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
						<?php
					endif;

					$code_manas_description = get_bloginfo( 'description', 'display' );
					if ( $code_manas_description || is_customize_preview() ) : ?>
						<p class="site-description"><?php echo $code_manas_description; /* WPCS: xss ok. */ ?></p>
					<?php endif; ?>
				</div><!-- .site-identity -->
			</div><!-- .site-branding -->
        	<?php if ( has_nav_menu( 'menu-1' ) ) : ?>
				<div id="site-header-menu" class="site-header-menu">
				    <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
	                    <span class="icon"></span>
	                    <span class="menu-label open"><?php esc_html_e( 'Menu', 'code-manas' );?></span>
	                    <span class="menu-label close"><?php esc_html_e( 'Close', 'code-manas' );?></span>
	                    <svg class="icon icon-close " aria-hidden="true" role="img"> <use href="#icon-close" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-close"></use> </svg>
	                </button>
		        		<?php
		        		wp_nav_menu( array(
		        			'theme_location' => 'menu-1',
		        			'menu_id'        => 'primary-menu',
		        			'menu_class'        => 'menu nav-menu',
		        			'container'		=> 'nav',
		        			'container_class'		=> 'main-navigation',
		        			'container_id'		=> 'site-navigation',
		        		) );
	        		?>
		    	</div><!-- #site-header-menu -->
		    <?php endif; ?>
		</div><!-- .container -->
	</header><!-- #masthead -->

	<?php 
	// Get all default values.
	$default = cm_kirki_fields()->get_theme_mods_defaults();

	$featured_enabled = get_theme_mod( 'featured_enable', 0 ); 
	$featured_enable_on = get_theme_mod( 'featured_enable_on', $default['featured_enable_on'] ); 
	$featured_enabled_on_homepage = ( is_home() || is_front_page() ) && 'homepage' === $featured_enable_on;

	if ( $featured_enabled && ( $featured_enabled_on_homepage || 'entire-site' === $featured_enable_on  ) ) : ?>
		<div class="manas-featured-section">
			<?php  
			if ( 'image' === get_theme_mod( 'featured_bg', $default['featured_bg'] ) ) {
				$style_attr = 'background-image: url(' . esc_url( get_header_image() ) . ');';
			} else {
				$style_attr = 'background-color:' . get_theme_mod( 'featured_bg_color', $default['featured_bg_color'] );
			}
			?>
			<div class="custom-featured-image" style="<?php echo esc_attr( $style_attr ); ?>">
			</div>
			<div class="featured-text-content">
				<h1><?php echo esc_html( get_theme_mod( 'featured_title', $default['featured_title'] ) ); ?></h1>
				<h2 class="theme-tagline"><?php echo wp_kses_post( get_theme_mod( 'featured_content', $default['featured_content'] ) ); ?></h2>
			</div>
		</div><!--manas featured section-->
	<?php endif; ?>

	<?php if ( has_nav_menu( 'menu-2' ) ) : ?>
		<div class="page-menu-container">
			<div class="container">
				<button class="secondary-menu-toggle" aria-controls="secondary-menu" aria-expanded="false">
					<span class="icon"></span>
	                <span class="menu-label open"><?php esc_html_e( 'Menu', 'code-manas' );?></span>
	                <span class="menu-label close"><?php esc_html_e( 'Close', 'code-manas' );?></span>
				</button>
				<div class="page-menu-wrapper">
					<?php
					wp_nav_menu( array(
						'theme_location' => 'menu-2',
						'menu_id'        => 'custom-page-menu',
						'menu_class'        => 'custom-page-menu',
						'container'		=> 'div',
						'container_class'		=> 'page-menu-wrapper',
					) );
					?>
				</div>
			</div>
		</div><!--page menu container-->
	<?php endif; ?>
