/* ============================================================
   Messages (role-aware chat): placement only.
   Both columns are panes: the conversation list holds a search bar and a
   list of whole-row links, the thread holds the chat component and the
   composer. This sheet owns the two-column split, the height each column
   scrolls within, and the circle a conversation's initials sit in.
   Reads only --t-* and --c-* tokens.
   ============================================================ */

@layer layout {
  /* Two panes: the conversation list and the open thread. They stack on a
     narrow container and split side-by-side once there is room. */
  .messages .messages-layout { display: grid; gap: var(--t-space-4);
                                grid-template-columns: 1fr; align-items: start;
                                min-block-size: 28rem; }
  @container (min-width: 44rem) {
    .messages .messages-layout { grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr); }
  }

  /* Each pane hands the room its cap leaves to its body, and the body hands
     its own leftover room to the part that scrolls. Without that the body
     takes its content's height, the pane's cap clips the tail, and whatever
     sat at the end — the last conversations, a refused composer whose alert
     makes it taller — is cut off instead of scrolled to. */
  .messages .messages-list,
  .messages .messages-thread { grid-template-rows: auto minmax(0, 1fr); }

  /* The list pane keeps its search bar fixed and scrolls the conversations. */
  .messages .messages-list { max-block-size: 34rem; }
  .messages .messages-list > .body { grid-template-rows: auto minmax(0, 1fr);
                                      min-block-size: 0; }
  .messages .messages-conversations { overflow-y: auto; min-block-size: 0; }

  .messages .messages-initials { display: inline-flex; align-items: center;
                                  justify-content: center; flex: none;
                                  inline-size: var(--t-space-10); block-size: var(--t-space-10);
                                  border-radius: var(--t-radius-pill);
                                  font-size: var(--t-font-size-sm);
                                  font-weight: var(--t-font-weight-bold); }

  /* The thread pane: who it is with, the messages, then the composer. Only
     the messages scroll. */
  .messages .messages-thread { max-block-size: 34rem; }
  .messages .messages-thread > .body { grid-template-rows: auto minmax(0, 1fr) auto;
                                        min-block-size: 0; }
  .messages .messages-thread .chat { overflow-y: auto; min-block-size: 0; }
  .messages .messages-role { margin: 0; }

  .messages .messages-composer { display: grid; grid-template-columns: minmax(0, 1fr) auto;
                                  align-items: end; gap: var(--t-space-2); }
  /* A refusal belongs above the field, across both columns. */
  .messages .messages-composer > .callout { grid-column: 1 / -1; }
  .messages .messages-send { flex-shrink: 0; }

  .messages .messages-support-desc { margin: 0; }
}

@layer design {
  .messages .messages-role { font-size: var(--t-font-size-sm);
                              color: var(--c-surface-text-color-muted); }
  .messages .messages-support-desc { color: var(--c-surface-text-color-muted); }
}
