/* Fichier css/chat.css · chargé par : toutes les pages (ajoutée par js/ui-fx.js avec la bulle de chat) */
/* =====================================================================
   IAI — assistant IA : mini-fenêtre (bulle de chat) + éléments de conversation partagés (.ic-*)
   ===================================================================== */
.ic-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- la fenêtre ---------- */
.ichat { --pad: 18px; position: fixed; z-index: 46; right: var(--dock-r, 24px); bottom: calc(var(--dock-b, 22px) + var(--chat, 58px) + 14px);
  width: min(392px, calc(100vw - 2 * var(--dock-r, 24px))); height: min(610px, calc(100svh - var(--dock-b, 22px) - var(--chat, 58px) - 110px));
  display: grid; grid-template-rows: auto 1fr auto auto auto; border-radius: 24px; overflow: hidden; isolation: isolate;
  color: var(--text); font-family: var(--font);
  background: linear-gradient(180deg, rgb(var(--surface-rgb) / .9), rgb(var(--bg-rgb) / .94));
  -webkit-backdrop-filter: blur(22px) saturate(1.4); backdrop-filter: blur(22px) saturate(1.4);
  border: 1px solid rgb(var(--text-rgb) / .12);
  box-shadow: 0 40px 90px -30px rgb(0 0 0 / .85), 0 0 0 1px rgb(var(--acc-rgb) / .08), 0 0 60px -20px rgb(var(--acc-rgb) / .35);
  transform-origin: calc(100% - var(--chat, 58px) / 2) calc(100% + 40px);
  opacity: 0; transform: translateY(18px) scale(.86); filter: blur(6px); pointer-events: none;
  transition: opacity .35s var(--ease), transform .5s cubic-bezier(.2, 1.2, .3, 1), filter .4s; }
