/* --------------------------------------------------
 *  Variables de Design V3 (Thème Clair par défaut)
 *  -------------------------------------------------- */
:root {
    --v3-font-text: 'Lora', serif;
    --v3-font-ui: 'Montserrat', sans-serif;
    --v3-color-brand: #ff6233;
    --v3-radius: 12px;
    --v3-bg: #ffffff;
    --v3-surface: #f8f9fa;
    --v3-text: #2c2c2c;
    --v3-text-mut: #777777;
    --v3-border: #eaeaea;
}

/* --------------------------------------------------
 *  Thème Sombre V3 (Piloté par le bouton / JS)
 *  -------------------------------------------------- */
html[data-theme="dark"],
html.theme-dark {
    --v3-bg: #121212;
    --v3-surface: #1e1e1e;
    --v3-text: #e0e0e0;
    --v3-text-mut: #999999;
    --v3-border: #333333;
}

body {
    background-color: var(--v3-bg);
    color: var(--v3-text);
    transition: background-color 0.3s, color 0.3s;
    margin: 0;
}

/* ============================================================
 * 1. STRUCTURE GLOBALE (Mobile First)
 * ============================================================ */
.ch-v3-body-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1400px !important;
    margin: 0 auto;
    padding: 0 1.5rem;
    box-sizing: border-box;
}

.ch-v3-reading-zone {
    width: 100%;
    min-width: 0;
}

/* Sur Mobile : Gauche cachée, Droite passe en bas de page */
.ch-v3-sidebar-left {
    display: none;
}

.ch-v3-sidebar-right {
    display: block;
    margin-top: 3rem;
    border-top: 2px solid var(--v3-border);
    padding-top: 2rem;
}

/* ============================================================
 * 2. STRUCTURE DESKTOP (3 Colonnes délimitées)
 * ============================================================ */
@media (min-width: 1024px) {
    .ch-v3-body-wrapper {
        flex-direction: row;
        justify-content: space-between;
        gap: 3rem;
    }

    .ch-v3-sidebar-left {
        display: block !important;
        flex: 0 0 220px;
        border-right: 1px solid var(--v3-border);
        padding-right: 2rem;
    }

    .ch-v3-main-content {
        flex: 1 1 auto;
        max-width: 780px;
    }

    .ch-v3-sidebar-right {
        display: block !important;
        flex: 0 0 320px;
        margin-top: 0;
        border-top: none;
        padding-top: 0;
        border-left: 1px solid var(--v3-border);
        padding-left: 2rem;
    }
}

/* ============================================================
 * 3. WIDGETS SIDEBARS
 * ============================================================ */
.ch-v3-sticky-sidebar {
    position: -webkit-sticky;
    position: sticky;
    top: 100px;
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.ch-v3-sidebar-label {
    display: block;
    font-family: var(--v3-font-ui);
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--v3-text-mut);
    margin-bottom: 0.8rem;
    letter-spacing: 1px;
    border-bottom: 2px solid var(--v3-border);
    padding-bottom: 0.5rem;
}

/* Grille de boutons de Partage (6 Boutons) */
.share-buttons-premium {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.share-buttons-premium .btn-share {
    width: 100%;
    height: 45px;
    border-radius: 8px;
    background: var(--v3-surface);
    border: 1px solid var(--v3-border);
    color: var(--v3-text-mut);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.share-buttons-premium .sb-facebook:hover {
    background: #1877F2;
    color: #fff;
    border-color: #1877F2;
}

.share-buttons-premium .sb-twitter:hover {
    background: #000000;
    color: #fff;
    border-color: #000000;
}

.share-buttons-premium .sb-linkedin:hover {
    background: #0A66C2;
    color: #fff;
    border-color: #0A66C2;
}

.share-buttons-premium .sb-whatsapp:hover {
    background: #25D366;
    color: #fff;
    border-color: #25D366;
}

.share-buttons-premium .sb-email:hover {
    background: #EA4335;
    color: #fff;
    border-color: #EA4335;
}

.share-buttons-premium .sb-copy:hover {
    background: var(--v3-color-brand);
    color: #fff;
    border-color: var(--v3-color-brand);
}

/* Sommaire généré */
.article-toc a:hover {
    color: var(--v3-color-brand) !important;
    text-decoration: underline !important;
}

/* Widget API Articles Aléatoires */
.ch-v3-widget-title {
    font-family: var(--v3-font-ui);
    font-size: 1rem;
    border-bottom: 2px solid var(--v3-color-brand);
    padding-bottom: 0.5rem;
    margin: 0 0 1rem 0;
    color: var(--v3-text);
}

.ch-v3-sidebar-widget ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ch-v3-sidebar-widget li {
    margin-bottom: 0.8rem;
    border-bottom: 1px dashed var(--v3-border);
    padding-bottom: 0.8rem;
}

.ch-v3-sidebar-widget li:last-child {
    border-bottom: none;
}

.ch-v3-sidebar-widget a {
    font-family: var(--v3-font-ui);
    font-size: 0.85rem;
    color: var(--v3-text);
    text-decoration: none;
    font-weight: 600;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: color 0.2s;
}

.ch-v3-sidebar-widget a:hover {
    color: var(--v3-color-brand);
}

.ch-v3-widget-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.ch-v3-sidebar-ad {
    background: var(--v3-surface);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--v3-border);
}

/* ============================================================
 * 4. HERO HEADER (En-tête de l'article)
 * ============================================================ */

/* --- DESKTOP (Ton code original intact) --- */
.ch-v3-hero {
    position: relative;
    min-height: 60vh;
    display: flex;
    align-items: flex-end;
    padding-bottom: 4rem;
    color: #fff;
    margin-bottom: 3rem;
}

.ch-v3-hero.no-image {
    min-height: auto;
    padding-top: 4rem;
    color: var(--v3-text);
    background-color: var(--v3-surface);
}

/* --- MOBILE UNIQUEMENT (Décalage haut + Raccourci bas) --- */
@media (max-width: 767px) {
    .ch-v3-hero {
        padding-top: 100px; /* Décale sous le header */
        padding-bottom: 2rem; /* Raccourcit en bas (au lieu de 4rem) */
        min-height: 50vh; /* Ajuste un peu la hauteur globale sur petit écran */
    }

    .ch-v3-hero.no-image {
        padding-top: 120px; /* Décale le texte sous le header */
        padding-bottom: 2rem; /* Raccourcit en bas */
    }
}

.ch-v3-hero-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.ch-v3-hero-bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ch-v3-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.2) 100%);
}

