/*
 * chat.css
 * Styles of the live chat bubble (/assets/chat.js) in Cloudcut's one theme: Midnight Navy on white and Mist,
 * Inter, no dark variant (docs/decisions.md B6 and B7). It is only on the site when the bubble is switched on:
 * tools/build.sh adds its <link> tag when CHAT_BUBBLE=1.
 *
 * Where it came from: williammunnichcom-site/site/assets/chat.css as of its commit c625fae (2026-11-13). The
 * class names are the same as there. That file grew by layers (a base, then several later blocks that override
 * it); here each rule is written once with its final value, and the colours are Cloudcut's. To refresh it, see
 * the header of /assets/chat.js.
 *
 * Colours: every colour is one of the variables on .wmc below, taken from the brand tokens in site.css (:root).
 * Do not add a prefers-color-scheme rule: the site has one theme.
 *
 * Project: cloudcut.team site
 * @author Claude (Anthropic), written for and prompted by William Munnich
 * @date Last edited 2026-11-14
 */

/* The widget's own colour names, set from the brand tokens.
   --accent      Midnight Navy   launcher button, panel header, the visitor's own bubbles, send button
   --on-accent   White           text and icons on those (brand pairing: White on Navy)
   --paper       White           panel and form background
   --plate       Mist            message list background
   --ink         Midnight Navy   text
   --quiet       #3D4B6B         secondary text (the site's --muted)
   --line*       Navy at 12/25%  borders
   --bubble*     White, Navy 15% Cloudcut's message bubbles, the preview bubble, the "Chat with us" pill
   --field-*     White, Navy 55% text fields
   --alert       #B3261E         unread badge, error notices, a missing required field (the form's error red) */
.wmc {
  color-scheme: light;
  --font: var(--body);
  --accent: var(--navy); --on-accent: #fff;
  --paper: #fff; --plate: var(--mist);
  --ink: var(--navy); --quiet: var(--muted);
  --line: #13254A1F; --line-strong: #13254A40;
  --bubble: #fff; --bubble-line: #13254A26;
  --field-bg: #fff; --field-line: #13254A8C;
  --alert: #B3261E;
  position: fixed; right: 20px; bottom: 20px; z-index: 50; font: 15px/1.45 var(--font); color: var(--ink);
}
.wmc[hidden] { display: none !important; }
.wmc button { font-family: inherit; }

