/* ChatPresence — the wait between Send and the mentor's first word.
   Colour: one candlelight hue, tuned per theme in skin.js (--presence-warm-rgb).
   See docs/design/mentor-chat-presence.md. */

.chat-presence-halo {
  animation: chat-presence-breath 4.4s ease-in-out infinite;
  border-radius: 9999px;
}
.chat-presence-halo-static {
  animation: none;
  box-shadow: 0 0 0 6px rgba(var(--presence-warm-rgb, 240, 180, 87), 0.18),
              0 0 22px 4px rgba(var(--presence-warm-rgb, 240, 180, 87), 0.24);
}
.chat-presence-halo-settle {
  animation: none;
  box-shadow: 0 0 0 0 rgba(var(--presence-warm-rgb, 240, 180, 87), 0);
  transition: box-shadow 0.7s ease-out;
}
@keyframes chat-presence-breath {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(var(--presence-warm-rgb, 240, 180, 87), 0),
                0 0 0 0 rgba(var(--presence-warm-rgb, 240, 180, 87), 0);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(var(--presence-warm-rgb, 240, 180, 87), 0.18),
                0 0 28px 8px rgba(var(--presence-warm-rgb, 240, 180, 87), 0.32);
  }
}

/* The bubble is sized to one line while waiting; hidden until the first line.
   !important: the chat modal sets `.chat-message-mentor .message-bubble { width: 82% }`
   with id specificity; each surface keeps its own max-width. */
.message-bubble.chat-presence-bubble {
  width: auto !important;
  min-width: 0 !important;
}
.message-bubble.chat-presence-bubble .chat-presence-line,
.message-bubble.chat-presence-bubble .message-content,
.message-bubble.chat-presence-bubble .message-content p {
  font-style: normal;
  opacity: 0.72;
  transition: opacity 0.26s ease;
  white-space: nowrap;
}
.message-bubble.chat-presence-hidden {
  display: none;
}
.chat-presence-line-out {
  opacity: 0 !important;
}

/* Timeout / error: plain text with actions, no red. */
.message-bubble.chat-presence-choice .chat-presence-line,
.message-bubble.chat-presence-choice .message-content,
.message-bubble.chat-presence-choice .message-content p {
  font-style: normal;
  opacity: 1;
  white-space: normal;
}
.chat-presence-action {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--button-bg, #8B5CF6);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.chat-presence-action:focus-visible {
  outline: 2px solid var(--button-bg, #8B5CF6);
  outline-offset: 2px;
  border-radius: 3px;
}
.chat-presence-sep {
  opacity: 0.6;
}

/* Tab pulse: the chat tab shows a warm dot while its mentor is working. */
.chat-tab .chat-presence-dot {
  display: none;
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  flex: none;
  background: rgb(var(--presence-warm-rgb, 240, 180, 87));
  box-shadow: 0 0 8px 2px rgba(var(--presence-warm-rgb, 240, 180, 87), 0.45);
}
.chat-tab.chat-presence-working .chat-presence-dot {
  display: inline-block;
  animation: chat-presence-pulse 1.6s ease-in-out infinite;
}
@keyframes chat-presence-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
  .chat-presence-halo {
    animation: none;
    box-shadow: 0 0 0 6px rgba(var(--presence-warm-rgb, 240, 180, 87), 0.18),
                0 0 22px 4px rgba(var(--presence-warm-rgb, 240, 180, 87), 0.24);
  }
  .chat-tab.chat-presence-working .chat-presence-dot {
    animation: none;
    opacity: 1;
  }
}
