/* ═══════════════════════════════════════════════════════════════
   Ikala-bot | bouton flottant et fenêtre de discussion
   Le bouton et la fenêtre sont construits par js/ikala/ikala-bot.js :
   seule leur apparence est décrite ici.

   Sommaire
     1. Bouton flottant, au-dessus de WhatsApp
     2. Fenêtre
     3. Messages et choix
     4. Saisie
     5. Mobile : la fenêtre prend tout l'écran
     6. Accessibilité du mouvement
   ═══════════════════════════════════════════════════════════════ */


/* ═════════ 1. BOUTON FLOTTANT ═════════
   Même colonne que WhatsApp, juste au-dessus. Le retour en haut monte d'un cran (commun.css). */
.ib-btn {
  position: fixed; right: clamp(16px, 3vw, 28px); bottom: calc(clamp(16px, 3vw, 28px) + 58px); z-index: 900;
  width: 52px; height: 52px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: none; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.ib-btn img { display: block; width: 100%; height: 100%; border-radius: 50%; }
.ib-btn:hover { transform: translateY(-2px) rotate(-4deg); box-shadow: 0 8px 26px rgba(201, 168, 76, 0.35); }
.ib-btn:focus-visible { outline: 2px solid var(--or); outline-offset: 3px; }


/* Petit salut du bouton quand la bulle d'appel apparaît */
.ib-btn.ib-salut { animation: ib-salut 0.9s var(--ease); }
@keyframes ib-salut {
  0%, 100% { transform: none; }
  20% { transform: rotate(-12deg) scale(1.06); }
  40% { transform: rotate(10deg) scale(1.06); }
  60% { transform: rotate(-6deg); }
  80% { transform: rotate(4deg); }
}

/* Bulle d'appel, à gauche du bouton, pointe tournée vers lui */
.ib-appel {
  position: fixed; right: calc(clamp(16px, 3vw, 28px) + 64px); bottom: calc(clamp(16px, 3vw, 28px) + 64px); z-index: 900;
  display: flex; align-items: center;
  background: #0a0a0a; border: 1px solid var(--filet-or); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: ib-glisse 0.5s var(--ease);
}
.ib-appel[hidden] { display: none; }
.ib-appel::after {
  content: ''; position: absolute; right: -6px; top: 50%; width: 10px; height: 10px;
  background: #0a0a0a; border: solid var(--filet-or); border-width: 1px 1px 0 0;
  transform: translateY(-50%) rotate(45deg);
}
.ib-appel-texte {
  min-height: 44px; padding: 10px 4px 10px 16px; cursor: pointer; white-space: nowrap;
  font: inherit; font-size: 0.875rem; color: var(--texte); background: none; border: 0;
}
.ib-appel-texte:hover { color: var(--or); }
.ib-appel-fermer {
  display: grid; place-items: center; width: 36px; height: 44px; padding: 0; cursor: pointer;
  font-size: 1.2rem; color: var(--texte-2); background: none; border: 0;
}
.ib-appel-fermer:hover { color: var(--or); }
.ib-appel button:focus-visible { outline: 2px solid var(--or); outline-offset: -2px; border-radius: 10px; }
@keyframes ib-glisse {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: none; }
}


/* ═════════ 2. FENÊTRE ═════════ */
.ib-panneau {
  position: fixed; right: clamp(16px, 3vw, 28px); bottom: calc(clamp(16px, 3vw, 28px) + 122px); z-index: 960;
  display: flex; flex-direction: column;
  width: min(380px, calc(100vw - 32px)); height: min(560px, calc(100vh - 170px));
  background: #0a0a0a; border: 1px solid var(--filet-or); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  animation: ib-apparait 0.35s var(--ease);
}
.ib-panneau[hidden] { display: none; }

