/* SMAU FILE
 * Path: css/smau-studio2-threads.css
 * Owns: Creator Studio 2.0 — ENSEMBLE CONVERSATIONS visuals ONLY
 *       (js/creator/creator.threads.js): the conversation list, the
 *       participants block, the ordered message editor, and the
 *       per-participant projection preview with its bubbles. Generic
 *       Studio 2.0 primitives (.s2-screen, .s2-head, .s2-card, .s2-btn,
 *       .s2-input, .s2-chip, …) are owned by css/smau-studio2.css; every rule
 *       here is scoped to a th2- prefixed class so the files never fight over
 *       the same name.
 * Depends: css/smau-studio2.css tokens on #studio-root — --s2-accent,
 *          --s2-accent-soft, --s2-warn, --s2-ink, --s2-muted, --s2-card,
 *          --s2-card-border, --s2-radius. Every one is read through a
 *          fallback so this file never renders blank if a token moves.
 */

#studio-root {
  --th2-accent: var(--s2-accent, #8b7cf8);
  --th2-accent-soft: var(--s2-accent-soft, rgba(139, 124, 248, 0.16));
  --th2-warn: var(--s2-warn, #ffb454);
  --th2-ink: var(--s2-ink, rgba(238, 240, 248, 0.94));
  --th2-muted: var(--s2-muted, rgba(238, 240, 248, 0.55));
  --th2-card: var(--s2-card, rgba(255, 255, 255, 0.035));
  --th2-card-border: var(--s2-card-border, rgba(255, 255, 255, 0.09));
  --th2-radius: var(--s2-radius, 16px);
  --th2-them: rgba(255, 255, 255, 0.07);
}

@media (prefers-color-scheme: light) {
  #studio-root {
    --th2-ink: var(--s2-ink, rgba(20, 20, 30, 0.92));
    --th2-muted: var(--s2-muted, rgba(20, 20, 30, 0.55));
    --th2-card: var(--s2-card, rgba(20, 20, 30, 0.035));
    --th2-card-border: var(--s2-card-border, rgba(20, 20, 30, 0.12));
    --th2-them: rgba(20, 20, 30, 0.07);
  }
}

/* The explicit toggle wins over the OS media query in both directions —
   specificity (:root[data-theme] #studio-root) beats the plain selector
   above regardless of source order. */
:root[data-theme="light"] #studio-root {
  --th2-ink: var(--s2-ink, rgba(20, 20, 30, 0.92));
  --th2-muted: var(--s2-muted, rgba(20, 20, 30, 0.55));
  --th2-card: var(--s2-card, rgba(20, 20, 30, 0.035));
  --th2-card-border: var(--s2-card-border, rgba(20, 20, 30, 0.12));
  --th2-them: rgba(20, 20, 30, 0.07);
}

:root[data-theme="dark"] #studio-root {
  --th2-ink: var(--s2-ink, rgba(238, 240, 248, 0.94));
  --th2-muted: var(--s2-muted, rgba(238, 240, 248, 0.55));
  --th2-card: var(--s2-card, rgba(255, 255, 255, 0.035));
  --th2-card-border: var(--s2-card-border, rgba(255, 255, 255, 0.09));
  --th2-them: rgba(255, 255, 255, 0.07);
}

/* ── Screen chrome ─────────────────────────────────────────────── */

.th2-screen {
  color: var(--th2-ink);
}

.th2-subtitle {
  margin: -6px 0 14px;
  color: var(--th2-muted);
}

.th2-explain {
  margin-bottom: 12px;
}

.th2-explain-body {
  margin-top: 6px;
  color: var(--th2-muted);
  font-size: 13px;
  line-height: 1.5;
}

.th2-tally {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 12px;
  color: var(--th2-muted);
  font-size: 13px;
}

.th2-tally-item b {
  color: var(--th2-ink);
  font-size: 15px;
}

/* ── The conversation list ─────────────────────────────────────── */

