<?php
/**
 * The template used for displaying hero content
 *
 * @package Signify
 */

$signify_title = get_theme_mod( 'signify_hero_content_title' );
$sub_title     = get_theme_mod( 'signify_hero_content_sub_title' );
$style         = get_theme_mod( 'signify_hero_content_style', 'style-one' );

$classes[] = 'hero-section';
$classes[] = 'section';
$classes[] = get_theme_mod( 'signify_hero_content_img_align', 'content-align-right' );
$classes[] = get_theme_mod( 'signify_hero_content_txt_align', 'text-align-left' );
$classes[] = $style;

if( ! $signify_title && ! $sub_title ) {
	$classes[] = 'no-section-heading';
}

?>
<div id="hero-section" class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>">
	<div class="wrapper">
		<div class="section-content-wrapper hero-content-wrapper">
			<?php $image = get_theme_mod( 'signify_hero_content_image' ); ?>
			<article id="post-0" class="hentry<?php echo $image ? ' has-post-thumbnail' : ''; ?>">
				<div class="hentry-inner">
					<?php
					if ( $image ) : ?>
						<div class="post-thumbnail-background" style="background-image: url( <?php echo esc_url( $image ); ?> )">
							<?php
							$signify_link   = get_theme_mod( 'signify_hero_content_link', '#' );
							$target = get_theme_mod( 'signify_hero_content_target' ) ? '_blank' : '_self';
							?>

							<a class="cover-link" href="<?php echo esc_url( $signify_link ); ?>" target="<?php echo esc_attr( $target ); ?>">
							</a>
						</div><!-- .post-thumbnail -->
						<div class="entry-container">
					<?php
					else: ?>
					<div class="entry-container full-width">
					<?php endif; 

					if ( 'style-two' === $style ) : ?>
					<div class="content-wrapper"> 
					<?php endif;

						if ( $signify_title || $sub_title ) : ?>
							<header class="entry-header section-title-wrapper">
								<?php if ( $sub_title ) : ?>
								<div class="section-subtitle">
									<?php
										echo esc_html( $sub_title );
									?>
								</div><!-- .section-description-wrapper -->
								<?php endif; ?>
								<?php if ( $signify_title ) : ?>
								<h2 class="entry-title section-title">
									<?php echo wp_kses_post( $signify_title ); ?>
								</h2>
								<?php endif; ?>

							</header><!-- .entry-header -->
						<?php endif; ?>

						<?php if ( $content = get_theme_mod( 'signify_hero_content_content' ) ) : ?>
							<div class="entry-content">
								<?php 
								echo wp_kses_post( $content );

								$more_text   = get_theme_mod( 'signify_hero_content_more_text' );
								$more_link   = get_theme_mod( 'signify_hero_content_more_link', '#' );
								$more_target = get_theme_mod( 'signify_hero_content_more_target' ) ? '_blank' : '_self' ;

								if ( $more_text ) : ?>
								<p class="more-button">
									<a href="<?php echo esc_url( $more_link ); ?>" target="<?php echo esc_attr( $more_target ); ?>" class="more-link"><?php echo esc_html( $more_text ); ?></a>
								</p>
								<?php
								endif;
								?>
							</div><!-- .entry-content -->
						<?php endif;
						
						if ( 'style-two' === $style ) : ?>
						</div><!-- .content-wrapper -->
					<?php endif; ?>
					</div><!-- .entry-container -->
				</div><!-- .hentry-inner -->
			</article>
		</div><!-- .section-content-wrapper -->
	</div><!-- .wrapper -->
</div><!-- .section -->
