/* The assistant panel. Same night-retail world as the store (DESIGN.md): near-black field, bone type, one crimson.
   Designed at 375px first; ruled rows, not cards. */

@font-face {
  font-family: "Barlow Condensed";
  font-weight: 600;
  font-display: swap;
  src: url("/assets/fonts/barlow-condensed-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/barlow-condensed-latin-700-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Source Sans 3";
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/source-sans-3-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Source Sans 3";
  font-weight: 600;
  font-display: swap;
  src: url("/assets/fonts/source-sans-3-latin-600-normal.woff2") format("woff2");
}

:root {
  --bg: #0b0b0d;
  --surface: #16161a;
  --surface-raised: #221f22;
  --primary: #c8102e;
  --primary-pressed: #9b0c23;
  --on-primary: #f6f3ee;
  --ink: #f6f3ee;
  --bone: #e7e1d6;
  --muted: #b7b1a8;
  --line: #2c2a2e;
  --line-strong: #47434a;
  /* Field outlines need 3:1 against both the page and the field fill. */
  --field-edge: #6f6a72;
  --success: #6fbf94;
  --warning: #e0a45c;
  --danger: #ff8a80;
  --label: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Source Sans 3", system-ui, sans-serif;
  --data: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --gutter: 16px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--line-strong) var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.5 var(--body);
  caret-color: var(--primary);
}

::selection {
  background: var(--primary);
  color: var(--on-primary);
}

:focus-visible {
  outline: 2px solid var(--bone);
  outline-offset: 2px;
}

a {
  color: inherit;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

h1 {
  margin: 28px 0 4px;
  font: 700 2rem/1 var(--label);
  letter-spacing: 0.005em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 var(--gutter) 96px;
}

/* ---- Top bar -------------------------------------------------------------------------------------------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 0 var(--gutter);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font: 700 1.25rem/1 var(--label);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
}

/* The store's slanted crimson mark. */
.slash {
  width: 9px;
  height: 20px;
  background: var(--primary);
  transform: skewX(-14deg);
}

.bar nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bar nav a,
.plain {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  background: none;
  color: var(--muted);
  font: 600 1.0625rem/1 var(--label);
  letter-spacing: 0.03em;
  text-decoration: none;
  cursor: pointer;
}

.bar nav a:hover,
.plain:hover {
  color: var(--ink);
}

.bar nav a[aria-current="page"] {
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--bone);
}

.bar form {
  margin: 0;
}

/* ---- Shared text ---------------------------------------------------------------------------------------- */

.count,
.lede {
  margin: 0 0 20px;
  color: var(--muted);
}

.count {
  font: 600 1rem/1.3 var(--label);
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.count strong {
  color: var(--ink);
  font-weight: 600;
}

.lede {
  max-width: 62ch;
}

.empty {
  margin: 24px 0;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  max-width: 62ch;
}

.back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 8px;
  color: var(--muted);
  font: 600 1rem/1 var(--label);
  letter-spacing: 0.03em;
  text-decoration: none;
}

.back::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.back:hover {
  color: var(--ink);
}

.back + h1 {
  margin-top: 4px;
}

/* ---- Inbox: ruled rows ---------------------------------------------------------------------------------- */

