/*
 * Reset "pare-feu" contre les styles globaux de bouton du thème/page builder.
 * Sur beaucoup de thèmes/Elementor, `button {}` porte un style CTA (fond
 * sombre, padding, radius, couleur inversée) qui "mange" nos liens de
 * sommaire si on ne le neutralise pas explicitement à chaque propriété.
 */
.wedrive-toc button {
    all: unset !important;
    box-sizing: border-box !important;
    cursor: pointer !important;
    font-family: var(--wedrive-toc-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif) !important;
}

.wedrive-toc {
    --wedrive-toc-accent: #2563eb; /* écrasé par les variables générées en PHP (réglages admin) */
    font-family: var(--wedrive-toc-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif) !important;
    background: #ffffff;
    border: 1px solid rgba(17, 24, 39, 0.06);
    border-radius: var(--wedrive-toc-radius, 16px);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
    padding: 22px 26px;
    margin: 24px 0;
    font-size: var(--wedrive-toc-font-size, 15px);
    line-height: var(--wedrive-toc-line-height, 1.65);
    box-sizing: border-box;
}

.wedrive-toc *,
.wedrive-toc *::before,
.wedrive-toc *::after {
    box-sizing: border-box;
    font-family: var(--wedrive-toc-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif) !important;
}

.wedrive-toc__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: nowrap;
}

.wedrive-toc__title {
    font-weight: 700;
    font-size: 1.05em;
    color: #111827;
    flex: 1 1 auto;
    min-width: 0;
}

.wedrive-toc__reading-time {
    display: block;
    font-weight: 400;
    color: #9ca3af;
    font-size: 0.85em;
    margin-top: 4px;
}

.wedrive-toc__toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 4px !important;
    flex: 0 0 auto;
}

.wedrive-toc__toggle-icon {
    width: 9px;
    height: 9px;
    border-right: 2px solid var(--wedrive-toc-toggle-color, var(--wedrive-toc-accent, #2563eb));
    border-bottom: 2px solid var(--wedrive-toc-toggle-color, var(--wedrive-toc-accent, #2563eb));
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    display: block;
}

.wedrive-toc__toggle[aria-expanded="false"] .wedrive-toc__toggle-icon {
    transform: rotate(-45deg);
}

/* Barre de progression de lecture */
.wedrive-toc__progress {
    width: 100%;
    height: 3px;
    background: rgba(17, 24, 39, 0.06);
    border-radius: 2px;
    margin-top: 14px;
    overflow: hidden;
}

.wedrive-toc__progress-bar {
    height: 100%;
    width: 0%;
    background: var(--wedrive-toc-progress, var(--wedrive-toc-accent, #2563eb));
    border-radius: 2px;
    transition: width 0.1s linear;
}

.wedrive-toc__list {
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
}

/* Style "sobre" (par défaut, façon image de référence) : texte simple, sans
   marqueur, espacement généreux */
.wedrive-toc__list--sober > .wedrive-toc__item > .wedrive-toc__link::before {
    content: "";
}

.wedrive-toc__list--numbered {
    counter-reset: wedrive-toc-counter;
}
.wedrive-toc__list--numbered > .wedrive-toc__item {
    counter-increment: wedrive-toc-counter;
}
.wedrive-toc__list--numbered > .wedrive-toc__item > .wedrive-toc__link::before {
    content: counter(wedrive-toc-counter) ". ";
    font-weight: 600;
    color: var(--wedrive-toc-accent, #2563eb);
}

.wedrive-toc__list--lettered {
    counter-reset: wedrive-toc-letter;
}
.wedrive-toc__list--lettered > .wedrive-toc__item {
    counter-increment: wedrive-toc-letter;
}
.wedrive-toc__list--lettered > .wedrive-toc__item > .wedrive-toc__link::before {
    content: counter(wedrive-toc-letter, lower-alpha) ". ";
    font-weight: 600;
    color: var(--wedrive-toc-accent, #2563eb);
}

.wedrive-toc__list--bullet > .wedrive-toc__item > .wedrive-toc__link::before {
    content: "•";
    display: inline-block;
    margin-right: 8px;
    color: var(--wedrive-toc-accent, #2563eb);
    font-weight: 700;
}

.wedrive-toc__item {
    margin: var(--wedrive-toc-item-spacing, 9px) 0;
}

.wedrive-toc__item--h3 {
    margin-left: 18px;
    font-size: 0.95em;
}

.wedrive-toc__item--h4 {
    margin-left: 36px;
    font-size: 0.9em;
}

.wedrive-toc__link {
    color: #4b5563 !important;
    text-align: left !important;
    display: inline-block !important;
    line-height: inherit !important;
    text-decoration: none !important;
    transition: color 0.15s ease;
}

.wedrive-toc__link:hover,
.wedrive-toc__link:focus-visible {
    color: var(--wedrive-toc-hover, var(--wedrive-toc-accent, #2563eb)) !important;
    text-decoration: underline !important;
}

.wedrive-toc__item.is-active > .wedrive-toc__link {
    color: var(--wedrive-toc-active, var(--wedrive-toc-accent, #2563eb)) !important;
    font-weight: 600;
}

/* Variante sticky (sidebar) — à activer en ajoutant la classe CSS
   additionnelle "wedrive-toc--sticky" au widget/conteneur dans Elementor */
.wedrive-toc--sticky {
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

/* Bouton "retour au sommaire", inséré à la fin de chaque section.
   Ici on VEUT un style de bouton visible : on rétablit explicitement
   chaque propriété après le reset "all: unset" plutôt que de compter
   sur la cascade, pour ne pas hériter du design CTA du thème. */
.wedrive-toc-back-wrap {
    margin: 20px 0;
    clear: both;
}

.wedrive-toc-back {
    display: inline-block !important;
    background: #f3f4f6 !important;
    border: 1px solid #e5e7eb !important;
    color: #374151 !important;
    font-size: 13px !important;
    padding: 6px 14px !important;
    border-radius: 999px !important;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.wedrive-toc-back:hover,
.wedrive-toc-back:focus-visible {
    background: var(--wedrive-toc-accent, #2563eb) !important;
    border-color: var(--wedrive-toc-accent, #2563eb) !important;
    color: #fff !important;
}

/* Ajustements pour petits écrans */
@media (max-width: 480px) {
    .wedrive-toc {
        padding: 16px 18px;
        font-size: 14px;
    }
    .wedrive-toc__header {
        gap: 8px;
    }
}
