<?php
/**
 * The header for our theme
 *
 * @package Zentorone
 */

?>
<!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 wp_body_open(); ?>

<a class="skip-link screen-reader-text" href="#primary"><?php esc_html_e( 'Skip to content', 'zentorone' ); ?></a>

<div id="page" class="site">

	<?php
	$navbar_class = 'navbar navbar-expand-lg';
	?>

	<header id="masthead" class="site-header">
		<?php do_action( 'zentorone_before_header' ); ?>
		<nav class="<?php echo esc_attr( $navbar_class ); ?>" data-text-toggle="<?php esc_attr_e( 'Toggle submenu', 'zentorone' ); ?>">
			<div class="container-fluid">
				<div class="navbar-brand d-flex align-items-center">
					<?php
					$show_logo    = zentorone_get_option( 'zentorone_show_logo', true );
					$show_title   = zentorone_get_option( 'zentorone_show_site_title', true );
					$show_tagline = zentorone_get_option( 'zentorone_show_site_tagline', false );

					// 1. Logo
					if ( $show_logo ) {
						if ( has_custom_logo() ) {
							the_custom_logo();
						} else {
							$logo_url = get_template_directory_uri() . '/assets/images/logo-vector-bw.svg';
							echo '<a href="' . esc_url( home_url( '/' ) ) . '" rel="home" class="me-2">';
							echo '<img src="' . esc_url( $logo_url ) . '" alt="' . esc_attr( get_bloginfo( 'name' ) ) . '" width="40" height="40" class="d-inline-block align-text-top">';
							echo '</a>';
						}
					}

					if ( $show_title || $show_tagline ) {
						echo '<div class="brand-text d-flex flex-column">';
						if ( $show_title ) {
							echo '<a class="text-decoration-none text-dark fw-bold h5 mb-0" href="' . esc_url( home_url( '/' ) ) . '">' . esc_html( get_bloginfo( 'name' ) ) . '</a>';
						}
						if ( $show_tagline ) {
							$description = get_bloginfo( 'description', 'display' );
							if ( $description || is_customize_preview() ) {
								echo '<small class="text-muted" style="font-size: 0.75rem;">' . esc_html( $description ) . '</small>';
							}
						}
						echo '</div>';
					}
					?>
				</div>

				<!-- Checkbox Hack Hamburger -->
				<input type="checkbox" id="navbarToggle" class="navbar-toggler-checkbox" aria-hidden="true" tabindex="-1">
				<label for="navbarToggle" class="navbar-toggler" role="button" aria-label="<?php esc_attr_e( 'Toggle navigation menu', 'zentorone' ); ?>" aria-controls="primary-menu-wrap" tabindex="0">
					<i class="bi bi-list"></i>
				</label>

				<div class="collapse navbar-collapse" id="primary-menu-wrap">
					<?php
					wp_nav_menu(
						array(
							'theme_location' => 'menu-1',
							'menu_id'        => 'primary-menu',
							'container'      => false,
							'menu_class'     => 'navbar-nav ms-auto no-caret caret-right',
							'fallback_cb'    => 'zentorone_menu_fallback',
							'walker'         => new Zentorone_Bootstrap_Nav_Walker(),
						)
					);
					?>
				
				<?php if ( class_exists( 'WooCommerce' ) ) : ?>
						<div class="navbar-nav ms-lg-3">
							<a href="<?php echo esc_url( wc_get_cart_url() ); ?>" class="nav-link position-relative d-flex align-items-center" aria-label="<?php esc_attr_e( 'View your shopping cart', 'zentorone' ); ?>">
								<i class="bi bi-cart fs-5"></i>
								<?php
								$count = WC()->cart->get_cart_contents_count();
								if ( $count > 0 ) {
									echo '<span class="top-0 start-100 translate-middle badge rounded-pill bg-danger z-3" style="font-size: 0.6rem; padding: 0.35em 0.5em; transform: translate(-30%, -30%);">' . esc_html( $count ) . '</span>';
								}
								?>
							</a>
						</div>
				<?php endif; ?>
				</div>
			</div>
		</nav>
		<?php do_action( 'zentorone_after_header' ); ?>
	</header><!-- #masthead -->

	<?php if ( ! is_front_page() ) : ?>
		<div class="container">
			<?php zentorone_breadcrumbs(); ?>
		</div>
	<?php endif; ?>
