<?php
/**
 * Template part for displaying posts with the "metro" display
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Tattoopress
 * @version 3.3.4
 */
extract( wp_parse_args( $template_args, array(
	'layout' => '',
	'overlay_color' => 'auto',
	'overlay_custom_color' => '',
	'overlay_text_color' => '',
	'overlay_text_custom_color' => '',
	'overlay_opacity' => 88,
) ) );

$text_style = '';

if ( $overlay_text_color && 'overlay' === $layout ) {
	$text_color = tattoopress_convert_color_class_to_hex_value( $overlay_text_color, $overlay_text_custom_color );
	if ( $text_color ) {
		$text_style .= 'color:' . tattoopress_sanitize_color( $text_color ) . ';';
	}
}

$dominant_color = tattoopress_get_image_dominant_color( get_post_thumbnail_id() );
$actual_overlay_color = '';

if ( 'auto' === $overlay_color ) {

	$actual_overlay_color = $dominant_color;

} else {
	$actual_overlay_color = tattoopress_convert_color_class_to_hex_value( $overlay_color, $overlay_custom_color );
}

$overlay_tone_class = 'overlay-tone-' . tattoopress_get_color_tone( $actual_overlay_color );
?>
<figure <?php tattoopress_post_attr( array( $overlay_tone_class ) ); ?>>
	<div class="entry-box">
		<div class="entry-outer">
			<div class="entry-container">
				<a class="entry-link-mask" href="<?php the_permalink(); ?>"></a>
				<div class="entry-image">
					<div class="entry-cover">
						<?php
							echo tattoopress_background_img( array( 'background_img_size' => 'large', ) );
						?>
					</div><!-- entry-cover -->
				</div>
				<div class="entry-inner">
					<?php
						$dominant_color = tattoopress_get_image_dominant_color( get_post_thumbnail_id() );

						if ( $dominant_color && 'auto' === $overlay_color ) {
							$overlay_custom_color = $dominant_color;
						}

						/**
						 * Overlay
						 */
						echo tattoopress_background_overlay( array(
							'overlay_color' => $overlay_color,
							'overlay_custom_color' => $overlay_custom_color,
							'overlay_opacity' => $overlay_opacity, )
						);
					?>
					<div style="<?php echo tattoopress_esc_style_attr( $text_style ); ?>" class="entry-summary">
						<h3 class="entry-title"><a href="<?php the_permalink(); ?>" style="<?php echo tattoopress_esc_style_attr( $text_style ); ?>"><?php the_title(); ?></a></h3>
						<div class="entry-meta">
							<?php
								/**
								 * Gallery meta
								 */
								tattoopress_gallery_meta();
							?>
						</div><!-- .entry-meta -->
					</div><!--  .entry-summary  -->
				</div>
			</div><!-- .entry-container -->
		</div><!-- .entry-outer -->
	</div><!-- .entry-box -->
</figure><!-- #post-## -->