/**
 * Fenêtres de chat animées de la section IA (page d'accueil).
 *
 * Une démonstration jouée en boucle : la question s'écrit, l'assistant
 * réfléchit, la réponse s'écrit à son tour. Rien n'est enregistré, rien n'est
 * appelé : c'est une mise en scène des deux exemples validés.
 *
 * L'animation est pilotée par webroot/js/ai-chat.js, qui pose et retire les
 * classes `est-visible` et `ecrit`. Sans JavaScript, les bulles restent
 * affichées avec leur texte complet : la section reste lisible.
 */

.ai-chat {
    background: #001a3f;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 18px 40px rgba(0, 47, 112, .18);
}

/* Barre de fenêtre ---------------------------------------------------------*/
.ai-chat-barre {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, .06);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.ai-chat-pastille {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ffbf23;
    flex: none;
}

.ai-chat-titre {
    color: #fff;
    font-family: "Space Grotesk", sans-serif;
    font-weight: 700;
    font-size: .82rem;
    letter-spacing: .04em;
}

/* Fil de discussion --------------------------------------------------------*/
.ai-chat-fil {
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 210px;
}

.ai-bulle {
    max-width: 88%;
    padding: 11px 14px;
    border-radius: 14px;
    font-size: .9rem;
    line-height: 1.5;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .28s ease, transform .28s ease;
}

.ai-bulle.est-visible {
    opacity: 1;
    transform: none;
}

.ai-bulle-user {
    align-self: flex-end;
    background: #0a4a9e;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-bulle-ia {
    align-self: flex-start;
    background: rgba(255, 255, 255, .09);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .12);
    border-bottom-left-radius: 4px;
}

/* Étincelle de l'assistant -------------------------------------------------*/
.ai-etincelle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: "Space Grotesk", sans-serif;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #ffbf23;
    margin-bottom: 6px;
}

.ai-etincelle svg {
    width: 13px;
    height: 13px;
    flex: none;
}

.ai-bulle-ia.est-visible .ai-etincelle svg {
    animation: ai-scintille 2.4s ease-in-out infinite;
    transform-origin: center;
}

@keyframes ai-scintille {
    0%, 70%, 100% { opacity: .9; transform: scale(1) rotate(0deg); }
    80%           { opacity: 1;  transform: scale(1.25) rotate(12deg); }
    90%           { opacity: 1;  transform: scale(1.1) rotate(-6deg); }
}

/* Texte et curseur ---------------------------------------------------------*/
.ai-bulle-texte {
    white-space: pre-wrap;
}

.ai-curseur {
    display: none;
    width: 7px;
    height: 1em;
    margin-left: 2px;
    background: #ffbf23;
    vertical-align: -2px;
}

.ai-bulle.ecrit .ai-curseur {
    display: inline-block;
    animation: ai-clignote .9s steps(1) infinite;
}

@keyframes ai-clignote {
    0%, 49%   { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* Indicateur de réflexion --------------------------------------------------*/
.ai-points {
    display: none;
    gap: 5px;
    padding: 2px 0;
}

.ai-bulle-ia.reflechit .ai-points {
    display: inline-flex;
}

.ai-points i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .75);
    animation: ai-rebond 1.1s ease-in-out infinite;
}

.ai-points i:nth-child(2) { animation-delay: .16s; }
.ai-points i:nth-child(3) { animation-delay: .32s; }

@keyframes ai-rebond {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30%           { transform: translateY(-5px); opacity: 1; }
}

/* Source citée par Assist --------------------------------------------------*/
.ai-source {
    display: none;
    margin-top: 9px;
    padding: 4px 9px;
    border: 1px solid rgba(255, 191, 35, .5);
    border-radius: 999px;
    font-size: .72rem;
    color: #ffbf23;
    opacity: 0;
    transition: opacity .3s ease;
}

.ai-bulle-ia.avec-source .ai-source {
    display: inline-block;
    opacity: 1;
}

/* Sans JavaScript, ou animation refusée : tout est montré, figé ------------*/
.no-js .ai-bulle,
.ai-chat.statique .ai-bulle {
    opacity: 1;
    transform: none;
}

.no-js .ai-source,
.ai-chat.statique .ai-source {
    display: inline-block;
    opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
    .ai-bulle {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .ai-source {
        display: inline-block;
        opacity: 1;
    }

    .ai-curseur,
    .ai-points {
        display: none !important;
    }

    .ai-bulle-ia.est-visible .ai-etincelle svg {
        animation: none;
    }
}
