/* /assistant — the site assistant chat.
 * BEM under .asst-*. DESIGN.md tokens only (tokens.css): no raw colours, no
 * off-scale spacing. App-page convention: the header is left-aligned.
 *
 * The one deliberate accent: an answer's citation numbers ([1], [2]) line up
 * with the numbered source list under it, so the list is an <ol> whose
 * markers are drawn as the same bracketed numbers.
 */

.asst {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--space-7) var(--space-4) var(--space-10);
}

/* ── Header ─────────────────────────────────────────────────────── */
.asst-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.asst-title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0 0 var(--space-2);
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.asst-title__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: var(--accent);
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
}

.asst-lede {
  margin: 0;
  max-width: 62ch;
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--text2);
}

.asst-new {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-4);
  font: inherit;
  font-size: var(--fs-14);
  color: var(--text2);
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.asst-new[hidden],
.asst-empty[hidden] {
  display: none;
}

.asst-new:hover {
  color: var(--text);
  border-color: var(--border3);
}

/* ── Feed ───────────────────────────────────────────────────────── */
.asst-feed {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.asst-empty {
  padding: var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.asst-empty__title {
  margin: 0 0 var(--space-1);
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text);
}

.asst-empty__text {
  margin: 0 0 var(--space-4);
  font-size: var(--fs-14);
  color: var(--muted2);
}

.asst-examples {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.asst-example {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  font: inherit;
  font-size: var(--fs-14);
  text-align: left;
  color: var(--text2);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.asst-example:hover {
  color: var(--text);
  border-color: var(--border2);
}

.asst-example .icon {
  flex: 0 0 auto;
  color: var(--accent);
}

.asst-msg {
  max-width: 100%;
}

.asst-msg__who {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--muted2);
}

.asst-msg__body {
  margin: 0;
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text);
  overflow-wrap: anywhere;
}

/* The visitor's turn: a quiet inset block, pushed right. */
.asst-msg--user {
  align-self: flex-end;
  max-width: 85%;
  padding: var(--space-3) var(--space-4);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.asst-msg--user .asst-msg__who {
  text-align: right;
}

/* The assistant's turn: a card with an accent rail — the answer is the content. */
.asst-msg--bot {
  padding: var(--space-4) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}

.asst-msg--pending .asst-msg__body {
  color: var(--muted2);
}

.asst-msg--error {
  border-left-color: var(--danger);
}

/* ── Sources: numbered like the citations in the answer ─────────── */
.asst-src {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.asst-src__title {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted2);
}

.asst-src__list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: asst-src;
}

.asst-src__item {
  counter-increment: asst-src;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space-2);
  padding: var(--space-1) 0;
}

.asst-src__item::before {
  content: "[" counter(asst-src) "]";
  flex: 0 0 auto;
  min-width: 2.2em;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  color: var(--accent);
}

.asst-src__link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  font-size: var(--fs-14);
  color: var(--accent);
  text-decoration: none;
}

.asst-src__link:hover {
  text-decoration: underline;
}

.asst-src__path {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--muted2);
  overflow-wrap: anywhere;
}

/* ── Status line (loading / error) ──────────────────────────────── */
.asst-status {
  min-height: 1.5em;
  margin: var(--space-3) 0 0;
  font-size: var(--fs-14);
  color: var(--muted2);
}

.asst-status--error {
  color: var(--danger);
}

/* ── Composer ───────────────────────────────────────────────────── */
.asst-form {
  margin-top: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
}

.asst-label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--fs-14);
  font-weight: 600;
  color: var(--text);
}

.asst-input {
  display: block;
  width: 100%;
  min-height: 88px;
  padding: var(--space-3);
  font: inherit;
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  resize: vertical;
}

.asst-input::placeholder {
  color: var(--muted);
}

.asst-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.asst-form__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.asst-count {
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--muted2);
}

.asst-count--near {
  color: var(--warn);
}

.asst-count--over {
  color: var(--danger);
}

.asst-send {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-5);
  font: inherit;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.asst-send:hover {
  background: var(--accent2);
}

.asst-send[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.asst-note {
  margin: var(--space-3) 0 0;
  font-size: var(--fs-xs);
  line-height: 1.45;
  color: var(--muted2);
}

.asst-new:focus-visible,
.asst-example:focus-visible,
.asst-src__link:focus-visible,
.asst-send:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ── Small screens ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .asst {
    padding: var(--space-5) var(--space-4) var(--space-9);
  }

  .asst-head {
    flex-direction: column;
    gap: var(--space-3);
  }

  .asst-title {
    font-size: var(--fs-xl);
  }

  .asst-msg--user {
    max-width: 92%;
  }

  .asst-msg--bot {
    padding: var(--space-4);
  }

  .asst-send {
    flex: 1 1 auto;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .asst * {
    scroll-behavior: auto;
  }
}
