/* La discussion avec Ketsia : une vraie messagerie, pas un widget.
   Bulles, avatar, indicateur de frappe, message vocal. */

.chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 12, 8, 0.72);
  backdrop-filter: blur(8px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 120;
  padding: 0;
}

.chat-backdrop.open { display: flex; }

@media (min-width: 720px) {
  .chat-backdrop { align-items: center; padding: 24px; }
}

.chat {
  width: min(520px, 100%);
  height: min(88vh, 720px);
  background: #f4f1e8;
  border-radius: 22px 22px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -20px 70px rgba(0, 0, 0, 0.45);
  animation: chat-monte 0.45s var(--ease, cubic-bezier(.22,.7,.25,1)) both;
}

@media (min-width: 720px) {
  .chat { border-radius: 22px; height: min(84vh, 700px); }
}

@keyframes chat-monte {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------ en-tete */

.chat-tete {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #0c2017;
  color: #f5efe0;
  flex: none;
}

.chat-tete img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #d9a94e;
  flex: none;
}

.chat-qui { flex: 1; min-width: 0; }

.chat-qui strong {
  display: block;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 16px;
  font-weight: 700;
}

.chat-qui span {
  font-size: 12.5px;
  color: #9fb3a4;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-qui span::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  flex: none;
}

.chat-fermer {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #f5efe0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  flex: none;
}

.chat-fermer:hover { background: rgba(255, 255, 255, 0.2); }

/* ------------------------------------------------ fil des messages */

.chat-fil {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.bulle {
  max-width: 82%;
  padding: 11px 15px;
  font-size: 15.5px;
  line-height: 1.5;
  border-radius: 18px;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: bulle-in 0.35s var(--ease, ease) both;
}

@keyframes bulle-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.bulle.elle {
  align-self: flex-start;
  background: #fff;
  color: #14291d;
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 2px rgba(12, 32, 23, 0.08);
}

.bulle.moi {
  align-self: flex-end;
  background: #1d4530;
  color: #f5efe0;
  border-bottom-right-radius: 6px;
}

.bulle .vocal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.75;
  margin-bottom: 4px;
}

.bulle-heure {
  font-size: 11px;
  opacity: 0.5;
  margin-top: 4px;
  display: block;
}

/* Ketsia tape */
.tape {
  align-self: flex-start;
  background: #fff;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  padding: 14px 18px;
  display: none;
  gap: 4px;
  box-shadow: 0 1px 2px rgba(12, 32, 23, 0.08);
}

.tape.on { display: flex; }

.tape i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8aa093;
  animation: tape-saute 1.2s infinite;
}

.tape i:nth-child(2) { animation-delay: 0.15s; }
.tape i:nth-child(3) { animation-delay: 0.3s; }

@keyframes tape-saute {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ------------------------------------------------ reponses rapides */

.chat-rapides {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 16px 10px;
}

.chat-rapides button {
  background: #fff;
  border: 1.5px solid #d9d2c0;
  border-radius: 999px;
  padding: 9px 16px;
  font-family: inherit;
  font-size: 14px;
  color: #14291d;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}

.chat-rapides button:hover { border-color: #d9a94e; background: #fdf8ec; }

/* ------------------------------------------------ barre de saisie */

.chat-barre {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-top: 1px solid #e4dcc8;
}

.chat-barre textarea {
  flex: 1;
  border: 1.5px solid #e4dcc8;
  border-radius: 20px;
  padding: 11px 16px;
  font-family: inherit;
  font-size: 15.5px;
  line-height: 1.4;
  resize: none;
  max-height: 120px;
  background: #f7f4ec;
  color: #14291d;
}

.chat-barre textarea:focus { outline: none; border-color: #d9a94e; background: #fff; }

.chat-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #d9a94e;
  color: #241a04;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: transform .2s, background .2s;
}

.chat-btn:hover { transform: scale(1.06); }
.chat-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.chat-btn.micro { background: #eee9dc; color: #1d4530; }

.chat-btn.micro.enreg {
  background: #c0392b;
  color: #fff;
  animation: micro-pulse 1.1s infinite;
}

@keyframes micro-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, .5); }
  50% { box-shadow: 0 0 0 10px rgba(192, 57, 43, 0); }
}

.chat-enreg-info {
  display: none;
  align-items: center;
  gap: 8px;
  flex: 1;
  font-size: 14px;
  color: #c0392b;
  font-weight: 600;
}

.chat-barre.enregistrement .chat-enreg-info { display: flex; }
.chat-barre.enregistrement textarea { display: none; }

.chat-erreur {
  font-size: 13px;
  color: #b5432f;
  padding: 0 16px 8px;
  min-height: 0;
}

/* ------------------------------------------------ invitation */

.chat-invite {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 1px solid #e4dcc8;
  border-radius: 18px;
  padding: 16px 18px;
  margin-top: 24px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: border-color .25s, transform .25s;
}

.chat-invite:hover { border-color: #d9a94e; transform: translateY(-2px); }

.chat-invite img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #d9a94e;
  flex: none;
}

.chat-invite div { flex: 1; }

.chat-invite strong {
  display: block;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 16px;
  color: #14291d;
}

.chat-invite span { font-size: 14px; color: #51665a; }

.chat-invite .point {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4ade80;
  flex: none;
  animation: point-pulse 2s infinite;
}

@keyframes point-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, .5); }
  50% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ------------------------------------------------ son et emojis */

.chat-son {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #f5efe0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.chat-son:hover { background: rgba(255, 255, 255, 0.2); }

.chat-son .barre { display: none; }
.chat-son.coupe .onde { display: none; }
.chat-son.coupe .barre { display: block; }

.chat-emojis {
  display: none;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 4px;
  padding: 10px 14px;
  background: #fff;
  border-top: 1px solid #e4dcc8;
  max-height: 168px;
  overflow-y: auto;
}

.chat-emojis.on { display: grid; }

.chat-emojis button {
  border: none;
  background: none;
  font-size: 23px;
  line-height: 1;
  padding: 7px 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, transform .15s;
}

.chat-emojis button:hover { background: #f4f1e8; transform: scale(1.15); }

.chat-btn.emoji { background: #eee9dc; color: #1d4530; }

.bulle .texte { display: block; }
