/* ==========================================================================
   Multiplayer room: chat in the bottom-right corner of the board (js/ui/room-chat.js)
   ========================================================================== */

/* Sits just above the bottom bar (68px tall, drawn over the board) and lets clicks
   through to the board unless the line to type in is open. */
.room-chat {
  position: absolute;
  right: 16px;
  bottom: 76px;
  z-index: 40;
  width: min(260px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  pointer-events: none;
  font-family: var(--font-main);
  letter-spacing: 0;
}

.room-chat-log {
  max-height: 180px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
}

.room-chat.is-open .room-chat-log {
  max-height: 240px;
  overflow-y: auto;
  pointer-events: auto;
}

/* Spacer that keeps the messages at the bottom of the log. */
.room-chat-log::before {
  content: '';
  flex: 1 1 auto;
}

.room-chat-msg {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.room-chat-msg.is-recent,
.room-chat.is-open .room-chat-msg {
  opacity: 1;
}

.room-chat-msg .room-avatar {
  margin-top: 1px;
}

.room-chat-text {
  min-width: 0;
  padding: 3px 9px;
  border-radius: 11px;
  background: var(--paper-bg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  color: var(--graphite-dark);
  font-size: 0.74rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  user-select: text;
}

.room-chat-input {
  display: none;
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  border: 1px solid var(--graphite-light);
  border-radius: 14px;
  background: var(--paper-bg);
  color: var(--graphite-dark);
  font: 0.76rem var(--font-main);
  outline: none;
  pointer-events: auto;
}

.room-chat-input:focus {
  border-color: var(--graphite-medium);
}

.room-chat.is-open .room-chat-input {
  display: block;
}
