/* CROSSFADE's floating buttons: the Discord badge (bottom left) and "Ask CROSSFADE", the site's own help (bottom right).
 * Solid colours, so both read the same over the black stage, the white bands and the grey ones. Nothing loops. */

.cf-fab {
  position: fixed; bottom: 20px; z-index: 2000;
  width: 52px; height: 52px; padding: 0; margin: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 50%; cursor: pointer;
  color: #fff; text-decoration: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16), 0 2px 6px rgba(0, 0, 0, .16), 0 10px 28px rgba(0, 0, 0, .22);
  transition: transform .25s cubic-bezier(.2, .8, .2, 1), box-shadow .25s ease, opacity .2s ease, visibility .2s;
  -webkit-tap-highlight-color: transparent;
}
.cf-fab:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2), 0 4px 10px rgba(0, 0, 0, .18), 0 16px 36px rgba(0, 0, 0, .26); }
.cf-fab:active { transform: scale(.96); }
.cf-fab:focus-visible { outline: 3px solid #4da3ff; outline-offset: 3px; }
.cf-fab svg { display: block; }

.cf-discord { left: 20px; background: #5865f2; }
.cf-discord:hover { background: #4752c4; }
.cf-discord svg { width: 26px; height: 26px; }

.cf-bot-toggle { right: 20px; background: #0071e3; }
.cf-bot-toggle:hover { background: #0077ed; }
.cf-bot-toggle svg { width: 24px; height: 24px; }
.cf-bot-toggle .cf-x { display: none; width: 20px; height: 20px; }
.cf-bot-toggle[aria-expanded="true"] .cf-chat { display: none; }
.cf-bot-toggle[aria-expanded="true"] .cf-x { display: block; }

/* The manual's back-to-top button sits above the bot's button. */
.to-top { bottom: 88px !important; right: 25px !important; }

/* Hidden while the phone menu is open, and when printing. */
html:has(#menu.open) .cf-fab { opacity: 0; visibility: hidden; pointer-events: none; }
@media print { .cf-fab, .cf-bot { display: none !important; } }

/* ── The panel ─────────────────────────────────────────────────────────── */
.cf-bot {
  --b-bg: #ffffff; --b-head: #f5f5f7; --b-line: rgba(0, 0, 0, .08); --b-text: #1d1d1f; --b-dim: #6e6e73;
  --b-bubble: #f2f2f7; --b-chip: #ffffff; --b-chip-line: #d2d2d7; --b-blue: #0071e3; --b-link: #0066cc; --b-field: #f5f5f7;
  --b-tile-hover: #e8e8ed; --b-mark: rgba(0, 113, 227, .14);
  position: fixed; right: 20px; bottom: 84px; z-index: 2001;
  width: 380px; max-width: calc(100vw - 24px); height: min(600px, calc(100vh - 120px)); height: min(600px, calc(100dvh - 120px));
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 20px; background: var(--b-bg); color: var(--b-text);
  box-shadow: 0 0 0 1px var(--b-line), 0 4px 12px rgba(0, 0, 0, .08), 0 30px 80px rgba(0, 0, 0, .25);
  font: 400 15px/1.45 -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  letter-spacing: normal; text-transform: none;
  opacity: 0; visibility: hidden; transform: translateY(12px) scale(.98); transform-origin: bottom right;
  transition: opacity .22s ease, transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .3s;
}
.cf-bot.is-open { opacity: 1; visibility: visible; transform: none; transition: opacity .22s ease, transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s; }
.cf-bot *, .cf-bot *::before, .cf-bot *::after { box-sizing: border-box; }

.cf-bot-head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; background: var(--b-head); border-bottom: 1px solid var(--b-line); flex: none; }
.cf-bot-logo { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 11px; background: #0b0b0c; }
.cf-bot-logo img { width: 26px; height: auto; display: block; }
.cf-bot-who { flex: 1; min-width: 0; }
.cf-bot-name { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.25; color: var(--b-text); }
.cf-bot-note { margin: 1px 0 0; font-size: 12.5px; color: var(--b-dim); line-height: 1.3; }
.cf-bot-icon {
  flex: none; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; background: rgba(0, 0, 0, .06); color: var(--b-dim);
}
.cf-bot-icon:hover { background: rgba(0, 0, 0, .1); color: var(--b-text); }
.cf-bot-icon:focus-visible { outline: 2px solid var(--b-blue); outline-offset: 2px; }
.cf-bot-close svg { width: 12px; height: 12px; }
.cf-bot-new svg { width: 15px; height: 15px; }
.cf-bot-new + .cf-bot-close { margin-left: -4px; }

.cf-bot-log { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; scrollbar-width: thin; }
.cf-msg { max-width: 86%; padding: 9px 13px; border-radius: 18px; font-size: 14.5px; line-height: 1.45; overflow-wrap: anywhere; }
.cf-msg p { margin: 0; }
.cf-msg p + p, .cf-msg p + ul, .cf-msg ul + p { margin-top: 6px; }
.cf-msg ul { margin: 0; padding-left: 18px; }
.cf-msg li + li { margin-top: 2px; }
.cf-msg strong { font-weight: 600; }
.cf-msg--bot { align-self: flex-start; background: var(--b-bubble); color: var(--b-text); border-bottom-left-radius: 6px; }
.cf-msg--me { align-self: flex-end; background: var(--b-blue); color: #fff; border-bottom-right-radius: 6px; }
.cf-msg--typing { display: flex; gap: 4px; padding: 13px 14px; }
.cf-msg--typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--b-dim); opacity: .45; }
.cf-msg--typing i:nth-child(2) { opacity: .65; }
.cf-msg--typing i:nth-child(3) { opacity: .85; }

/* the welcome: a greeting and a grid of topics, filling the panel instead of leaving it empty */
.cf-msg--welcome { max-width: none; padding: 2px 0 4px; }
.cf-hello { margin: 0 2px 12px !important; font-size: 15px; color: var(--b-text); }
.cf-topics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cf-topic {
  display: flex; align-items: center; gap: 10px; min-width: 0; padding: 11px 12px; border: 0; border-radius: 14px; cursor: pointer; text-align: left;
  background: var(--b-bubble); color: var(--b-text); font: inherit;
}
.cf-topic:hover { background: var(--b-tile-hover); }
.cf-topic:focus-visible { outline: 2px solid var(--b-blue); outline-offset: 2px; }
.cf-topic svg { flex: none; width: 30px; height: 30px; padding: 6px; border-radius: 9px; background: var(--b-blue); color: #fff; }
.cf-topic span { display: flex; flex-direction: column; min-width: 0; }
.cf-topic b { font-size: 13.5px; font-weight: 600; line-height: 1.25; }
.cf-topic small { font-size: 12px; color: var(--b-dim); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* where an answer came from, the words it matched, and the small notes */
.cf-src { margin: 0 0 4px !important; font-size: 11.5px; font-weight: 600; letter-spacing: .01em; color: var(--b-dim); }
.cf-msg mark { background: var(--b-mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.cf-fix { margin: 0 0 6px !important; font-size: 12px; color: var(--b-dim); font-style: italic; }
.cf-more { margin-top: 8px !important; font-size: 13px; color: var(--b-dim); }
.cf-msg a:not(.cf-act) { color: var(--b-link); text-decoration: none; }
.cf-msg a:not(.cf-act):hover { text-decoration: underline; }
.cf-list { list-style: none; padding: 0 !important; margin: 6px 0 0 !important; }
.cf-list li { padding: 3px 0; }
.cf-list span { font-size: 12px; color: var(--b-dim); margin-left: 4px; }

.cf-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cf-act {
  display: inline-flex; align-items: center; min-height: 30px; padding: 5px 13px; border-radius: 980px;
  background: var(--b-blue); color: #fff !important; font-size: 13px; font-weight: 500; line-height: 1.2; text-decoration: none !important;
}
.cf-act:hover { background: #0077ed; }
.cf-act--plain { background: var(--b-chip); color: var(--b-link) !important; box-shadow: inset 0 0 0 1px var(--b-chip-line); }
.cf-act--plain:hover { background: var(--b-chip); box-shadow: inset 0 0 0 1px var(--b-link); }
.cf-act:focus-visible { outline: 2px solid var(--b-blue); outline-offset: 2px; }

/* follow-up questions wrap onto a second line rather than running off the edge */
.cf-bot-chips { flex: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 14px 10px; }
.cf-bot-chips[hidden] { display: none; }
.cf-chip {
  max-width: 100%; padding: 6px 12px; overflow: hidden; text-overflow: ellipsis; border: 0; border-radius: 980px; cursor: pointer;
  background: var(--b-chip); color: var(--b-link); box-shadow: inset 0 0 0 1px var(--b-chip-line);
  font-family: inherit; font-size: 13px; font-weight: 500; line-height: 1.25; white-space: nowrap;
}
.cf-chip:hover { box-shadow: inset 0 0 0 1px var(--b-link); }
.cf-chip:focus-visible { outline: 2px solid var(--b-blue); outline-offset: 2px; }

.cf-bot-form { position: relative; flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--b-line); background: var(--b-bg); }
.cf-bot-input {
  flex: 1; min-width: 0; height: 38px; padding: 0 14px; border-radius: 980px; border: 1px solid transparent;
  background: var(--b-field); color: var(--b-text); font-family: inherit; font-size: 15px; line-height: 1.2; outline: none;
}
.cf-bot-input::placeholder { color: var(--b-dim); opacity: 1; }
.cf-bot-input:focus { border-color: var(--b-blue); box-shadow: 0 0 0 3px rgba(0, 113, 227, .18); }
.cf-bot-send {
  flex: none; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; background: var(--b-blue); color: #fff;
}
.cf-bot-send:disabled { background: var(--b-chip-line); cursor: default; }
.cf-bot-send:focus-visible { outline: 2px solid var(--b-blue); outline-offset: 2px; }
.cf-bot-send svg { width: 16px; height: 16px; }

/* questions offered as you type */
.cf-ac {
  position: absolute; left: 10px; right: 10px; bottom: calc(100% + 6px); z-index: 2; margin: 0; padding: 6px; list-style: none;
  border-radius: 14px; background: var(--b-bg); box-shadow: 0 0 0 1px var(--b-line), 0 10px 30px rgba(0, 0, 0, .18);
}
.cf-ac[hidden] { display: none; }
.cf-ac li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer;
  font-size: 14px; line-height: 1.3; color: var(--b-text);
}
.cf-ac li:hover, .cf-ac li[aria-selected="true"] { background: var(--b-bubble); }
.cf-ac li span { flex: none; font-size: 11px; font-weight: 600; color: var(--b-dim); }

@media (prefers-color-scheme: dark) {
  .cf-bot {
    --b-bg: #1c1c1e; --b-head: #242426; --b-line: rgba(255, 255, 255, .1); --b-text: #f5f5f7; --b-dim: #a1a1a6;
    --b-bubble: #2c2c2e; --b-chip: #1c1c1e; --b-chip-line: #48484a; --b-blue: #0a84ff; --b-link: #4da3ff; --b-field: #2c2c2e;
    --b-tile-hover: #3a3a3c; --b-mark: rgba(10, 132, 255, .3);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .12), 0 4px 12px rgba(0, 0, 0, .3), 0 30px 80px rgba(0, 0, 0, .55);
  }
  .cf-bot-icon { background: rgba(255, 255, 255, .1); }
  .cf-bot-icon:hover { background: rgba(255, 255, 255, .16); }
  .cf-ac { box-shadow: 0 0 0 1px rgba(255, 255, 255, .12), 0 10px 30px rgba(0, 0, 0, .5); }
  .cf-act:hover { background: #409cff; }
}

@media (max-width: 600px) {
  .cf-fab { width: 46px; height: 46px; bottom: 16px; }
  .cf-discord { left: 14px; }
  .cf-discord svg { width: 23px; height: 23px; }
  .cf-bot-toggle { right: 14px; }
  .cf-bot-toggle svg { width: 21px; height: 21px; }
  .to-top { bottom: 76px !important; right: 16px !important; }
  .cf-bot { left: 10px; right: 10px; bottom: 72px; width: auto; max-width: none; height: min(560px, calc(100dvh - 92px)); border-radius: 18px; }
  .cf-bot-input { font-size: 16px; } /* 16px stops iPhones zooming in on the field */
}

@media (prefers-reduced-motion: reduce) {
  .cf-fab, .cf-bot, .cf-bot.is-open { transition: none; }
  .cf-fab:hover { transform: none; }
}
