<?php
/**
 * The Header: Logo and main menu
 *
 * @package HYGIA
 * @since HYGIA 1.0
 */
?><!DOCTYPE html>
<html <?php language_attributes(); ?> class="no-js<?php
	// Class scheme_xxx need in the <html> as context for the <body>!
	echo ' scheme_' . esc_attr( hygia_get_theme_option( 'color_scheme' ) );
?>">

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

<body <?php body_class(); ?>>

	<?php
	if ( function_exists( 'wp_body_open' ) ) {
		wp_body_open();
	} else {
		do_action( 'wp_body_open' );
	}

	$hygia_full_post_loading = ( hygia_is_singular( 'post' ) || hygia_is_singular( 'attachment' ) ) && hygia_get_value_gp( 'action' ) == 'full_post_loading';
	$hygia_prev_post_loading = ( hygia_is_singular( 'post' ) || hygia_is_singular( 'attachment' ) ) && hygia_get_value_gp( 'action' ) == 'prev_post_loading';

	// Don't display the short links while actions 'full_post_loading' and 'prev_post_loading'
	if ( ! $hygia_full_post_loading && ! $hygia_prev_post_loading ) {
		// Short links to fast access to the content, sidebar and footer from the keyboard
		?><a class="skip-link hygia_skip_link skip_to_content_link" href="#content_skip_link_anchor" tabindex="<?php echo esc_attr( apply_filters( 'hygia_filter_skip_links_tabindex', 0 ) ); ?>"><?php esc_html_e( "Skip to content", 'hygia' ); ?></a><?php
		if ( hygia_sidebar_present() ) {
			?><a class="skip-link hygia_skip_link skip_to_sidebar_link" href="#sidebar_skip_link_anchor" tabindex="<?php echo esc_attr( apply_filters( 'hygia_filter_skip_links_tabindex', 0 ) ); ?>"><?php esc_html_e( "Skip to sidebar", 'hygia' ); ?></a><?php
		}
		?><a class="skip-link hygia_skip_link skip_to_footer_link" href="#footer_skip_link_anchor" tabindex="<?php echo esc_attr( apply_filters( 'hygia_filter_skip_links_tabindex', 0 ) ); ?>"><?php esc_html_e( "Skip to footer", 'hygia' ); ?></a><?php
	}

	do_action( 'hygia_action_before_body' );
	?>

	<div class="<?php echo esc_attr( apply_filters( 'hygia_filter_body_wrap_class', 'body_wrap' ) ); ?>" <?php do_action('hygia_action_body_wrap_attributes'); ?>>

		<?php do_action( 'hygia_action_before_page_wrap' ); ?>

		<div class="<?php echo esc_attr( apply_filters( 'hygia_filter_page_wrap_class', 'page_wrap' ) ); ?>" <?php do_action('hygia_action_page_wrap_attributes'); ?>>

			<?php do_action( 'hygia_action_page_wrap_start' ); ?>

			<?php

			// Don't display the header elements while actions 'full_post_loading' and 'prev_post_loading'
			if ( ! $hygia_full_post_loading && ! $hygia_prev_post_loading ) {

				do_action( 'hygia_action_before_header' );

				// Header
				$hygia_header_type = hygia_get_theme_option( 'header_type' );
				if ( 'custom' == $hygia_header_type && ! hygia_is_layouts_available() ) {
					$hygia_header_type = 'default';
				}
				get_template_part( apply_filters( 'hygia_filter_get_template_part', "templates/header-" . sanitize_file_name( $hygia_header_type ) ) );

				// Side menu
				if ( in_array( hygia_get_theme_option( 'menu_side', 'none' ), array( 'left', 'right' ) ) ) {
					get_template_part( apply_filters( 'hygia_filter_get_template_part', 'templates/header-navi-side' ) );
				}

				// Mobile menu
				if ( apply_filters( 'hygia_filter_use_navi_mobile', hygia_sc_layouts_showed( 'menu_button' ) || $hygia_header_type == 'default' ) ) {
					get_template_part( apply_filters( 'hygia_filter_get_template_part', 'templates/header-navi-mobile' ) );
				}

				do_action( 'hygia_action_after_header' );

			}
			?>

			<?php do_action( 'hygia_action_before_page_content_wrap' ); ?>

			<div class="page_content_wrap<?php
				if ( hygia_is_off( hygia_get_theme_option( 'remove_margins' ) ) ) {
					if ( empty( $hygia_header_type ) ) {
						$hygia_header_type = hygia_get_theme_option( 'header_type' );
					}
					if ( 'custom' == $hygia_header_type && hygia_is_layouts_available() ) {
						$hygia_header_id = hygia_get_custom_header_id();
						if ( $hygia_header_id > 0 ) {
							$hygia_header_meta = hygia_get_custom_layout_meta( $hygia_header_id );
							if ( ! empty( $hygia_header_meta['margin'] ) ) {
								?> page_content_wrap_custom_header_margin<?php
							}
						}
					}
					$hygia_footer_type = hygia_get_theme_option( 'footer_type' );
					if ( 'custom' == $hygia_footer_type && hygia_is_layouts_available() ) {
						$hygia_footer_id = hygia_get_custom_footer_id();
						if ( $hygia_footer_id ) {
							$hygia_footer_meta = hygia_get_custom_layout_meta( $hygia_footer_id );
							if ( ! empty( $hygia_footer_meta['margin'] ) ) {
								?> page_content_wrap_custom_footer_margin<?php
							}
						}
					}
				}
				do_action( 'hygia_action_page_content_wrap_class', $hygia_prev_post_loading );
				?>"<?php
				if ( apply_filters( 'hygia_filter_is_prev_post_loading', $hygia_prev_post_loading ) ) {
					?> data-single-style="<?php echo esc_attr( hygia_get_theme_option( 'single_style' ) ); ?>"<?php
				}
				do_action( 'hygia_action_page_content_wrap_data', $hygia_prev_post_loading );
			?>>
				<?php
				do_action( 'hygia_action_page_content_wrap', $hygia_full_post_loading || $hygia_prev_post_loading );

				// Single posts banner
				if ( apply_filters( 'hygia_filter_single_post_header', hygia_is_singular( 'post' ) || hygia_is_singular( 'attachment' ) ) ) {
					if ( $hygia_prev_post_loading ) {
						if ( hygia_get_theme_option( 'posts_navigation_scroll_which_block', 'article' ) != 'article' ) {
							do_action( 'hygia_action_between_posts' );
						}
					}
					// Single post thumbnail and title
					$hygia_path = apply_filters( 'hygia_filter_get_template_part', 'templates/single-styles/' . hygia_get_theme_option( 'single_style' ) );
					if ( hygia_get_file_dir( $hygia_path . '.php' ) != '' ) {
						get_template_part( $hygia_path );
					}
				}

				// Widgets area above page
				$hygia_body_style   = hygia_get_theme_option( 'body_style' );
				$hygia_widgets_name = hygia_get_theme_option( 'widgets_above_page', 'hide' );
				$hygia_show_widgets = ! hygia_is_off( $hygia_widgets_name ) && is_active_sidebar( $hygia_widgets_name );
				if ( $hygia_show_widgets ) {
					if ( 'fullscreen' != $hygia_body_style ) {
						?>
						<div class="content_wrap">
							<?php
					}
					hygia_create_widgets_area( 'widgets_above_page' );
					if ( 'fullscreen' != $hygia_body_style ) {
						?>
						</div>
						<?php
					}
				}

				// Content area
				do_action( 'hygia_action_before_content_wrap' );
				?>
				<div class="content_wrap<?php echo 'fullscreen' == $hygia_body_style ? '_fullscreen' : ''; ?>">

					<?php do_action( 'hygia_action_content_wrap_start' ); ?>

					<div class="content">
						<?php
						do_action( 'hygia_action_page_content_start' );

						// Skip link anchor to fast access to the content from keyboard
						?>
						<span id="content_skip_link_anchor" class="hygia_skip_link_anchor"></span>
						<?php
						// Single posts banner between prev/next posts
						if ( ( hygia_is_singular( 'post' ) || hygia_is_singular( 'attachment' ) )
							&& $hygia_prev_post_loading 
							&& hygia_get_theme_option( 'posts_navigation_scroll_which_block', 'article' ) == 'article'
						) {
							do_action( 'hygia_action_between_posts' );
						}

						// Widgets area above content
						hygia_create_widgets_area( 'widgets_above_content' );

						do_action( 'hygia_action_page_content_start_text' );
