/* Message reactions (frontend/chat/reactions.js): a port of the Control UI's chat-message-reactions.css and
   grouped.css (.chat-message-reactions, .chat-reaction-chip, .chat-reaction-action) at v2026.11.6. Shapes and
   sizes are the Control UI's; tokens come from composer-tokens.css (--accent: ClawChats' accent, the "selected"
   colour; the Control UI's red --accent means the same there, its brand colour, not danger). */

/* Chip row: its own line under the bubble, above the action row (the action row fades on hover and keeps fixed
   button slots; the Control UI puts chips in its footer row instead). Always shown. */
.chat-message-reactions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  max-width: 100%;
}

.chat-message-reactions[hidden] {
  display: none;
}

/* Under one's own prompt (right-aligned), the chips line up with the bubble's right edge. */
.chat-message-reactions--own {
  justify-content: flex-end;
}

.chat-reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}

.chat-reaction-chip:disabled {
  cursor: default;
}

.chat-reaction-chip__emoji {
  font-size: 14px;
  line-height: 1;
}

.chat-reaction-chip[aria-pressed="true"],
.chat-reaction-chip[aria-pressed="true"]:enabled:hover {
  border-color: var(--accent);
  background: var(--accent-subtle);
  color: var(--accent);
}

.chat-reaction-chip:enabled:hover {
  border-color: color-mix(in srgb, var(--muted) 45%, var(--border));
  background: var(--bg-hover);
  color: var(--text);
}

.chat-reaction-chip:focus-visible,
.chat-reaction-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

@media (prefers-reduced-motion: no-preference) {
  .chat-reaction-chip {
    animation: chat-reaction-chip-in 160ms ease-out;
  }

  .chat-reaction-chip__count {
    display: inline-block;
    animation: chat-reaction-count-in 200ms cubic-bezier(0.2, 0.9, 0.3, 1.4);
  }
}

@keyframes chat-reaction-chip-in {
  from { transform: scale(0.85); opacity: 0; }
}

@keyframes chat-reaction-count-in {
  from { transform: translateY(35%); opacity: 0; }
}

/* The chip row's add button: shown while the message is hovered or focused (always on touch). */
.chat-reaction-add {
  display: inline-flex;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.message:hover .chat-reaction-add,
.message:focus-within .chat-reaction-add,
.chat-reaction-add.rx-open {
  opacity: 1;
  pointer-events: auto;
}

@media (hover: none) {
  .chat-reaction-add {
    opacity: 1;
    pointer-events: auto;
  }
}

.chat-reaction-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.chat-reaction-trigger svg {
  width: 14px;
  height: 14px;
}

.chat-reaction-trigger--compact {
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
}

.chat-reaction-trigger--compact:hover,
.chat-reaction-trigger--compact[aria-expanded="true"] {
  border-color: var(--accent);
  background: var(--accent-subtle);
  color: var(--accent);
}

/* The action row's button: the row's own look; its slot stays when the chip row takes over. */
.msg-action-btn.react-btn:hover,
.msg-action-btn.react-btn[aria-expanded="true"] {
  color: var(--accent-text);
}

.msg-action-btn.react-btn.rx-slot-hidden {
  visibility: hidden;
}

/* Keep the row visible while its picker is open. */
.message .message-actions:has(.react-btn[aria-expanded="true"]) {
  opacity: 1;
}

/* Picker: a pill of quick reactions; "More…" turns it into the shortcode search. */
.chat-reaction-picker {
  position: fixed;
  z-index: 10050;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--popover);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 12px 32px rgba(0, 0, 0, 0.16);
}

.chat-reaction-picker.custom {
  width: min(292px, calc(100vw - 32px));
  border-radius: var(--radius-md);
}

.chat-reaction-picker button {
  font: inherit;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.chat-reaction-picker button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.chat-reaction-picker .palette {
  display: flex;
  align-items: center;
  gap: 2px;
}

.chat-reaction-picker .palette .emoji {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  font-size: 20px;
  line-height: 1;
  transition: transform 120ms ease, background-color 120ms ease;
}

.chat-reaction-picker .palette .emoji:hover {
  background: var(--bg-hover);
  transform: scale(1.18);
}

.chat-reaction-picker .palette .emoji[aria-pressed="true"] {
  background: var(--accent-subtle);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.chat-reaction-picker .divider {
  width: 1px;
  height: 20px;
  margin: 0 3px;
  background: var(--border);
}

.chat-reaction-picker .more,
.chat-reaction-picker .back {
  border-radius: var(--radius-full);
  color: var(--muted);
}

.chat-reaction-picker .more:hover,
.chat-reaction-picker .back:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.chat-reaction-picker .more {
  width: 30px;
  height: 30px;
}

.chat-reaction-picker .more svg {
  width: 16px;
  height: 16px;
}

.chat-reaction-picker > .custom {
  padding: 4px;
}

.chat-reaction-picker .back {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
}

.chat-reaction-picker .back svg {
  width: 14px;
  height: 14px;
}

/* Emoji search (Control UI emoji-search-panel.css). */
.chat-reaction-picker .emoji-search-panel {
  display: grid;
  gap: 8px;
}

.chat-reaction-picker .emoji-search-panel__row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-reaction-picker .emoji-search-panel__search {
  flex: 1;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.chat-reaction-picker .emoji-search-panel__search:focus-visible {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.chat-reaction-picker .emoji-search-panel__grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  max-height: min(260px, 40vh);
  overflow-y: auto;
}

.chat-reaction-picker .emoji-search-panel__choice {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 42px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 24px;
}

.chat-reaction-picker .emoji-search-panel__choice:hover,
.chat-reaction-picker .emoji-search-panel__choice:focus-visible,
.chat-reaction-picker .emoji-search-panel__choice[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.chat-reaction-picker .emoji-search-panel__empty {
  grid-column: 1 / -1;
  padding: 12px;
  color: var(--muted);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .chat-reaction-trigger,
  .chat-reaction-picker .palette .emoji {
    transition: none;
  }

  .chat-reaction-picker .palette .emoji:hover {
    transform: none;
  }
}