.ichat[hidden] { display: none; }
html.ichat-open .ichat { opacity: 1; transform: none; filter: none; pointer-events: auto; }
/* grille HUD discrète + liseré lumineux en haut */
.ichat::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(120% 60% at 50% 0%, rgb(var(--acc-rgb) / .16), transparent 60%),
    linear-gradient(rgb(var(--text-rgb) / .03) 1px, transparent 1px) 0 0 / 100% 22px,
    linear-gradient(90deg, rgb(var(--text-rgb) / .03) 1px, transparent 1px) 0 0 / 22px 100%;
  -webkit-mask: linear-gradient(#000, transparent 70%); mask: linear-gradient(#000, transparent 70%); }
.ichat::after { content: ""; position: absolute; left: 12%; right: 12%; top: 0; height: 1px; background: linear-gradient(90deg, transparent, rgb(var(--acc-rgb) / .9), transparent); }

.ichat__hd { display: flex; align-items: center; gap: 12px; padding: 14px 14px 12px var(--pad); border-bottom: 1px solid rgb(var(--text-rgb) / .08); }
.ichat__orb { position: relative; flex: none; width: 46px; height: 46px; border-radius: 50%; background: radial-gradient(circle, rgb(var(--bg-rgb)) 40%, transparent 72%); }
.ichat__orb canvas { position: absolute; inset: -9px; width: calc(100% + 18px); height: calc(100% + 18px); }
.ichat__id { flex: 1; min-width: 0; display: grid; gap: 2px; }
.ichat__id strong { font-size: .95rem; font-weight: 700; letter-spacing: -.01em; }
.ichat__st { display: flex; align-items: center; gap: 7px; font-size: .6875rem; letter-spacing: .06em; text-transform: uppercase; color: rgb(var(--text-rgb) / .55); }
.ichat__st i { width: 7px; height: 7px; border-radius: 50%; background: rgb(var(--acc2-rgb, 152 202 193)); box-shadow: 0 0 10px rgb(var(--acc2-rgb, 152 202 193)); animation: ic-blink 2.4s ease-in-out infinite; }
@keyframes ic-blink { 50% { opacity: .35; } }
.ichat__ic { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: rgb(var(--text-rgb) / .75);
  border: 1px solid rgb(var(--text-rgb) / .12); background: rgb(var(--text-rgb) / .04); transition: color .25s, border-color .25s, background .25s, transform .3s var(--ease); }
.ichat__ic:hover { color: var(--text); border-color: rgb(var(--acc-rgb) / .6); background: rgb(var(--acc-rgb) / .12); }
.ichat__full:hover { transform: scale(1.06); }

/* ---------- fil de discussion ---------- */
.ic-log { overflow-y: auto; overscroll-behavior: contain; padding: 18px var(--pad) 8px; display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; scrollbar-color: rgb(var(--text-rgb) / .2) transparent; }
.ic-msg { max-width: 88%; font-size: .875rem; line-height: 1.55; animation: ic-in .45s var(--ease) both; }
.ic-msg p { margin: 0; } .ic-msg p + p { margin-top: .6em; }
@keyframes ic-in { from { opacity: 0; transform: translateY(8px); } }
.ic-msg--me { align-self: flex-end; padding: 10px 14px; border-radius: 16px 16px 4px 16px; background: var(--action); color: var(--on-action); font-weight: 600; }
.ic-msg--ai { align-self: flex-start; position: relative; padding: 12px 14px 12px 16px; border-radius: 4px 16px 16px 16px;
  background: rgb(var(--text-rgb) / .05); border: 1px solid rgb(var(--text-rgb) / .08); }
.ic-msg--ai::before { content: ""; position: absolute; left: -1px; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: linear-gradient(rgb(var(--acc-rgb)), rgb(var(--acc2-rgb, 152 202 193))); }
.ic-caret { display: inline-block; width: .5em; height: 1em; margin-left: 2px; vertical-align: -.14em; background: rgb(var(--acc-rgb)); box-shadow: 0 0 10px rgb(var(--acc-rgb)); animation: ic-blink .8s steps(2) infinite; }
.ic-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ic-act { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; font-size: .78rem; font-weight: 700; text-decoration: none;
  color: var(--text); border: 1px solid rgb(var(--text-rgb) / .18); transition: background .25s, border-color .25s, transform .3s var(--ease); }
.ic-act.is-main { background: var(--action); color: var(--on-action); border-color: transparent; }
.ic-act:hover { transform: translateY(-1px); border-color: rgb(var(--acc-rgb) / .7); }
.ic-act span { transition: transform .3s var(--ease); } .ic-act:hover span { transform: translateX(3px); }
/* « Analyse… » */
.ic-think { display: inline-flex; align-items: center; gap: 10px; overflow: hidden; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: rgb(var(--text-rgb) / .6); }
.ic-think__bar { position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgb(var(--acc2-rgb, 152 202 193) / .18), transparent); transform: translateX(-100%); animation: ic-scan 1.1s linear infinite; }
@keyframes ic-scan { to { transform: translateX(100%); } }
.ic-dots { display: inline-flex; gap: 4px; } .ic-dots i { width: 4px; height: 4px; border-radius: 50%; background: rgb(var(--acc-rgb)); animation: ic-dot 1s ease-in-out infinite; }
.ic-dots i:nth-child(2) { animation-delay: .15s; } .ic-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ic-dot { 50% { transform: translateY(-4px); opacity: .4; } }

