/* chat.css — Chat bubble + panel.
   Inherits CSS custom properties from warm.css / dark.css automatically. */

/* ── Bubble ────────────────────────────────────────────────── */
.chat-bubble {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--chat-bubble-color, var(--warm-accent, #e8875a));
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  z-index: 9000;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.chat-bubble:hover { transform: scale(1.07); }
.chat-bubble:focus-visible {
  outline: 3px solid var(--warm-accent, #e8875a);
  outline-offset: 3px;
}
.chat-bubble.chat-thinking {
  animation: chat-pulse 1.4s ease-in-out infinite;
}
@keyframes chat-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(0,0,0,0.18); }
  50%       { box-shadow: 0 4px 24px rgba(0,0,0,0.28),
                          0 0 0 6px rgba(255,255,255,0.15); }
}
@media (prefers-reduced-motion: reduce) {
  .chat-bubble.chat-thinking { animation: none; }
}

/* ── Panel ─────────────────────────────────────────────────── */
.chat-panel {
  position: fixed;
  bottom: calc(1.5rem + 3.25rem + 0.75rem);
  right: 1.5rem;
  width: min(320px, calc(100vw - 24px));
  max-height: min(60vh, 480px);
  background: var(--warm-bg, #faf6f1);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.16);
  display: flex;
  flex-direction: column;
  z-index: 9001;
  overflow: hidden;
}
.chat-panel[hidden] { display: none !important; }

/* ── Header ────────────────────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  flex-shrink: 0;
}
.chat-header-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--warm-text, #2c2015);
}
.chat-header-mood {
  font-size: 0.8rem;
  color: var(--warm-muted, #a08060);
  flex: 1;
}
.chat-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
  color: var(--warm-muted, #a08060);
  border-radius: 4px;
}
.chat-close:hover { color: var(--warm-text, #2c2015); }
.chat-close:focus-visible {
  outline: 2px solid var(--warm-accent, #e8875a);
  outline-offset: 2px;
}

/* ── Messages ──────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.chat-msg {
  max-width: 85%;
  font-size: 0.88rem;
  line-height: 1.45;
  border-radius: 12px;
  padding: 0.5rem 0.75rem;
  word-break: break-word;
}
.chat-msg--spark {
  align-self: flex-start;
  background: var(--warm-card, #f2ece3);
  border-left: 3px solid var(--chat-bubble-color, var(--warm-accent, #e8875a));
  color: var(--warm-text, #2c2015);
}
.chat-msg--user {
  align-self: flex-end;
  background: rgba(0,0,0,0.06);
  color: var(--warm-text, #2c2015);
}

/* Thinking dots */
.chat-thinking-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.chat-thinking-dots span {
  display: inline-block;
  font-size: 1.2rem;
  animation: chat-dot-bounce 1.2s ease-in-out infinite;
  color: var(--warm-muted, #a08060);
}
.chat-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%            { transform: translateY(-4px); }
}
@media (prefers-reduced-motion: reduce) {
  .chat-thinking-dots span { animation: none; }
}

/* ── Input row ─────────────────────────────────────────────── */
.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-top: 1px solid rgba(0,0,0,0.06);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  resize: none;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.88rem;
  font-family: inherit;
  background: var(--warm-bg, #faf6f1);
  color: var(--warm-text, #2c2015);
  line-height: 1.4;
  max-height: 6rem;
  overflow-y: auto;
}
.chat-input:focus {
  outline: 2px solid var(--warm-accent, #e8875a);
  outline-offset: 1px;
  border-color: transparent;
}
.chat-input:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-send {
  background: var(--chat-bubble-color, var(--warm-accent, #e8875a));
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 2.25rem;
  height: 2.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.chat-send:hover { opacity: 0.85; }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; }
.chat-send:focus-visible {
  outline: 2px solid var(--warm-accent, #e8875a);
  outline-offset: 2px;
}