.th2-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.th2-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--th2-card-border);
  border-radius: var(--th2-radius);
  background: var(--th2-card);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.th2-row:hover {
  border-color: var(--th2-accent);
}

.th2-row-body {
  flex: 1 1 auto;
  min-width: 0;
}

.th2-row-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.th2-row-sub {
  margin-top: 2px;
  color: var(--th2-muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.th2-row-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex: 0 0 auto;
}

.th2-count {
  color: var(--th2-muted);
  font-size: 11px;
  white-space: nowrap;
}

.th2-empty {
  text-align: center;
}

.th2-empty-body {
  margin-top: 6px;
  color: var(--th2-muted);
  font-size: 13px;
  line-height: 1.5;
}

.th2-none {
  padding: 10px 0;
  color: var(--th2-muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ── One conversation: editor on the left, projection on the right.
      Phone width first — one column, preview underneath. ───────── */

.th2-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.th2-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.th2-card {
  padding: 14px;
}

.th2-label {
  display: block;
  margin-bottom: 6px;
}

/* ── Participants ─────────────────────────────────────────────── */

.th2-parts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0;
}

.th2-part {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--th2-card-border);
  border-radius: 12px;
}

.th2-part-meta {
  color: var(--th2-muted);
  font-size: 12px;
}

.th2-part-del {
  justify-self: start;
}

.th2-add-part,
.th2-add-msg {
  align-self: flex-start;
  margin-top: 4px;
}

/* ── Messages, in order ───────────────────────────────────────── */

.th2-msgs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.th2-msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--th2-card-border);
  border-radius: 12px;
}

/* A message from somebody who isn't in the conversation — the blocking
   finding, shown where it is rather than only at export time. */
.th2-msg--orphan {
  border-color: var(--th2-warn);
}

.th2-msg-text {
  resize: vertical;
  min-height: 44px;
}

.th2-msg-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.th2-msg-time {
  flex: 1 1 auto;
  color: var(--th2-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ── The projection preview — what THAT phone actually shows ──── */

.th2-preview-card {
  position: relative;
}

.th2-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.th2-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
  cursor: pointer;
}

.th2-tab--on {
  border-color: var(--th2-accent);
  background: var(--th2-accent-soft);
}

.th2-tab-sub {
  color: var(--th2-muted);
  font-size: 10px;
}

.th2-screen-title {
  padding: 8px 0;
  border-bottom: 1px solid var(--th2-card-border);
  font-weight: 600;
  text-align: center;
}

.th2-bubbles {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding: 12px 4px;
}

.th2-bubble-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}

.th2-bubble-row--me {
  align-self: flex-end;
  align-items: flex-end;
}

.th2-bubble-row--them {
  align-self: flex-start;
  align-items: flex-start;
}

.th2-bubble-name {
  margin-bottom: 2px;
  padding: 0 6px;
  color: var(--th2-muted);
  font-size: 11px;
}

.th2-bubble {
  padding: 8px 12px;
  border-radius: 16px;
  background: var(--th2-them);
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.th2-bubble-row--me .th2-bubble {
  background: var(--th2-accent);
  color: #fff;
}

.th2-bubble-time {
  margin-top: 2px;
  padding: 0 6px;
  color: var(--th2-muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.th2-outside {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--th2-card-border);
  color: var(--th2-muted);
  font-size: 12px;
  line-height: 1.5;
}

/* Wide screens get the preview beside the editor, because checking the
   projection while writing is the whole point of it. */
@media (min-width: 900px) {
  .th2-layout {
    flex-direction: row;
    align-items: flex-start;
  }

  .th2-col {
    flex: 1 1 0;
  }

  .th2-col--preview {
    position: sticky;
    top: 8px;
  }

  .th2-part {
    grid-template-columns: 1fr 1fr;
  }

  .th2-part-meta,
  .th2-part-del {
    grid-column: 1 / -1;
  }
}
