<?php
/**
 * The header for the theme.
 *
 * 303 Radon Mitigation — Lafayette, CO
 *
 * @package EnduraApex
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$endura_apex_phone        = trim( (string) apply_filters( 'endura_apex_phone', get_theme_mod( 'endura_apex_phone', '' ) ) );
$endura_apex_phone_digits = preg_replace( '/[^0-9+]/', '', $endura_apex_phone );

$endura_apex_cta_url  = '/contact/';
$endura_apex_cta_text = __( 'Free Consultation', 'endura-apex' );
?>
<!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" href="#primary"><?php esc_html_e( 'Skip to content', 'endura-apex' ); ?></a>

<header class="site-header" role="banner">
	<div class="container header__inner">
		<a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="header__brand" rel="home" aria-label="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>">
			<?php if ( has_custom_logo() ) : ?>
				<?php
				$custom_logo_id = get_theme_mod( 'custom_logo' );
				$logo_image     = wp_get_attachment_image_src( $custom_logo_id, 'full' );
				if ( $logo_image ) :
					?>
					<img src="<?php echo esc_url( $logo_image[0] ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" class="header__logo" width="<?php echo esc_attr( $logo_image[1] ); ?>" height="<?php echo esc_attr( $logo_image[2] ); ?>">
				<?php endif; ?>
			<?php else : ?>
				<span class="header__site-title"><?php bloginfo( 'name' ); ?></span>
			<?php endif; ?>
		</a>

		<button class="menu-toggle" aria-controls="primary-navigation" aria-expanded="false" aria-label="<?php esc_attr_e( 'Toggle navigation menu', 'endura-apex' ); ?>">
			<span class="menu-toggle__bar"></span>
			<span class="menu-toggle__bar"></span>
			<span class="menu-toggle__bar"></span>
		</button>

		<div class="header__nav" id="primary-navigation">
			<?php
			$nav_items = array(
				array(
					'label'   => __( 'Crawl Space', 'endura-apex' ),
					'url'     => '/crawl-space-radon-mitigation-lafayette-co/',
					'current' => is_page( 'crawl-space-radon-mitigation-lafayette-co' ),
				),
				array(
					'label'   => __( 'Fan Replacement', 'endura-apex' ),
					'url'     => '/radon-fan-replacement-lafayette-co/',
					'current' => is_page( 'radon-fan-replacement-lafayette-co' ),
				),
				array(
					'label'   => __( 'Sub-Slab Systems', 'endura-apex' ),
					'url'     => '/sub-slab-depressurization-lafayette-co/',
					'current' => is_page( 'sub-slab-depressurization-lafayette-co' ),
				),
				array(
					'label'   => __( 'About', 'endura-apex' ),
					'url'     => '/about/',
					'current' => is_page( 'about' ),
				),
			);
			?>
			<nav class="primary-nav" aria-label="<?php esc_attr_e( 'Primary Navigation', 'endura-apex' ); ?>">
				<ul class="primary-nav__list">
					<?php foreach ( $nav_items as $item ) : ?>
						<li class="primary-nav__item<?php echo $item['current'] ? ' is-current' : ''; ?>">
							<a href="<?php echo esc_url( home_url( $item['url'] ) ); ?>"<?php echo $item['current'] ? ' aria-current="page"' : ''; ?>><?php echo esc_html( $item['label'] ); ?></a>
						</li>
					<?php endforeach; ?>
				</ul>
			</nav>

			<div class="header__cta-group">
				<a href="<?php echo esc_url( home_url( $endura_apex_cta_url ) ); ?>" class="btn btn--primary header__estimate-btn"><?php echo esc_html( $endura_apex_cta_text ); ?></a>
				<?php if ( '' !== $endura_apex_phone_digits ) : ?>
					<a href="tel:<?php echo esc_attr( $endura_apex_phone_digits ); ?>" class="btn btn--phone header__phone" aria-label="<?php esc_attr_e( 'Call us', 'endura-apex' ); ?>" data-gtm="phone_click"><?php echo esc_html( $endura_apex_phone ); ?></a>
				<?php endif; ?>
			</div>
		</div>
	</div>
</header>

<main id="primary" class="site-main">