/* CONTAINER SPA ACTUS */
.news-page-spa-container {
    display: none; /* Masqué par défaut */
    padding-top: 70px;
    min-height: 100vh;
    width: 100%;
    background-color: #ffffff !important; /* Empeche de voir l'accueil par transparence */
    position: relative;
    z-index: 100; /* Passe au-dessus de l'accueil */
}

/* Règle essentielle active */
.news-page-spa-container.active {
    display: block !important;
}

/* BANDEAU DE FIXATION DES CATÉGORIES */
.news-categories-bar {
    position: sticky;
    top: 106px; /* Header fixe (80px) + bandeau dédicaces (36px) */
    background: #ffffff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 100;
    padding: 12px 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.news-categories-inner {
    max-width: 1300px;
    margin: 0 auto;
    display: flex;
    gap: 15px;
    padding: 0 20px;
    align-items: center;
}

.cat-btn {
    background: #f0f0f2;
    border: none;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1c1c1e;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cat-btn:hover, .cat-btn.active {
    background: #E50914;
    color: #ffffff;
}

/* MENU DÉROULANT */
.cat-dropdown {
    position: relative;
    display: inline-block;
}

.cat-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 5px;
    background: #ffffff;
    min-width: 180px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    padding: 8px 0;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.cat-dropdown:hover .cat-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.cat-dropdown-menu a {
    padding: 10px 16px;
    color: #1c1c1e;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s;
}

.cat-dropdown-menu a:hover {
    background: #f5f5f7;
    color: #E50914;
}

/* SECTIONS D'ACTUS */
.news-spa-content {
    max-width: 1300px;
    margin: 0 auto;
    padding: 30px 20px;
}

.news-category-section {
    padding-top: 20px;
    margin-bottom: 40px;
}

.category-title {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 15px;
    color: #111;
}

/* ==========================================================================
   CARROUSEL BENTO PAR PAGES
   ========================================================================== */

.bento-carousel-wrapper {
    position: relative;
    width: 100%;
    margin: 10px 0 20px 0;
    box-sizing: border-box;
}

/* PISTE DU CARROUSEL */
.bento-carousel-track {
    display: flex !important;
    gap: 0 !important;
    width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x mandatory !important;
    scroll-behavior: smooth;
    padding: 5px 0 15px 0;
    box-sizing: border-box;
    scrollbar-width: none;
}

.bento-carousel-track::-webkit-scrollbar {
    display: none;
}

/* SLIDE BENTO (DESKTOP) */
.bento-slide-page {
    flex: 0 0 100% !important;
    width: 100% !important;
    min-width: 100% !important;
    height: 416px;
    scroll-snap-align: start !important;
    scroll-snap-stop: always !important;
    
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    grid-template-rows: repeat(2, 200px) !important;
    grid-auto-flow: dense !important;
    gap: 16px !important;
    box-sizing: border-box;
    overflow: hidden !important;
}

/* CARTES BENTO */
.news-card-bento {
    position: relative !important;
    border-radius: 18px !important;
    overflow: hidden !important;
    cursor: pointer;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-end !important;
    padding: 16px !important;
    box-sizing: border-box !important;
    width: 100% !important;
    height: 100% !important;
    transition: transform 0.25s ease !important;
    /* Les cartes sont maintenant de vrais <a href> (voir news.js) pour rester
       crawlables par Google — on annule le style de lien par défaut du
       navigateur pour que rien ne change visuellement. */
    text-decoration: none !important;
    color: inherit !important;
}

.news-card-bento:hover {
    transform: translateY(-3px) !important;
}

/* TAILLES DE CARTE */
.news-card-bento.bento-standard {
    grid-column: span 1 !important;
    grid-row: span 1 !important;
}

.news-card-bento.bento-wide {
    grid-column: span 2 !important;
    grid-row: span 1 !important;
}

.news-card-bento.bento-tall {
    grid-column: span 1 !important;
    grid-row: span 2 !important;
}

.news-card-bento.bento-full-hero {
    grid-column: span 3 !important;
    grid-row: span 2 !important;
}

.news-card-bento.bento-half-hero {
    grid-column: span 2 !important;
    grid-row: span 2 !important;
}

/* Overlay & typographie */
.bento-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0) 20%, rgba(0,0,0,0.7) 60%, rgba(0,0,0,0.95) 100%);
    z-index: 1;
}

.bento-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bento-date {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.75);
    font-weight: 600;
}

.bento-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.25;
}

.bento-excerpt {
    margin: 0;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Boutons de navigation */
.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    backdrop-filter: blur(8px);
    transition: background 0.2s ease;
}

.carousel-btn:hover {
    background: rgba(0, 0, 0, 0.95);
}

.carousel-btn.prev { left: -10px; }
.carousel-btn.next { right: -10px; }

