<?php
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

if ( ! roof_water_proofing_has_page_header() ) {
    return;
}

$roof_water_proofing_classes = array( 'page-header' );
$roof_water_proofing_style = roof_water_proofing_page_header_style();

if ( $roof_water_proofing_style ) {
    $roof_water_proofing_classes[] = $roof_water_proofing_style . '-page-header';
}

$roof_water_proofing_visibility = get_theme_mod( 'roof_water_proofing_page_header_visibility', 'all-devices' );

if ( 'hide-all-devices' === $roof_water_proofing_visibility ) {
    // Don't show the header at all
    return;
}

if ( 'hide-tablet' === $roof_water_proofing_visibility ) {
    $roof_water_proofing_classes[] = 'hide-on-tablet';
} elseif ( 'hide-mobile' === $roof_water_proofing_visibility ) {
    $roof_water_proofing_classes[] = 'hide-on-mobile';
} elseif ( 'hide-tablet-mobile' === $roof_water_proofing_visibility ) {
    $roof_water_proofing_classes[] = 'hide-on-tablet-mobile';
}

$roof_water_proofing_PAGE_TITLE_background_color = get_theme_mod('roof_water_proofing_page_title_background_color_setting', '');

// Get the toggle switch value
$roof_water_proofing_background_image_enabled = get_theme_mod('roof_water_proofing_page_header_style', true);

// Add background image to the header if enabled
$roof_water_proofing_background_image = get_theme_mod( 'roof_water_proofing_page_header_background_image', '' );
$roof_water_proofing_background_height = get_theme_mod( 'roof_water_proofing_page_header_image_height', '200' );
$roof_water_proofing_inline_style = '';

if ( $roof_water_proofing_background_image_enabled && ! empty( $roof_water_proofing_background_image ) ) {
    $roof_water_proofing_inline_style .= 'background-image: url(' . esc_url( $roof_water_proofing_background_image ) . '); ';
    $roof_water_proofing_inline_style .= 'height: ' . esc_attr( $roof_water_proofing_background_height ) . 'px; ';
    $roof_water_proofing_inline_style .= 'background-size: cover; ';
    $roof_water_proofing_inline_style .= 'background-position: center center; ';

    // Add the unique class if the background image is set
    $roof_water_proofing_classes[] = 'has-background-image';
}

$roof_water_proofing_classes = implode( ' ', $roof_water_proofing_classes );
$roof_water_proofing_heading = get_theme_mod( 'roof_water_proofing_page_header_heading_tag', 'h1' );
$roof_water_proofing_heading = apply_filters( 'roof_water_proofing_page_header_heading', $roof_water_proofing_heading );

?>

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

<header class="<?php echo esc_attr( $roof_water_proofing_classes ); ?>" style="<?php echo esc_attr( $roof_water_proofing_inline_style ); ?> background-color: <?php echo esc_attr($roof_water_proofing_PAGE_TITLE_background_color); ?>;">

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

    <div class="asterthemes-wrapper page-header-inner">

        <?php if ( roof_water_proofing_has_page_header() ) : ?>

            <<?php echo esc_attr( $roof_water_proofing_heading ); ?> class="page-header-title">
                <?php echo wp_kses_post( roof_water_proofing_get_page_title() ); ?>
            </<?php echo esc_attr( $roof_water_proofing_heading ); ?>>

        <?php endif; ?>

        <?php if ( function_exists( 'roof_water_proofing_breadcrumb' ) ) : ?>
            <?php roof_water_proofing_breadcrumb(); ?>
        <?php endif; ?>

    </div><!-- .page-header-inner -->

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

</header><!-- .page-header -->

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