/* ═══════════════════════════════════════════════════════════
   Mjolnir Comm Bubble — floating agent on main site
   Matches SpaceX / D-DIN cinematic theme
   ═══════════════════════════════════════════════════════════ */

.mpl-comm {
  --mpl-c-black: #000000;
  --mpl-c-panel: rgba(8, 10, 14, 0.92);
  --mpl-c-panel-solid: #0b0d12;
  --mpl-c-white: #f0f0fa;
  --mpl-c-muted: rgba(240, 240, 250, 0.55);
  --mpl-c-faint: rgba(240, 240, 250, 0.12);
  --mpl-c-accent: #3ecfff;
  --mpl-c-accent-dim: rgba(62, 207, 255, 0.18);
  --mpl-c-err: #ff5f6e;
  --mpl-c-ok: #3ddc84;
  --mpl-font: "D-DIN", Arial, Verdana, sans-serif;
  --mpl-font-b: "D-DIN-Bold", "D-DIN", Arial, Verdana, sans-serif;
  --mpl-ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --mpl-z: 12000;
  font-family: var(--mpl-font);
  color: var(--mpl-c-white);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body.light-mode .mpl-comm {
  --mpl-c-black: #f2f3f5;
  --mpl-c-panel: rgba(255, 255, 255, 0.96);
  --mpl-c-panel-solid: #ffffff;
  --mpl-c-white: #0a0c10;
  --mpl-c-muted: #3d4a5c;
  --mpl-c-faint: rgba(10, 12, 16, 0.1);
  --mpl-c-accent: #0047c7;
  --mpl-c-accent-dim: rgba(0, 71, 199, 0.1);
}

.mpl-comm *,
.mpl-comm *::before,
.mpl-comm *::after {
  box-sizing: border-box;
}

/* ── Launcher FAB ─────────────────────────────────────────── */
.mpl-comm-fab {
  position: fixed;
  right: 1.35rem;
  bottom: 1.35rem;
  z-index: var(--mpl-z);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid rgba(62, 207, 255, 0.45);
  background:
    radial-gradient(circle at 30% 25%, rgba(62, 207, 255, 0.35), transparent 55%),
    linear-gradient(145deg, #0a1018 0%, #050608 100%);
  color: var(--mpl-c-accent);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 12px 40px rgba(0, 0, 0, 0.55),
    0 0 32px rgba(62, 207, 255, 0.25);
  transition: transform 0.25s var(--mpl-ease), box-shadow 0.25s, border-color 0.2s;
  padding: 0;
}

body.light-mode .mpl-comm-fab {
  background:
    radial-gradient(circle at 30% 25%, rgba(0, 71, 199, 0.18), transparent 55%),
    linear-gradient(145deg, #ffffff 0%, #eef1f6 100%);
  box-shadow:
    0 10px 30px rgba(10, 12, 16, 0.12),
    0 0 24px rgba(0, 71, 199, 0.15);
}

.mpl-comm-fab:hover {
  transform: translateY(-2px) scale(1.04);
  border-color: var(--mpl-c-accent);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.55),
    0 0 48px rgba(62, 207, 255, 0.4);
}

.mpl-comm-fab:focus-visible {
  outline: 2px solid var(--mpl-c-accent);
  outline-offset: 3px;
}

.mpl-comm-fab svg {
  width: 28px;
  height: 28px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mpl-comm-fab.is-open {
  border-color: var(--mpl-c-white);
  color: var(--mpl-c-white);
}

/* Pulse ring when agent is live / speaking */
.mpl-comm-fab::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid rgba(62, 207, 255, 0.35);
  opacity: 0;
  pointer-events: none;
}

.mpl-comm-fab.is-live::before {
  animation: mpl-comm-pulse 1.8s var(--mpl-ease) infinite;
  opacity: 1;
}

.mpl-comm-fab.is-listening {
  color: #ff5f6e;
  border-color: rgba(255, 95, 110, 0.65);
  box-shadow:
    0 0 0 1px rgba(255, 95, 110, 0.2) inset,
    0 12px 40px rgba(0, 0, 0, 0.55),
    0 0 36px rgba(255, 95, 110, 0.35);
}

@keyframes mpl-comm-pulse {
  0% { transform: scale(0.92); opacity: 0.85; }
  70% { transform: scale(1.18); opacity: 0; }
  100% { transform: scale(1.18); opacity: 0; }
}

.mpl-comm-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--mpl-c-ok);
  border: 2px solid #000;
  box-shadow: 0 0 10px rgba(61, 220, 132, 0.7);
}

