<?php
/**
 * Theme header template
 *
 * @package KsPortfolio
 * @since 1.0.0
 */

namespace KsPortfolio;

global $views;

$headerLogo = getFieldValue( 'header.header_logo.url' ) ? getFieldValue( 'header.header_logo.url' ) : get_theme_file_uri( '/static/img/logo.svg' );
$linkResume = getFieldValue( 'header.resume_link' ) ? getFieldValue( 'header.resume_link' ) : '';

// Expose resume link to the main nav component (used by the mobile menu's footer area).
$GLOBALS['ks_portfolio_link_resume'] = $linkResume;

// Check conditions for displaying the hero section
$showHero = in_array(
	true,
	array(
		get_field( 'hero_style' ) === 'default',
		is_home(),
		is_archive(),
		is_single(),
		is_search(),
		is_404(),
	),
	true
);
?>

<!DOCTYPE html>
<html <?php language_attributes(); ?>>

<head>
	<meta charset="<?php bloginfo( 'charset' ); ?>">
	<meta name="viewport" content="width=device-width, initial-scale=1">

	<?php wp_head(); ?>
</head>

<body <?php echo body_class(); ?>>
	<a class="skip-link" href="#maincontent">
		<?php echo esc_html__( 'Skip to main content' ); ?>
	</a>

	<?php get_template_part( 'views/partials/aura-bg' ); ?>

	<header role="banner" class="site-header bg-secondary flex flex-col items-center justify-start">
		<div class="header__nav-main lg:container py-4 items-center flex gap-x-8 gap-y-0 justify-between">
			<a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="site-header__logo m-0 p-0 flex gap-x-4 items-center justify-start text-white! text-45px font-bold leading-none hover:underline">
				<img class="site-header__logo-img aspect-square h-full w-full max-h-12 max-w-12" src="<?php echo esc_url( $headerLogo ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?> logo" /> Keith Solomon
			</a>

			<?php get_template_part( 'views/components/nav-main' ); ?>

			<div class="site-header__aux hidden lg:flex">
				<a class="button button--outline" href="<?php echo esc_url( $linkResume ); ?>">
					<?php echo esc_html__( 'Resume', 'ks-portfolio' ); ?>
				</a>
			</div>
		</div>
	</header>

	<main id="maincontent" class="overflow-hidden min-h-[78dvh]">
		<?php if ( $showHero ) : ?>
			<?php get_template_part( 'views/partials/page-hero' ); ?>
		<?php endif; ?>
