<?php
/**
 * The header for our theme
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package roof_water_proofing
 */
$roof_water_proofing_header_button_label = get_theme_mod( 'roof_water_proofing_header_button_label_', '' );
$roof_water_proofing_header_button_link  = get_theme_mod( 'roof_water_proofing_header_button_link_', '' );
$roof_water_proofing_top_header_phone_number = get_theme_mod( 'roof_water_proofing_top_header_phone_number', '' );
$roof_water_proofing_top_header_email_id = get_theme_mod( 'roof_water_proofing_top_header_email_id', '' );

$roof_water_proofing_menu_text_color = get_theme_mod('roof_water_proofing_menu_text_color', '#000000'); 
$roof_water_proofing_sub_menu_text_color = get_theme_mod('roof_water_proofing_sub_menu_text_color', 'var(--background-color-white)'); 

?>
<!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(get_theme_mod('roof_water_proofing_website_layout', false) ? 'site-boxed--layout' : ''); ?>>
<?php wp_body_open(); ?>
<div id="page" class="site asterthemes-site-wrapper">
<a class="skip-link screen-reader-text" href="#primary"><?php esc_html_e( 'Skip to content', 'roof-water-proofing' ); ?></a>
    <?php if (get_theme_mod('roof_water_proofing_enable_preloader', false)) : ?>
        <div id="loader" class="<?php echo esc_attr(get_theme_mod('roof_water_proofing_preloader_style', 'style1')); ?>">
            <div class="loader-container">
                <div id="preloader">
                    <?php 
                    $roof_water_proofing_preloader_style = get_theme_mod('roof_water_proofing_preloader_style', 'style1');
                    if ($roof_water_proofing_preloader_style === 'style1') : ?>
                        <!-- STYLE 1 -->
                        <img src="<?php echo esc_url(get_template_directory_uri() . '/resource/loader.gif'); ?>" alt="<?php esc_attr_e('Loading...', 'roof-water-proofing'); ?>">
                    <?php elseif ($roof_water_proofing_preloader_style === 'style2') : ?>
                        <!-- STYLE 2 -->
                        <div class="dot"></div>
                    <?php elseif ($roof_water_proofing_preloader_style === 'style3') : ?>
                        <!-- STYLE 3 -->
                        <div class="bars">
                            <div class="bar"></div>
                            <div class="bar"></div>
                            <div class="bar"></div>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    <?php endif; ?>
