<?php

/**
 * The single CPT séries template file 
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package WordPress
 * @subpackage IZI_THEME
 * @since 1.0.0
 */

get_header();
?>
<!-- /* INTERNAL PAGE HEADER IMG -->
<div class="container-fluid p-0 position-relative singlehead">
	<div class="filterdiv internalpage position-absolute top-0 start-0"></div>
	<?php
	if (has_post_thumbnail()) {
		the_post_thumbnail('full', ['class' => 'img-fluid w-100']); 
	} else {
		echo '<img src="' . get_template_directory_uri() . '/assets/img/actu/fallout-serie-tv.jpg" class="img-fluid w-100" alt="Actu Séries" loading="lazy">';
	}
	?>
</div>
<!-- IMG END -->


    <!-- PAGE CONTENT -->
    <section class="container position-relative cptposition">
        <div class="row justify-content-md-center">
            <div class="col-12 col-lg-5 mb-4">
            <?php
			if (has_post_thumbnail()) {
				the_post_thumbnail('full', ['class' => 'img-fluid w-100 poster']); 
			} else {
				echo '<img src="' . get_template_directory_uri() . '/assets/img/series/affiche/defaut.jpg" class="img-fluid w-100" alt="Actu Séries" loading="lazy">';
			}
			?>
            </div>
            <div class="col-12 col-lg-7 mb-4 position-relative">
                <div class="row">
                    <div class="col-12">
                        <span class="cptyear"><?php echo strip_tags(get_the_term_list($post->ID, 'annee', '')); ?></span>
                        <h1 class="position-absolute cpttitle my-4"><?php the_title(); ?></h1>
                    </div>

                    <div class="col-12 cpttext cptmargin">
                        <div class="my-5 cptdetail">
                            <?php
                                $youtube_id = get_post_meta($post->ID, '_id_iframe', true);
                                if (empty($youtube_id) || $youtube_id == 'insérez votre url YouTube ici !' || $youtube_id == 'URL invalide !') {
                                    $youtube_id = 'Ya-N4per4yw';
                                }
                            ?>
                            <div class="playme triggeron" id="0">
                                <div class="playicon" id="trailer0" data-value="<?php echo $youtube_id; ?>" data-title="<?php the_title(); ?>"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"
                                        viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
                                        stroke-linecap="round" stroke-linejoin="round">
                                        <polygon points="5 3 19 12 5 21 5 3"></polygon>
                                    </svg>
                                </div><span>Bande-Annonce</span>
                            </div>
                            <div class="cptinfo">
							<?php echo strip_tags(get_the_term_list($post->ID, 'saisons', '', '', ' saisons ')); ?> / <?php echo get_the_term_list($post->ID, 'vod', ' ', ' | '); ?>
                            </div>
                        </div>
                        <div class="pb-4"><?php echo get_the_term_list($post->ID, 'genre', ' ', ' &diams; '); ?></div>
                        <div class="justif pt-lg-3">
						<?php 
						if (have_posts()) : while (have_posts()) : the_post();
						the_excerpt();
						?>
						<?php
						endwhile;
						else :
							echo '<p>Aucun contenu à afficher</p>';
						endif;
						wp_reset_postdata();
						?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row justify-content-md-center">
            <div class="col-12 cpttext">
                <?php the_content(); ?> 
            </div>
        </div>
    </section>
    <!-- PAGE CONTENT END -->
    
    <!-- TRAILER OVERLAY BEGIN -->
    <div id="overlay">
        <div class="overlay-effect triggeroff"></div>
        <div class="iframebox">
            <button aria-label="close modal" type="button" class="overlay-btn triggeroff">X</button>
<!--             <iframe id="videoIframe" src="https://www.youtube.com/embed/Q98lpkw4ZPg" title="Périphériques, les mondes de Flynne"
                allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
                allowfullscreen></iframe> -->
        </div>
    </div>
    <!-- TRAILER OVERLAY END -->

<?php
get_template_part('template-parts/content-videobg');
get_template_part('template-parts/content-prefooter');
get_footer();
