<?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 dark_fitness
 */
$dark_fitness_menu_text_transform = get_theme_mod( 'dark_fitness_menu_text_transform', 'capitalize' );
$dark_fitness_menu_text_transform_css = ( $dark_fitness_menu_text_transform !== 'capitalize' ) ? 'text-transform: ' . $dark_fitness_menu_text_transform . ';' : '';

$dark_fitness_menu_text_color = get_theme_mod('dark_fitness_menu_text_color', ''); 
$dark_fitness_sub_menu_text_color = get_theme_mod('dark_fitness_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('dark_fitness_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', 'dark-fitness' ); ?></a>
    <?php if (get_theme_mod('dark_fitness_enable_preloader', false)) : ?>
        <div id="loader" class="<?php echo esc_attr(get_theme_mod('dark_fitness_preloader_style', 'style1')); ?>">
            <div class="loader-container">
                <div id="preloader">
                    <?php 
                    $dark_fitness_preloader_style = get_theme_mod('dark_fitness_preloader_style', 'style1');
                    if ($dark_fitness_preloader_style === 'style1') : ?>
                        <!-- STYLE 1 -->
                        <img src="<?php echo esc_url(get_template_directory_uri() . '/assets/loader.gif'); ?>" alt="<?php esc_attr_e('Loading...', 'dark-fitness'); ?>">
                    <?php elseif ($dark_fitness_preloader_style === 'style2') : ?>
                        <!-- STYLE 2 -->
                        <div class="dot"></div>
                    <?php elseif ($dark_fitness_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; ?>
<!-- #loader -->
<header id="masthead" class="site-header">
        <div class="header-main-wrapper">
        <?php
        if ( get_theme_mod( 'dark_fitness_enable_topbar', true ) === true ) {
            $dark_fitness_contact_number = get_theme_mod( 'dark_fitness_contact_number', '123456789');
            ?>
            <div class="top-header-part">
                <div class="asterthemes-wrapper">
                    <div class="top-header-part-wrapper">
                        <div class="top-header-left-part">
                            <div class="top-header-contact">
                                <?php if ( ! empty( $dark_fitness_contact_number ) ) { ?>
                                    <div class="header-contact-inner">
                                        <span class="contact-details">
                                            <span class="contact-no">
                                                <a href="tel:<?php echo esc_attr( $dark_fitness_contact_number ); ?>">
                                                    <i class="<?php echo esc_attr(get_theme_mod('dark_fitness_call_header_icon')); ?>"></i>
                                                    <?php echo esc_html( substr($dark_fitness_contact_number, 0, 10) ); ?>
                                                </a> 
                                            </span>
                                        </span>
                                    </div>

                                    <?php
                                }
                                ?> 
                            </div>
                        </div>
                        <?php
                        if ( get_theme_mod( 'dark_fitness_enable_social', true ) === true ) { ?>
                            <div class="top-header-right-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>
                        <?php } ?>
                    </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 hello <?php echo esc_attr( get_theme_mod( 'dark_fitness_enable_sticky_header', false ) ? 'sticky-header' : '' ); ?>">
                        <div class="bottom-header-left-part">
                            <div class="site-branding">
                                <?php
                                // Check if the 'Enable Site Logo' setting is true.
                                if ( get_theme_mod( 'dark_fitness_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() . '/assets/img/Logo.png'); ?>" alt="<?php bloginfo('name'); ?>">
                                            </a>
                                        </div>
                                    <?php }
                                } ?>
                                <div class="site-identity">
                                    <?php
                                    $dark_fitness_site_title_size = get_theme_mod('dark_fitness_site_title_size', 30);

                                    if (get_theme_mod('dark_fitness_enable_site_title_setting', false)) {
                                        if (is_front_page() && is_home()) : ?>
                                            <h1 class="site-title" style="font-size: <?php echo esc_attr($dark_fitness_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($dark_fitness_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('dark_fitness_enable_tagline_setting', false)) :
                                        $dark_fitness_description = get_bloginfo('description', 'display');
                                        if ($dark_fitness_description || is_customize_preview()) : ?>
                                            <p class="site-description"><?php echo esc_html($dark_fitness_description); ?></p>
                                        <?php endif;
                                    endif;
                                    ?>
                                </div>
                            </div>
                        </div>
                        <div class="bottom-header-middle-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" style="<?php echo esc_attr( $dark_fitness_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($dark_fitness_menu_text_color); ?> !important;
                                        }

                                        /* 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($dark_fitness_sub_menu_text_color); ?> !important;
                                        }
                                    </style>
                                </nav><!-- #site-navigation -->
                            </div>
                        </div>
                        <div class="bottom-header-right-part">
                            <div class="custom-button-search">
                                <?php
                                $dark_fitness_menu_button = get_theme_mod( 'dark_fitness_menu_custom_button_label');
                                $dark_fitness_button_url  = get_theme_mod( 'dark_fitness_menu_custom_button_url');
                                if ( ! empty( $dark_fitness_menu_button ) ) {
                                    ?>
                                    <div class="asterthemes-custom-button">
                                        <a class="asterthemes-button" href="<?php echo esc_url( $dark_fitness_button_url ); ?>"><?php echo esc_html( $dark_fitness_menu_button ); ?></a>
                                    </div>
                                    <?php
                                } ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</header><!-- #masthead -->
<?php
    if ( ! is_front_page() || is_home() ) {
	if ( is_front_page() ) {
		require get_template_directory() . '/sections/sections.php';
		dark_fitness_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 } ?>