/* ─────────────────────────────────────────────────────────────────────────────
   The site chat: a launcher, a panel, and a transcript.

   In the site's own tokens (`site.css` sets them), so this looks like the rest of
   askcaelia.com rather than a bolted-on third-party widget. It loads no font, no
   image and no script of its own — the whole thing is this file and `chat.js`.
   ──────────────────────────────────────────────────────────────────────────── */

.cchat-launch {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 18px 12px 15px;
  border: 0;
  border-radius: 999px;
  font: 600 14.5px/1 "Inter", system-ui, -apple-system, sans-serif;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #a855f7, #7c3aed);
  box-shadow: 0 14px 36px rgba(124, 58, 237, 0.34);
  transition: transform 0.16s ease, filter 0.16s ease;
}
.cchat-launch:hover { filter: brightness(1.08); }
.cchat-launch:active { transform: translateY(1px); }
.cchat-launch svg { width: 18px; height: 18px; flex: none; }
.cchat-launch[hidden] { display: none; }

/* The panel. A dialog, and it says so to a screen reader. */
.cchat-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 40px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: #0b0f16;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.9);
  font: 14px/1.55 "Inter", system-ui, -apple-system, sans-serif;
  color: rgba(255, 255, 255, 0.92);
}
.cchat-panel[hidden] { display: none; }

.cchat-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 14px 13px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.22), rgba(0, 133, 255, 0.1));
}
.cchat-head b { font-size: 14.5px; font-weight: 650; }
.cchat-head span { display: block; font-size: 11.5px; color: rgba(255, 255, 255, 0.6); }
.cchat-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(150deg, #7c3aed, #38bdf8);
}
.cchat-mark svg { width: 18px; height: 18px; }
.cchat-x {
  margin-left: auto;
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.cchat-x:hover { background: rgba(255, 255, 255, 0.09); color: #fff; }

.cchat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cchat-msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cchat-msg.them {
  align-self: flex-start;
  background: rgba(168, 85, 247, 0.1);
  border-color: rgba(168, 85, 247, 0.24);
  border-bottom-left-radius: 5px;
}
.cchat-msg.you {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.05);
  border-bottom-right-radius: 5px;
}
.cchat-msg.waiting { color: rgba(255, 255, 255, 0.55); font-style: italic; }

/* The pages an answer came from, so a claim is checkable. */
.cchat-src { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cchat-src a {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
}
.cchat-src a:hover { border-color: #a855f7; color: #fff; }

.cchat-wa {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 9px;
  padding: 8px 13px;
  border-radius: 9px;
  background: #25d366;
  color: #04220f;
  font-weight: 650;
  font-size: 13px;
  text-decoration: none;
}
.cchat-wa:hover { filter: brightness(1.06); }
.cchat-wa svg { width: 15px; height: 15px; }

.cchat-ask {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.015);
}
.cchat-ask input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: #070a10;
  color: inherit;
  font: inherit;
}
.cchat-ask input::placeholder { color: rgba(255, 255, 255, 0.38); }
.cchat-ask button {
  flex: none;
  width: 42px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #a855f7, #7c3aed);
}
.cchat-ask button:disabled { opacity: 0.5; cursor: default; }
.cchat-ask button svg { width: 17px; height: 17px; }

.cchat-foot {
  padding: 0 14px 11px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
}

.cchat-launch:focus-visible,
.cchat-x:focus-visible,
.cchat-ask input:focus-visible,
.cchat-ask button:focus-visible,
.cchat-wa:focus-visible,
.cchat-src a:focus-visible {
  outline: 2px solid #a855f7;
  outline-offset: 2px;
}

/* On a phone it is a sheet, not a 380px box wedged into a corner. */
@media (max-width: 520px) {
  .cchat-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: auto;
    height: 88vh;
    max-height: none;
    border-radius: 18px 18px 0 0;
  }
  .cchat-launch { right: 14px; bottom: 14px; padding: 11px 16px 11px 13px; }
}

/* Nothing of this prints. */
@media print {
  .cchat-launch,
  .cchat-panel { display: none !important; }
}
