/* messenger/composer.css — 5 of 9. Needs base.css, thread.css, message-actions.css.
   The bottom of the thread, plus the page's main narrow-screen layout.
   Sections, in order:
     - Typing indicator (KAN-38): .typing-row, .typing-avatars, .typing-bubble,
       @keyframes typing-wave, and its prefers-reduced-motion block
     - .composer-error, .thread-unavailable (a deleted account's chat, KAN-63),
       .composer, .composer-input-wrap, textarea and send button
     - .thread-back — the back button that only exists on narrow screens (KAN-34)
     - @media (max-width: 720px): the one-pane layout, where the open chat replaces
       the list. This is the main mobile block for sidebar + thread.
     - Reaction toast (KAN-31): .reaction-toast
   Driven by composer.js and notifications.js (typing, toast).
   Other 720px blocks exist in conversation-settings.css (info panel) and motion.css
   (slide-ins) — check those too when changing mobile behaviour. */

/* Typing indicator (KAN-38): the typers' avatars beside a bubble of bouncing dots, as
   the thread's last row. */

.typing-row {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
}

.typing-avatars {
  display: flex;
  align-items: center;
}

.typing-avatars > * + * {
  margin-left: -8px;
}

.typing-avatars .avatar,
.typing-more {
  width: 28px;
  height: 28px;
  min-width: 28px;
  font-size: 0.6rem;
  border: 2px solid var(--bg);
  box-sizing: content-box;
}

.typing-more {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--border);
  color: var(--text);
  font-weight: 700;
}

.typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.75rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-bubble);
  border-bottom-left-radius: 4px;
}

.typing-bubble span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-wave 1.2s infinite ease-in-out;
}

.typing-bubble span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-bubble span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-wave {
  0%, 60%, 100% {
    opacity: 0.3;
  }
  30% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .typing-bubble span {
    animation: none;
  }
}

.composer-error {
  margin: 0 1.5rem;
  background: var(--error-bg);
  color: var(--error);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.9rem;
  font-size: var(--text-sm);
}

/* Stands where the composer was in a chat with a deleted account (KAN-63). */
.thread-unavailable {
  margin: 0;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: var(--text-sm);
  text-align: center;
}

.composer {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.composer-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
}

.composer textarea {
  flex: 1;
  resize: none;
  min-height: 2.5rem;
  max-height: 8rem;
  padding: 0.6rem 2.4rem 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: var(--text-md);
  font-family: inherit;
  color: var(--text);
}

.composer textarea:focus {
  outline: none;
  border-color: var(--accent-ink);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.composer button {
  border: none;
  border-radius: var(--radius-lg);
  background: var(--orange);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 1rem;
  padding: 0 0.9rem;
  cursor: pointer;
}

.composer button:hover:not(:disabled) {
  background: var(--orange-dark);
}

.composer button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Back button only exists on narrow screens (KAN-34), where the open chat replaces the list. */
.thread-back {
  display: none;
  padding: 0.25rem 0.5rem;
  border: none;
  border-radius: var(--radius-md);
  background: none;
  color: var(--heading);
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.thread-back:hover {
  background: var(--bg);
}

@media (max-width: 720px) {
  /* One pane at a time, Messenger-mobile style (KAN-34): the list until a chat is opened,
     then the chat alone with a back button to return to the list. */
  .messenger {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
  }

  .messenger:not(.messenger--chat-open) .thread,
  .messenger--chat-open .sidebar {
    display: none;
  }

  .thread-header {
    padding: 0.75rem 1rem;
  }

  .thread-back {
    display: flex;
  }
}

/* Reaction toast (KAN-31) — "Alex reacted ❤️ to your message", click to open. Top-right,
   just under the thread header, so it never covers the composer's Send button. */
.reaction-toast {
  position: fixed;
  top: 88px;
  right: 20px;
  z-index: 1000;
  max-width: 320px;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--tooltip-bg);
  color: #fff;
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

.reaction-toast:hover {
  background: #26327a;
}

