/* =========================================================
   Défilement fluide lors d'un clic sur une ancre
   ========================================================= */
html {
    scroll-behavior: smooth;
}

/* =========================================================
   Base visuelle générale
   - finesse premium
   - lisibilité
   ========================================================= */
/* =========================================================
   PALETTE SOBRE (style Microsoft Docs)
   ========================================================= */
:root {
    --toc-bg: #ffffff;
    --toc-bg-soft: #f6f8fb;

    --toc-border: #e5e7eb;

    --toc-text: #1f2937;
    --toc-text-soft: #6b7280;

    --toc-primary: #2563eb;        /* bleu plus doux */
    --toc-primary-soft: #93c5fd;   /* bleu clair */

    --toc-track: #e5eaf2;

    --toc-shadow-soft: 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* =========================================================
   Bloc global du sommaire mobile
   ========================================================= */
.toc-shell {
    border: 1px solid var(--toc-border);
    border-radius: 0.75rem;
    background: var(--toc-bg);
    overflow: hidden;
    margin: 1rem 0 1.5rem;
    box-shadow: var(--toc-shadow-soft);
}

/* =========================================================
   Bouton du sommaire
   ========================================================= */
.toc-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;

    width: 100%;
    border: 0;
    background: var(--toc-bg-soft);
    color: #111827;
    padding: 0.95rem 1rem;
    text-align: left;
    font-weight: 700;
    line-height: 1.3;
    cursor: pointer;
    transition:
        background-color 0.2s ease,
        color 0.2s ease;
}

.toc-toggle:hover,
.toc-toggle:focus-visible {
    background: #eef2f6;
    color: #0b5ed7;
    outline: none;
}

/* =========================================================
   Flèche du bouton : mobile uniquement
   ========================================================= */
@media (max-width: 991.98px) {
    .toc-toggle::after {
        content: "▼";
        transition: transform 0.25s ease;
    }

    .toc-toggle.open::after {
        transform: rotate(180deg);
    }
}

/* Desktop : bouton affiché comme titre passif */
@media (min-width: 992px) {
    .toc-toggle {
        pointer-events: none;
        opacity: 0.72;
        cursor: default;
    }

    .toc-toggle::after {
        content: "";
    }
}

/* =========================================================
   Panneau du sommaire
   ========================================================= */
.toc-panel {
    padding: 0.75rem 1rem 1rem;
    background: var(--toc-bg);
    overflow: hidden;
    transition:
        max-height 0.3s ease,
        opacity 0.25s ease;
}

/* Fermé */
.toc-panel[hidden] {
    max-height: 0;
    opacity: 0;
}

/* Ouvert */
.toc-panel:not([hidden]) {
    max-height: 200vh;
    opacity: 1;
}

/* =========================================================
   Message d’aide mobile
   ========================================================= */
.toc-help-text {
    margin: 0.5rem 1rem 0.8rem;
    font-size: 0.92rem;
    line-height: 1.45;
    color: var(--toc-text-soft);
}

/* =========================================================
   Sidebar desktop
   ========================================================= */
.toc-sidebar {
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding-right: 0.5rem;
}

.toc-sidebar::-webkit-scrollbar {
    width: 6px;
}

.toc-sidebar::-webkit-scrollbar-thumb {
    background: #c7ced8;
    border-radius: 999px;
}

.toc-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

/* =========================================================
   Liste du sommaire
   ========================================================= */
.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-list li {
    margin: 0;
    padding: 0;
}

.toc-list a {
    position: relative;
    display: block;
    text-decoration: none;
    color: var(--toc-text);
    padding: 0.42rem 0.5rem 0.42rem 1.7rem;
    border-radius: 0.5rem;
    line-height: 1.35;

    transition:
        background-color 0.18s ease,
        color 0.18s ease,
        transform 0.18s ease,
        opacity 0.18s ease,
        box-shadow 0.18s ease;
}

/* =========================================================
   Amélioration visuelle des liens (plus sobre)
   ========================================================= */

.toc-list a {
    font-size: 0.95rem;
    color: var(--toc-text);
}

/* Hover discret */
.toc-list a:hover {
    background: #f5f8ff;
    color: var(--toc-primary);
    transform: translateX(2px);
}

/* Actif plus subtil */
.toc-list a.is-active {
    background: #eef4ff;
    color: var(--toc-primary);
    font-weight: 600;
}

/* Déjà parcouru */
.toc-list a.is-passed {
    color: #4f6fbf;
}

/* Hover */
.toc-list a:hover {
    background: #f3f6fb;
    color: var(--toc-primary);
    transform: translateX(3px);
}

