/*
 * The chat widget at /chat. Built on styles.css for its tokens and fonts.
 * It runs full page or framed on a newsroom's site, often on a phone, so it
 * is one column, the question box pinned to the bottom.
 */

body.chat {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.chat-head {
  padding: var(--space-4) 0 var(--space-3);
  border-bottom: 1px solid var(--rule);
}

.chat-head h1 {
  font-family: var(--font-serif);
  font-size: var(--step-2);
  line-height: 1.15;
  margin: 0 0 var(--space-1);
}

.chat-head p {
  margin: 0;
  font-size: var(--step--1);
  color: var(--ink-muted);
}

.chat-main {
  flex: 1;
  padding: var(--space-4) 0;
}

.chat-log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.chat-msg--user {
  align-self: flex-end;
  max-width: 85%;
  background: var(--accent-wash);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
}

.chat-msg--user p {
  margin: 0;
}

.chat-body > :first-child {
  margin-top: 0;
}

.chat-body > :last-child {
  margin-bottom: 0;
}

.chat-body h2 {
  font-family: var(--font-serif);
  font-size: var(--step-1);
  line-height: 1.25;
  margin: var(--space-4) 0 var(--space-2);
}

.chat-body p,
.chat-body ul,
.chat-body ol,
.chat-body blockquote {
  margin: 0 0 var(--space-3);
}

.chat-body ul,
.chat-body ol {
  padding-left: 1.25rem;
}

.chat-body li + li {
  margin-top: var(--space-1);
}

.chat-body blockquote {
  border-left: 3px solid var(--rule-strong);
  padding-left: var(--space-3);
  font-family: var(--font-serif);
}

.chat-body a {
  color: var(--accent);
}

.chat-wait {
  color: var(--ink-muted);
  font-style: italic;
}

.chat-msg--error .chat-body {
  color: var(--bad);
}

.chat-card {
  display: block;
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-raised);
  margin-top: var(--space-3);
}

.chat-card[height="0"] {
  border: 0;
  margin: 0;
}

.chat-start p {
  margin: 0 0 var(--space-2);
  color: var(--ink-muted);
  font-size: var(--step--1);
}

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

.chat-chip {
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: var(--step--1);
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
}

.chat-chip:hover {
  border-color: var(--accent);
}

.chat-form {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
  padding: var(--space-3) 0 var(--space-2);
  background: var(--paper);
  border-top: 1px solid var(--rule);
}

.chat-form textarea {
  flex: 1;
  min-width: 0;
  font: inherit;
  /* 16px or more, or iOS zooms the page when the box is tapped. */
  font-size: max(1rem, var(--step-0));
  line-height: 1.4;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper-raised);
  color: var(--ink);
  /* styles.css gives every textarea 8rem; this one starts at a line and grows. */
  min-height: 0;
  resize: none;
}

.chat-form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.chat-form .button[disabled] {
  opacity: 0.6;
  cursor: wait;
}

.chat-note {
  margin: 0 0 var(--space-3);
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--ink-muted);
}

.chat-report {
  margin: var(--space-2) 0 0;
  font-size: 0.8rem;
}

.chat-report a {
  color: var(--ink-muted);
}

/* Staging's Flag button (site/chat.js, addFlag). */
.chat-flag {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
  color: var(--ink-muted);
}

.chat-flag button {
  font: inherit;
  color: var(--ink-muted);
  background: none;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
}

.chat-flag input {
  font: inherit;
  flex: 1 1 12rem;
  min-width: 0;
  padding: 2px 6px;
}