@keyframes ib-apparait {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.ib-entete {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px 14px 16px; border-bottom: 1px solid var(--filet);
}
.ib-entete img { flex: none; border-radius: 50%; }
.ib-entete > div { flex: 1; }
.ib-titre { margin: 0; font-family: var(--titre); font-size: 1.25rem; color: var(--texte); }
.ib-sous-titre { margin: 0; font-size: 0.75rem; color: var(--texte-2); }
.ib-fermer {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0; cursor: pointer;
  font-size: 1.6rem; line-height: 1; color: var(--texte-2);
  background: transparent; border: 0; border-radius: 50%;
}
.ib-fermer:hover { color: var(--or); }
.ib-fermer:focus-visible { outline: 2px solid var(--or); outline-offset: -2px; }


/* ═════════ 3. MESSAGES ET CHOIX ═════════ */
.ib-fil {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px; padding: 16px;
}
.ib-bulle {
  max-width: 88%; padding: 10px 14px; border-radius: 12px;
  font-size: 0.9rem; line-height: 1.55; overflow-wrap: anywhere;
}
.ib-bot { align-self: flex-start; background: #161616; color: var(--texte); border-bottom-left-radius: 4px; }
.ib-visiteur {
  align-self: flex-end; background: rgba(201, 168, 76, 0.14); color: var(--texte);
  border: 1px solid var(--filet-or); border-bottom-right-radius: 4px;
}
.ib-bot a { color: var(--or); text-decoration: underline; text-underline-offset: 3px; }
.ib-bot a:hover { color: var(--texte); }

/* Trois points qui patientent pendant que le bot répond */
.ib-attente { display: inline-flex; gap: 5px; padding: 14px; }
.ib-attente span:not(.lecteur-ecran) {
  width: 7px; height: 7px; border-radius: 50%; background: var(--or);
  animation: ib-points 1.2s infinite ease-in-out;
}
.ib-attente span:nth-child(2) { animation-delay: 0.15s; }
.ib-attente span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ib-points {
  0%, 80%, 100% { opacity: 0.25; transform: none; }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* Boutons de choix : les deux portes, puis les questions suggérées */
.ib-choix { display: flex; flex-wrap: wrap; gap: 8px; }
.ib-choix button {
  min-height: 44px; padding: 8px 14px; cursor: pointer;
  font: inherit; font-size: 0.8125rem; color: var(--texte);
  background: transparent; border: 1px solid var(--filet-or); border-radius: 999px;
  transition: background 0.2s, color 0.2s;
}
.ib-choix button:hover { background: var(--or); color: var(--noir); }
.ib-choix button:focus-visible { outline: 2px solid var(--or); outline-offset: 2px; }


/* ═════════ 4. SAISIE ═════════ */
.ib-saisie { display: flex; align-items: flex-end; gap: 8px; padding: 12px 12px 6px; border-top: 1px solid var(--filet); }
.ib-saisie textarea {
  flex: 1; min-height: 44px; max-height: 120px; padding: 11px 14px; resize: none;
  font: inherit; font-size: 0.9rem; color: var(--texte);
  background: #141414; border: 1px solid var(--filet); border-radius: 12px;
}
.ib-saisie textarea::placeholder { color: var(--texte-2); }
.ib-saisie textarea:focus { outline: none; border-color: var(--or); }
.ib-envoyer {
  flex: none; width: 44px; height: 44px; padding: 0; cursor: pointer;
  font-size: 1.1rem; color: var(--noir);
  background: var(--or-metal); background-size: 200% 100%; border: 0; border-radius: 50%;
  transition: background-position 0.6s var(--ease);
}
.ib-envoyer:hover { background-position: 100% 0; }
.ib-envoyer:focus-visible { outline: 2px solid var(--texte); outline-offset: 2px; }

.ib-mention { margin: 0; padding: 0 14px 12px; font-size: 0.6875rem; line-height: 1.5; color: var(--texte-2); }
.ib-mention a { color: var(--texte-2); text-decoration: underline; }
.ib-mention a:hover { color: var(--or); }


/* ═════════ 5. MOBILE ═════════
   Sur téléphone, la fenêtre prend tout l'écran : le clavier ne la coupe pas
   et la page derrière ne défile plus. */
@media (max-width: 560px) {
  .ib-btn { width: 48px; height: 48px; bottom: calc(clamp(16px, 3vw, 28px) + 58px); }
  .ib-appel { right: calc(clamp(16px, 3vw, 28px) + 58px); bottom: calc(clamp(16px, 3vw, 28px) + 60px); }
  .ib-appel-texte { padding-left: 12px; font-size: 0.8125rem; }
  .ib-appel-fermer { width: 32px; }
  .ib-panneau {
    inset: 0; width: 100%; height: 100%; height: 100dvh;
    border: 0; border-radius: 0;
  }
  html.ib-ouvert { overflow: hidden; }
  html.ib-ouvert .wa-float, html.ib-ouvert .ib-btn, html.ib-ouvert .retour-haut, html.ib-ouvert .a11y-btn { visibility: hidden; }
}


/* ═════════ 6. ACCESSIBILITÉ DU MOUVEMENT ═════════ */
/* Préférence du système, ou réglage « animations » du bouton d'accessibilité du site */
@media (prefers-reduced-motion: reduce) {
  .ib-panneau, .ib-attente span, .ib-appel, .ib-btn.ib-salut { animation: none; }
  .ib-btn { transition: none; }
}
html.a11y-anim-off .ib-panneau, html.a11y-anim-off .ib-attente span,
html.a11y-anim-off .ib-appel, html.a11y-anim-off .ib-btn.ib-salut { animation: none; }
html.a11y-anim-off .ib-btn { transition: none; }