.ch-v3-hero-content {
    position: relative;
    z-index: 1;
    padding: 0 1.5rem;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

/* Breadcrumb & Tags */
.ch-v3-breadcrumb {
    font-family: var(--v3-font-ui);
    font-size: 0.8rem;
    color: rgba(255,255,255,0.7);
    margin-bottom: 2rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ch-v3-hero.no-image .ch-v3-breadcrumb {
    color: var(--v3-text-mut);
}

.ch-v3-breadcrumb a {
    color: #fff;
    text-decoration: none;
}

.ch-v3-hero.no-image .ch-v3-breadcrumb a {
    color: var(--v3-color-brand);
}

.ch-v3-tags {
    margin-bottom: 1.5rem;
}

.ch-v3-tag {
    background: var(--v3-color-brand);
    color: #fff;
    font-family: var(--v3-font-ui);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    margin-right: 0.5rem;
}

/* Titre principal souligné chic */
.ch-v3-title {
    font-family: var(--v3-font-text);
    font-size: clamp(2rem, 5vw, 3.5rem);
    line-height: 1.1;
    margin: 0 0 1.5rem 0;
    position: relative;
    padding-bottom: 15px;
}

.ch-v3-title::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 80px;
    height: 4px;
    background-color: var(--v3-color-brand);
    border-radius: 2px;
}

.ch-v3-subtitle {
    font-family: var(--v3-font-ui);
    font-size: 1.1rem;
    line-height: 1.5;
    opacity: 0.9;
    margin: 0 0 2rem 0;
    max-width: 700px;
}

/* Méta Données */
.ch-v3-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-family: var(--v3-font-ui);
    font-size: 0.9rem;
}

.ch-v3-meta-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.2);
}

.ch-v3-meta-author a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* ============================================================
 *  SMOOTH SCROLL & ANCLES (Sommaire)
 *  ============================================================ */

/* Rend le défilement fluide sur toute la page au clic sur une ancre */
html {
    scroll-behavior: smooth;
}

/* * Décalage vital !
 * Évite que les titres H2 et H3 ne soient cachés sous le header
 * quand on clique sur un lien du sommaire.
 */
.ch-v3-h2,
.ch-v3-h3 {
    scroll-margin-top: 120px; /* Ajuste si ton header est plus ou moins haut */
}

/* ============================================================
 *  6. SOMMAIRE MOBILE (Bouton flottant & Modale)
 *  ============================================================ */

/* Bouton flottant (masqué sur bureau, affiché sur mobile/tablette) */
.ch-v3-toc-fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 90;
    background-color: var(--v3-color-brand);
    color: #ffffff;
    border: none;
    border-radius: 50px;
    padding: 0.8rem 1.5rem;
    font-family: var(--v3-font-ui);
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.ch-v3-toc-fab:hover {
    transform: translateY(-3px);
}

/* Cache le bouton et la modale sur les grands écrans */
@media (min-width: 1024px) {
    .ch-v3-toc-fab,
    .ch-v3-toc-overlay {
        display: none !important;
    }
}

/* Overlay sombre (arrière-plan flouté) */
.ch-v3-toc-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    display: flex;
    align-items: flex-end; /* Modale collée en bas façon tiroir */
}

.ch-v3-toc-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

/* La modale tiroir */
.ch-v3-toc-modal {
    width: 100%;
    max-height: 80vh;
    background-color: var(--v3-surface);
    color: var(--v3-text);
    border-radius: 20px 20px 0 0;
    padding: 2rem;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -10px 25px rgba(0,0,0,0.2);
}

.ch-v3-toc-overlay.is-active .ch-v3-toc-modal {
    transform: translateY(0);
}

/* En-tête de la modale */
.ch-v3-toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--v3-border);
}

.ch-v3-toc-title {
    font-family: var(--v3-font-ui);
    font-weight: 700;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ch-v3-toc-close {
    background: none;
    border: none;
    color: var(--v3-text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

/* Liste du sommaire mobile */
.ch-v3-toc-mobile-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ch-v3-toc-mobile-list li {
    margin-bottom: 0.8rem;
}

.ch-v3-toc-mobile-list .is-subitem {
    padding-left: 20px;
}

.ch-v3-toc-link {
    color: var(--v3-text);
    text-decoration: none;
    font-family: var(--v3-font-ui);
    display: block;
    padding: 0.5rem 0;
    font-weight: 600;
    border-bottom: 1px solid transparent;
}

.ch-v3-toc-mobile-list .is-subitem .ch-v3-toc-link {
    font-weight: 400;
    font-size: 0.9rem;
}
