/* Ask Tweety (/ask-tweety). Built on the site's theme tokens so it follows
   the light/dark switch. Linked in the page head (works without JavaScript). */
.tweety {
  --tw-accent: var(--accent-color, #1e40af);
  --tw-fill: #1e40af;            /* backgrounds under white text, ≥ 4.5:1 */
  --tw-card: var(--card-bg, #fff);
  --tw-line: var(--border-color, #e2e8f0);
  --tw-muted: var(--text-muted, #475569);
  --tw-soft: rgba(30, 64, 175, 0.07);
  --tw-user: #1e3a8a;
  --tw-warn-bg: #fff7ed;
  --tw-warn-fg: #9a3412;
  --tw-danger: #b91c1c;
  max-width: 780px;
  margin: 0 auto;
}
[data-theme="dark"] .tweety {
  --tw-fill: #2563eb;
  --tw-soft: rgba(96, 165, 250, 0.12);
  --tw-user: #1d4ed8;
  --tw-warn-bg: #2a1708;
  --tw-warn-fg: #fdba74;
  --tw-danger: #fca5a5;
}
.tweety [hidden] { display: none !important; }

/* Header */
.tweety-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 1.5rem; }
.tweety-head h1 { margin: 0 0 0.25rem; }
.tweety-lead { margin: 0; color: var(--tw-muted); line-height: 1.7; }
.tweety-avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--tw-fill), #7c3aed);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 800;
  box-shadow: var(--shadow-md);
}

/* Conversation */
.tweety-chat-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--tw-muted);
  margin: 0 0 0.75rem;
  letter-spacing: 0.02em;
}
.tweety-log { display: flex; flex-direction: column; gap: 1rem; }
.tweety-msg {
  max-width: 88%;
  padding: 0.85rem 1.1rem;
  border-radius: 18px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}
.tweety-msg-bot {
  align-self: flex-start;
  background: var(--tw-card);
  border: 1px solid var(--tw-line);
  border-start-start-radius: 6px;
  box-shadow: var(--shadow-sm);
}
.tweety-msg-user {
  align-self: flex-end;
  background: var(--tw-user);
  color: #fff;
  border-start-end-radius: 6px;
}
.tweety-who {
  margin: 0 0 0.3rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--tw-muted);
}
.tweety-msg-user .tweety-who { color: rgba(255, 255, 255, 0.85); }
.tweety-body > :first-child { margin-top: 0; }
.tweety-body > :last-child { margin-bottom: 0; }
.tweety-body p, .tweety-body ul, .tweety-body ol { margin: 0.5rem 0; }
.tweety-body ul, .tweety-body ol { padding-inline-start: 1.25rem; }
.tweety-body li + li { margin-top: 0.25rem; }
.tweety-body a { color: var(--tw-accent); font-weight: 600; text-underline-offset: 3px; }
.tweety-msg-user .tweety-body a { color: #fff; }
.tweety-body code { background: var(--tw-soft); padding: 0.1rem 0.35rem; border-radius: 6px; font-size: 0.9em; }
.tweety-body pre { white-space: pre-wrap; background: var(--tw-soft); padding: 0.75rem; border-radius: 10px; }
.tweety-subhead { margin-top: 0.75rem; }
.tweety-msg.is-new { animation: tweety-in 0.25s ease-out; }
@keyframes tweety-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Typing indicator */
.tweety-typing { display: flex; align-items: center; gap: 0.6rem; margin: 1rem 0 0; color: var(--tw-muted); font-size: 0.9rem; }
.tweety-dots { display: inline-flex; gap: 4px; }
.tweety-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--tw-accent); animation: tweety-dot 1.2s infinite ease-in-out; }
.tweety-dots span:nth-child(2) { animation-delay: 0.15s; }
.tweety-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes tweety-dot { 0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); } 40% { opacity: 1; transform: none; } }

/* Notices */
.tweety-error, .tweety-blocked {
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border-inline-start: 4px solid currentColor;
  font-weight: 600;
  line-height: 1.7;
}
.tweety-error { background: var(--tw-warn-bg); color: var(--tw-danger); }
.tweety-blocked { background: var(--tw-warn-bg); color: var(--tw-warn-fg); }
.tweety-error:focus, .tweety-blocked:focus { outline: 3px solid var(--tw-accent); outline-offset: 2px; }

/* Suggestions */
.tweety-suggest { margin: 1.25rem 0 0; }
.tweety-suggest-title { margin: 0 0 0.5rem; font-size: 0.9rem; font-weight: 700; color: var(--tw-muted); }
.tweety-suggest-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tweety-chip {
  min-height: 44px;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--tw-line);
  background: var(--tw-card);
  color: var(--text-main);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  width: auto;
  box-shadow: none;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.tweety-chip:hover { border-color: var(--tw-accent); color: var(--tw-accent); background: var(--tw-soft); }

/* Composer: stays at the bottom of the screen while the conversation scrolls. */
.tweety-form { margin: 0; padding: 0; background: none; border: 0; box-shadow: none; }
.tweety-composer {
  position: sticky;
  bottom: 0.75rem;
  margin-top: 1.25rem;
  padding: 0.75rem;
  background: var(--tw-card);
  border: 1px solid var(--tw-line);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  z-index: 5;
}
.tweety-label { display: block; font-weight: 700; font-size: 0.9rem; margin: 0 0 0.4rem; }
.tweety-composer textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 3.25rem;
  max-height: 14rem;
  resize: vertical;
  font: inherit;
  line-height: 1.6;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--tw-line);
  background: var(--bg-color, #f8fafc);
  color: var(--text-main);
}
.tweety-composer textarea:focus { outline: 3px solid var(--tw-accent); outline-offset: 1px; border-color: transparent; }
.tweety-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; align-items: center; }
.tweety-send {
  min-height: 44px;
  padding: 0 1.4rem;
  border: 0;
  border-radius: 12px;
  background: var(--tw-fill);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  width: auto;
}
.tweety-send:hover { filter: brightness(1.1); }
.tweety-send[aria-disabled="true"] { opacity: 0.6; cursor: progress; }
.tweety-secondary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1rem;
  border-radius: 12px;
  border: 1px solid var(--tw-line);
  background: transparent;
  color: var(--text-main);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  width: auto;
  box-shadow: none;
}
.tweety-secondary:hover { border-color: var(--tw-accent); color: var(--tw-accent); }
.tweety-send:focus-visible, .tweety-secondary:focus-visible, .tweety-chip:focus-visible {
  outline: 3px solid var(--tw-accent);
  outline-offset: 2px;
}
.tweety-hint, .tweety-privacy { color: var(--tw-muted); font-size: 0.85rem; line-height: 1.7; }
.tweety-hint { margin: 0.6rem 0 0; }
.tweety-privacy { margin: 1.5rem 0 0; }

@media (max-width: 640px) {
  .tweety-head { align-items: flex-start; }
  .tweety-avatar { width: 2.75rem; height: 2.75rem; font-size: 1.2rem; }
  .tweety-msg { max-width: 100%; }
  .tweety-composer { bottom: 0.5rem; padding: 0.6rem; }
}
@media (prefers-reduced-motion: reduce) {
  .tweety-msg.is-new, .tweety-dots span { animation: none; }
}