.rows {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.row {
  display: grid;
  gap: 2px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  transition: background-color 160ms var(--ease-out);
}

.row:hover {
  background: var(--surface);
  box-shadow: 0 0 0 100vmax var(--surface);
  clip-path: inset(0 -100vmax);
}

.row-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.who {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.chan {
  flex: none;
  color: var(--muted);
  font: 600 0.875rem/1 var(--label);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.row time {
  flex: none;
  margin-left: auto;
  color: var(--muted);
  font: 600 0.9375rem/1 var(--label);
  font-variant-numeric: tabular-nums;
}

.row-text {
  color: var(--muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.wait {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font: 600 1rem/1.2 var(--label);
  letter-spacing: 0.03em;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

/* ---- Conversation --------------------------------------------------------------------------------------- */

.states {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0 0 4px;
  border: 1px solid var(--line);
}

.states button {
  min-height: 44px;
  border: 0;
  border-right: 1px solid var(--line);
  background: none;
  color: var(--muted);
  font: 600 1.0625rem/1 var(--label);
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out);
}

.states button:last-child {
  border-right: 0;
}

.states button:hover {
  color: var(--ink);
  background: var(--surface);
}

.states button[aria-pressed="true"] {
  background: var(--bone);
  color: var(--bg);
}

.thread {
  margin: 0;
  padding: 0;
  list-style: none;
}

.msg {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.by {
  margin: 0 0 4px;
  color: var(--muted);
  font: 600 0.9375rem/1.2 var(--label);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.text {
  margin: 0;
  max-width: 68ch;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.notice {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.notice summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  list-style: none;
}

.notice summary::-webkit-details-marker {
  display: none;
}

.notice summary::marker {
  content: "";
}

.notice p {
  margin: 4px 0 8px;
  max-width: 68ch;
  overflow-wrap: anywhere;
}

/* What the assistant said sits on a raised strip, indented: the ledger's second column. */
.msg.out {
  margin-left: 24px;
  padding-left: 16px;
  padding-right: 16px;
  background: var(--surface);
}

.msg.out .by {
  color: var(--bone);
}

.msg.draft {
  background: none;
  outline: 1px dashed var(--line-strong);
  outline-offset: -1px;
}

.msg.discarded .text,
.msg.failed .text {
  color: var(--muted);
}

.msg.discarded .text {
  text-decoration: line-through;
}

.msg.failed .by {
  color: var(--danger);
}

.msg.note {
  margin-left: 24px;
  padding-left: 16px;
  padding-right: 16px;
}

.msg.note .by {
  margin-bottom: 0;
  color: var(--warning);
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.actions form {
  margin: 0;
}

/* ---- The receipt: why the assistant did that ------------------------------------------------------------ */

.receipt {
  margin-top: 14px;
  border-top: 1px dashed var(--line-strong);
}

.receipt summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-height: 44px;
  padding-top: 12px;
  color: var(--muted);
  font: 600 0.9375rem/1.25 var(--label);
  letter-spacing: 0.04em;
  cursor: pointer;
  list-style: none;
}

.receipt summary::-webkit-details-marker {
  display: none;
}

.receipt summary > span:first-child {
  flex: none;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

.receipt summary::after {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-3px) rotate(45deg);
  transition: transform 200ms var(--ease-out);
}

.receipt[open] summary::after {
  transform: translateY(1px) rotate(-135deg);
}

.sum {
  min-width: 0;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.receipt dl {
  display: grid;
  grid-template-columns: minmax(84px, max-content) 1fr;
  gap: 0 16px;
  margin: 4px 0 4px;
  animation: unfold 220ms var(--ease-out);
}

.receipt dt,
.receipt dd {
  margin: 0;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}

.receipt dt {
  color: var(--muted);
  font: 600 0.9375rem/1.5 var(--label);
  letter-spacing: 0.04em;
}

.receipt dd {
  min-width: 0;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.calls {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.calls li {
  display: grid;
  gap: 2px;
}

.calls code,
.calls span {
  font: 400 0.8125rem/1.45 var(--data);
  overflow-wrap: anywhere;
}

.calls span {
  color: var(--muted);
}

.calls .bad {
  color: var(--danger);
}

@keyframes unfold {
  from {
    opacity: 0;
    clip-path: inset(0 0 100% 0);
  }
  to {
    opacity: 1;
    clip-path: inset(0);
  }
}

/* ---- Forms ---------------------------------------------------------------------------------------------- */

.narrow {
  max-width: 440px;
}

.stack {
  display: grid;
  gap: 8px;
}

label,
legend {
  color: var(--muted);
  font: 600 1rem/1.2 var(--label);
  letter-spacing: 0.03em;
}

.stack label:not(.choice),
.stack fieldset {
  margin-top: 12px;
}

input:not([type="radio"]),
textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--field-edge);
  border-radius: 2px;
  background: var(--surface);
  color: var(--ink);
  font: 400 1.0625rem/1.4 var(--body);
}

textarea {
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #9a948b;
}

input:not([type="radio"]):hover,
textarea:hover {
  border-color: var(--muted);
}

input:not([type="radio"]):focus-visible,
textarea:focus-visible {
  outline-offset: 0;
  border-color: var(--bone);
}

input[aria-invalid="true"] {
  border-color: var(--danger);
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 4px;
}

legend {
  padding: 0;
  margin-bottom: 4px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  font: 400 1.0625rem/1.3 var(--body);
  letter-spacing: 0;
  cursor: pointer;
}

input[type="radio"] {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--primary);
}

.error {
  margin: 4px 0 0;
  color: var(--danger);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: none;
  color: var(--ink);
  font: 700 1.125rem/1 var(--label);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out), transform 120ms var(--ease-out);
}

.btn:hover {
  border-color: var(--bone);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}

.btn.primary:hover {
  border-color: var(--primary-pressed);
  background: var(--primary-pressed);
}

.stack .btn {
  margin-top: 16px;
  justify-self: start;
}

/* The simulator's composer stays at the thumb. */
.composer {
  position: sticky;
  bottom: 0;
  margin: 0 calc(-1 * var(--gutter));
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}

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

.send {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.send textarea {
  min-height: 48px;
  resize: none;
}

.send .btn {
  flex: none;
  padding: 0 16px;
}

@media (min-width: 720px) {
  h1 {
    font-size: 2.5rem;
  }

  .bar {
    padding: 0 max(var(--gutter), calc((100vw - 760px) / 2 + var(--gutter)));
  }

  .msg.out,
  .msg.note {
    margin-left: 96px;
  }

  .composer {
    margin: 0;
    padding-left: 0;
    padding-right: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