<header id="masthead" class="site-header">
    <?php if ( get_theme_mod( 'roof_water_proofing_enable_topbar', false ) === true ) {
        ?>
        <div class="top-header-part">
            <div class="asterthemes-wrapper">
                <div class="top-header-part-wrapper">
                    <div class="top-header-left-part">
                        <?php if ( ! empty( $roof_water_proofing_top_header_phone_number ) ) { ?>
                            <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512"><!--!Font Awesome Free 7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M497.4 361.8l-112-48a24 24 0 0 0 -28 6.9l-49.6 60.6A370.7 370.7 0 0 1 130.6 204.1l60.6-49.6a23.9 23.9 0 0 0 6.9-28l-48-112A24.2 24.2 0 0 0 122.6 .6l-104 24A24 24 0 0 0 0 48c0 256.5 207.9 464 464 464a24 24 0 0 0 23.4-18.6l24-104a24.3 24.3 0 0 0 -14-27.6z"/></svg><span><a href="tel:<?php echo esc_html( $roof_water_proofing_top_header_phone_number ); ?>"><?php echo esc_html( $roof_water_proofing_top_header_phone_number ); ?></a></span> 
                       <?php } ?>
                    </div>
                    <div class="top-header-left-part">
                        <?php if ( ! empty( $roof_water_proofing_top_header_email_id ) ) { ?>
                            <svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512"><!--!Font Awesome Free 7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M464 64H48C21.5 64 0 85.5 0 112v288c0 26.5 21.5 48 48 48h416c26.5 0 48-21.5 48-48V112c0-26.5-21.5-48-48-48zm0 48v40.8c-22.4 18.3-58.2 46.7-134.6 106.5-16.8 13.2-50.2 45.1-73.4 44.7-23.2 .4-56.6-31.5-73.4-44.7C106.2 199.5 70.4 171.1 48 152.8V112h416zM48 400V214.4c22.9 18.3 55.4 43.9 104.9 82.6 21.9 17.2 60.1 55.2 103.1 55 42.7 .2 80.5-37.2 103.1-54.9 49.5-38.8 82-64.4 104.9-82.7V400H48z"/></svg><span>
                                <a href="mailto:<?php echo esc_html( $roof_water_proofing_top_header_email_id ); ?>"><?php echo esc_html( $roof_water_proofing_top_header_email_id ); ?></a>
                            </span>
                        <?php } ?>
                    </div>
                    
                    <div class="top-top-header-left-part">
                        <div class="socail-search">
                            <div class="social-icons">
                                <?php
                                if ( has_nav_menu( 'social' ) ) {
                                    wp_nav_menu(
                                        array(
                                            'menu_class'     => 'menu social-links',
                                            'link_before'    => '<span class="screen-reader-text">',
                                            'link_after'     => '</span>',
                                            'theme_location' => 'social',
                                        )
                                    );
                                }
                                ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    <?php } ?>
    <div class="header-main-wrapper">
        <div class="bottom-header-outer-wrapper <?php echo esc_attr( get_theme_mod( 'roof_water_proofing_enable_sticky_header', false ) ? 'sticky-header' : '' ); ?>">
            <div class="bottom-header-part">
                <div class="asterthemes-wrapper">
                    <div class="bottom-header-part-wrapper hello ">
                        <div class="bottom-header-middle-part">
                            <div class="site-branding">
                                <?php
                                // Check if the 'Enable Site Logo' setting is true.
                                if ( get_theme_mod( 'roof_water_proofing_enable_site_logo', true ) ) {
                                    if ( has_custom_logo() ) { ?>
                                        <div class="site-logo">
                                            <?php the_custom_logo(); ?>
                                        </div>
                                    <?php } else { ?>
                                        <div class="site-logo">
                                            <!-- Fallback logo if no custom logo is set -->
                                            <a href="<?php echo esc_url(home_url('/')); ?>" rel="home">
                                                <img src="<?php echo esc_url(get_template_directory_uri() . '/resource/img/logo.png'); ?>" alt="<?php bloginfo('name'); ?>">
                                            </a>
                                        </div>
                                    <?php }
                                } ?>
                                <div class="site-identity">
                                        <?php
                                            if ( get_theme_mod( 'roof_water_proofing_enable_site_title_setting', false ) ) {
                                                // Get the site title
                                                $site_title = get_bloginfo( 'name' );
                                                
                                                // Explode the title into words and extract the last one
                                                $title_parts = explode(' ', $site_title);
                                                $last_word = array_pop($title_parts);
                                                $title_without_last_word = implode(' ', $title_parts);

                                                if ( is_front_page() && is_home() ) :
                                                    ?>
                                                    <h1 class="site-title">
                                                        <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
                                                            <?php echo $title_without_last_word . ' <span class="yellow-text">' . $last_word . '</span>'; ?>
                                                        </a>
                                                    </h1>
                                                    <?php
                                                else :
                                                    ?>
                                                    <p class="site-title">
                                                        <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
                                                            <?php echo $title_without_last_word . ' <span class="yellow-text">' . $last_word . '</span>'; ?>
                                                        </a>
                                                    </p>
                                                    <?php
                                                endif;
                                            }

                                        if ( get_theme_mod( 'roof_water_proofing_enable_tagline_setting', false ) ) :
                                            $roof_water_proofing_description = get_bloginfo( 'description', 'display' );

                                            if ( $roof_water_proofing_description || is_customize_preview() ) :
                                                ?>
                                            <p class="site-description">
                                                <?php
                                                echo esc_html( $roof_water_proofing_description ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 
                                                ?>
                                            </p>
                                                <?php
                                            endif;
                                                ?>
                                        <?php endif; ?>
                                </div>
                            </div>
                        </div>
                        <div class="bottom-header-left-part">
                            <div class="navigation-part">
                                <nav id="site-navigation" class="main-navigation">
                                    <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
                                        <span></span>
                                        <span></span>
                                        <span></span>
                                    </button>
                                    <div class="main-navigation-links">
                                        <?php
                                            wp_nav_menu(
                                                array(
                                                    'theme_location' => 'primary',
                                                )
                                            );
                                        ?>
                                    </div>
                                    <style>
                                        /* Main Menu Links */
                                        .main-navigation ul li a, .menu a {
                                            color: <?php echo esc_attr($roof_water_proofing_menu_text_color); ?>;
                                        }

                                        /* Submenu Links */
                                        .main-navigation ul.children a, 
                                        .home .main-navigation ul.children a, 
                                        .main-navigation ul.menu li .sub-menu a, 
                                        .home .main-navigation ul ul a {
                                            color: <?php echo esc_attr($roof_water_proofing_sub_menu_text_color); ?>;
                                        }
                                    </style>
                                </nav>
                            </div>
                        </div>
                        <div class="bottom-header-right-part">
                            <?php
                                $roof_water_proofing_enable_header_search_section = get_theme_mod( 'roof_water_proofing_enable_header_search_section', true );
                                if ( $roof_water_proofing_enable_header_search_section ) : ?>
                                <span class="search-main">
                                  <span class="btn">
                                    <i class="fa fa-search" aria-hidden="true"></i>
                                  </span>
                                  <div class="form">
                                    <form method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
                                        <label>
                                            <span class="screen-reader-text"><?php echo esc_html( 'Search for:', 'label', 'roof-water-proofing' ); ?></span>
                                            <input type="search" class="search-field" placeholder="<?php echo esc_attr_x( 'Search...', 'placeholder', 'roof-water-proofing' ); ?>" value="<?php echo get_search_query(); ?>" name="s" />
                                        </label>
                                        <button type="submit" class="search-submit"><span class="screen-reader-text"><?php echo esc_html( 'Search', 'submit button', 'roof-water-proofing' ); ?></span></button>
                                    </form>
                                  </div>
                                </span>
                            <?php endif; ?>
                            <?php if ( ! empty( $roof_water_proofing_header_button_label ) ) { ?>
                                <div class="header-btn">
                                    <a href="<?php echo esc_url( $roof_water_proofing_header_button_link ); ?>" class="asterthemes-button"><?php echo esc_html( $roof_water_proofing_header_button_label ); ?></a>
                                </div>
                            <?php } ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</header>
<?php
if ( ! is_front_page() || is_home() ) {
	if ( is_front_page() ) {
		require get_template_directory() . '/sections/sections.php';
		roof_water_proofing_homepage_sections();

	}
	?>
    <?php
        if (!is_front_page() || is_home()) {
            get_template_part('page-header');
        }
    ?>
	<div id="content" class="site-content">
		<div class="asterthemes-wrapper">
			<div class="asterthemes-page">
			<?php } ?>