/* ---------- suggestions ---------- */
.ic-chips { display: flex; gap: 8px; padding: 6px var(--pad) 10px; overflow-x: auto; scrollbar-width: none; -webkit-mask: linear-gradient(90deg, #000 85%, transparent); mask: linear-gradient(90deg, #000 85%, transparent); }
.ic-chips::-webkit-scrollbar { display: none; }
.ic-chips:empty { padding-block: 0; }
.ic-chip { flex: none; padding: 7px 12px; border-radius: 999px; font: 600 .75rem/1.2 var(--font); color: rgb(var(--text-rgb) / .85); white-space: nowrap; cursor: pointer;
  background: rgb(var(--text-rgb) / .04); border: 1px solid rgb(var(--acc2-rgb, 152 202 193) / .28); animation: ic-in .4s calc(var(--i, 0) * 60ms) var(--ease) both;
  transition: background .25s, border-color .25s, color .25s; }
.ic-chip:hover { background: rgb(var(--acc2-rgb, 152 202 193) / .12); border-color: rgb(var(--acc2-rgb, 152 202 193) / .7); color: var(--text); }

/* ---------- saisie ---------- */
.ic-form { position: relative; display: flex; align-items: center; gap: 8px; margin: 0 12px; padding: 6px 6px 6px 16px; border-radius: 999px;
  background: rgb(var(--bg-rgb) / .7); border: 1px solid rgb(var(--text-rgb) / .14); transition: border-color .3s, box-shadow .3s; }
.ic-form:focus-within { border-color: rgb(var(--acc-rgb) / .7); box-shadow: 0 0 0 4px rgb(var(--acc-rgb) / .12), 0 0 24px -6px rgb(var(--acc-rgb) / .5); }
.ic-in { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); font: 500 .9rem/1.3 var(--font); padding: 8px 0; }
.ic-in::placeholder { color: rgb(var(--text-rgb) / .42); }
.ic-send, .ic-mic { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; border: 0; cursor: pointer; transition: transform .3s var(--ease), background .25s, opacity .25s; }
.ic-send { background: var(--action); color: var(--on-action); }
.ic-send:hover { transform: scale(1.07); }
.is-busy .ic-send { opacity: .45; pointer-events: none; }
.ic-mic { background: rgb(var(--text-rgb) / .06); color: var(--text); }
.ic-mic.is-on { background: rgb(var(--acc-rgb) / .2); color: rgb(var(--acc-rgb)); box-shadow: 0 0 0 0 rgb(var(--acc-rgb) / .6); animation: ic-mic 1.2s ease-out infinite; }
@keyframes ic-mic { to { box-shadow: 0 0 0 14px rgb(var(--acc-rgb) / 0); } }
.ichat__note { margin: 0; padding: 8px var(--pad) 12px; font-size: .64rem; text-align: center; color: rgb(var(--text-rgb) / .4); }

/* ---------- la bulle devient « fermer » quand la fenêtre est ouverte ---------- */
.chat-fab__x { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transform: rotate(-90deg) scale(.6); transition: opacity .3s, transform .45s var(--ease); }
.chat-fab > svg { transition: opacity .3s, transform .45s var(--ease); }
html.ichat-open .chat-fab > svg { opacity: 0; transform: rotate(90deg) scale(.6); }
html.ichat-open .chat-fab__x { opacity: 1; transform: none; }
html.ichat-open .chat-fab__ring { animation: none; opacity: 0; }
html.ichat-open .chat-fab__tip { display: none; }

/* ---------- téléphone : plein écran, la bulle se cache (bouton fermer en haut) ---------- */
html.f-phone .ichat { inset: 0; width: auto; height: auto; border-radius: 0; border: 0; z-index: 60;
  padding-top: env(safe-area-inset-top); padding-bottom: max(8px, env(safe-area-inset-bottom)); transform-origin: 85% 100%; }
html.f-phone.ichat-open .chat-fab { opacity: 0; pointer-events: none; }
html.f-phone .ic-msg { max-width: 92%; font-size: .9rem; }
html.f-phone .ic-in { font-size: 16px; }   /* pas de zoom automatique sur iPhone */
/* téléphone à l'horizontale : fenêtre compacte */
html.f-short .ichat { height: calc(100svh - 24px); bottom: 12px; right: calc(var(--dock-r) + var(--chat) + 12px); width: min(420px, 60vw); }
html.f-short .ichat__note { display: none; }
html.f-short.f-phone .ichat { inset: 0; width: auto; height: auto; }

/* sections claires : la fenêtre reste sombre (elle flotte au-dessus de la page) */
@media (prefers-reduced-motion: reduce) { .ichat { transition: opacity .2s; transform: none; filter: none; } }
