/* SIDEBAR & WIDGETS — vidéos, populaires hebdo, sticky. Chargé sur home + single. Extrait de main.css (2026-05-29). */

/* Espacement vertical UNIFORME entre tous les blocs de sidebar (anti-cumul) :
   margin-bottom unique, margin-top 0 → écarts identiques quel que soit le widget. */
#secondary > *,
#secondary-left > * {
    margin-top: 0;
    margin-bottom: var(--card-gap);
}
#secondary > *:last-child,
#secondary-left > *:last-child {
    margin-bottom: 0;
}

/*--------------------------------------------------------------
# 9.0 - Sidebar & Widgets
--------------------------------------------------------------*/
#secondary {
    /* Pas de width fixe — la cellule de grille parente (home: 380px, single:
       340px) définit la largeur. `width: auto` annule explicitement l'ancienne
       règle 380px qui peut survivre dans le critical CSS inline. min-width:0
       évite que le contenu (image, iframe) ne force la colonne à s'élargir. */
    width: auto;
    min-width: 0;
}
.widget-area {
    padding-top: 0;
    /* This allows the sticky element to calculate its boundary correctly */
    height: 100%;
}
.widget {
    margin-bottom: var(--spacing-unit);
    background: var(--soft-surface);
    padding: var(--spacing-unit);
    border: 0;
    border-radius: var(--soft-radius);
    box-shadow: var(--soft-shadow);
}
/* Bandeau de widget — aligné sur le composant DS (.senego-section-head), version
   sidebar : barre d'accent à gauche, Public Sans, casse normale, tokens. */
.widget-title {
    position: relative;
    margin: 0 0 var(--senego-space-md);
    padding: 0 0 0 12px;
    font-family: var(--senego-font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    text-transform: none;
    color: var(--senego-color-heading);
    border-bottom: none;
}
.widget-title::before {
    content: "";
    position: absolute;
    left: 0;
    top: .14em;
    bottom: .14em;
    width: 4px;
    border-radius: 2px;
    background: var(--senego-color-primary);
}
.widget ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.widget ul li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
}
.widget ul li:last-child {
    border-bottom: none;
}
.widget .search-form .search-submit {
    display: none;
}
/* =========================================
   PINNED ARTICLES COMPONENT
   ========================================= */

/* CSS pour Articles Épinglés - Template Part */
.pinned-articles-sidebar {
    width: 100%;
    margin-bottom: 2rem;
}

.pinned-articles-container {
    position: relative;
}

.pinned-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    position: relative;
    z-index: 2;
    background: var(--color-primary);
    padding: 5px;
    border-radius: 6px 6px 0 0;
}