/* RÉINITIALISATION DU CONTENEUR DE CATÉGORIE */
[id^="grid-news-"] {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* ==========================================================================
   CAS PARTICULIER : DESKTOP SEULEMENT (> 768px) POUR 3 CARTES
   ========================================================================== */
@media screen and (min-width: 769px) {
    .bento-slide-page:has(> .news-card-bento:nth-child(3):last-child) {
        grid-template-columns: repeat(3, 1fr) !important;
        grid-template-rows: 1fr !important;
        height: 380px !important;
    }

    .bento-slide-page:has(> .news-card-bento:nth-child(3):last-child) .news-card-bento {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
        height: 100% !important;
    }
}

/* ==========================================================================
   BENTO MOBILE DYNAMIQUE (<= 768px)
   ========================================================================== */
@media screen and (max-width: 768px) {

    .news-spa-content {
        padding: 15px 10px 100px 10px !important;
    }

    /* Grille flexible à emboîtement automatique */
    .bento-slide-page {
        height: auto !important;
        min-height: 350px !important;
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        grid-auto-rows: 165px !important;
        grid-auto-flow: dense !important;
        gap: 12px !important;
        padding: 4px !important;
        overflow: visible !important;
    }

    /* Cas spécifique 3 articles en mobile : 1 large en haut + 2 carrés en bas */
    .bento-slide-page:has(> .news-card-bento:nth-child(3):last-child) {
        grid-template-columns: repeat(2, 1fr) !important;
        grid-template-rows: 165px 165px !important;
    }

    .bento-slide-page:has(> .news-card-bento:nth-child(3):last-child) .news-card-bento:nth-child(1) {
        grid-column: span 2 !important;
        grid-row: span 1 !important;
    }

    .bento-slide-page:has(> .news-card-bento:nth-child(3):last-child) .news-card-bento:nth-child(2),
    .bento-slide-page:has(> .news-card-bento:nth-child(3):last-child) .news-card-bento:nth-child(3) {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
    }

    /* Styles de base des cartes */
    .news-card-bento {
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        border-radius: 16px !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    /* Tailles dynamiques injectables */
    .news-card-bento.bento-small {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
    }

    .news-card-bento.bento-wide {
        grid-column: span 2 !important;
        grid-row: span 1 !important;
    }

    .news-card-bento.bento-tall {
        grid-column: span 1 !important;
        grid-row: span 2 !important;
    }

    .news-card-bento.bento-hero {
        grid-column: span 2 !important;
        grid-row: span 2 !important;
    }

    /* Typo mobile */
    .bento-title {
        font-size: 0.88rem !important;
        line-height: 1.2 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 3 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }

    .news-card-bento.bento-wide .bento-title,
    .news-card-bento.bento-hero .bento-title {
        font-size: 1.05rem !important;
    }

    .bento-excerpt { display: none !important; }
}

/* ==========================================================================
   BENTO CARROUSEL — SECTION ACTUALITÉS DE LA PAGE D'ACCUEIL
   ========================================================================== */

/* Neutralise le display:grid par défaut de .grid pour laisser la place
   au carrousel bento (mêmes règles que [id^="grid-news-"] pour la SPA Actus) */
#recent-news-grid.home-bento-mode,
#top-liked-news-grid.home-bento-mode,
#old-news-grid.home-bento-mode {
    display: block !important;
    grid-template-columns: none !important;
    gap: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Boutons Aimer / Partager sur les cartes bento (accueil) */
.news-card-bento .bento-actions {
    position: relative;
    z-index: 2;
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

/* Carte "Voir plus" (renvoie vers la page Actus dédiée) */
.news-card-bento.bento-see-more {
    background-image: none !important;
    background: linear-gradient(135deg, #E50914 0%, #a40710 100%) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.bento-see-more-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #ffffff;
    text-align: center;
    position: relative;
    z-index: 2;
}

.bento-see-more-label {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.3px;
}

.bento-see-more-arrow {
    font-size: 1.4rem;
    font-weight: 800;
    transition: transform 0.25s ease;
}

.news-card-bento.bento-see-more:hover .bento-see-more-arrow {
    transform: translateX(4px);
}

@media screen and (max-width: 768px) {
    .bento-see-more-label {
        font-size: 0.92rem !important;
    }
}

/* MASQUER LA BARRE ET AJUSTER L'ESPACEMENT SUR MOBILE */
@media screen and (max-width: 768px) {
    .news-categories-bar {
        display: none !important;
    }

    .news-page-spa-container {
        padding-top: 106px !important; /* Hauteur du header fixe + bandeau dédicaces */
    }

    .news-spa-content {
        padding-top: 65px !important; /* Espace propre entre le header et le 1er article */
    }
}