/*! Vauban — Composant Info-bulle unifié (.vauban-tip + #vauban-tip-portal)
 * =====================================================================
 * Remplace les mécanismes historiques (.vauban-help-tip, .vad-tip, le portail
 * step-4 .tooltip-container, .vbn-sup-count-info, et les title= natifs) par UN
 * composant unique, sobre et moderne.
 *
 * Convention :
 *   - Pastille d'aide « ? / i » : <span class="vauban-tip" data-vauban-tip="…">
 *     (générée par le helper PHP vauban_tip()).
 *   - N'importe quel élément (bouton, lien, badge) : data-vauban-tip="…"
 *     (et data-vauban-tip-title="…" pour la variante riche titre + corps).
 *
 * Le moteur JS (assets/js/components/vauban-tooltip.js) rend la bulle dans un
 * portail unique sur <body> (position:fixed → échappe aux overflow / z-index).
 *
 * Couleurs : 100 % via tokens --vt-tip-* (socle 00-semantic-tokens.css) → bascule
 * clair / sombre automatique, aucune couleur en dur ici (lint anti-hex conforme).
 * ===================================================================== */

/* ── Pastille déclencheur « ? / i » (inline, hérite du thème de son conteneur) ── */
.vauban-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 13px;
    height: 13px;
    margin-left: 4px;
    padding: 0;
    border: 1px solid var(--vt-tip-pill-border);
    border-radius: 50%;
    background: var(--vt-tip-pill-bg);
    color: var(--vt-tip-pill-fg);
    font-family: inherit;
    font-size: 9px;
    font-weight: 700;
    font-style: normal;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    vertical-align: middle;
    cursor: help;
    user-select: none;
    -webkit-user-select: none;
    transition: background .14s ease, color .14s ease, border-color .14s ease, box-shadow .14s ease;
}

.vauban-tip:hover {
    background: var(--vt-tip-pill-bg-hover);
    color: var(--vt-tip-pill-fg-hover);
    border-color: var(--vt-tip-pill-bg-hover);
}

.vauban-tip:focus-visible {
    background: var(--vt-tip-pill-bg-hover);
    color: var(--vt-tip-pill-fg-hover);
    border-color: var(--vt-tip-pill-bg-hover);
    outline: none;
    box-shadow: 0 0 0 3px var(--vt-tip-pill-border);
}

/* ── Portail (bulle) — rendu unique sur <body>, positionné par JS ── */
#vauban-tip-portal {
    position: fixed;
    top: -9999px;
    left: -9999px;
    z-index: 2147483647;
    box-sizing: border-box;
    max-width: min(300px, calc(100vw - 24px));
    padding: 9px 13px;
    border: 1px solid var(--vt-tip-border);
    border-radius: 12px;
    background: var(--vt-tip-bg);
    /* blur(14px) réduit à blur(4px) : l'effet verre dépoli est conservé mais le
     * coût GPU est ~12× inférieur (rayon de blur est la variable la plus coûteuse).
     * La bulle est petite (~300px) : la différence visuelle est imperceptible. */
    -webkit-backdrop-filter: blur(4px) saturate(130%);
    backdrop-filter: blur(4px) saturate(130%);
    color: var(--vt-tip-text);
    box-shadow: var(--vt-tip-shadow);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.45;
    text-align: left;
    white-space: normal;
    word-wrap: break-word;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-4px) scale(.94);
    transform-origin: center top;
    transition: opacity .14s ease, transform .2s cubic-bezier(.34, 1.56, .64, 1);
    /* Pré-promotion GPU : opacity+transform restent sur le compositor thread
     * sans déclencher de layout ni de paint durant l'animation. */
    will-change: transform, opacity;
}

#vauban-tip-portal.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Variante riche : titre + corps */
#vauban-tip-portal .vauban-tip-portal__title {
    display: block;
    margin: 0 0 3px;
    color: var(--vt-tip-title);
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.35;
}

#vauban-tip-portal .vauban-tip-portal__body {
    display: block;
    color: var(--vt-tip-text);
}

/* Flèche : carré pivoté, même fond que la bulle, à cheval sur le bord (placé par JS) */
#vauban-tip-portal .vauban-tip-portal__arrow {
    position: absolute;
    width: 9px;
    height: 9px;
    background: var(--vt-tip-bg);
    transform: rotate(45deg);
    pointer-events: none;
}

/* Voile de fond : léger flou du site derrière l'infobulle ouverte.
   Sous le portail (z-index inférieur), plein écran, sans interception du pointeur
   (pointer-events:none) → ne coupe pas le survol du déclencheur. */
#vauban-tip-scrim {
    position: fixed;
    inset: 0;
    z-index: 2147483646;
    pointer-events: none;
    opacity: 0;
    background: var(--vt-tip-scrim-bg);
    /* backdrop-filter retiré du state initial : animer blur sur un overlay
     * plein-écran force le navigateur à composite-r toute la page à chaque frame
     * → source principale de saccade. On anime uniquement opacity (GPU, zéro
     * reflow). Le blur est posé statiquement sur .is-visible : il apparaît
     * instantanément (imperceptible à 0.8px) pendant que l'opacity transite. */
    transition: opacity .25s ease;
    will-change: opacity;
}

#vauban-tip-scrim.is-visible {
    opacity: 1;
    -webkit-backdrop-filter: blur(0.8px);
    backdrop-filter: blur(0.8px);
}

/* Respect de prefers-reduced-motion : pas d'animation de translation/échelle */
@media (prefers-reduced-motion: reduce) {
    #vauban-tip-scrim {
        transition: opacity .01ms linear;
    }
    .vauban-tip {
        transition: none;
    }
    #vauban-tip-portal {
        transition: opacity .01ms linear;
        transform: none;
    }
    #vauban-tip-portal.is-visible {
        transform: none;
    }
}