.pinned-title {
    color: rgba(255,255,255,0.9);
    font-family: var(--font-headings);
    font-size: 19px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.pinned-icon {
    color: rgba(255,255,255,0.9);
}

.pinned-badge {
    background: linear-gradient(45deg, #ff6b6b, #e74c3c);
    color: var(--color-bg-alt);
    padding: 6px 14px;
    border-radius: 20px;
    font-family: var(--font-headings);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.pinned-articles-list {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.pinned-article {
    background: var(--color-bg-alt);
    border-radius: var(--soft-radius);
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
    border: 1px solid var(--color-border);
    position: relative;
}

.pinned-article:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}

.pinned-article-image {
    position: relative;
    height: 140px;
    overflow: hidden;
}

.pinned-article-image a {
    display: block;
    height: 100%;
}

.pinned-article-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.pinned-article:hover .pinned-article-image img {
    transform: scale(1.05);
}

.pinned-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.4) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pinned-article:hover .pinned-overlay {
    opacity: 1;
}

.play-icon {
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.pinned-article:hover .play-icon {
    transform: scale(1);
}

.pinned-article-content {
    padding: 18px;
}

.pinned-article-title {
    margin: 0 0 10px 0;
    font-family: var(--font-headings);
    font-size: 16px;
    line-height: 1.4;
}

.pinned-article-title a {
    color: var(--color-text);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pinned-article-title a:hover {
    color: var(--color-primary);
}

.pinned-article-excerpt {
    color: var(--color-meta);
    font-family: var(--font-primary);
    font-size: 13px;
    line-height: 1.5;
    margin: 0 0 14px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pinned-article-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
}

.pinned-meta-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pinned-date {
    color: var(--color-meta);
    font-family: var(--font-primary);
    font-weight: 500;
}

.pinned-author {
    color: var(--color-meta);
    font-family: var(--font-primary);
    font-size: 10px;
    opacity: 0.8;
}

.pinned-read-more {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--color-primary);
    font-family: var(--font-headings);
    font-weight: 600;
    text-decoration: none;
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 20px;
    background: rgba(255, 153, 0, 0.1);
    transition: all 0.3s ease;
}

.pinned-read-more:hover {
    background: rgba(255, 153, 0, 0.2);
    color: var(--color-secondary);
    transform: translateX(3px);
}

.pinned-read-more svg {
    transition: transform 0.3s ease;
}

.pinned-read-more:hover svg {
    transform: translateX(2px);
}

/* Animation d'apparition */
.pinned-articles-container {
    animation: slideInUp 0.6s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .pinned-articles-container {
        padding: 20px;
        border-radius: var(--soft-radius);
    }

    .pinned-title {
        font-size: 17px;
    }

    .pinned-article-image {
        height: 120px;
    }

    .pinned-article-content {
        padding: 16px;
    }

    .pinned-article-title {
        font-size: 15px;
    }

    .pinned-article-excerpt {
        font-size: 12px;
    }

    .pinned-article-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .pinned-read-more {
        align-self: flex-end;
    }
}

@media (max-width: 480px) {
    .pinned-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .pinned-badge {
        align-self: flex-end;
    }
}

/* États de chargement */
.pinned-article.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Accessibilité */
@media (prefers-reduced-motion: reduce) {
    .pinned-article,
    .pinned-article-image img,
    .pinned-overlay,
    .pinned-read-more {
        transition: none;
    }

    .pinned-badge {
        animation: none;
    }

    .pinned-articles-container {
        animation: none;
    }
}

/* Focus states pour l'accessibilité */
.pinned-article-title a:focus,
.pinned-read-more:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 8px;
}

/* --- 9.1 Video Posts Widget --- */
#secondary-left {
    width: 300px;
    flex-shrink: 0;
}
.widget_video_posts .widget-title {
    margin-bottom: var(--spacing-unit);
}
.video-posts-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-unit);
}
.video-post-card {
    background-color: var(--color-bg-subtle);
    border-radius: var(--soft-radius);
    overflow: hidden;
}
.video-thumbnail-container {
    position: relative;
}
.video-thumbnail-container a {
    display: block;
}
.video-thumbnail-container .post-thumbnail {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    transition: filter 0.3s ease;
}
.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.video-post-card:hover .video-overlay {
    opacity: 1;
}
.video-post-card:hover .post-thumbnail {
    filter: brightness(0.8);
}
.play-icon {
    width: 48px;
    height: 48px;
    background-color: rgba(0,0,0,0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    stroke: #fff;
    transition: transform 0.3s ease;
}
.video-post-card:hover .play-icon {
    transform: scale(1.1);
}
.video-post-content {
    padding: 1rem;
}
.video-post-title {
    font-family: var(--font-headings);
    font-size: 1.1rem;
    line-height: 1.4;
    margin: 0;
}
.video-post-title a {
    color: var(--color-text);
    text-decoration: none;
}
.video-post-title a:hover {
    color: var(--color-primary);
}

/* --- 9.2 Weekly Popular Widget --- */
.widget_popular_weekly .popular-weekly-list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: popular-counter;
}
.popular-weekly-item {
    padding: 1rem 0;
    border-bottom: 1px solid var(--color-border);
    counter-increment: popular-counter;
}
.popular-weekly-item:first-child {
    padding-top: 0;
}
.popular-weekly-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.popular-weekly-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
}
.popular-weekly-link::before {
    content: counter(popular-counter);
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-meta);
    min-width: 2rem;
    text-align: center;
}
.popular-weekly-thumbnail img {
    border-radius: var(--soft-radius);
    width: 60px;
    height: 60px;
    object-fit: cover;
}
.popular-weekly-content {
    flex: 1;
}
.popular-weekly-title {
    font-family: var(--font-headings);
    font-size: 1rem;
    line-height: 1.4;
    margin: 0 0 0.25rem 0;
    color: var(--color-text);
}
.popular-weekly-link:hover .popular-weekly-title {
    color: var(--color-primary);
}

/* --- 9.3 Sticky Sidebar --- */
.sticky-sidebar-wrapper {
    position: -webkit-sticky; /* For Safari */
    position: sticky;
    /* The ad will stick below the sticky header */
    top: 120px; /* Adjust based on sticky header height + desired margin */
}

