/* =================================================
   Chat comparison — shared across all homepage variants
   Two chat panels side-by-side showing Claude's actual
   responses with vs. without Stash's context.
   ================================================= */

.chat-demo-section {
  background: var(--bg-warm);
  padding: 66px 0 120px;
}
.chat-demo-section.dark {
  background: var(--bg-dark);
}

.chat-demo-head {
  text-align: center;
  max-width: 820px;
  margin: 0 auto 56px;
}
.chat-demo-head .caption {
  display: inline-block;
  margin-bottom: 14px;
  color: var(--green-2);
}
.chat-demo-head h2 { margin-bottom: 18px; }
.chat-demo-head .lead {
  max-width: 680px;
  margin: 0 auto;
  color: var(--text-2);
}

.chat-demo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: stretch;
}
@media (max-width: 960px) {
  .chat-demo-grid { grid-template-columns: 1fr; gap: 32px; }
}

.chat-demo-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chat-demo-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 4px;
}
.chat-demo-mark {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: white;
  line-height: 1;
}
.chat-demo-mark-bad  { background: var(--red); }
.chat-demo-mark-good { background: var(--green); }
.chat-demo-panel-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-demo-panel-tool {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.chat-demo-panel-sub {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

/* The chat window */
.chat-pane {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.chat-demo-with .chat-pane {
  box-shadow: 0 24px 56px rgba(34, 197, 94, 0.14), 0 4px 12px rgba(15, 23, 42, 0.04);
  border-color: rgba(34, 197, 94, 0.18);
}
.chat-pane-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: -0.005em;
}
.chat-pane-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
}
.chat-pane-body {
  padding: 24px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  flex: 1;
}

/* Blank text input row — matches the real LLM chat UI input bar.
   Generic styling; per-LLM skins in llm-switcher.css override chrome. */
.chat-pane-input {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 18px 18px;
  padding: 10px 10px 10px 16px;
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: 24px;
  min-height: 44px;
}
.chat-pane-input-text {
  flex: 1;
  font-size: 14px;
  color: var(--text-4);
}
.chat-pane-input-send {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--text);
  display: grid;
  place-items: center;
}
.chat-pane-input-send::before {
  content: '';
  display: block;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M12 19V5M5 12l7-7 7 7'/></svg>");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* Messages */
.chat-demo-msg {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-demo-msg.user { align-items: flex-end; }
.chat-demo-msg.ai   { align-items: flex-start; }

/* Nimbus login thumbnail — a small recognizable mock of the login page
   used as the shared example screenshot across the site. The Sign-in
   button fill (#0A1628) vs card fill (#1E293B) gives 1.01:1 contrast in
   dark mode — literally the bug the AI responses diagnose. */
.chat-demo-thumb {
  position: relative;
  width: 200px; height: 110px;
  border-radius: 10px;
  background: #0F172A;
  overflow: hidden;
  border: 1px solid #334155;
  flex-shrink: 0;
}
.chat-demo-thumb-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.chat-demo-thumb-label {
  position: absolute;
  top: 5px; left: 8px;
  font-size: 8.5px;
  color: #64748B;
  font-family: var(--mono);
  z-index: 3;
  letter-spacing: 0.02em;
}
.chat-demo-thumb-form {
  position: absolute;
  left: 18px; right: 18px; top: 20px; bottom: 16px;
  background: #1E293B;
  border: 0.5px solid #475569;
  border-radius: 5px;
  padding: 7px 9px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 1;
}
.chat-demo-thumb-title {
  font-size: 8.5px;
  font-weight: 600;
  color: #E2E8F0;
  letter-spacing: 0.01em;
  margin-bottom: 1px;
}
.chat-demo-thumb-input {
  height: 8px;
  background: #0F172A;
  border: 0.5px solid #334155;
  border-radius: 2px;
}
.chat-demo-thumb-button {
  height: 9px;
  margin-top: 2px;
  /* THE bug: button is rendered with fill #0A1628 on a card of #1E293B —
     1.01:1 contrast in dark mode, so it visually ghosts. Keep the fill
     exactly matching the JS response copy so the visual and the
     diagnosis are the same fact. */
  background: #0A1628;
  border-radius: 2px;
}
.chat-demo-thumb-banner-line {
  position: absolute;
  bottom: 3px; left: 5px; right: 5px;
  font-size: 8px;
  color: var(--green-3);
  font-family: var(--mono);
  z-index: 4;
  background: rgba(10, 22, 40, 0.92);
  padding: 2px 5px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.chat-demo-bubble {
  padding: 13px 16px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.55;
  max-width: 88%;
}
.user-bubble {
  background: var(--green);
  color: white;
  border-bottom-right-radius: 5px;
  font-weight: 500;
}
.ai-bubble {
  background: var(--bg-soft);
  color: var(--text);
  border-bottom-left-radius: 5px;
}
.ai-bubble strong { color: var(--text); font-weight: 600; }
.ai-bubble code {
  background: rgba(15, 23, 42, 0.08);
  color: var(--text);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 12.5px;
}
.ai-bubble em {
  font-style: normal;
  color: var(--text-3);
}

.chat-demo-code {
  background: var(--bg-dark);
  color: #E2E8F0;
  padding: 14px 16px;
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  overflow-x: auto;
  margin: 12px 0 10px;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
  border: 1px solid rgba(148, 163, 184, 0.14);
}
.chat-demo-code .tok-com  { color: #64748B; font-style: italic; }
.chat-demo-code .tok-tag  { color: #7DD3FC; }
.chat-demo-code .tok-attr { color: #FBBF24; }
.chat-demo-code .tok-str  { color: #4ADE80; }
.chat-demo-code .tok-kw   { color: #C084FC; }

.chat-demo-footer {
  text-align: center;
  margin-top: 44px;
  font-size: 16px;
  color: var(--text-2);
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.55;
}
.chat-demo-footer strong { color: var(--text); font-weight: 600; }

/* =================================================
   Streaming states — AI message goes through:
   hidden → typing (dots) → streaming (typed char-by-char) → done (HTML)
   ================================================= */
.chat-demo-msg.ai {
  transition: opacity 0.25s ease;
}
.chat-demo-msg.ai[data-state="hidden"] {
  opacity: 0;
}
.chat-demo-msg.ai[data-state="typing"],
.chat-demo-msg.ai[data-state="streaming"],
.chat-demo-msg.ai[data-state="done"] {
  opacity: 1;
}

/* Typing dots */
.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 2px 0;
}
.typing-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-4);
  animation: typing-bounce 1.1s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.14s; }
.typing-dots span:nth-child(3) { animation-delay: 0.28s; }
@keyframes typing-bounce {
  0%, 70%, 100% { transform: translateY(0); opacity: 0.45; }
  35% { transform: translateY(-3px); opacity: 1; }
}

/* Streaming text + caret */
.stream-content {
  white-space: pre-wrap;
  word-wrap: break-word;
}
.stream-caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--text);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: stream-blink 0.9s step-end infinite;
  transform: translateY(2px);
  color: var(--text);
}
.chat-demo-section.dark .stream-caret { background: var(--text-inv); color: var(--text-inv); }
@keyframes stream-blink {
  0%, 50%   { opacity: 1; }
  51%, 100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .typing-dots span, .stream-caret { animation: none; }
}

/* Dark-section override — when chat-demo-section is inside a dark context */
.chat-demo-section.dark .chat-demo-head h2 { color: var(--text-inv); }
.chat-demo-section.dark .chat-demo-head .lead { color: var(--text-inv-2); }
.chat-demo-section.dark .chat-pane {
  background: var(--bg-dark-2);
  border-color: var(--border-dark);
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.4);
}
.chat-demo-section.dark .chat-pane-bar {
  background: var(--bg-dark-3);
  border-color: var(--border-dark);
  color: var(--text-inv-2);
}
.chat-demo-section.dark .ai-bubble {
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-inv);
}
.chat-demo-section.dark .ai-bubble strong { color: var(--text-inv); }
.chat-demo-section.dark .ai-bubble code {
  background: rgba(226, 232, 240, 0.08);
  color: var(--text-inv);
}
.chat-demo-section.dark .chat-demo-footer { color: var(--text-inv-2); }
.chat-demo-section.dark .chat-demo-footer strong { color: var(--text-inv); }
