/* The ONE thread stylesheet (docs/build-one-chat.md). Every conversation
 * surface — peer, facilitator, first interview, feedback, the opening
 * questions — draws its bubbles, dots, skeletons and composer from here,
 * rendered by thread.js. Surface-specific chrome (thread list, headers,
 * immersive mode, interview furniture) stays in the surface's own sheet.
 *
 * The measure comes from :root in app.css; test/measure.test.js fails on a
 * second declaration. test/one-chat.test.js fails any rule that mixes this
 * vocabulary with an ob- class — that is the two-dialect split growing
 * back, and it is the reason the same width bug shipped twice. */

/* ------------------------------------------------------------ the column */

/* THE MEASURE LIVES ON THE COLUMN, not on each thing in it. The padding
 * centres the content box without a wrapper element, and falls back to
 * plain padding once the pane is narrower than the measure. */
.chat-scroll {
  overflow-y: auto;
  min-height: 0;
  padding: 20px max(24px, (100% - var(--measure)) / 2) 8px;
  display: flex;
  flex-direction: column;
}
/* Short conversations sit at the bottom, where the next message will land. */
.chat-scroll::before { content: ''; flex: 1 0 auto; }

.chat-day {
  align-self: center;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 18px 0 10px;
}
.chat-day:first-child { padding-top: 4px; }

.chat-empty {
  margin: auto;
  max-width: 380px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 24px;
}

/* ------------------------------------------------------------- messages */

.grp { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.grp.mine { align-items: flex-end; }
.grp.theirs { align-items: flex-start; }
.grp__name {
  font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 0 4px 2px;
}

.msg {
  /* A percentage OF THE COLUMN. 62% keeps a bubble a bubble — wider stops
   * reading as one (checked on a screenshot when the cap was unified). */
  max-width: 62%;
  padding: 9px 14px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.grp.theirs .msg { background: var(--raised); color: var(--text); }
.grp.mine .msg { background: var(--accent); color: var(--accent-on); }

/* Suppressed tails: the grouped side flattens instead of growing a tail.
 * :last-of-type, not :last-child — a group may end in a stamp, a card or a
 * note, and the closing BUBBLE keeps its round tail regardless. */
.grp.mine .msg { border-bottom-right-radius: 6px; }
.grp.mine .msg:last-of-type { border-bottom-right-radius: 18px; }
.grp.mine .msg + .msg { border-top-right-radius: 6px; }
.grp.theirs .msg { border-bottom-left-radius: 6px; }
.grp.theirs .msg:last-of-type { border-bottom-left-radius: 18px; }
.grp.theirs .msg + .msg { border-top-left-radius: 6px; }

.msg.pending { opacity: .65; }

/* One thing moves at a time: only a newly appended element carries
 * .arrive, and simultaneous turns are staggered by inline animation-delay.
 * The global reduced-motion rule in app.css collapses this to nothing. */
/* The house curve (--t's cubic-bezier), not built-in ease-out: one arrive
 * animation, one easing family (review-animations, 2026-08-09). */
.arrive { animation: thread-arrive 180ms cubic-bezier(.2, .7, .3, 1) both; }
@keyframes thread-arrive {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Timestamps live on the group and appear on hover or tap. */
.grp__stamp {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  padding: 3px 6px 0;
  opacity: 0;
  transition: opacity var(--t);
}
.grp:hover .grp__stamp, .grp.show .grp__stamp { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .grp__stamp { transition: none; } }

/* typing indicator: three quiet dots in a raised bubble */
.msg.dots { display: inline-flex; gap: 5px; align-items: center; min-height: 20px; }
.msg.dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
  animation: threaddot 1.1s ease-in-out infinite;
}
.msg.dots i:nth-child(2) { animation-delay: .18s; }
.msg.dots i:nth-child(3) { animation-delay: .36s; }
@keyframes threaddot {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Loading frame: the conversation shape before the conversation arrives. */
.msg-skel {
  height: 40px;
  border-radius: 18px;
  margin-top: 10px;
  flex: none;
  /* Matches .msg above rather than repeating a pixel cap. */
  max-width: 62%;
}
.msg-skel.mine { align-self: flex-end; border-bottom-right-radius: 6px; }
.msg-skel.theirs { align-self: flex-start; border-bottom-left-radius: 6px; }

/* ------------------------------------------------------------- composer */

.chat-compose {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  /* Shares the scroller measure: a full-width composer under a measured
   * column reads as two surfaces rather than one conversation. */
  padding: 12px max(20px, (100% - var(--measure)) / 2) calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
}
.chat-ta {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 160px;
  padding: 10px 14px;
  border-radius: 21px;
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--text);
  font: inherit;
  line-height: 1.4;
  transition: border-color var(--t), box-shadow var(--t);
}
.chat-ta::placeholder { color: var(--muted); }
.chat-ta:focus {
  outline: none;
  border-color: var(--accent-text);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

/* Send is the brand rung on magenta: a message is a step. Near-black mark
 * (docs/brand.md measured contrast). */
.chat-send {
  flex: none;
  width: 42px; height: 42px;
  border: 0; border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform var(--t), filter var(--t);
}
.chat-send .rung { color: var(--accent-on); width: 15px; height: 15px; }
.chat-send:hover { filter: brightness(1.08); }
.chat-send:active { transform: scale(.92); }
.chat-send:disabled { opacity: .45; }
.chat-send[aria-busy="true"] .rung { animation: climb .7s ease-in-out infinite; }

/* --------------------------------------------------------------- phone */

@media (max-width: 760px) {
  .msg { max-width: 82%; }
  .chat-scroll { padding: 16px 14px 8px; }
  .chat-compose { padding-left: 14px; padding-right: 14px; }
}