/* ---------- launcher: the round button with a "Chat with us" pill beside it */
.wmc-launch { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.wmc-bubble { position: relative; width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; cursor: pointer; box-shadow: 0 10px 30px -6px #13254A80, 0 2px 6px #0003; transition: transform .2s; margin-left: auto; }
.wmc-bubble:hover { transform: scale(1.05); }
.wmc-bubble:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.wmc-bubble svg { width: 28px; height: 28px; }
/* the small dot: green when someone is online, grey otherwise */
.wmc-bubble::after { content: ""; position: absolute; right: 2px; bottom: 2px; width: 12px; height: 12px; border-radius: 50%; background: #2fbf5a; border: 2px solid var(--paper); }
.wmc[data-online="false"] .wmc-bubble::after { background: #9a9aa0; }
.wmc-badge { position: absolute; right: -6px; top: -6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--alert); color: #fff;
  font-size: 12px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--paper); }
.wmc-badge[hidden] { display: none; }
.wmc-label { height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--bubble-line); background: var(--bubble); color: var(--ink);
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; box-shadow: 0 8px 24px -8px #0004; white-space: nowrap; animation: wmc-in .3s cubic-bezier(.2,.7,.2,1); }
.wmc-label:hover { border-color: var(--accent); }
.wmc-label[hidden] { display: none; }

/* ---------- the preview bubble: a small speech bubble above the launcher, never more than ~260px, dismissible */
.wmc-peek { position: relative; width: max-content; max-width: 260px; margin: 0 0 12px auto; border-radius: 16px 16px 4px 16px;
  border: 1px solid var(--bubble-line); background: var(--bubble); color: var(--ink); box-shadow: 0 12px 32px -8px #0004;
  animation: wmc-in .25s cubic-bezier(.2,.7,.2,1); }
.wmc-peek[hidden] { display: none; }
.wmc-peek-open { display: flex; gap: 10px; align-items: flex-start; width: 100%; margin: 0; padding: 10px 32px 10px 12px; border: 0; border-radius: inherit;
  background: none; color: inherit; text-align: left; font: inherit; font-size: 14px; line-height: 1.35; cursor: pointer; }
.wmc-peek-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wmc-peek-open img { border-radius: 50%; flex: none; width: 28px; height: 28px; }
.wmc-peek-body { display: grid; gap: 1px; min-width: 0; }
.wmc-peek-name { font-weight: 700; font-size: 12px; color: var(--quiet); }
.wmc-peek-text { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.wmc-peek-x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: transparent;
  color: var(--quiet); display: grid; place-items: center; cursor: pointer; }
.wmc-peek-x:hover, .wmc-peek-x:focus-visible { background: var(--line); color: var(--ink); }
.wmc-peek-x svg { width: 14px; height: 14px; }

/* ---------- the open panel */
.wmc-panel { position: absolute; right: 0; bottom: 76px; width: 380px; height: min(680px, calc(100vh - 110px)); display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink); border-radius: 20px; overflow: hidden; border: 1px solid var(--line);
  box-shadow: 0 24px 64px -12px #0005, 0 4px 12px #0002; animation: wmc-in .22s cubic-bezier(.2,.7,.2,1); }
.wmc-panel[hidden] { display: none; }
.wmc-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--accent); color: var(--on-accent); }
.wmc-head img { border-radius: 50%; border: 2px solid #ffffff55; width: 40px; height: 40px; flex: none; }
.wmc-who { flex: 1; min-width: 0; }
.wmc-name { margin: 0; font-family: var(--font); font-weight: 700; font-size: 1.05rem; line-height: 1.3; }
.wmc-status { margin: 0; font-size: .8125rem; opacity: .9; }
.wmc-close { width: 38px; height: 38px; flex: none; border: 0; border-radius: 50%; background: var(--on-accent); color: var(--accent); display: grid; place-items: center;
  cursor: pointer; box-shadow: 0 1px 4px #0004; }
.wmc-close svg { width: 18px; height: 18px; stroke-width: 2.8; }
.wmc-close:focus-visible { outline: 3px solid var(--on-accent); outline-offset: 2px; }

/* ---------- messages */
.wmc-list { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--plate); overscroll-behavior: contain; }
.wmc-msg { max-width: 80%; display: flex; flex-direction: column; }
.wmc-msg time { font-size: 11px; color: var(--quiet); margin-top: 3px; padding: 0 6px; }
.wmc-text { margin: 0; padding: 9px 13px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.wmc-them { align-self: flex-start; }
.wmc-them .wmc-text { background: var(--bubble); border: 1px solid var(--bubble-line); color: var(--ink); border-bottom-left-radius: 6px; }
.wmc-me { align-self: flex-end; align-items: flex-end; }
.wmc-me .wmc-text { background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 6px; }
.wmc-pending { opacity: .6; }
.wmc-error { align-self: center; margin: 4px 0; font-size: 12px; color: var(--alert); }
.wmc-typing { display: flex; gap: 4px; padding: 0 16px 10px 28px; background: var(--plate); }
.wmc-typing[hidden] { display: none; }
.wmc-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--quiet); animation: wmc-dot 1.2s infinite; }
.wmc-typing span:nth-child(2) { animation-delay: .15s; } .wmc-typing span:nth-child(3) { animation-delay: .3s; }