/* Focus accessibilité */
.toc-list a:focus-visible {
    background: #f3f6fb;
    color: var(--toc-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

/* =========================================================
   États : actif + déjà parcouru
   ========================================================= */
.toc-list a.is-active {
    background: #e7f1ff;
    color: var(--toc-primary);
    font-weight: 700;
}

.toc-list a.is-passed {
    color: #2457c5;
}

/* =========================================================
   Indentation des niveaux
   ========================================================= */
.toc-level-1 a { padding-left: 1.7rem; }
.toc-level-2 a { padding-left: 2.25rem; }
.toc-level-3 a { padding-left: 2.8rem; }
.toc-level-4 a { padding-left: 3.35rem; }

/* =========================================================
   Numéro injecté devant les titres
   ========================================================= */
.section-no {
    margin-right: 0.35rem;
    color: #6c757d;
    font-weight: 700;
}

/* =========================================================
   Décalage pour header fixe
   IMPORTANT :
   utilisé par le scroll d’ancre et la logique JS
   ========================================================= */
#article-content h1,
#article-content h2,
#article-content h3,
#article-content h4 {
    scroll-margin-top: 120px;
}

/* =========================================================
   PROGRESS BAR AVANCÉE (DESKTOP)
   ========================================================= */
@media (min-width: 992px) {

    /* Variable dynamique alimentée par /js/toc.js */
    #tdm-desktop {
        --toc-progress: 0%;
        background: linear-gradient(180deg, rgba(255,255,255,0.92) 0%, rgba(255,255,255,1) 100%);
        border: 1px solid rgba(217, 217, 217, 0.7);
        border-radius: 0.75rem;
        box-shadow: var(--toc-shadow-soft)
        backdrop-filter: blur(6px);
    }

    #tdm-desktop .toc-list {
        position: relative;
        padding: 0.1rem 0;
    }

    /* Ligne verticale de fond */
    #tdm-desktop .toc-list::before {
        content: "";
        position: absolute;
        left: 11px;
        top: 0.55rem;
        bottom: 0.55rem;
        width: 2px;
        background: var(--toc-track);
        border-radius: 2px;
    }

    /* Ligne bleue de progression */
    #tdm-desktop .toc-list::after {
        content: "";
        position: absolute;
        left: 11px;
        top: 0.55rem;
        width: 2px;
        height: var(--toc-progress);
        background: linear-gradient(180deg, #9ec5ff 0%, #2563eb 100% );
        border-radius: 2px;
        transition: height 0.18s ease-out;
    }

    /* Point de chaque entrée */
    #tdm-desktop .toc-list a::before {
        content: "";
        position: absolute;
        top: 50%;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #d1d9e6;
        transform: translateY(-50%);
        transition:
            background-color 0.18s ease,
            transform 0.18s ease,
            box-shadow 0.18s ease;
    }

    /* Position des points selon le niveau */
    #tdm-desktop .toc-level-1 a::before { left: 8px; }
    #tdm-desktop .toc-level-2 a::before { left: 13px; }
    #tdm-desktop .toc-level-3 a::before { left: 18px; }
    #tdm-desktop .toc-level-4 a::before { left: 23px; }

    /* Section active */
    #tdm-desktop .toc-list a.is-active::before {
    background: var(--toc-primary);
    transform: translateY(-50%) scale(1.15);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    }

    /* Sections déjà parcourues */
    #tdm-desktop .toc-list a.is-passed::before {
        background: var(--toc-primary-soft);
    }

    /* Masquage du TOC mobile en desktop */
    #tdm-mobile,
    .toc-shell,
    .toc-help-text {
        display: none !important;
    }

    .toc-panel[hidden] {
        display: block !important;
    }
}

/* =========================================================
   MOBILE
   ========================================================= */
@media (max-width: 991.98px) {

    #tdm-desktop,
    .toc-sidebar {
        display: none !important;
    }

    .toc-panel[hidden] {
        display: none !important;
    }

    /* Pas de progress bar envahissante sur mobile */
    #tdm-mobile .toc-list a::before {
        content: none;
    }
}

/* =========================================================
   STRUCTURE TYPOGRAPHIQUE DU CONTENU
   - améliore la précision du sommaire
   - améliore la lisibilité
   ========================================================= */
.article-body {
    max-width: 760px; /* meilleure lecture */
    /*color: #1f2937;*/
    color: var(--text-main);
}

.article-body h2 {
    margin-top: 3rem;
    margin-bottom: 1rem;
    font-weight: 650;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.article-body h3 {
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
}

.article-body p,
.article-body ul {
    margin-bottom: 1.2rem;
}

.article-body p {
    font-size: 1rem;
    line-height: 1.75;
    color: #2d3748;
}

.article-body ul {
    padding-left: 1.25rem;
}

.article-body code {
    background: #f3f6fb;
    border: 1px solid #e5eaf2;
    border-radius: 0.35rem;
    padding: 0.08rem 0.35rem;
    font-size: 0.95em;
    color: #0b5ed7;
}

/* =========================================================
   Respect de l’accessibilité :
   réduit les animations si l’utilisateur le demande
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .toc-toggle,
    .toc-toggle::after,
    .toc-panel,
    .toc-list a,
    #tdm-desktop .toc-list::after,
    #tdm-desktop .toc-list a::before {
        transition: none !important;
    }
}