/* ==========================================================================
   DIGITAL LION · Leo, l'assistant IA (assets/js/assistant.js)
   Bouton flottant en bas à droite + fenêtre de discussion.
   Sous la fenêtre « projet » des réalisations et sous le bandeau cookies.
   ========================================================================== */
.leo { --leo-gap: clamp(16px, 2.4vw, 28px); position: fixed; right: var(--leo-gap); bottom: var(--leo-gap); z-index: 250; font-family: var(--f-main, system-ui, sans-serif); }

/* La police du site n'existe qu'en 400 et 500 : jamais de gras plus épais (sinon faux gras écrasé) */
/* ---------- Mascotte et animations ---------- */
.leo-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.leo-svg--live .leo-eyes { transform-box: fill-box; transform-origin: center; animation: leo-blink 4.6s infinite; }
.leo-svg--live .leo-ear { transform-box: view-box; transform-origin: 76px 47px; animation: leo-twitch 6.5s infinite 1.2s; }
.leo.is-thinking .leo__avatar .leo-ear { animation: leo-twitch-fast 1.3s infinite; }
@keyframes leo-blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.12); } }
@keyframes leo-twitch { 0%, 82%, 100% { transform: rotate(0); } 85% { transform: rotate(16deg); } 88% { transform: rotate(-6deg); } 91% { transform: rotate(0); } }
@keyframes leo-twitch-fast { 0%, 55%, 100% { transform: rotate(0); } 65% { transform: rotate(16deg); } 78% { transform: rotate(-6deg); } }

