/**
 * Single — Sommaire automatique (TOC)
 * Charte carnet de voyage — guide-expatriation.fr
 *
 * Variables héritées du thème : --ink, --ink-muted, --terra, --terra-deep,
 * --bg-card, --rule, --hand (Caveat), --sans (Manrope)
 *
 * @since 1.1.0
 */

/* ── Smooth scroll global (compense header sticky) ── */
html {
    scroll-behavior: smooth;
    scroll-padding-top: 88px; /* header height ~72px + marge */
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* Composant partagé .ge-article-toc                                          */
/* ─────────────────────────────────────────────────────────────────────────── */

.ge-article-toc {
    background: var(--bg-card, #FFFAF0);
    border: 1px solid var(--rule, #E8D5A5);
    border-radius: 16px;
    padding: 1.5rem 1.25rem 1.25rem;
    position: relative;
}

/* Titre "Au sommaire" — Caveat manuscrit, incliné, terracotta */
.ge-toc-title {
    display: block;
    font-family: var(--hand, 'Caveat', cursive);
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--terra, #C2410C);
    line-height: 1.1;
    margin: 0 0 1rem -0.15rem;
    transform: rotate(-2deg);
    transform-origin: left center;
}

/* Liste numérotée */
.ge-toc-list {
    margin: 0;
    padding: 0 0 0 0.25rem;
    list-style: none;
    counter-reset: toc-counter;
}

.ge-toc-item {
    counter-increment: toc-counter;
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.35rem 0;
    border-bottom: 1px dashed var(--rule, #E8D5A5);
}

.ge-toc-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* Numéro — annotation Caveat terracotta */
.ge-toc-item::before {
    content: counter(toc-counter);
    font-family: var(--hand, 'Caveat', cursive);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--terra, #C2410C);
    flex-shrink: 0;
    min-width: 1.2rem;
    line-height: 1;
}

/* Liens */
.ge-toc-link {
    font-family: var(--sans, 'Manrope', sans-serif);
    font-size: 0.93rem;
    font-weight: 500;
    color: var(--ink-muted, #7A5C36);
    text-decoration: none;
    line-height: 1.4;
    transition: color 0.2s ease;
}

.ge-toc-link:hover,
.ge-toc-link:focus-visible {
    color: var(--terra, #C2410C);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Lien actif (mis à jour par IntersectionObserver) */
.ge-toc-link.is-active {
    color: var(--terra, #C2410C);
    font-weight: 700;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* Version desktop sticky (dans .ge-article-aside)                            */
/* ─────────────────────────────────────────────────────────────────────────── */

.ge-toc-desktop {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--rule, #E8D5A5) transparent;
}

.ge-toc-desktop::-webkit-scrollbar {
    width: 4px;
}
.ge-toc-desktop::-webkit-scrollbar-track {
    background: transparent;
}
.ge-toc-desktop::-webkit-scrollbar-thumb {
    background: var(--rule, #E8D5A5);
    border-radius: 2px;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* Version mobile accordéon (<details>/<summary>)                             */
/* ─────────────────────────────────────────────────────────────────────────── */

.ge-toc-mobile {
    margin-bottom: 1.75rem;
}

/* Masquer le marqueur natif du <details> */
.ge-toc-mobile summary {
    list-style: none;
}
.ge-toc-mobile summary::-webkit-details-marker {
    display: none;
}

.ge-toc-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0;
    user-select: none;
}

/* Le titre "Au sommaire" est directement dans le summary — même style Caveat */
.ge-toc-summary .ge-toc-title {
    margin-bottom: 0;
    pointer-events: none;
}

/* Chevron d'ouverture/fermeture */
.ge-toc-toggle-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    background-color: var(--terra, #C2410C);
    border-radius: 50%;
    position: relative;
    transition: transform 0.25s ease;
}

.ge-toc-toggle-icon::before,
.ge-toc-toggle-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 2px;
    background: #fff;
    border-radius: 1px;
    transform-origin: center;
}
.ge-toc-toggle-icon::before {
    transform: translate(-50%, -50%) rotate(-45deg);
    margin-left: -2px;
}
.ge-toc-toggle-icon::after {
    transform: translate(-50%, -50%) rotate(45deg);
    margin-left: 2px;
}

/* Rotation quand ouvert */
.ge-toc-mobile[open] .ge-toc-toggle-icon {
    transform: rotate(180deg);
}

/* Liste dans l'accordéon — espacement après ouverture */
.ge-toc-mobile .ge-toc-list {
    margin-top: 1rem;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* Breakpoints — affichage conditionnel                                        */
/* ─────────────────────────────────────────────────────────────────────────── */

/* Mobile : cacher le sticky desktop */
@media (max-width: 1023px) {
    .ge-toc-desktop {
        display: none;
    }
}

/* Desktop : cacher l'accordéon mobile */
@media (min-width: 1024px) {
    .ge-toc-mobile {
        display: none;
    }
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* Layout .ge-article-aside — colonne latérale                                */
/* ─────────────────────────────────────────────────────────────────────────── */

.ge-article-aside {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Sur mobile la colonne aside est naturellement sous le content */
@media (max-width: 1023px) {
    .ge-article-aside {
        display: none; /* aside masqué sur mobile — le TOC mobile prend le relais */
    }
}
