/*
 * The emails with a lead, on the lead card, under the texts (lane t22-leadmail2, 15 Oct 2026; js/v21_leademails.js).
 * One box in the lead's panel (the l418-box look), the bubbles in the texts' own chat style (styles/v21_leadsms.css):
 * theirs on the left, ours on the right, the subject small; a click opens the whole email inside its bubble. The
 * desk's own tokens, so it follows every theme, light and dark and High contrast. No inline styles.
 */

.lem { grid-column: 1 / -1; }
.lem-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.lem-n { color: var(--ink-2); font-size: .8125rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* the thread: it scrolls inside its own box, the newest at the bottom */
.lem-thread {
  position: relative; list-style: none; margin: 0; padding: 2px; display: flex; flex-direction: column; gap: 6px;
  max-height: 22rem; overflow: auto; overscroll-behavior: contain;
}
.lem-thread:has(.lem-msg.is-open) { max-height: none; overflow: visible; } /* an open email shows whole, no inner scroll */
.lem-msg {
  display: grid; max-width: min(78%, 36rem); min-width: 0; border-radius: 12px;
  border: 1px solid var(--glass-rim); background: var(--solid);
}
.lem-msg.is-in { align-self: flex-start; border-bottom-left-radius: 4px; }
.lem-msg.is-out { align-self: flex-end; border-bottom-right-radius: 4px; background: var(--brand-soft); border-color: var(--brand-soft); }
.lem-msg.is-open { max-width: min(94%, 44rem); }

/* the closed bubble: the subject small, the time, one quiet line of its first words */
.lem-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 0 10px; width: 100%;
  margin: 0; padding: 6px 10px; border: 0; border-radius: inherit; background: transparent; color: var(--ink);
  font: inherit; text-align: left; cursor: pointer;
}
.lem-head:hover .lem-subj { text-decoration: underline; text-underline-offset: 2px; }
.lem-head:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.lem-subj {
  min-width: 0; color: var(--ink); font-size: .75rem; font-weight: 700; line-height: 1.1rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lem-when { color: var(--ink-2); font-size: .6875rem; line-height: 1.1rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lem-prev {
  grid-column: 1 / -1; min-width: 0; color: var(--ink-2); font-size: .75rem; line-height: 1.1rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lem-msg.is-open .lem-prev { display: none; }
.lem-msg.is-open .lem-subj { white-space: normal; overflow-wrap: anywhere; }

/* the open bubble: the whole email, plain text */
.lem-full { display: grid; gap: 4px; padding: 0 10px 8px; min-width: 0; }
.lem-full[hidden] { display: none; }
.lem-from { margin: 0; padding-top: 4px; border-top: 1px solid var(--glass-rim); color: var(--ink-2); font-size: .75rem; line-height: 1.1rem; }
.lem-body {
  color: var(--ink); font-size: .875rem; line-height: 1.35rem; white-space: pre-wrap; overflow-wrap: anywhere;
}
.lem-foot { color: var(--ink-2); font-size: .6875rem; line-height: 1rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.lem-att { margin: 0; color: var(--ink-2); font-size: .75rem; font-weight: 600; }
.lem-hint { margin: 0; }

@media (max-width: 760px) {
  .lem-msg { max-width: 88%; }
  .lem-msg.is-open { max-width: 100%; }
  .lem-thread { max-height: 18rem; }
  /* narrow: the subject has the whole first line, the time under it */
  .lem-head { grid-template-columns: minmax(0, 1fr); }
  .lem-when { font-size: .6875rem; line-height: 1rem; }
}
