/* ==========================================================================
   Carte « Léo » du héros — démonstration animée de l'assistant.
   Chargée par base.html (toutes pages, coût nul hors accueil : le JS sort si
   la carte n'existe pas). Animation progressive : sans JS ou avec
   prefers-reduced-motion, la conversation est affichée telle quelle.

   Cycle : toutes les étapes partagent la même durée (--leo-cycle) et ne
   diffèrent que par leurs pourcentages → aucune dérive possible entre elles.
   .is-live est posé par leo-chat.js tant que la carte est à l'écran (retiré
   à la sortie → les animations repartent de zéro à la prochaine entrée).
   Séquence (16 s, calquée sur le rythme du short « Léo ») :
   question → frappe → suggestions → frappe → réponse chiffrée → « Appliqué ».
   ========================================================================== */

.leo-chat {
  --leo-cycle: 16s;
  margin-top: var(--s4);
  background: var(--white);
  border: 1px solid var(--line);
  padding: var(--s5);
}

.leo-chat__head {
  display: flex;
  align-items: center;
  gap: 13px;
  padding-bottom: var(--s4);
  border-bottom: 1px solid var(--line);
}

/* Sphère de Léo — même matériau que l'avatar de l'app (orbe accent). */
.leo-chat__orb {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: radial-gradient(circle at 34% 28%, #e2895c 0%, var(--accent) 52%, #6f2a0d 100%);
  box-shadow: inset -4px -6px 10px rgba(20, 15, 10, .28);
}

.leo-chat__id {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.leo-chat__live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  padding: 3px 8px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ok);
  white-space: nowrap;
}

.leo-chat__live i { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }

.leo-chat__sub {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--fg-muted);
}

.leo-chat__body { display: flex; flex-direction: column; gap: 10px; padding: var(--s4) 0; }

.leo-b { max-width: 92%; padding: 10px 14px; font-size: 14.5px; line-height: 1.5; }
.leo-b--user { align-self: flex-end; background: var(--ink); color: var(--fg-on-dark); }
.leo-b--leo { align-self: flex-start; background: var(--paper-2); border: 1px solid var(--line); }
.leo-b--chip {
  align-self: flex-start;
  padding: 7px 12px;
  font-size: 13.5px;
  font-weight: 600;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--accent-ink);
}

/* Suggestions de l'app, rendues comme une liste (jamais comme des boutons :
   dans l'aperçu du héros, rien n'est cliquable). */
.leo-sugg { align-self: flex-start; max-width: 92%; }
.leo-sugg__k {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.leo-sugg ul { display: grid; gap: 5px; margin-top: 7px; }
.leo-sugg li { position: relative; padding-left: 14px; font-size: 13.5px; line-height: 1.35; color: var(--fg-dense); }
.leo-sugg li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .5em;
  width: 5px;
  height: 5px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
}

/* Indicateur de frappe — décoratif (aria-hidden), masqué par défaut. */
.leo-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 5px;
  padding: 13px 16px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  opacity: 0;
}
.leo-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--fg-muted); animation: leo-dot 1.1s ease-in-out infinite; }
.leo-typing i:nth-child(2) { animation-delay: .16s; }
.leo-typing i:nth-child(3) { animation-delay: .32s; }

.leo-chat__foot {
  border-top: 1px solid var(--line);
  padding-top: var(--s3);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

@keyframes leo-dot {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Pastille « En ligne » : anneau discret, continuité « assistant vivant ». */
@keyframes leo-pulse {
  0% { box-shadow: 0 0 0 0 rgba(31, 122, 69, .45); }
  70%, 100% { box-shadow: 0 0 0 5px rgba(31, 122, 69, 0); }
}

/* ---- Cycle de démonstration (16 s) --------------------------------------
   0–0,5 s    question (bulle utilisateur)
   1–2,2 s    frappe
   2,2–6,2 s  suggestions
   6,7–7,9 s  frappe
   7,9–15 s   réponse + « Appliqué »
   15–15,6 s  tout s'efface → la boucle repart                                    */

@keyframes leo-c-user {
  0% { opacity: 0; transform: translateY(8px); }
  3% { opacity: 1; transform: none; }
  93.5% { opacity: 1; transform: none; }
  97% { opacity: 0; transform: none; }
  100% { opacity: 0; transform: none; }
}

@keyframes leo-c-typing {
  0%, 5% { opacity: 0; transform: translateY(8px); }
  6.5% { opacity: 1; transform: none; }
  12.5% { opacity: 1; transform: none; }
  14% { opacity: 0; transform: none; }
  40% { opacity: 0; transform: none; }
  42% { opacity: 1; transform: none; }
  47.5% { opacity: 1; transform: none; }
  49.5% { opacity: 0; transform: none; }
  100% { opacity: 0; transform: none; }
}

@keyframes leo-c-sugg {
  0%, 14% { opacity: 0; transform: translateY(8px); }
  17% { opacity: 1; transform: none; }
  36% { opacity: 1; transform: none; }
  39% { opacity: 0; transform: none; }
  100% { opacity: 0; transform: none; }
}

@keyframes leo-c-answer {
  0%, 49.5% { opacity: 0; transform: translateY(8px); }
  53% { opacity: 1; transform: none; }
  93.5% { opacity: 1; transform: none; }
  97% { opacity: 0; transform: none; }
  100% { opacity: 0; transform: none; }
}

@keyframes leo-c-chip {
  0%, 54.5% { opacity: 0; transform: translateY(6px); }
  57% { opacity: 1; transform: none; }
  93.5% { opacity: 1; transform: none; }
  97% { opacity: 0; transform: none; }
  100% { opacity: 0; transform: none; }
}

@media (prefers-reduced-motion: no-preference) {
  html.js .leo-chat .leo-anim { opacity: 0; }
  html.js .leo-chat.is-live .leo-anim--1 { animation: leo-c-user var(--leo-cycle) cubic-bezier(.16, 1, .3, 1) infinite both; }
  html.js .leo-chat.is-live .leo-typing { animation: leo-c-typing var(--leo-cycle) cubic-bezier(.16, 1, .3, 1) infinite both; }
  html.js .leo-chat.is-live .leo-anim--s { animation: leo-c-sugg var(--leo-cycle) cubic-bezier(.16, 1, .3, 1) infinite both; }
  html.js .leo-chat.is-live .leo-anim--2 { animation: leo-c-answer var(--leo-cycle) cubic-bezier(.16, 1, .3, 1) infinite both; }
  html.js .leo-chat.is-live .leo-anim--3 { animation: leo-c-chip var(--leo-cycle) cubic-bezier(.16, 1, .3, 1) infinite both; }
  html.js .leo-chat.is-live .leo-chat__live i { animation: leo-pulse 2.4s ease-out infinite; }
}
