/* Badge ancre */
.heading-anchor {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 10px;
    padding: 3px 8px;
    background-color: #f1f3f5;
    color: #3b3b3b;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.45em; /* Ajusté proportionnellement au titre */
    font-weight: 500;
    line-height: 1;
    vertical-align: middle;
    text-decoration: none;
    opacity: 0;
    cursor: pointer;
    transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    user-select: none;
}

/* Génération du texte en CSS (invisible pour la table des matières) */
.heading-anchor .anchor-icon::before {
    content: "#";
}

.heading-anchor .anchor-text::before {
    content: "Copier le lien";
}

/* Apparition au survol du titre */
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor {
    opacity: 1;
}

/* Survol direct du badge */
.heading-anchor:hover {
    background-color: #e9ecef;
    color: #212529;
    border-color: #ced4da;
}

/* État après clic (Lien copié) */
.heading-anchor.copied {
    background-color: #e6fcf5;
    color: #0ca678;
    border-color: #b2f2bb;
}

.heading-anchor.copied .anchor-icon::before {
    content: "✔";
}

.heading-anchor.copied .anchor-text::before {
    content: "Lien copié !";
}