/*
 * CP-21 Message — app/components/ui/message_component.rb
 *
 * Chat bubble: own side right-aligned on the accent tint, the other side
 * left-aligned on the surrounding surface's field fill. Ink text on both fills keeps AA at
 * body size (white on --color-accent does not). Bubbles cap at 85% of the
 * thread width so a long message never reads as a full-width block, and
 * long URLs break rather than overflow the 375px referrer column.
 *
 * Token vars only — enforced by test/lint/css_token_lint_test.rb.
 */

.ui-message {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  max-width: 85%;
}

.ui-message--other {
  align-self: flex-start;
  align-items: flex-start;
}

.ui-message--own {
  align-self: flex-end;
  align-items: flex-end;
}

.ui-message__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
  padding-inline: var(--space-1);
  font-size: var(--text-xs);
  line-height: var(--text-xs--line-height);
  color: var(--color-ink-muted);
}

.ui-message--own .ui-message__meta {
  justify-content: flex-end;
}

.ui-message__sender {
  font-weight: 500;
  color: var(--color-ink);
}

.ui-message__bubble {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  /* Follows the nearest surface the same way form fields do (forms.css):
     inset on a card, solid white on the bare referrer canvas — where the
     inset tint is the page colour and the bubble would vanish. */
  background: var(--fm-control-bg);
  color: var(--color-ink);
}

.ui-message--other .ui-message__bubble {
  border-top-left-radius: var(--radius-xs);
}

.ui-message--own .ui-message__bubble {
  background: var(--color-accent-100);
  border-top-right-radius: var(--radius-xs);
}

.ui-message__body {
  font-size: var(--text-sm);
  line-height: var(--text-sm--line-height);
  overflow-wrap: anywhere;
}

.ui-message__link {
  color: var(--color-accent-strong);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* --color-accent-strong is only 4.15:1 on the own-side accent tint, under
   WCAG AA's 4.5:1; the pressed step is 5.92:1 there. */
.ui-message--own .ui-message__link {
  color: var(--color-accent-pressed);
}

.ui-message--unread .ui-message__bubble {
  box-shadow: inset 0 0 0 1.5px var(--color-accent-strong);
}
