/* Chat page. Everything here is progressive enhancement over a static
   transcript that already exists in the HTML. */

.chat {
  display: flex;
  flex-direction: column;
  max-inline-size: 680px;
  margin-inline: auto;
  block-size: min(70vh, 640px);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .chat {
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
}

.chat__head {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-block-end: 1px solid var(--line);
  background: linear-gradient(120deg, var(--accent-soft), transparent 65%);
}

/* the avatar sits in a soft ring, like a node with a halo */
.chat__head .brand__mark {
  inline-size: 44px;
  block-size: 44px;
  font-size: 0.95rem;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--mint) 16%, transparent);
}

.chat__who b { display: block; font-size: 1.02rem; font-weight: 800; }

.chat__who span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.78rem;
  color: var(--faint);
}

/* a live presence dot that breathes */
.chat__who span::before {
  content: '';
  inline-size: 7px;
  block-size: 7px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--mint) 60%, transparent);
  animation: chat-live 2.4s ease-out infinite;
}

@keyframes chat-live {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--mint) 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 7px transparent; }
}

.chat__thread {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  scroll-behavior: smooth;
  /* faint node grid — the same motif as the hero graph, at rest */
  background-image: radial-gradient(var(--line) 1px, transparent 1.5px);
  background-size: 22px 22px;
  /* the thread scrolls by touch and wheel; its scrollbar is pure clutter */
  scrollbar-width: none;
}

.chat__thread::-webkit-scrollbar { display: none; }

.chat__msg {
  position: relative;
  max-inline-size: 82%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  line-height: 1.6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  animation: chat-pop 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

.chat__msg--bot {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-end-start-radius: var(--space-2);
}

.chat__msg--bot b { color: var(--fg); font-weight: 700; }

.chat__msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--lime), var(--mint));
  color: var(--accent-ink);
  font-weight: 600;
  border-end-end-radius: var(--space-2);
}

.chat__time {
  display: block;
  font-size: 0.64rem;
  color: var(--faint);
  margin-block-start: var(--space-2);
  text-align: end;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

.chat__msg--user .chat__time { color: color-mix(in srgb, var(--accent-ink) 60%, transparent); }

.chat__card {
  align-self: flex-start;
  max-inline-size: 88%;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: chat-pop 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

.chat__card-head {
  padding: var(--space-3) var(--space-4);
  background: var(--accent-soft);
  font-weight: 800;
  font-size: 0.95rem;
  border-block-end: 1px solid var(--line);
}

.chat__card-body {
  padding: var(--space-4);
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--dim);
}

.chat__card-body b { color: var(--fg); }

.chat__typing {
  display: none;
  gap: var(--space-1);
  padding: var(--space-4) var(--space-5);
}

.chat__typing.is-on { display: flex; }

.chat__typing i {
  inline-size: 7px;
  block-size: 7px;
  border-radius: 50%;
  background: var(--faint);
  animation: chat-bounce 1.2s infinite;
}

.chat__typing i:nth-child(2) { animation-delay: 0.15s; }
.chat__typing i:nth-child(3) { animation-delay: 0.3s; }

.chat__replies {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-4);
  border-block-start: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 60%, transparent);
  max-block-size: 34vh;
  overflow-y: auto;
  scrollbar-width: none;
}

.chat__replies::-webkit-scrollbar { display: none; }

.chat__reply {
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--lime);
  background: transparent;
  border: 1.5px solid color-mix(in srgb, var(--lime) 45%, transparent);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  cursor: pointer;
  animation: chat-pop 0.28s both;
}

.chat__reply {
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.chat__reply:hover {
  background: linear-gradient(135deg, var(--lime), var(--mint));
  border-color: transparent;
  color: var(--accent-ink);
  transform: translateY(-2px);
}

.transcript__node {
  border-inline-start: 2px solid var(--line);
  padding-inline-start: var(--space-4);
  margin-block-end: var(--space-4);
}

.transcript__node p {
  color: var(--dim);
  margin-block-end: var(--space-2);
  font-size: 0.95rem;
}

@keyframes chat-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

@keyframes chat-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ---------- transcript ---------- */

/* The full conversation stays in the DOM for crawlers, but readers get a
   tidy collapsible instead of a wall of text. */
.transcript {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  max-inline-size: 760px;
}

.transcript > summary {
  cursor: pointer;
  list-style: none;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

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

.transcript > summary::before {
  content: '';
  flex-shrink: 0;
  inline-size: 9px;
  block-size: 9px;
  border-radius: 50%;
  border: 2px solid var(--mint);
  transition: background-color 0.2s ease;
}

.transcript[open] > summary::before { background: var(--mint); }
.transcript[open] > summary { margin-block-end: var(--space-4); }
