/**
 * Conversation surface styles (AI Space Stage 1).
 *
 * Deliberately a NEW stylesheet rather than additions to dashboard.css or
 * components.css: both of those are being edited concurrently by the
 * in-flight e2e/a11y workstream, and a separate file lets the two land in
 * either order with no textual conflict.
 *
 * Reuses the existing design tokens and the .tr-msg family already defined
 * in dashboard.css rather than restating them — the .cv-* classes here only
 * add what the real conversation needs on top: citations, flags, notices,
 * and the streaming state.
 */

/* transcript container ---------------------------------------------------
 *
 * The Creator-side surfaces inherit their transcript box from dashboard.css's
 * `.tr-thread`, but the subscriber-facing creator-space.html is a PUBLIC page
 * and deliberately does not load dashboard.css (it is a dashboard stylesheet,
 * and pulling it onto a public page to reach four declarations would drag in
 * the entire dashboard chrome). `.cv-thread` states just those four here, so
 * both surfaces get the same transcript behavior from the stylesheet each one
 * already loads.
 */
.cv-thread {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
}

/* transcript ------------------------------------------------------------- */
.cv-msg {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.85rem;
  max-width: 80%;
  overflow-wrap: anywhere;
}
.cv-msg-user {
  background: rgba(44, 130, 255, 0.16);
  border: 1px solid rgba(95, 150, 255, 0.3);
  margin-left: auto;
  color: #e6edff;
}
.cv-msg-space {
  background: rgba(140, 160, 190, 0.1);
  border: 1px solid var(--line);
  color: #dce5f2;
  max-width: 92%;
}
.cv-msg-body {
  margin: 0;
  white-space: pre-wrap;
}
.cv-empty {
  color: var(--muted);
  font-size: 0.85rem;
  list-style: none;
}

/* the in-progress answer; aria-hidden while it streams (see conversation-ui.js) */
.cv-msg.is-streaming {
  opacity: 0.92;
}
.cv-msg.is-streaming .cv-msg-body::after {
  content: "▍";
  margin-left: 2px;
  animation: cv-caret 1s steps(2, start) infinite;
}
@keyframes cv-caret {
  50% {
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .cv-msg.is-streaming .cv-msg-body::after {
    animation: none;
  }
}

/* citations -------------------------------------------------------------- */
.cv-citations {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
}
.cv-citations-label {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.cv-citation-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cv-citation {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(72, 116, 200, 0.14);
  color: #cfe0ff;
  font-size: 0.72rem;
  text-decoration: none;
  border: 1px solid rgba(95, 150, 255, 0.22);
}
.cv-citation:hover,
.cv-citation:focus-visible {
  background: rgba(72, 116, 200, 0.26);
  color: #fff;
}

/* A citation with nowhere correct to link (the subscriber-facing Space — see
 * conversation-ui.js's citationHref). Same shape as a linked citation so the
 * attribution reads identically, minus the affordances that would imply it is
 * clickable. */
.cv-citation-static {
  cursor: default;
  color: var(--muted);
  background: rgba(140, 160, 190, 0.1);
  border-color: var(--line);
}

/* truncation / notices --------------------------------------------------- */
.cv-msg-flag {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: #ffcf7a;
}
.cv-notice-msg {
  list-style: none;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 190, 80, 0.1);
  border: 1px solid rgba(255, 190, 80, 0.28);
  color: #ffd9a0;
  font-size: 0.8rem;
  display: grid;
  gap: 3px;
}
.cv-notice-title {
  font-weight: 700;
}
.cv-notice-detail {
  color: var(--muted);
}
.cv-notice {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(140, 160, 190, 0.1);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  display: grid;
  gap: 4px;
}

/* composer / actions ----------------------------------------------------- */
.cv-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.cv-space-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.cv-space-note {
  margin: 12px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* hiding, on a page that does not load dashboard.css --------------------
 *
 * `.dash-hidden{display:none}` is declared in base.css — the FIRST stylesheet
 * every page loads — so any later rule that also sets `display` at equal
 * specificity beats it. Three do, and all three are on creator-space.html:
 * `.page-grid{display:grid}` (layout.css) keeps `#space-main` visible before
 * the page has loaded and even when the creator is not found, `.btn`'s own
 * display keeps the "Try again" button on screen after a successful answer,
 * and `.cv-notice`'s `display:grid` above leaves an empty notice box taking
 * up space.
 *
 * The dashboard surfaces never showed this because dashboard.css re-declares
 * `.dash-hidden` late enough to win. The PUBLIC creator-space.html does not
 * load dashboard.css. Re-declaring it here — this file is loaded after
 * layout.css and components.css on every page that includes it, and after
 * dashboard.css on the ones that have it — restores the meaning of the class
 * without putting `!important` on a global utility every other page relies on.
 */
.dash-hidden {
  display: none;
}

/* composer ---------------------------------------------------------------
 *
 * `.input` is full-width by default, so inside `.component-row`'s wrapping
 * flex row the Send button is pushed onto its own line at every width. On the
 * subscriber Space the composer is the primary control on the page and reads
 * better as one line, so the input is allowed to shrink instead — down to a
 * 260px basis, below which the responsive rule takes over.
 */
#cv-form .input {
  flex: 1 1 260px;
  width: auto;
  min-width: 0;
}

/* responsive ------------------------------------------------------------- */
@media (max-width: 640px) {
  .cv-msg,
  .cv-msg-space {
    max-width: 100%;
  }
  /* Below 640px the composer gives up the single line the desktop rule above
     asks for: the input takes a full row and Send sits under it at an
     accessible touch height, rather than the two squeezing together. */
  #cv-form .input {
    flex-basis: 100%;
  }
  #cv-form .btn {
    min-height: 44px;
    flex: 1 1 auto;
  }
  .cv-thread {
    max-height: 50vh;
  }
  .cv-actions {
    flex-direction: column;
    align-items: stretch;
  }
  /* keeps send/publish controls at an accessible touch size on phones */
  .cv-actions .btn,
  .cv-space-row .btn {
    min-height: 44px;
  }
}
