{% extends 'base.html.twig' %}{% block title %}Galerie - WA BENIN en images{% endblock %}{% block body %}<div class="page-header" style="height: 35vh; min-height: 250px; background-image: linear-gradient(rgba(31, 31, 31, 0.8), rgba(31, 31, 31, 0.8)), url('https://images.unsplash.com/photo-1501281668745-f7f57925c3b4?ixlib=rb-4.0.3&auto=format&fit=crop&w=1920&q=80'); margin-bottom: 40px;"><div class="container fade-up"><h1 class="page-title">Galerie Média</h1><p style="font-size: 1.2rem; color: var(--gold); max-width: 600px; margin: 0 auto;">Revivez les moments forts de nos événements en images et en vidéos.</p></div></div><section class="section-padding" style="padding-top: 0;"><div class="container"><!-- Filtres --><div style="display: flex; justify-content: center; flex-wrap: wrap; gap: 15px; margin-bottom: 40px;"><a href="{{ path('app_galerie') }}" class="btn {% if not current_category %}btn-primary{% else %}btn-outline{% endif %}" style="padding: 8px 20px;">Tout voir</a>{% for cat in categories %}<a href="{{ path('app_galerie', {category: cat}) }}" class="btn {% if current_category == cat %}btn-primary{% else %}btn-outline{% endif %}" style="padding: 8px 20px;">{{ cat }}</a>{% endfor %}</div><!-- Masonry Layout --><div style="columns: 3 300px; gap: 20px;">{% for item in images %}{% set is_youtube = 'youtube.com' in item.image or 'youtu.be' in item.image %}{% set img_src = item.image %}{% if item.isVideo and is_youtube %}{% set yt_id = item.image|split('v=')|last|split('&')|first|split('/')|last %}{% set img_src = 'https://img.youtube.com/vi/' ~ yt_id ~ '/0.jpg' %}{% endif %}<div class="fade-up gallery-item" style="margin-bottom: 20px; break-inside: avoid; border-radius: var(--border-radius); overflow: hidden; position: relative; cursor: pointer;" onclick="openLightbox('{{ item.image }}', {{ item.isVideo ? 'true' : 'false' }})"><img src="{{ img_src }}" alt="{{ item.title }}" style="width: 100%; display: block; transition: transform 0.3s;">{% if item.isVideo %}<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: rgba(244, 180, 0, 0.9); border-radius: 50%; display: flex; align-items: center; justify-content: center;"><i class="fas fa-play" style="color: #fff; font-size: 1.5rem; margin-left: 5px;"></i></div>{% else %}<div style="position: absolute; top:0; left:0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); opacity: 0; transition: opacity 0.3s; display: flex; align-items: center; justify-content: center;"><i class="fas fa-search-plus fa-2x" style="color: #fff;"></i></div>{% endif %}</div>{% else %}<p style="text-align: center; grid-column: 1 / -1;">Aucun média disponible pour le moment.</p>{% endfor %}</div>{% if total_pages > 1 %}<div style="margin-top: 40px; display: flex; justify-content: center; gap: 10px;">{% for i in 1..total_pages %}<a href="{{ path('app_galerie', {page: i, category: current_category}) }}" style="width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; {% if current_page == i %}background: var(--gold); color: #fff; border: none;{% else %}background: #fff; border: 1px solid #ddd; color: var(--black-dark);{% endif %} border-radius: 8px; font-weight: bold;">{{ i }}</a>{% endfor %}</div>{% endif %}</div></section><style>/* Hover effect for masonry items */.gallery-item:hover > img {transform: scale(1.05);}.gallery-item:hover > div:not(.fa-play) {opacity: 1 !important;}</style><!-- Lightbox Modal --><div id="lightbox" style="display: none; position: fixed; z-index: 9999; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.9); align-items: center; justify-content: center;"><span onclick="closeLightbox()" style="position: absolute; top: 20px; right: 30px; color: white; font-size: 40px; font-weight: bold; cursor: pointer;">×</span><div id="lightbox-content" style="max-width: 90%; max-height: 90%; text-align: center;"></div></div><script>function openLightbox(url, isVideo) {const lightbox = document.getElementById('lightbox');const content = document.getElementById('lightbox-content');lightbox.style.display = 'flex';if (isVideo) {let embedUrl = url;if (url.includes('youtube.com/watch?v=')) {embedUrl = url.replace('watch?v=', 'embed/');} else if (url.includes('youtu.be/')) {embedUrl = url.replace('youtu.be/', 'youtube.com/embed/');}content.innerHTML = `<iframe width="800" height="450" style="max-width: 100%; border: none;" src="${embedUrl}?autoplay=1" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>`;} else {content.innerHTML = `<img src="${url}" style="max-width: 100%; max-height: 90vh; border-radius: 8px;">`;}}function closeLightbox() {document.getElementById('lightbox').style.display = 'none';document.getElementById('lightbox-content').innerHTML = ''; // Stop video}</script>{% endblock %}