body.light-mode .mpl-comm-badge {
  border-color: #fff;
}

/* ── Panel ────────────────────────────────────────────────── */
.mpl-comm-panel {
  position: fixed;
  right: 1.35rem;
  bottom: calc(1.35rem + 72px);
  z-index: calc(var(--mpl-z) + 1);
  width: min(400px, calc(100vw - 1.5rem));
  height: min(620px, calc(100vh - 7rem));
  display: flex;
  flex-direction: column;
  background: var(--mpl-c-panel);
  border: 1px solid var(--mpl-c-faint);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(62, 207, 255, 0.08) inset;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.97);
  transform-origin: bottom right;
  transition:
    opacity 0.28s var(--mpl-ease),
    transform 0.32s var(--mpl-ease),
    visibility 0.28s;
  overflow: hidden;
}

.mpl-comm-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

body.light-mode .mpl-comm-panel {
  box-shadow: 0 20px 50px rgba(10, 12, 16, 0.14);
}

/* Header */
.mpl-comm-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--mpl-c-faint);
  background:
    linear-gradient(180deg, rgba(62, 207, 255, 0.08), transparent 80%),
    transparent;
}

.mpl-comm-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(62, 207, 255, 0.4);
  background:
    radial-gradient(circle at 35% 30%, rgba(62, 207, 255, 0.45), transparent 55%),
    #05080c;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  position: relative;
}

.mpl-comm-avatar::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mpl-c-ok);
  position: absolute;
  right: 1px;
  bottom: 1px;
  box-shadow: 0 0 8px rgba(61, 220, 132, 0.8);
}

.mpl-comm-avatar svg {
  width: 18px;
  height: 18px;
  stroke: var(--mpl-c-accent);
  fill: none;
  stroke-width: 1.6;
}

.mpl-comm-head-text {
  flex: 1;
  min-width: 0;
}

.mpl-comm-title {
  line-height: 1.25;
  max-width: 16rem;
  font-family: var(--mpl-font-b);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mpl-c-white);
}

.mpl-comm-sub {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mpl-c-muted);
  margin-top: 0.1rem;
}

.mpl-comm-sub[data-state="listening"] { color: #ff7a86; }
.mpl-comm-sub[data-state="speaking"] { color: var(--mpl-c-accent); }
.mpl-comm-sub[data-state="thinking"] { color: #ffb454; }

.mpl-comm-head-actions {
  display: flex;
  gap: 0.35rem;
}

.mpl-comm-icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--mpl-c-faint);
  background: transparent;
  color: var(--mpl-c-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.mpl-comm-icon-btn:hover {
  color: var(--mpl-c-white);
  border-color: rgba(62, 207, 255, 0.4);
}

.mpl-comm-icon-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Messages */
.mpl-comm-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
}

.mpl-comm-log::-webkit-scrollbar { width: 6px; }
.mpl-comm-log::-webkit-scrollbar-thumb {
  background: rgba(62, 207, 255, 0.25);
}

.mpl-comm-msg {
  max-width: 92%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--mpl-c-faint);
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
  animation: mpl-comm-in 0.35s var(--mpl-ease);
}

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

.mpl-comm-msg .mpl-who {
  display: block;
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
  color: var(--mpl-c-accent);
}

.mpl-comm-msg.user {
  align-self: flex-end;
  border-color: rgba(62, 207, 255, 0.35);
  background: var(--mpl-c-accent-dim);
}

.mpl-comm-msg.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.02);
}

body.light-mode .mpl-comm-msg.assistant {
  background: rgba(10, 12, 16, 0.03);
}

.mpl-comm-msg.system {
  align-self: center;
  max-width: 100%;
  border-style: dashed;
  color: var(--mpl-c-muted);
  font-size: 0.78rem;
  text-align: center;
  background: transparent;
}

/* Wave visualizer */
.mpl-comm-wave {
  display: none;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 28px;
  padding: 0 1rem 0.35rem;
}

.mpl-comm-wave.is-on { display: flex; }

.mpl-comm-wave span {
  width: 3px;
  height: 6px;
  background: var(--mpl-c-accent);
  border-radius: 1px;
  animation: mpl-comm-bar 0.9s ease-in-out infinite;
  opacity: 0.85;
}

