/* Orbi, l'assistant ACTUARUS : mascotte animée (components/orbi.js) et fenêtre de discussion (components/orbi-chat.js). */

/* ---------- Mascotte ---------- */
.orbi { display: block; overflow: visible; }
.orbi .orbi-planet { fill: #cff5b8; stroke: #16306b; stroke-width: 8; }
.orbi .orbi-antenna { fill: none; stroke: #16306b; stroke-width: 8; stroke-linejoin: round; stroke-linecap: round; }
.orbi .orbi-antenna-ball { fill: #16306b; }
.orbi .orbi-highlight { fill: none; stroke: #a6df8a; stroke-width: 7; stroke-linecap: round; }
.orbi .orbi-cheek { fill: #a9d3e0; }
.orbi .orbi-spot { fill: #a6df8a; }
.orbi .orbi-eyes path, .orbi .orbi-mouth { fill: none; stroke: #16306b; stroke-width: 6; stroke-linecap: round; }
.orbi .orbi-mouth { stroke-width: 5; }
.orbi .orbi-ring-line { fill: none; stroke: #93bfe3; stroke-width: 14; }
.orbi .orbi-ring-shine { fill: none; stroke: #ffffff; stroke-opacity: .85; stroke-width: 5; stroke-linecap: round; stroke-dasharray: 7 93; }
.orbi .orbi-stars circle { fill: #8fb8de; }
.orbi .orbi-shadow { fill: #16306b; opacity: .14; }

/* Animations : coordonnées des origines dans le repère du dessin (viewBox). */
.orbi .orbi-body { animation: orbi-float 4.2s ease-in-out infinite; }
.orbi .orbi-shadow { transform-box: view-box; transform-origin: 100px 198px; animation: orbi-shadow 4.2s ease-in-out infinite; }
.orbi .orbi-ring { transform-box: view-box; transform-origin: 100px 112px; animation: orbi-ring 6s ease-in-out infinite; }
.orbi .orbi-ring-shine { animation: orbi-shine 3.2s linear infinite; }
.orbi .orbi-eyes { transform-box: view-box; transform-origin: 100px 102px; animation: orbi-blink 5.5s ease-in-out infinite; }
.orbi .orbi-antenna-ball { transform-box: view-box; transform-origin: 100px 24px; }
.orbi .orbi-stars circle { animation: orbi-twinkle 3s ease-in-out infinite; }
.orbi .orbi-stars circle:nth-child(2) { animation-delay: .8s; }
.orbi .orbi-stars circle:nth-child(3) { animation-delay: 1.6s; }
.orbi .orbi-stars circle:nth-child(4) { animation-delay: 2.2s; }

/* Orbi écrit : antenne qui pulse, anneau et reflet qui accélèrent. */
.is-thinking .orbi .orbi-antenna-ball { fill: #2f62c8; animation: orbi-pulse .8s ease-in-out infinite; }
.is-thinking .orbi .orbi-ring { animation-duration: 1.8s; }
.is-thinking .orbi .orbi-ring-shine { animation-duration: .9s; }

@keyframes orbi-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes orbi-shadow { 0%, 100% { transform: scaleX(1); opacity: .16; } 50% { transform: scaleX(.8); opacity: .08; } }
@keyframes orbi-ring { 0%, 100% { transform: rotate(-16deg); } 50% { transform: rotate(-5deg); } }
@keyframes orbi-shine { to { stroke-dashoffset: -100; } }
@keyframes orbi-blink { 0%, 88%, 100% { transform: scaleY(1); } 91% { transform: scaleY(.12); } 94% { transform: scaleY(1); } }
@keyframes orbi-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.3); } }
@keyframes orbi-twinkle { 0%, 100% { opacity: .9; } 50% { opacity: .3; } }

@media (prefers-reduced-motion: reduce) {
  .orbi *, .orbi-typing span { animation: none !important; }
}

/* ---------- Bulle flottante ---------- */
.orbi-launcher {
  position: fixed; right: var(--space-5); bottom: var(--space-5); z-index: calc(var(--z-toast) - 1);
  width: 72px; height: 72px; padding: 6px; border-radius: 50%; border: 1px solid var(--border-2);
  background: #eef9e8; box-shadow: var(--shadow-3); cursor: pointer; display: grid; place-items: center;
  transition: transform var(--dur-2) var(--ease-out);
}
.orbi-launcher:hover { transform: translateY(-2px) scale(1.04); }
.orbi-launcher:focus-visible { outline: none; box-shadow: var(--shadow-focus), var(--shadow-3); }
.orbi-launcher.is-open { transform: scale(.92); }
/* Notifications au-dessus de la bulle. */
body.has-orbi .toast-region { bottom: calc(var(--space-5) + 84px); }

/* ---------- Fenêtre de discussion ---------- */
.orbi-panel {
  position: fixed; right: var(--space-5); bottom: calc(var(--space-5) + 84px); z-index: calc(var(--z-toast) - 1);
  width: min(390px, calc(100vw - 32px)); height: min(580px, calc(100vh - 140px));
  display: flex; flex-direction: column; background: var(--bg-surface); color: var(--fg-1);
  border: 1px solid var(--border-2); border-radius: var(--radius-lg); box-shadow: var(--shadow-3); overflow: hidden;
  animation: orbi-panel-in var(--dur-2) var(--ease-out);
}
.orbi-panel[hidden] { display: none; }
@keyframes orbi-panel-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.orbi-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4); background: #eef9e8; border-bottom: 1px solid var(--border-1); }
.orbi-avatar { flex: none; }
.orbi-title { flex: 1; display: flex; flex-direction: column; line-height: 1.25; color: #16306b; }
.orbi-title strong { font-size: var(--text-lg); }
.orbi-title span { font-size: var(--text-xs); color: #3d5a8f; }

.orbi-log { flex: 1; overflow-y: auto; padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.orbi-msg { max-width: 88%; padding: var(--space-3) var(--space-4); border-radius: 16px; font-size: var(--text-sm); line-height: 1.5; overflow-wrap: anywhere; }
.orbi-msg p { margin: 0; }
.orbi-msg p + p, .orbi-msg p + ul, .orbi-msg ul + p { margin-top: var(--space-2); }
.orbi-msg ul { margin: 0; padding-left: 1.2em; }
.orbi-msg-bot { align-self: flex-start; background: var(--bg-surface-2); border-bottom-left-radius: 4px; }
.orbi-welcome { background: #16306b; color: #ffffff; }
.orbi-msg-user { align-self: flex-end; background: var(--btn-primary); color: var(--fg-on-brand); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.orbi-suggestions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.orbi-suggestions .chip { font-size: var(--text-xs); }

.orbi-typing { display: inline-flex; gap: 5px; align-items: center; }
.orbi-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-3); animation: orbi-dot 1.1s infinite ease-in-out; }
.orbi-typing span:nth-child(2) { animation-delay: .15s; }
.orbi-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes orbi-dot { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }

.orbi-form { display: flex; gap: var(--space-2); align-items: flex-end; padding: var(--space-3) var(--space-3) 0; border-top: 1px solid var(--border-1); }
.orbi-form .textarea { flex: 1; min-height: 44px; max-height: 140px; resize: none; }
.orbi-note { margin: 0; padding: var(--space-2) var(--space-4) var(--space-3); font-size: var(--text-xs); color: var(--fg-3); }

/* Thème sombre : l'en-tête et la bulle gardent les couleurs de la mascotte, assombries. */
[data-theme="dark"] .orbi-launcher, [data-theme="dark"] .orbi-head { background: #1d3354; }
[data-theme="dark"] .orbi-title { color: #e6efff; }
[data-theme="dark"] .orbi-title span { color: #a9bfe3; }
[data-theme="dark"] .orbi-welcome { background: #2a4a85; }

/* Mobile : fenêtre en bas de l'écran sur toute la largeur. */
@media (max-width: 640px) {
  .orbi-launcher { right: var(--space-4); bottom: var(--space-4); width: 62px; height: 62px; }
  .orbi-panel { right: 0; left: 0; bottom: 0; width: 100%; height: min(85vh, calc(100vh - 56px)); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  body.has-orbi .toast-region { bottom: calc(var(--space-4) + 72px); }
}