/* ---------- Bouton flottant ---------- */
.leo__launcher {
  position: relative; display: grid; place-items: center; width: 62px; height: 62px; padding: 0; border: 0; border-radius: 50%;
  background: #0a0a1a; cursor: pointer; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 28px rgba(0, 212, 255, 0.18);
  opacity: 0; transform: translateY(16px) scale(0.9); pointer-events: none;
  transition: opacity 0.5s var(--ease-out, ease), transform 0.6s var(--ease-out, ease), box-shadow 0.3s;
}
.leo__launcher::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%; padding: 2px;
  background: linear-gradient(135deg, #00d4ff, #8b5cf6);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}
.leo__launcher .leo-svg { width: 48px; height: 48px; transition: transform 0.4s var(--ease-out, ease); }
.leo.is-ready .leo__launcher { opacity: 1; transform: none; pointer-events: auto; }
.leo__launcher:hover { box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55), 0 0 36px rgba(0, 212, 255, 0.32); }
.leo__launcher:hover .leo-svg { transform: scale(1.06) rotate(-4deg); }
.leo__launcher:focus-visible, .leo button:focus-visible, .leo a:focus-visible, .leo__log:focus-visible { outline: 2px solid #00d4ff; outline-offset: 3px; }

/* ---------- Petite bulle d'invitation ---------- */
.leo__hint { position: absolute; right: 0; bottom: 74px; display: flex; align-items: center; gap: 2px; padding: 4px 4px 4px 14px; border-radius: 14px 14px 4px 14px; background: #fff; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35); white-space: nowrap; opacity: 0; transform: translateY(8px); transition: opacity 0.4s, transform 0.5s var(--ease-out, ease); }
.leo__hint.is-in { opacity: 1; transform: none; }
.leo__hint-text { padding: 6px 0; border: 0; background: none; color: #0a0a1a; font: 500 14px/1.2 var(--f-main, system-ui, sans-serif); cursor: pointer; }
.leo__hint-close { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 50%; background: none; color: #64748b; cursor: pointer; }
.leo__hint-close:hover { background: #f1f5f9; color: #0a0a1a; }
.leo__hint-close svg, .leo__icon-btn svg, .leo__send svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Fenêtre ---------- */
.leo__panel {
  position: absolute; right: 0; bottom: 78px; display: flex; flex-direction: column;
  width: min(390px, calc(100vw - 2 * var(--leo-gap))); height: min(620px, calc(100vh - 130px)); height: min(620px, calc(100dvh - 130px));
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 20px; overflow: hidden;
  background: rgba(13, 13, 32, 0.97); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 212, 255, 0.05);
  color: #f1f5f9; opacity: 0; transform: translateY(14px) scale(0.98); transform-origin: bottom right;
  transition: opacity 0.3s, transform 0.45s var(--ease-out, ease);
}
.leo__panel.is-in { opacity: 1; transform: none; }
.leo__panel[hidden] { display: none; }

.leo__head { display: flex; align-items: center; gap: 12px; padding: 14px 12px 14px 16px; background: linear-gradient(135deg, rgba(0, 212, 255, 0.12), rgba(139, 92, 246, 0.16)); border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.leo__avatar { width: 44px; height: 44px; flex: none; }
.leo__who { flex: 1; min-width: 0; }
.leo__name { margin: 0; font-size: 16px; font-weight: 500; color: #fff; line-height: 1.2; }
.leo__role { margin: 2px 0 0; font-size: 12.5px; color: #a9b6c8; line-height: 1.2; }
.leo__role::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #22e3a0; box-shadow: 0 0 8px rgba(34, 227, 160, 0.7); vertical-align: 1px; }
.leo__icon-btn { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border: 0; border-radius: 10px; background: none; color: #a9b6c8; cursor: pointer; transition: background 0.2s, color 0.2s; }
.leo__icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

/* ---------- Messages ---------- */
.leo__log { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 18px 16px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.15) transparent; }
.leo__msg { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.leo__mini { width: 26px; height: 26px; flex: none; }
.leo__bubble { min-width: 0; padding: 10px 13px; border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 14px 14px 14px 4px; background: rgba(255, 255, 255, 0.06); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.leo__bubble p { margin: 0; }
.leo__bubble p + p, .leo__bubble p + ul, .leo__bubble ul + p { margin-top: 8px; }
.leo__bubble ul { margin: 6px 0 0; padding-left: 18px; }
.leo__bubble li + li { margin-top: 3px; }
.leo__bubble strong { color: #fff; font-weight: 500; }
.leo__bubble a { color: #00d4ff; text-decoration: underline; text-underline-offset: 2px; }
.leo__bubble a:hover { color: #fff; }
.leo__msg--me { justify-content: flex-end; }
.leo__msg--me .leo__bubble { max-width: 82%; border: 0; border-radius: 14px 14px 4px 14px; background: linear-gradient(135deg, #00b8e6, #7c4dee); color: #fff; }

.leo__chips { display: flex; flex-wrap: wrap; gap: 8px; padding-left: 34px; }
.leo__chip { padding: 7px 12px; border: 1px solid rgba(0, 212, 255, 0.35); border-radius: 999px; background: rgba(0, 212, 255, 0.06); color: #f1f5f9; font: 13px/1.2 var(--f-main, system-ui, sans-serif); cursor: pointer; transition: background 0.2s, border-color 0.2s; }
.leo__chip:hover { background: rgba(0, 212, 255, 0.16); border-color: #00d4ff; }

/* « Leo écrit » */
.leo__typing .leo__bubble { display: flex; gap: 5px; padding: 14px 14px; }
.leo__typing .leo__bubble span { width: 7px; height: 7px; border-radius: 50%; background: #a9b6c8; animation: leo-dot 1.2s infinite; }
.leo__typing .leo__bubble span:nth-child(2) { animation-delay: 0.15s; }
.leo__typing .leo__bubble span:nth-child(3) { animation-delay: 0.3s; }
@keyframes leo-dot { 0%, 60%, 100% { opacity: 0.35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

/* Carte « Recevoir la réponse par e-mail » */
.leo__fw { margin-left: 34px; padding: 14px; border: 1px solid rgba(139, 92, 246, 0.35); border-radius: 14px; background: linear-gradient(135deg, rgba(0, 212, 255, 0.07), rgba(139, 92, 246, 0.1)); }
.leo__fw-title { margin: 0; font-size: 14px; font-weight: 500; color: #fff; }
.leo__fw-text, .leo__fw-note { margin: 4px 0 0; font-size: 12.5px; line-height: 1.45; color: #a9b6c8; }
.leo__fw-note { margin-top: 8px; font-size: 11.5px; color: #8391a7; }
.leo__fw-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.leo__fw-mail { flex: 1 1 170px; min-width: 0; padding: 9px 11px; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 10px; background: rgba(10, 10, 26, 0.7); color: #fff; font: 14px/1.3 var(--f-main, system-ui, sans-serif); }
.leo__fw-mail:focus { outline: none; border-color: #00d4ff; }
.leo__fw-send { flex: 0 0 auto; padding: 9px 14px; border: 0; border-radius: 10px; background: linear-gradient(135deg, #00b8e6, #7c4dee); color: #fff; font: 500 13.5px/1.2 var(--f-main, system-ui, sans-serif); cursor: pointer; }
.leo__fw-send:disabled { opacity: 0.6; cursor: default; }
.leo__fw-error { margin: 8px 0 0; font-size: 12.5px; color: #ff8a8a; }
.leo__hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.leo__done { margin: 0 0 0 34px; padding: 10px 13px; border-radius: 12px; background: rgba(34, 227, 160, 0.1); border: 1px solid rgba(34, 227, 160, 0.3); font-size: 13px; line-height: 1.45; color: #c9f7e6; }

/* Vérification anti-robot Turnstile : invisible, sauf si Cloudflare a un doute */
.leo__ts { margin: 0 12px 10px; }
.leo__ts:empty { display: none; }

/* ---------- Saisie ---------- */
.leo__form { display: flex; align-items: flex-end; gap: 8px; margin: 0 12px; padding: 6px 6px 6px 14px; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 14px; background: rgba(255, 255, 255, 0.05); transition: border-color 0.2s; }
.leo__form:focus-within { border-color: rgba(0, 212, 255, 0.6); }
.leo__input { flex: 1; min-width: 0; max-height: 120px; padding: 8px 0; border: 0; background: none; color: #fff; font: 14.5px/1.4 var(--f-main, system-ui, sans-serif); resize: none; outline: none; }
.leo__input::placeholder { color: #7c8aa0; }
.leo__send { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border: 0; border-radius: 10px; background: linear-gradient(135deg, #00b8e6, #7c4dee); color: #fff; cursor: pointer; transition: opacity 0.2s, transform 0.2s; }
.leo__send:hover { transform: translateY(-1px); }
.leo__send:disabled { opacity: 0.5; cursor: default; transform: none; }
.leo__legal { margin: 0; padding: 8px 16px 12px; font-size: 11.5px; line-height: 1.4; color: #7c8aa0; text-align: center; }
.leo__legal a { color: #a9b6c8; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Mobile : fenêtre plein écran ---------- */
@media (max-width: 600px) {
  .leo.is-under-cc .leo__launcher, .leo.is-under-cc .leo__hint { opacity: 0; pointer-events: none; }
  .leo__panel { position: fixed; inset: 0; width: auto; height: auto; border: 0; border-radius: 0; transform-origin: bottom center; }
  .leo.is-open .leo__launcher, .leo.is-open .leo__hint { opacity: 0; pointer-events: none; }
  .leo__head { padding-top: max(14px, env(safe-area-inset-top)); }
  .leo__legal { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .leo__input { font-size: 16px; } /* évite le zoom automatique sur iPhone */
}

@media (prefers-reduced-motion: reduce) {
  .leo-svg--live .leo-eyes, .leo-svg--live .leo-ear, .leo.is-thinking .leo__avatar .leo-ear, .leo__typing .leo__bubble span { animation: none; }
  .leo__launcher, .leo__panel, .leo__hint { transition: opacity 0.2s; transform: none; }
}

@media print { .leo { display: none; } }
