/*
Theme Name: Kadence Child
Theme URI: https://www.kadencewp.com/
Description: Thème enfant Kadence – Site JPO IUT d'Évry
Author: IUT d'Évry
Author URI: https://www.iut-evry.fr/
Template: kadence
Version: 1.0
Text Domain: kadence-child
*/

/* CSS personnalisé éventuel en dessous */



/* =====================================================
   FILIÈRES – STRUCTURE GLOBALE
   ===================================================== */

.single-filieres .content-wrap,
.single-filieres .site-content {
  max-width: none !important;
}

.site-main-filiere {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.filiere section {
  margin-bottom: 3rem;
}

/* =====================================================
   GRILLES (VIDÉO / SESSIONS / BLOCS)
   ===================================================== */

.filiere-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2rem;
}

@media (max-width: 900px) {
  .filiere-grid {
    grid-template-columns: 1fr;
  }
}

/* =====================================================
   VIDÉO RESPONSIVE (OBLIGATOIRE)
   ===================================================== */

.video-wrapper {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
  background: #000;
  border-radius: 8px;
}

.video-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* =====================================================
   SESSIONS – CARTES
   ===================================================== */

.sessions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.session-card {
  padding: 1.5rem;
  border-radius: 8px;
  background: var(--global-palette9);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.session-card h3 {
  margin-top: 0;
}

.session-link .button {
  margin-top: auto;
}
@media (max-width: 768px) {
  .jpo-lieu-grid {
    grid-template-columns: 1fr;
  }

  .osm-map {
    min-height: 250px;
  }
}

/* =====================================================
   BADGE SESSION (OPTIONNEL)
   ===================================================== */

.session-badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  background: var(--global-palette1);
  color: #fff;
  width: fit-content;
}

/* =====================================================
   JPO PHYSIQUE – INFOS PRATIQUES
   ===================================================== */

.filiere-jpo-physique {
  max-width: 900px;
  margin: 4rem auto;
}

.jpo-map-wrapper {
  margin-bottom: 1.5rem;
  border-radius: 8px;
  overflow: hidden;
}

.osm-map {
  height: 100%;
  min-height: 300px;
}

.jpo-infos p {
  margin: 0.5rem 0;
}

/* =====================================================
   ACCESSIBILITÉ & CONFORT LECTURE
   ===================================================== */

a.button {
  text-decoration: none;
}

@media (max-width: 768px) {
  .session-card {
    padding: 1.25rem;
  }
}

.jpo-lieu-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
  align-items: stretch;
}

/* === MODALE CONTACT FILIÈRE === */

/* ===========================
   MODALE CONTACT FILIÈRE
   =========================== */

.modal {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.6);
	z-index: 99999;
	align-items: center;
	justify-content: center;
	padding: 2rem;
}

.modal.is-open {
	display: flex;
}

.modal:target {
	display: flex;
}

.modal-content {
	background: #fff;
	width: 100%;
	max-width: 700px;

	padding: 2rem;
	border-radius: 6px;

	max-height: calc(100vh - 4rem);
	overflow-y: auto;

	position: relative;
}

/* Bouton fermer */
.modal-close {
	position: absolute;
	top: 0.75rem;
	right: 1rem;
	font-size: 2rem;
	line-height: 1;
	text-decoration: none;
	color: #000;
}

/* Bouton ouverture */
.filiere-contact-btn {
	display: inline-block;
	padding: 0.75rem 1.5rem;
	background: var(--global-palette1);
	color: #fff;
	text-decoration: none;
	border-radius: 4px;
	cursor: pointer;
}
/* Accessibilite */
:focus-visible {
  outline: 3px solid #005faa;
  outline-offset: 2px;
}

/* =====================================================
   GALERIE VIDÉO AVEC MINIATURES
   ===================================================== */

.video-gallery-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 1024px) {
    .video-gallery-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* Carrousel principal */
.video-carousel-main {
    position: relative;
    width: 100%;
}

.video-carousel-main .video-wrapper {
    width: 100%;
    min-height: 300px; /* Hauteur minimale pour éviter le collapsing */
}

/* Galerie des miniatures */
.video-thumbnails h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--global-palette7);
}

.thumbnails-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Scrollbar personnalisée */
.thumbnails-grid::-webkit-scrollbar {
    width: 6px;
}