/* ---------- the form under the messages */
.wmc-form { padding: 10px 12px 6px; border-top: 1px solid var(--line); background: var(--paper); margin: 0; }
.wmc-whois { display: grid; gap: 6px; margin-bottom: 8px; }
.wmc-whois[hidden] { display: none; }
.wmc-leadnote { margin: 0 0 2px; font-size: 13px; color: var(--quiet); }
.wmc-leadnote[hidden] { display: none; }
/* folded details: one quiet line until opened */
.wmc-more { justify-self: start; border: 0; background: none; padding: 2px 2px 4px; color: var(--ink); font: inherit; font-size: 13px;
  text-decoration: underline; text-underline-offset: .2em; text-decoration-color: var(--line-strong); cursor: pointer; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wmc-more:hover, .wmc-more:focus-visible { text-decoration-color: var(--accent); }
.wmc-more[hidden], .wmc-fields[hidden] { display: none; }
.wmc-fields { display: grid; gap: 6px; }
/* The visitor's details (chat.js, "THE VISITOR'S DETAILS"): the saved line with its "Change details" button, the
   "Save details" / "Cancel" buttons under the open fields, and the line that confirms a save or names a problem. */
.wmc-saved { display: flex; align-items: center; gap: 10px; font-size: 13px; min-width: 0; }
.wmc-saved[hidden], .wmc-actions[hidden] { display: none; }
.wmc-saved-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--quiet); }
.wmc-actions { display: flex; gap: 8px; align-items: center; }
.wmc-save, .wmc-cancel, .wmc-change { flex: none; min-height: 34px; padding: 0 14px; border-radius: 17px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.wmc-save { border: 1.5px solid var(--accent); background: var(--accent); color: var(--on-accent); }
.wmc-cancel, .wmc-change { border: 1.5px solid var(--field-line); background: var(--paper); color: var(--ink); }
.wmc-cancel:hover, .wmc-change:hover { border-color: var(--accent); }
.wmc-save:focus-visible, .wmc-cancel:focus-visible, .wmc-change:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wmc-detailnote { margin: 0; font-size: 12px; line-height: 1.4; color: var(--quiet); }
.wmc-detailnote:empty { display: none; }
.wmc-detailnote.wmc-problem { color: var(--alert); }
.wmc-field, .wmc-input { width: 100%; border: 1.5px solid var(--field-line); border-radius: 12px; padding: 9px 12px; background: var(--field-bg); color: var(--ink);
  font: inherit; outline: none; }
.wmc-field[hidden] { display: none; }
.wmc-field::placeholder, .wmc-input::placeholder { color: var(--quiet); opacity: 1; }
/* The page's own focus outline (site.css) is replaced by a border and a soft ring inside the panel. */
.wmc .wmc-field:focus, .wmc .wmc-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #13254A38; }
.wmc-field.wmc-bad { border-color: var(--alert); box-shadow: 0 0 0 2px #B3261E40; }
.wmc-row { display: flex; gap: 8px; align-items: flex-end; }
.wmc-input { resize: none; max-height: 120px; }
.wmc-send { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center;
  cursor: pointer; box-shadow: 0 2px 8px -2px #0006; }
.wmc-send svg { width: 20px; height: 20px; }
.wmc-send:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wmc-note { margin: 0; padding: 4px 14px 10px; font-size: 11px; line-height: 1.4; color: var(--quiet); background: var(--paper); }
.wmc-note a { color: inherit; }

@keyframes wmc-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes wmc-dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .wmc-panel, .wmc-peek, .wmc-label { animation: none; } .wmc-typing span { animation: none; opacity: .6; } }

/* ---------- phones: no pill, and the open chat fills the screen. 16px inputs stop iOS from zooming in;
   the paddings keep clear of the notch, the home bar and the keyboard. */
@media (max-width: 480px) {
  .wmc { right: 16px; bottom: 16px; }
  .wmc-label { display: none; }
  .wmc-peek { max-width: min(260px, calc(100vw - 32px)); }
  .wmc[data-open="true"] { inset: 0; }
  .wmc[data-open="true"] .wmc-launch, .wmc[data-open="true"] .wmc-peek { display: none; }
  .wmc-panel { position: fixed; inset: 0; width: auto; height: 100dvh; border-radius: 0; border: 0; }
  .wmc-head { padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); gap: 10px; }
  .wmc-head img { width: 32px; height: 32px; }
  .wmc-name { font-size: .95rem; }
  .wmc-status { font-size: .75rem; }
  .wmc-list { padding: 12px; }
  .wmc-msg { max-width: 86%; }
  .wmc-form { padding: 8px 10px 4px; }
  .wmc-field, .wmc-input { font-size: 16px; padding: 8px 12px; }
  .wmc-fields { gap: 5px; }
  .wmc-note { padding: 2px 12px max(8px, env(safe-area-inset-bottom)); font-size: 10.5px; }
}