.mpl-comm-wave span:nth-child(2) { animation-delay: 0.1s; }
.mpl-comm-wave span:nth-child(3) { animation-delay: 0.2s; }
.mpl-comm-wave span:nth-child(4) { animation-delay: 0.3s; }
.mpl-comm-wave span:nth-child(5) { animation-delay: 0.15s; }
.mpl-comm-wave span:nth-child(6) { animation-delay: 0.25s; }
.mpl-comm-wave span:nth-child(7) { animation-delay: 0.05s; }

@keyframes mpl-comm-bar {
  0%, 100% { height: 5px; opacity: 0.4; }
  50% { height: 22px; opacity: 1; }
}

/* Composer */
.mpl-comm-foot {
  border-top: 1px solid var(--mpl-c-faint);
  padding: 0.75rem;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.25), transparent);
}

body.light-mode .mpl-comm-foot {
  background: linear-gradient(0deg, rgba(255, 255, 255, 0.6), transparent);
}

.mpl-comm-composer {
  display: flex;
  gap: 0.45rem;
  align-items: flex-end;
}

.mpl-comm-composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 110px;
  resize: none;
  border: 1px solid var(--mpl-c-faint);
  background: rgba(0, 0, 0, 0.35);
  color: var(--mpl-c-white);
  font: inherit;
  font-size: 0.92rem;
  padding: 0.65rem 0.75rem;
  line-height: 1.35;
}

body.light-mode .mpl-comm-composer textarea {
  background: #f4f5f7;
}

.mpl-comm-composer textarea:focus {
  outline: none;
  border-color: var(--mpl-c-accent);
  box-shadow: 0 0 0 1px var(--mpl-c-accent);
}

.mpl-comm-composer textarea::placeholder {
  color: var(--mpl-c-muted);
}

.mpl-comm-send,
.mpl-comm-mic {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 1px solid var(--mpl-c-faint);
  background: transparent;
  color: var(--mpl-c-white);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.mpl-comm-send {
  background: var(--mpl-c-white);
  color: #000;
  border-color: var(--mpl-c-white);
}

.mpl-comm-send:hover:not(:disabled) {
  background: var(--mpl-c-accent);
  border-color: var(--mpl-c-accent);
  color: #000;
}

body.light-mode .mpl-comm-send:hover:not(:disabled) {
  color: #fff;
}

.mpl-comm-send:disabled,
.mpl-comm-mic:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mpl-comm-mic:hover:not(:disabled) {
  border-color: var(--mpl-c-accent);
  color: var(--mpl-c-accent);
}

.mpl-comm-mic.is-hot {
  border-color: #ff5f6e;
  color: #ff5f6e;
  background: rgba(255, 95, 110, 0.12);
  box-shadow: 0 0 20px rgba(255, 95, 110, 0.25);
  animation: mpl-comm-micglow 1.2s ease-in-out infinite;
}

@keyframes mpl-comm-micglow {
  0%, 100% { box-shadow: 0 0 12px rgba(255, 95, 110, 0.2); }
  50% { box-shadow: 0 0 24px rgba(255, 95, 110, 0.45); }
}

.mpl-comm-send svg,
.mpl-comm-mic svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mpl-comm-hint {
  margin-top: 0.45rem;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mpl-c-muted);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.mpl-comm-hint a {
  color: var(--mpl-c-accent);
  text-decoration: none;
}

.mpl-comm-hint a:hover { text-decoration: underline; }

/* Mobile */
@media (max-width: 520px) {
  .mpl-comm-panel {
    right: 0.65rem;
    left: 0.65rem;
    width: auto;
    bottom: calc(0.65rem + 70px);
    height: min(70vh, 560px);
  }
  .mpl-comm-fab {
    right: 0.9rem;
    bottom: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mpl-comm-fab,
  .mpl-comm-panel,
  .mpl-comm-msg,
  .mpl-comm-fab::before,
  .mpl-comm-wave span,
  .mpl-comm-mic.is-hot {
    animation: none !important;
    transition: none !important;
  }
}

.mpl-comm-icon-btn.is-voice-on {
  color: #3ecfff;
  border-color: rgba(62,207,255,.45);
  background: rgba(62,207,255,.12);
}

