/* ==========================================================================
   Schémas interactifs (fiches glossaire) — feuille chargée uniquement sur les
   pages dont le front matter porte `figure:` (voir base.njk).
   Variables de tokens.css (`--figure-*`), aucune couleur en dur.
   Le SVG est dessiné par /assets/js/figure-engine.js dans `.figure-interactive-stage`.
   ========================================================================== */

.prose .figure-interactive {
    margin: var(--space-8) 0;
    padding: var(--space-5);
    background: var(--surface-light);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

.figure-interactive-stage {
    position: relative;
}

.figure-interactive-nojs {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Barre du haut : commandes à gauche, compteurs à droite */
.figure-interactive-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-light);
}

.figure-interactive-controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.figure-interactive-pick {
    position: relative;
}

.figure-interactive-pick .filter-btn.is-off {
    opacity: 0.45;
}

.figure-interactive-caret {
    margin-left: 0.4em;
    font-size: 0.75em;
}

/* Choix d'un sélecteur : petite boîte sous le bouton */
.figure-interactive-chips {
    display: none;
    position: absolute;
    top: calc(100% + var(--space-2));
    left: 0;
    z-index: 3;
    flex-wrap: wrap;
    gap: var(--space-2);
    width: max-content;
    max-width: min(300px, 80vw);
    padding: var(--space-2);
    background: var(--surface-light);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.figure-interactive-pick.is-open .figure-interactive-chips {
    display: flex;
}

/* Compteurs (tokens, erreurs, état) */
.figure-interactive-stats {
    display: flex;
    gap: var(--space-5);
    margin: 0 0 0 auto;
}

.figure-stat dt {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.figure-stat dd {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    color: var(--secondary);
}

.figure-stat.is-small dd {
    font-size: 1.125rem;
}

.figure-stat dd.is-bump {
    animation: figure-bump 0.35s ease-out;
}

@keyframes figure-bump {
    0% { transform: scale(1.15); }
    100% { transform: none; }
}

/* Message court après une action : une ligne réservée sous la barre, rien ne bouge */
.figure-interactive-toast {
    display: inline-block;
    min-height: 1.6em;
    margin-top: var(--space-3);
    max-width: 100%;
    padding: var(--space-1) var(--space-3);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    color: var(--white);
    background: var(--secondary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    opacity: 0;
    transition: opacity var(--transition-fast);
    pointer-events: none;
}

.figure-interactive-toast.is-shown {
    opacity: 1;
}

/* Le dessin */
.figure-interactive-svg {
    display: block;
    width: 100%;
    max-width: 820px;
    height: auto;
    margin: var(--space-2) auto 0;
    overflow: visible;
    font-family: var(--font-mono);
    user-select: none;
}

.figure-interactive-svg [data-act] {
    cursor: pointer;
}

.prose .figure-interactive figcaption {
    margin-top: var(--space-3);
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
}

@media (max-width: 640px) {
    .prose .figure-interactive {
        padding: var(--space-3);
    }

    .figure-interactive-stats {
        width: 100%;
        justify-content: space-between;
    }

    .figure-stat dd {
        font-size: 1.375rem;
    }

}

@media (prefers-reduced-motion: reduce) {
    .figure-stat dd.is-bump {
        animation: none;
    }
}
