/* Global floating "Ask MIRA" launcher.
 *
 * A subtle orb pinned bottom-right that "awakens" to a bright brand→gold
 * gradient on hover/focus, and a small slide-up composer that posts a message
 * to mira:chat_new. Markup: templates/partials/_mira_launcher.html. Behaviour:
 * static/js/mira-launcher.js. Loaded globally from base.html. */

.mira-launcher {
  position: fixed;
  right: 20px;
  /* Clear the fixed bottom status bar. */
  bottom: calc(var(--statusbar-h, 30px) + 18px);
  z-index: 1030;                 /* above content + status bar, below modals (1050) */
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

/* ---------- The orb ---------- */
.mira-launcher__orb {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  /* Subtle at rest: muted surface, faint icon, soft lift. */
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  color: var(--text-faint, #9aa0aa);
  opacity: .78;
  box-shadow: 0 6px 18px -10px rgba(15, 17, 40, .5);
  transition: opacity .18s ease, color .18s ease, border-color .18s ease,
              background .22s ease, box-shadow .22s ease, transform .18s ease;
  -webkit-appearance: none;
  appearance: none;
}

.mira-launcher__orb-spark {
  display: inline-flex;
  line-height: 0;
}
.mira-launcher__orb-spark svg,
.mira-launcher__orb-spark .icon {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  transition: transform .3s ease;
}

/* Awaken: bright brand→gold gradient, white mark, glow + lift. */
.mira-launcher__orb:hover,
.mira-launcher__orb:focus-visible,
.mira-launcher.is-open .mira-launcher__orb {
  opacity: 1;
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--brand, #3b3aa6), var(--gold, #b08a3e));
  box-shadow: 0 12px 30px -8px color-mix(in srgb, var(--brand, #3b3aa6) 65%, transparent),
              0 0 0 4px color-mix(in srgb, var(--brand, #3b3aa6) 14%, transparent);
  transform: translateY(-2px) scale(1.05);
  outline: none;
}
.mira-launcher__orb:hover .mira-launcher__orb-spark svg,
.mira-launcher__orb:focus-visible .mira-launcher__orb-spark svg,
.mira-launcher.is-open .mira-launcher__orb-spark svg {
  transform: rotate(90deg);
}

/* ---------- Compose panel ---------- */
.mira-launcher__panel {
  width: 340px;
  max-width: calc(100vw - 40px);
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 16px;
  box-shadow: 0 24px 60px -24px rgba(15, 17, 40, .55);
  overflow: hidden;
  transform-origin: bottom right;
  animation: mira-launcher-in .16s ease;
}
.mira-launcher__panel[hidden] { display: none; }

@keyframes mira-launcher-in {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.mira-launcher__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 8px 14px;
}
.mira-launcher__head-spark {
  display: inline-flex;
  line-height: 0;
  color: var(--gold, #b08a3e);
}
.mira-launcher__head-spark svg,
.mira-launcher__head-spark .icon { width: 18px; height: 18px; }
.mira-launcher__head-title {
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: .01em;
  color: var(--text, #1a1c2b);
  margin-right: auto;
}
.mira-launcher__kbd {
  font: 600 10.5px/1 ui-monospace, "JetBrains Mono", monospace;
  color: var(--text-faint, #9aa0aa);
  background: var(--bg-elev, #f4f5f7);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  padding: 3px 6px;
  letter-spacing: .04em;
  white-space: nowrap;
}
.mira-launcher__kbd span { font: inherit; }

.mira-launcher__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--text-faint, #9aa0aa);
  cursor: pointer;
  transition: background .14s ease, color .14s ease;
}
.mira-launcher__close:hover {
  background: var(--bg-elev, #f4f5f7);
  color: var(--text, #1a1c2b);
}

.mira-launcher__form { padding: 0 12px 12px; }
.mira-launcher__input {
  width: 100%;
  resize: none;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text, #1a1c2b);
  background: var(--bg, #fff);
  transition: border-color .14s ease, box-shadow .14s ease;
}
.mira-launcher__input::placeholder { color: var(--text-faint, #9aa0aa); }
.mira-launcher__input:focus {
  outline: none;
  border-color: var(--brand, #3b3aa6);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand, #3b3aa6) 16%, transparent);
}

.mira-launcher__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.mira-launcher__hint {
  font-size: 11px;
  color: var(--text-faint, #9aa0aa);
  margin-right: auto;
}
.mira-launcher__send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--brand, #3b3aa6), var(--gold, #b08a3e));
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--brand, #3b3aa6) 70%, transparent);
  transition: transform .14s ease, box-shadow .14s ease, opacity .14s ease;
}
.mira-launcher__send:hover { transform: translateY(-1px); }
.mira-launcher__send:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

@media (max-width: 520px) {
  .mira-launcher { right: 14px; bottom: calc(var(--statusbar-h, 30px) + 14px); }
  .mira-launcher__orb { width: 48px; height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  .mira-launcher__orb,
  .mira-launcher__orb-spark svg,
  .mira-launcher__send { transition: none; }
  .mira-launcher__orb:hover,
  .mira-launcher__orb:focus-visible,
  .mira-launcher.is-open .mira-launcher__orb { transform: none; }
  .mira-launcher__panel { animation: none; }
}