/* === Widgets sidebar desktop : NOS VIDÉOS + DÉBATS DE LA SEMAINE (déplacé de core.css — modularité) === */
@media (min-width: 992px) {
       PREMIUM "NOS VIDÉOS" SIDEBAR (Left Column)
       Hero first card + compact list, glassmorphism play button
       ============================================================= */

    /* Widget container */
    .widget_video_posts {
        background: #fff;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: var(--soft-shadow);
        padding: 0 !important;
    }

    /* Bandeau unifié = même style que le composant DS (.senego-section-head) :
       fine barre orange à gauche, Public Sans, séparateur discret. Plus de rond
       orange 22px ni de soulignement orange épais (incohérents avec le reste). */
    .widget_video_posts .widget-title {
        position: relative;
        display: block;
        font-size: 1.05rem;
        font-weight: 700;
        text-transform: none !important;
        letter-spacing: 0;
        padding: 0.85rem 1.1rem 0.7rem 1.5rem;
        margin-bottom: 0 !important;
        border-bottom: 1px solid var(--senego-color-border-soft);
    }
    .widget_video_posts .widget-title::before {
        content: "";
        position: absolute;
        left: 1.1rem;
        top: 0.9rem;
        bottom: 0.7rem;
        width: 4px;
        border-radius: 2px;
        background: var(--senego-color-primary);
    }

    /* Video list: remove gap, tighter spacing */
    .widget_video_posts .video-posts-list {
        gap: 0 !important;
        padding: 0;
    }

    /* --- First video card: Hero style with overlay title --- */
    .widget_video_posts .video-post-card:first-child {
        border-radius: 0;
        position: relative;
    }

    .widget_video_posts .video-post-card:first-child .video-thumbnail-container {
        aspect-ratio: 16/9;
    }

    .widget_video_posts .video-post-card:first-child .video-thumbnail-container a {
        height: 100%;
    }

    /* Gradient overlay on first card */
    .widget_video_posts .video-post-card:first-child .video-overlay {
        opacity: 1 !important;
        background: linear-gradient(
            to top,
            hsla(0, 0%, 0%, 0.85) 0%,
            hsla(0, 0%, 0%, 0.55) 35%,
            hsla(0, 0%, 0%, 0.15) 60%,
            hsla(0, 0%, 0%, 0) 100%
        ) !important;
    }

    .widget_video_posts .video-post-card:first-child .video-post-content {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 0.8rem 1rem;
        z-index: 2;
    }

    .widget_video_posts .video-post-card:first-child .video-post-title {
        font-size: 0.85rem !important;
        line-height: 1.3 !important;
        text-transform: none !important;
    }

    .widget_video_posts .video-post-card:first-child .video-post-title a {
        color: #fff !important;
        text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    }

    /* Glassmorphism play button */
    .widget_video_posts .play-icon {
        width: 40px !important;
        height: 40px !important;
        background: rgba(255, 255, 255, 0.2) !important;
        /* backdrop-filter removed for CPU performance */
        border: 1px solid rgba(255, 255, 255, 0.3);
        border-radius: 50%;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    }

    .widget_video_posts .play-icon svg {
        width: 18px;
        height: 18px;
        fill: #fff;
        stroke: #fff;
    }

    /* First card: play button repositioned top-right */
    .widget_video_posts .video-post-card:first-child .play-icon {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        z-index: 3;
    }

    /* --- Cards 2-5: Compact horizontal layout --- */
    .widget_video_posts .video-post-card:not(:first-child) {
        display: flex !important;
        flex-direction: row !important;
        align-items: center;
        border-radius: 0 !important;
        background: #fff !important;
        border-top: 1px solid #f0f0f0;
        padding: 0.6rem 1rem;
        gap: 0.7rem;
    }

    .widget_video_posts .video-post-card:not(:first-child) .video-thumbnail-container {
        flex: 0 0 80px;
        border-radius: 8px;
        overflow: hidden;
        position: relative;
    }

    .widget_video_posts .video-post-card:not(:first-child) .video-thumbnail-container img {
        width: 80px !important;
        height: 52px !important;
        aspect-ratio: auto !important;
        object-fit: cover;
    }

    /* Small play button on compact cards */
    .widget_video_posts .video-post-card:not(:first-child) .play-icon {
        width: 24px !important;
        height: 24px !important;
    }

    .widget_video_posts .video-post-card:not(:first-child) .play-icon svg {
        width: 11px;
        height: 11px;
    }

    .widget_video_posts .video-post-card:not(:first-child) .video-overlay {
        opacity: 1 !important;
        background: rgba(0, 0, 0, 0.25) !important;
        border-radius: 8px;
    }

    .widget_video_posts .video-post-card:not(:first-child) .video-post-content {
        flex: 1;
        min-width: 0;
        padding: 0 !important;
    }

    .widget_video_posts .video-post-card:not(:first-child) .video-post-title {
        font-size: 0.78rem !important;
        line-height: 1.3 !important;
        text-transform: none !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .widget_video_posts .video-post-card:not(:first-child) .video-post-title a {
        color: #333 !important;
        text-decoration: none;
    }

    .widget_video_posts .video-post-card:not(:first-child) .video-post-title a:hover {
        color: var(--senego-color-primary) !important;
    }

    /* Hover effect on compact cards */
    .widget_video_posts .video-post-card:not(:first-child):hover {
        background: var(--senego-color-surface-subtle) !important;
    }

    /* Right sidebar ad containers */
    .home-content-area #secondary .widget {
        max-width: 100%;
        overflow: hidden;
    }

    /* =============================================================
       PREMIUM "DÉBATS DE LA SEMAINE" WIDGET
       Inspired by: NYT "Most Popular" sidebar, The Verge trending,
       numbered ranking with accent color highlight
       ============================================================= */

    .widget_popular_weekly {
        background: #fff;
        border-radius: var(--soft-radius);
        overflow: hidden;
        box-shadow: var(--soft-shadow);
        padding: 0 !important;
        margin-bottom: 1.5rem;
    }

    /* Bandeau unifié = même style que le composant DS (.senego-section-head). */
    .widget_popular_weekly .widget-title {
        position: relative;
        display: block;
        font-size: 1.05rem;
        font-weight: 700;
        text-transform: none !important;
        letter-spacing: 0;
        padding: 0.85rem 1.1rem 0.7rem 1.5rem;
        margin-bottom: 0 !important;
        border-bottom: 1px solid var(--senego-color-border-soft);
    }
    .widget_popular_weekly .widget-title::before {
        content: "";
        position: absolute;
        left: 1.1rem;
        top: 0.9rem;
        bottom: 0.7rem;
        width: 4px;
        border-radius: 2px;
        background: var(--senego-color-primary);
    }

    .widget_popular_weekly .popular-weekly-list {
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Each ranked item */
    .widget_popular_weekly .popular-weekly-item {
        padding: 0 !important;
        border-bottom: 1px solid #f0f0f0 !important;
    }
    .widget_popular_weekly .popular-weekly-item:last-child {
        border-bottom: none !important;
    }

    .widget_popular_weekly .popular-weekly-link {
        display: flex;
        align-items: center;
        gap: 0.8rem;
        padding: 0.75rem 1rem;
        text-decoration: none;
        transition: background 0.15s ease;
    }
    .widget_popular_weekly .popular-weekly-link:hover {
        background: var(--senego-color-surface-subtle);
    }

    /* Large rank number — bold accent style */
    .widget_popular_weekly .popular-weekly-link::before {
        font-size: 1.6rem !important;
        font-weight: 800 !important;
        color: var(--senego-color-primary) !important;
        min-width: 1.8rem !important;
        text-align: center;
        line-height: 1;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    }

    /* Top 3 get special treatment */
    .widget_popular_weekly .popular-weekly-item:nth-child(1) .popular-weekly-link::before {
        color: #ff6600 !important;
        font-size: 1.8rem !important;
    }
    .widget_popular_weekly .popular-weekly-item:nth-child(2) .popular-weekly-link::before {
        color: #ff8800 !important;
    }
    .widget_popular_weekly .popular-weekly-item:nth-child(3) .popular-weekly-link::before {
        color: #ffaa00 !important;
    }

    /* Thumbnail — rounded square */
    .widget_popular_weekly .popular-weekly-thumbnail {
        flex-shrink: 0;
        width: 56px !important;
        height: 56px !important;
        border-radius: 8px;
        overflow: hidden;
    }
    .widget_popular_weekly .popular-weekly-thumbnail img {
        width: 56px !important;
        height: 56px !important;
        object-fit: cover;
        border-radius: 8px;
    }

    /* Title text */
    .widget_popular_weekly .popular-weekly-title {
        font-size: 0.82rem !important;
        line-height: 1.35 !important;
        font-weight: 600;
        color: var(--senego-color-text);
        margin: 0 0 0.2rem 0 !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-transform: none !important;
    }
    .widget_popular_weekly .popular-weekly-link:hover .popular-weekly-title {
        color: var(--senego-color-primary);
    }

    /* Comment count badge */
    .widget_popular_weekly .comment-count {
        display: inline-flex;
        align-items: center;
        gap: 3px;
        font-size: 0.72rem;
        color: #595959;
        font-weight: 500;
    }
    .widget_popular_weekly .comment-count svg {
        width: 12px;
        height: 12px;
        color: #767676;
    }

    /* "Aucun article" fallback */
    .widget_popular_weekly > p {
        padding: 1.5rem 1rem;
        color: #999;
        font-size: 0.85rem;
        text-align: center;
    }
}

/* === Pinned articles responsive (déplacé de core.css — modularité) === */
@media (max-width: 767px) {
    /* Pinned articles (sidebar component - show on mobile too) */
    .pinned-articles-sidebar {
        margin: 0;
        padding: 0 var(--mobile-padding);
    }

    .pinned-articles-container {
        padding: 0;
    }

    .pinned-article-image {
        height: 100px;
        border-radius: 8px 8px 0 0;
    }

    .pinned-article {
        border-radius: var(--mobile-radius);
        box-shadow: var(--card-shadow);
    }
}
