/* Troy landing: motion for the conversation component (chat.js). Only opacity and transform are animated.
   The static look of the phone is in phone.css. Everything here applies only once chat.js has taken
   over a mount (.convo.is-live), which never happens with reduced motion or without JavaScript. */

/* The script scrolls the list itself. The visitor's wheel or finger always scrolls the page. */
.convo.is-live .msg-list { overflow: hidden; }
/* A long conversation scrolls; nothing in it is squeezed to make room. */
.convo.is-live .msg-list > * { flex-shrink: 0; }

/* Bubbles arriving */
@keyframes chat-pop {
  from { opacity: 0; transform: translateY(6px) scale(0.7); }
  to { opacity: 1; transform: none; }
}
.convo.is-live .bubble.from-them.is-new,
.convo.is-live .typing {
  transform-origin: 0 100%;
  animation: chat-pop 220ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* Typing dots */
@keyframes chat-dot {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}
.convo.is-live .typing i { animation: chat-dot 1.2s infinite both; }
.convo.is-live .typing i:nth-child(2) { animation-delay: 0.2s; }
.convo.is-live .typing i:nth-child(3) { animation-delay: 0.4s; }

/* Delivered, then Read */
@keyframes chat-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.convo.is-live .msg-status,
.convo.is-live .msg-sender { animation: chat-fade 200ms ease-out both; }

/* Tapback landing. The bubble it will land on keeps its room from the start, so nothing shifts. */
@keyframes chat-tapback {
  0% { opacity: 0; transform: scale(0.2); }
  60% { opacity: 1; transform: scale(1.2); }
  100% { opacity: 1; transform: none; }
}
.convo.is-live .tapback { animation: chat-tapback 380ms ease-out both; }
.bubble.awaits-tapback { margin-top: 16px; }

/* Input bar: caret while typing, send button dim until there is text, a press when it sends */
@keyframes chat-caret {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
.msg-input.is-typing .msg-input-text::after {
  content: "";
  display: inline-block;
  width: 1.5px;
  height: 1.15em;
  margin-left: 1px;
  vertical-align: -0.2em;
  background: var(--imessage-blue);
  animation: chat-caret 1s infinite;
}
.convo.is-live .msg-send { transition: opacity 150ms ease-out, transform 120ms ease-out; }
.convo.is-live .msg-input-text:empty + .msg-send { opacity: 0.35; }
.convo.is-live .msg-send.is-pressed { transform: scale(0.8); }

/* Group chat (after a "switch-group" step): the header shows a small cluster of round avatars,
   and gray bubbles carry the sender's name, as Messages does in a group. */
.msg-header.is-group > .msg-avatar { display: none; }
.msg-group {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding-left: 8px;
}
.msg-group > * {
  position: relative;
  flex: none;
  width: 32px;
  height: 32px;
  margin-left: -8px;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--stone);
  object-fit: cover;
  overflow: hidden;
}
.msg-group > img { z-index: 1; background: var(--line); }
/* A plain person shape for the two students */
.msg-group > i::before,
.msg-group > i::after {
  content: "";
  position: absolute;
  left: 50%;
  background: var(--paper);
  border-radius: 50%;
}
.msg-group > i::before { top: 6px; width: 10px; height: 10px; margin-left: -5px; }
.msg-group > i::after { top: 18px; width: 22px; height: 18px; margin-left: -11px; }

.msg-sender {
  align-self: flex-start;
  margin: 8px 0 1px 12px;
  font-size: 10.5px;
  line-height: 1.3;
  color: var(--stone);
}
.msg-sender + .bubble { margin-top: 0; }

/* The hero phone can be paused with a tap */
.convo.is-live[data-convo-loop] .phone { cursor: pointer; }

/* Small labels naming the two screens (chat.js adds them to .stage). Shown by day.css when one phone shows at a time. */
.stage-who { display: none; }
