<?php

/**
 * The header for our theme
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package aster_travel_blog
 */
$aster_travel_blog_menu_text_transform = get_theme_mod('menu_text_transform', 'capitalize');
$aster_travel_blog_menu_text_transform_css = ( $aster_travel_blog_menu_text_transform !== 'capitalize' ) ? 'text-transform: ' . $aster_travel_blog_menu_text_transform . ';' : '';
$aster_travel_blog_menu_text_color = get_theme_mod('aster_travel_blog_menu_text_color', ''); 
$aster_travel_blog_sub_menu_text_color = get_theme_mod('aster_travel_blog_sub_menu_text_color', ''); 
?>

<!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('aster_travel_blog_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', 'aster-travel-blog'); ?></a>
<?php if (get_theme_mod('aster_travel_blog_enable_preloader', false)) : ?>
    <div id="loader" class="<?php echo esc_attr(get_theme_mod('aster_travel_blog_preloader_style', 'style1')); ?>">
        <div class="loader-container">
            <div id="preloader">
                <?php 
                $aster_travel_blog_preloader_style = get_theme_mod('aster_travel_blog_preloader_style', 'style1');
                if ($aster_travel_blog_preloader_style === 'style1') : ?>
                    <!-- STYLE 1 -->
                    <img src="<?php echo esc_url(get_template_directory_uri() . '/resource/loader.gif'); ?>" alt="<?php esc_attr_e('Loading...', 'aster-travel-blog'); ?>">
                <?php elseif ($aster_travel_blog_preloader_style === 'style2') : ?>
                    <!-- STYLE 2 -->
                    <div class="dot"></div>
                <?php elseif ($aster_travel_blog_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">
    <div class="header-main-wrapper">
        <?php if (get_theme_mod('aster_travel_blog_enable_topbar', false) === true) {
            $aster_travel_blog_welcome_topbar_text = get_theme_mod('aster_travel_blog_welcome_topbar_text');
        ?>
            <div class="top-header-part">
                <div class="asterthemes-wrapper">
                    <div class="bottom-header-part-wrapper">
                        <div class="header-social-inner">
                            <?php if (!empty($aster_travel_blog_welcome_topbar_text)) { ?>
                                <span><?php echo esc_html($aster_travel_blog_welcome_topbar_text); ?></span>
                            <?php } ?>
                        </div>
                    </div>
                </div>
            </div>
        <?php } ?>
        <div class="bottom-header-outer-wrapper">
            <div class="bottom-header-part">
                <div class="asterthemes-wrapper">
                    <div class="bottom-header-part-wrapper">
                        <div class="bottom-header-left-part">
                            <div class="site-branding">
                                <?php
                                    // Check if the 'Enable Site Logo' setting is true.
                                    if ( get_theme_mod( 'aster_travel_blog_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
                                    $aster_travel_blog_site_title_size = get_theme_mod('aster_travel_blog_site_title_size', 30);

                                    if (get_theme_mod('aster_travel_blog_enable_site_title_setting', false)) {
                                        if (is_front_page() && is_home()) : ?>
                                            <h1 class="site-title" style="font-size: <?php echo esc_attr($aster_travel_blog_site_title_size); ?>px;">
                                                <a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a>
                                            </h1>
                                        <?php else : ?>
                                            <p class="site-title" style="font-size: <?php echo esc_attr($aster_travel_blog_site_title_size); ?>px;">
                                                <a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php bloginfo('name'); ?></a>
                                            </p>
                                        <?php endif;
                                    }

                                    if (get_theme_mod('aster_travel_blog_enable_tagline_setting', false)) :
                                        $aster_travel_blog_description = get_bloginfo('description', 'display');
                                        if ($aster_travel_blog_description || is_customize_preview()) : ?>
                                            <p class="site-description"><?php echo esc_html($aster_travel_blog_description); ?></p>
                                        <?php endif;
                                    endif;
                                    ?>
                                </div>
                            </div>
                        </div>
                        <div class="navigation-menus hello <?php echo esc_attr(get_theme_mod('aster_travel_blog_enable_sticky_header', false) ? 'sticky-header' : ''); ?>">
                            <div class="asterthemes-wrapper">
                                <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" style="<?php echo esc_attr($aster_travel_blog_menu_text_transform_css); ?>">
                                            <?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($aster_travel_blog_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($aster_travel_blog_sub_menu_text_color); ?>;
                                            }
                                        </style>
                                    </nav>
                                </div>
                            </div>
                        </div>
                        <div class="bottom-header-middle-part">
                            <span class="search-main">
                                <div class="form">
                                <form method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
                                        <span class="btn">
                                            <i class="fa fa-search" aria-hidden="true"></i>
                                        </span>
                                    <label>
                                        <span class="screen-reader-text"><?php echo esc_html( 'Search for:', 'label', 'aster-travel-blog' ); ?></span>
                                        <input type="search" class="search-field" placeholder="<?php echo esc_attr_x( '', 'placeholder', 'aster-travel-blog' ); ?>" 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', 'aster-travel-blog' ); ?></span></button>
                                </form>
                                </div>
                            </span>
                            <?php if(get_theme_mod('aster_travel_blog_account_button_link') != '') {?>
                                <div class="account-box">
                                <a href="<?php echo esc_html(get_theme_mod('aster_travel_blog_account_button_link')); ?>"><i class="<?php echo esc_attr(get_theme_mod('aster_travel_blog_account_icon','far fa-user')); ?>"></i></a>
                                </div>
                            <?php } ?>
                            <?php if (get_theme_mod('aster_travel_blog_wishlist_button_link') != '') { ?>
                                <div class="wishlist-box">
                                    <a href="<?php echo esc_html(get_theme_mod('aster_travel_blog_wishlist_button_link')); ?>">
                                        <i class="<?php echo esc_attr(get_theme_mod('aster_travel_blog_wishlist_icon', 'far fa-heart')); ?>"></i>
                                    </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';
            aster_travel_blog_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 } ?>