/* mitanshu.dev — ask-me-anything chat widget. Reuses the site's tokens. */

.chat-launch {
  position: fixed;
  right: clamp(14px, 3vw, 26px);
  bottom: clamp(14px, 3vw, 26px);
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
}
.chat-launch:hover { filter: brightness(1.06); }
.chat-launch:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.chat-launch .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--bg); opacity: 0.9;
  box-shadow: 0 0 0 0 rgba(19, 17, 16, 0.6);
  animation: chat-pulse 2.4s ease-out infinite;
}
@keyframes chat-pulse {
  0% { box-shadow: 0 0 0 0 rgba(19, 17, 16, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(19, 17, 16, 0); }
  100% { box-shadow: 0 0 0 0 rgba(19, 17, 16, 0); }
}
.chat-launch[hidden] { display: none; }

.chat-panel {
  position: fixed;
  right: clamp(14px, 3vw, 26px);
  bottom: clamp(14px, 3vw, 26px);
  z-index: 61;
  width: min(380px, calc(100vw - 28px));
  height: min(560px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}
.chat-panel[hidden] { display: none; }

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}
.chat-head .who { display: flex; flex-direction: column; gap: 2px; }
.chat-head .who b { font-size: 13.5px; letter-spacing: 0.01em; }
.chat-head .who span {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
}
.chat-close {
  background: none; border: 1px solid var(--line); color: var(--muted);
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer; font-size: 15px;
  line-height: 1; flex-shrink: 0;
}
.chat-close:hover { color: var(--ink); border-color: var(--line-strong); }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  scroll-behavior: smooth;
}
.chat-msg { max-width: 86%; font-size: 14px; line-height: 1.5; }
.chat-msg p { margin: 0 0 7px; }
.chat-msg p:last-child { margin-bottom: 0; }
.chat-msg.bot {
  align-self: flex-start;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px 13px 13px 13px;
  padding: 10px 12px;
}
.chat-msg.me {
  align-self: flex-end;
  color: var(--bg);
  background: var(--accent);
  border-radius: 13px 3px 13px 13px;
  padding: 10px 12px;
}
.chat-msg.bot a { color: var(--accent); }
.chat-msg .cursor {
  display: inline-block; width: 7px; height: 14px; vertical-align: -2px;
  background: var(--accent); margin-left: 1px; animation: chat-blink 1s steps(2) infinite;
}
@keyframes chat-blink { 50% { opacity: 0; } }
.chat-msg.err { color: var(--muted); border-style: dashed; }

.chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 8px; }
.chat-suggest button {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.02em;
  color: var(--muted); background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 11px; cursor: pointer; text-align: left;
}
.chat-suggest button:hover { color: var(--ink); border-color: var(--accent); }

.chat-form {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 11px; border-top: 1px solid var(--line);
}
.chat-form textarea {
  flex: 1; resize: none; max-height: 96px; min-height: 22px;
  font: inherit; font-size: 14px; line-height: 1.4;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px;
  overflow-y: auto;
  scrollbar-width: thin;                              /* Firefox: thin, themed */
  scrollbar-color: var(--line-strong) transparent;
}
.chat-form textarea:focus { outline: none; border-color: var(--accent); }
.chat-form textarea::placeholder { color: var(--muted); }
/* WebKit/Blink: replace the bright default scrollbar with a subtle dark one */
.chat-form textarea::-webkit-scrollbar { width: 7px; }
.chat-form textarea::-webkit-scrollbar-track { background: transparent; }
.chat-form textarea::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: 4px;
  border: 2px solid var(--bg);
}
.chat-send {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 9px;
  background: var(--accent); color: var(--bg); border: none; cursor: pointer;
  font-size: 16px; line-height: 1;
}
.chat-send:disabled { opacity: 0.4; cursor: default; }

.chat-foot {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--muted);
  text-align: center; padding: 0 12px 9px;
}

@media (prefers-reduced-motion: reduce) {
  .chat-launch .dot, .chat-msg .cursor { animation: none; }
  .chat-log { scroll-behavior: auto; }
}

@media print {
  .chat-launch, .chat-panel { display: none !important; }
}
