/* Chat assistant widget. Inherits the redesign tokens from cph-redesign.css
   (--fg, --bg-panel, --line, --red …) so it follows light/dark automatically. */

.cphchat{position:fixed;right:20px;bottom:20px;z-index:900;font-family:var(--body)}

/* An element with display: set in a class rule beats the UA's [hidden]{display:none},
   so every such element needs its own [hidden] rule or it can never be hidden. */
.cphchat-panel[hidden],.cphchat-form[hidden],.cphchat-chips[hidden]{display:none}

/* ===== Launcher (chat head) ===== */
.cphchat-launch{display:grid;place-items:center;width:58px;height:58px;margin-left:auto;
  border:0;border-radius:50%;cursor:pointer;background:var(--red);color:#fff;
  box-shadow:0 8px 28px rgba(216,12,24,.32);transition:transform .18s,box-shadow .18s}
.cphchat-launch:hover{transform:translateY(-2px) scale(1.04);box-shadow:0 12px 34px rgba(216,12,24,.42)}
.cphchat-launch svg{width:28px;height:28px;fill:currentColor}
.cphchat.is-open .cphchat-launch{display:none}

/* Visible to screen readers, not to the eye. */
.cphchat-sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;
  clip:rect(0 0 0 0);white-space:nowrap;border:0}

/* ===== Nudge ===== */
.cphchat-nudge[hidden]{display:none}
.cphchat-nudge{position:relative;max-width:250px;margin:0 0 12px auto;padding:13px 30px 13px 15px;
  background:var(--bg-panel);color:var(--fg);border:1px solid var(--line);border-radius:14px;
  border-bottom-right-radius:4px;box-shadow:0 10px 30px rgba(0,0,0,.16);cursor:pointer;
  animation:cphchat-nudge-in .35s ease-out}
.cphchat-nudge p{margin:0;font-size:.86rem;line-height:1.4}
.cphchat-nudge-x{position:absolute;top:5px;right:7px;border:0;background:none;cursor:pointer;
  color:var(--fg-faint);font-size:1.1rem;line-height:1;padding:2px 4px}
.cphchat-nudge-x:hover{color:var(--fg)}
@keyframes cphchat-nudge-in{from{opacity:0;transform:translateY(8px) scale(.96)}}
@media (prefers-reduced-motion:reduce){.cphchat-nudge{animation:none}}

/* ===== Panel ===== */
.cphchat-panel{display:flex;flex-direction:column;width:min(380px,calc(100vw - 40px));
  height:min(560px,calc(100vh - 120px));background:var(--bg-panel);color:var(--fg);
  border:1px solid var(--line);border-radius:18px;overflow:hidden;
  box-shadow:0 24px 70px rgba(0,0,0,.28);animation:cphchat-in .2s ease-out}
@keyframes cphchat-in{from{opacity:0;transform:translateY(12px)}}
@media (prefers-reduced-motion:reduce){.cphchat-panel{animation:none}.cphchat-launch{transition:none}}

.cphchat-head{display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:14px 16px;background:var(--ink);color:var(--hero-ink)}
.cphchat-head strong{font-family:var(--display);font-weight:600;font-size:.98rem}
.cphchat-beta{margin-left:8px;padding:2px 7px;border-radius:4px;background:var(--red);
  color:#fff;font-size:.62rem;font-weight:700;letter-spacing:.12em;text-transform:uppercase;vertical-align:2px}
.cphchat-head-btns{display:flex;align-items:center;gap:10px;flex:none}
.cphchat-reset{border:1px solid rgba(255,255,255,.28);background:none;color:inherit;
  font-family:var(--body);font-size:.72rem;line-height:1;padding:5px 9px;border-radius:999px;
  cursor:pointer;opacity:.75;white-space:nowrap}
.cphchat-reset:hover{opacity:1;border-color:rgba(255,255,255,.6)}
.cphchat-close{border:0;background:none;color:inherit;font-size:1.6rem;line-height:1;
  cursor:pointer;opacity:.7;padding:0 4px}
.cphchat-close:hover{opacity:1}

/* ===== Message log ===== */
.cphchat-log{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;padding:16px;
  display:flex;flex-direction:column;gap:12px}
/* overflow-wrap: an unbroken string (a URL, a long club name) must break rather
   than widen the bubble and give the log a horizontal scrollbar. */
.cphchat-msg{max-width:86%;padding:11px 14px;border-radius:14px;font-size:.92rem;line-height:1.5;
  overflow-wrap:anywhere;word-break:break-word}
.cphchat-msg p{margin:0;white-space:pre-line}
.cphchat-msg.is-bot{align-self:flex-start;background:var(--bg);border:1px solid var(--line);
  border-bottom-left-radius:4px}
.cphchat-msg.is-me{align-self:flex-end;background:var(--red);color:#fff;border-bottom-right-radius:4px}
.cphchat-msg.is-note{align-self:center;max-width:100%;text-align:center;background:none;
  color:var(--fg-faint);font-size:.82rem;padding:4px}
.cphchat-msg a{text-decoration:underline;overflow-wrap:anywhere}

/* Typing indicator */
.cphchat-dots{display:flex;gap:4px;align-items:center;height:20px}
.cphchat-dots i{width:6px;height:6px;border-radius:50%;background:var(--fg-faint);
  animation:cphchat-blink 1.2s infinite}
.cphchat-dots i:nth-child(2){animation-delay:.18s}
.cphchat-dots i:nth-child(3){animation-delay:.36s}
@keyframes cphchat-blink{0%,60%,100%{opacity:.25}30%{opacity:1}}

/* ===== Suggestion chips ===== */
.cphchat-chips{display:flex;flex-wrap:wrap;gap:7px;padding:0 16px 12px}
.cphchat-chip{padding:7px 12px;border:1px solid var(--line-strong);border-radius:999px;
  background:none;color:var(--fg-soft);font-size:.82rem;font-family:var(--body);cursor:pointer;
  transition:border-color .15s,color .15s}
.cphchat-chip:hover{border-color:var(--red);color:var(--red)}

/* ===== Composer ===== */
.cphchat-form{display:flex;gap:8px;padding:12px 16px;border-top:1px solid var(--line)}
.cphchat-form input{flex:1;min-width:0;padding:11px 14px;border:1px solid var(--line-strong);
  border-radius:999px;background:var(--bg);color:var(--fg);font-family:var(--body);font-size:.92rem}
.cphchat-form input::placeholder{color:var(--fg-faint)}
.cphchat-form button{flex:none;width:42px;height:42px;border:0;border-radius:50%;
  background:var(--red);color:#fff;cursor:pointer;display:grid;place-items:center}
.cphchat-form button:disabled{opacity:.45;cursor:default}
.cphchat-form button svg{width:19px;height:19px;fill:currentColor}

.cphchat-foot{margin:0;padding:0 16px 12px;font-size:.72rem;line-height:1.4;color:var(--fg-faint)}
.cphchat-foot a{text-decoration:underline}

/* ===== Mobile: full-height sheet ===== */
@media (max-width:600px){
  .cphchat{right:16px;bottom:16px;left:16px}
  .cphchat-panel{width:100%;height:min(600px,calc(100vh - 90px))}
}
