/* Styles additionnels pour le système d'articles */

/* Modale pour les images */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    /* Centrage parfait en mode flex */
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Quand la modale est affichée (display: block via JS) */
.modal[style*="display: block"] {
    display: flex !important;
}

.modal-content {
    margin: auto;
    display: block;
    max-width: 95vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    animation: zoom 0.3s;
    border-radius: 8px;
}

/* Sur mobile, limiter encore plus pour éviter débordements */
@media (max-width: 768px) {
    .modal-content {
        max-width: 90vw;
        max-height: 80vh;
    }
    
    .modal {
        padding: 10px;
    }
}

@keyframes zoom {
    from {transform: scale(0.8)}
    to {transform: scale(1)}
}

.close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #bbb;
}

/* Bouton "Voir plus" */
.read-more-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    margin-top: 1rem;
    transition: all 0.3s;
}

.read-more-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 78, 0, 0.3);
}

/* Contenu avec "Voir plus" */
.news-text-content {
    max-height: 300px;
    overflow: hidden;
    position: relative;
    transition: max-height 0.5s ease;
}

.news-text-content.expanded {
    max-height: none;
}

.news-text-content:not(.expanded)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(to bottom, transparent, white);
}

.news-text-content.expanded::after {
    display: none;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.6s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Filtres */
.filter-container {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin: 2rem 0;
    padding: 0 1rem;
}

.filter-btn {
    padding: 0.6rem 1.5rem;
    border: 2px solid var(--primary);
    background: white;
    color: var(--primary);
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.filter-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.filter-btn.active {
    background: var(--primary);
    color: white;
}

/* Bouton loupe de recherche */
.search-toggle-btn {
    padding: 0.6rem 1rem;
    border: 2px solid var(--primary);
    background: white;
    color: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-toggle-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px) scale(1.1);
}

/* Barre de recherche dépliable */
.search-bar {
    max-width: 600px;
    margin: 0 auto 2rem;
    padding: 0 1rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-bar input {
    width: calc(100% - 50px);
    padding: 0.8rem 1.2rem;
    border: 2px solid var(--primary);
    border-radius: 25px;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
}

.search-bar input:focus {
    box-shadow: 0 0 0 3px rgba(233, 30, 99, 0.1);
}

.search-bar button {
    width: 40px;
    height: 40px;
    margin-left: 10px;
    border: none;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s;
    vertical-align: middle;
}

.search-bar button:hover {
    background: #c2185b;
    transform: rotate(90deg);
}

/* Galeries d'images */
.news-gallery {
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
}

.news-gallery.photo-1 {
    grid-template-columns: 1fr;
    max-width: 450px;
    margin-left: auto;
    margin-right: auto;
}

.news-gallery.photo-2 {
    grid-template-columns: repeat(2, 1fr);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.news-gallery.photo-3 {
    grid-template-columns: repeat(3, 1fr);
}

.news-gallery.photo-4 {
    grid-template-columns: repeat(2, 1fr);
}

.news-gallery img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.3s;
}

.news-gallery img:hover {
    transform: scale(1.05);
}

/* Conteneur pour la 4ème image avec overlay */
.more-photos-overlay {
    position: relative;
    cursor: pointer;
    border-radius: 10px;
    overflow: hidden;
    height: 250px;
}

/* L'image à l'intérieur prend toute la place */
.more-photos-overlay img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin: 0;
}

/* Le voile sombre qui s'affiche par-dessus */
.more-photos-overlay::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6); /* Voile noir à 60% */
    transition: background 0.3s;
    border-radius: 10px;
}

.more-photos-overlay:hover::after {
    background: rgba(0, 0, 0, 0.75); /* Plus sombre au survol */
}

/* Le texte "+X" */
.overlay-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 3rem;
    font-family: 'Bebas Neue', sans-serif;
    font-weight: bold;
    z-index: 2;
    pointer-events: none; /* Le clic passe à travers vers le conteneur */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

/* Articles */
.news-card {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    position: relative !important;  /* Force sur toutes les cartes, statiques et dynamiques */
    overflow: visible !important;   /* Permet au badge de ne pas être coupé */
    border-left: 5px solid var(--primary);  /* Reprend le style de style.css */
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.news-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 0.8rem;  /* Espace sous le badge avant le titre */
}

/* Couleurs par type */
.news-card.course     .news-badge { background: var(--primary); }
.news-card.sortie     .news-badge { background: #2e7d32; }
.news-card.evenement  .news-badge { background: #1565c0; }
.news-card.actualite  .news-badge { background: #e65100; }
.news-card.prochainement .news-badge { background: #6a1b9a; }

.news-content h2 {
    font-family: 'Righteous', cursive;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.news-date {
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    /* Empêcher le débordement des cartes sur mobile */
    .news-card {
        overflow: hidden !important;
        max-width: 100%;
        padding: 1.5rem;
    }
    
    .news-gallery.photo-3,
    .news-gallery.photo-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .news-gallery img {
        height: 150px;
    }
    
    /* Empêcher tout débordement sur mobile */
    .news-gallery {
        max-width: 100%;
        overflow: hidden;
    }
    
    .filter-container {
        gap: 0.5rem;
    }
    
    .filter-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .modal-content {
        width: 95%;
    }
}

@media (max-width: 480px) {
    /* Contraintes encore plus strictes pour très petits écrans */
    .news-card {
        overflow: hidden !important;
        padding: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .news-gallery.photo-2,
    .news-gallery.photo-3,
    .news-gallery.photo-4 {
        grid-template-columns: 1fr;
    }
    
    /* Contraintes strictes pour très petits écrans */
    .news-gallery {
        max-width: 100%;
        width: 100%;
        overflow: hidden;
    }
    
    .news-gallery img {
        max-width: 100%;
        height: auto;
        min-height: 200px;
        object-fit: cover;
    }
}

/* Les variables CSS sont déjà définies dans style.css */

/* ── Bouton lien externe sur les cartes ──────────────────────────────────── */
.article-link-btn {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.7rem 1.5rem;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.article-link-btn:hover {
    background: var(--secondary);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(233, 30, 99, 0.3);
}



/* ── Barre de recherche ─────────────────────────────────────────────────── */
.search-container {
    display: flex;
    align-items: center;
    max-width: 600px;
    margin: 0 auto 2rem;
    padding: 0 1rem;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.8rem 3rem 0.8rem 1.2rem;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-family: 'Work Sans', sans-serif;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(233, 30, 99, 0.1);
}

.clear-search-btn {
    position: absolute;
    right: 1.8rem;
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #ccc;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: background 0.2s;
}

.clear-search-btn:hover {
    background: var(--primary);
}

.no-results-message {
    text-align: center;
    color: #999;
    padding: 3rem 1rem;
    font-size: 1.1rem;
}

/* ── Placeholder chargement images ──────────────────────────────────────── */
.images-placeholder {
    margin-top: 1.5rem;
    border-radius: 10px;
    background: #f5f5f5;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.images-loading {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: #bbb;
    font-size: 0.9rem;
}

.img-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}