.thumbnails-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.thumbnails-grid::-webkit-scrollbar-thumb {
    background: var(--global-palette1);
    border-radius: 3px;
}

.thumbnails-grid::-webkit-scrollbar-thumb:hover {
    background: var(--global-palette2);
}

/* Miniatures individuelles */
.thumbnail-item {
    position: relative;
    cursor: pointer;
    border-radius: 6px;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.thumbnail-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.thumbnail-item.active {
    border-color: var(--global-palette1);
}

.thumbnail-image {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
    background: #000;
}

.thumbnail-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

.thumbnail-item:hover .thumbnail-image img {
    opacity: 0.9;
}

.play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.thumbnail-item:hover .play-icon {
    opacity: 1;
}

.thumbnail-number {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: var(--global-palette1);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

/* ======================================================
   3. SWIPER CARROUSEL VIDÉO - VERSION SIMPLIFIÉE
====================================================== */
function filiere_video_carousel_assets() {
    if (is_singular('filieres')) {
        // Swiper CSS
        wp_enqueue_style(
            'swiper',
            'https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css',
            [],
            '11.0.7'
        );

        // Swiper JS
        wp_enqueue_script(
            'swiper',
            'https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js',
            [],
            '11.0.7',
            true
        );

        // JavaScript ultra-simplifié
        wp_add_inline_script('swiper', "
            document.addEventListener('DOMContentLoaded', function() {
                // Attendre un peu que tout soit chargé
                setTimeout(function() {
                    const carousel = document.querySelector('.video-carousel');
                    if (carousel) {
                        // Initialiser Swiper
                        const swiper = new Swiper('.video-carousel', {
                            slidesPerView: 1,
                            spaceBetween: 20,
                            loop: false,
                            navigation: {
                                nextEl: '.swiper-button-next',
                                prevEl: '.swiper-button-prev',
                            },
                            pagination: {
                                el: '.swiper-pagination',
                                clickable: true,
                            }
                        });
                        
                        // Gérer les miniatures
                        document.querySelectorAll('.thumbnail-item').forEach(thumb => {
                            thumb.addEventListener('click', function() {
                                const index = parseInt(this.dataset.index);
                                if (!isNaN(index)) {
                                    swiper.slideTo(index);
                                    // Mettre à jour les classes actives
                                    document.querySelectorAll('.thumbnail-item').forEach(item => {
                                        item.classList.remove('active');
                                    });
                                    this.classList.add('active');
                                }
                            });
                        });
                    }
                }, 200);
            });
        ");
    }
}
add_action('wp_enqueue_scripts', 'filiere_video_carousel_assets');

/* =====================================================
   URGENT - FIX ABSOLU POUR LES VIDÉOS YOUTUBE
   ===================================================== */

/* Reset complet pour les conteneurs vidéo */
.video-wrapper,
.video-container,
.main-video-container > div {
    position: relative !important;
    width: 100% !important;
    padding-bottom: 56.25% !important;
    height: 0 !important;
    overflow: hidden !important;
    background: #000 !important;
    min-height: 300px !important;
}

/* Fix absolu pour les iframes YouTube */
.video-wrapper iframe,
.video-container iframe,
.main-video-container iframe {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 300px !important;
    border: none !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Force l'affichage sur desktop */
@media (min-width: 769px) {
    .video-wrapper,
    .video-container,
    .main-video-container > div {
        min-height: 400px !important;
    }
    
    .video-wrapper iframe,
    .video-container iframe,
    .main-video-container iframe {
        min-height: 400px !important;
    }
}

/* Fix pour mobile */
@media (max-width: 768px) {
    .video-wrapper,
    .video-container,
    .main-video-container > div {
        min-height: 250px !important;
        height: 56.25vw !important; /* Ratio 16:9 basé sur viewport width */
        padding-bottom: 0 !important;
    }
    
    .video-wrapper iframe,
    .video-container iframe,
    .main-video-container iframe {
        min-height: 250px !important;
        height: 100% !important;
    }
}

/* Cache les éléments Swiper si ils existent encore */
.swiper,
.swiper-wrapper,
.swiper-slide {
    display: none !important;
}

/* Affiche notre solution simple */
.simple-video-gallery,
.main-video-container,
.video-selector {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}