/* ============================================================
   Kit — widgets.css   (reusable parts: answer widgets)
   The ways the agent asks the user a question inside the chat:
     .bp-choices / .bp-choice   lettered A/B/C options (single)
     .bp-badges  / .bp-badge    pill badges (multi-select)
     .bp-score                  a 1–N segmented score
     .bp-slider                 a sentiment slider, emoji knob
   Selected states pick up the client accent. The slider uses
   semantic red-to-green colours (sentiment), not the brand.
   Behaviour is in widgets.js.
   ============================================================ */

/* shared circled-check (the "approve" mark). Themed: accent disc + a
   knocked-out white tick. Used selected-right on choices and badges, and
   in the checklist circle. A Lottie (icon-check-circle) can mount into the
   same slot for the draw-in; this is the static / no-JS form. */
.bp-checkmark {
  --bp-tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 13l4 4L19 7' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  position: relative; flex: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--bp-accent);
  transition: background .16s ease, box-shadow .16s ease;   /* smooth outline → filled */
}
.bp-checkmark::after {
  content: ""; position: absolute; inset: 0;
  background: var(--bp-accent-foreground);
  transition: background .16s ease;                          /* line tick → knocked-out tick */
  -webkit-mask: var(--bp-tick) center / 12px 12px no-repeat;
          mask: var(--bp-tick) center / 12px 12px no-repeat;
}

/* ---------- lettered choices (single select) ---------- */
.bp-choices { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.bp-choice {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--bp-border-strong);
  border-radius: var(--bp-radius-btn); corner-shape: squircle;   /* same radius as buttons */
  background: var(--bp-surface);
  font: inherit; text-align: left; cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.bp-choice:hover { background: color-mix(in srgb, #101010 4%, var(--bp-surface));   /* neutral hover (rule 4: all grays neutral, no warm off-white) */ }
/* the A/B/C key — a small squircle badge, not a circle. box-sizing:border-box so the
   22px is the whole badge (a <span> is content-box by default, which made it 34px when
   the host has no global reset — the button rows are already border-box via the UA). */
.bp-choice__key {
  box-sizing: border-box;
  flex: none; min-width: 22px; height: 22px; padding: 0 5px;
  display: grid; place-items: center;
  border: 1px solid var(--bp-border-strong);
  border-radius: 8px; corner-shape: squircle;
  font-size: 12px; font-weight: 600; line-height: 1;
  color: var(--bp-surface-muted);
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.bp-choice__label { flex: 1; min-width: 0; font-size: 14px; line-height: 20px; font-weight: 600; color: var(--bp-surface-foreground); }
/* selected: accent badge + a circled check that reveals flush-right */
.bp-choice__check {
  flex: none; margin-left: 4px;
  width: 0; opacity: 0; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  transition: width .22s var(--bp-ease-emphasized, ease), opacity .16s ease, margin .22s ease;
}
.bp-choice.is-selected { border-color: var(--bp-accent); background: var(--bp-accent-tint); }
.bp-choice.is-selected .bp-choice__key { border-color: var(--bp-accent); color: var(--bp-accent-foreground); background: var(--bp-accent); }
.bp-choice.is-selected .bp-choice__check { width: 20px; opacity: 1; margin-left: 8px; }

/* The check RESTS as an OUTLINE ring (hollow, line tick) and fills to the accent disc only
   once the row is selected. Resting-outline matters: the check is revealed on hover from a
   0-width slot, and if its resting look were the filled disc you'd see it flash filled -> outline
   as the base's background transition ran. Starting outline means the reveal is clean, and
   selecting is the only thing that fills it. */
.bp-choice .bp-checkmark { background: transparent; box-shadow: inset 0 0 0 1.5px var(--bp-border-strong); }
.bp-choice .bp-checkmark::after { background: var(--bp-surface-muted); }
.bp-choice.is-selected .bp-checkmark { background: var(--bp-accent); box-shadow: none; }
.bp-choice.is-selected .bp-checkmark::after { background: var(--bp-accent-foreground); }
/* the check reveals in the same flush-right slot on hover (as the "tappable" affordance) */
.bp-choice:hover:not(.is-selected) .bp-choice__check { width: 20px; opacity: 1; margin-left: 8px; }

/* hover arrow: an optional .bp-choice__go slides in on the right on hover, as a
   quiet "tappable" nudge — until the row is chosen, when the check takes over. */
.bp-choice__go {
  flex: none; margin-left: 4px;
  width: 0; opacity: 0; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--bp-surface-muted);
  transition: width .18s var(--bp-ease-emphasized, ease), opacity .14s ease, margin .18s ease;
}
.bp-choice__go svg { width: 16px; height: 16px; display: block; }
.bp-choice:hover:not(.is-selected) .bp-choice__go { width: 16px; opacity: 1; margin-left: 8px; }
.bp-choice.is-selected .bp-choice__go { width: 0; opacity: 0; margin-left: 4px; }

/* ---------- badges (multi-select) ---------- */
.bp-badges { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.bp-badge {
  height: 40px; padding: 0 12px;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--bp-border-strong);
  border-radius: var(--bp-radius); corner-shape: squircle;
  background: var(--bp-surface);
  font: inherit; font-size: 14px; font-weight: 600;
  color: var(--bp-surface-foreground); cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.bp-badge:hover { background: color-mix(in srgb, #101010 4%, var(--bp-surface));   /* neutral hover (rule 4: all grays neutral, no warm off-white) */ }
.bp-badge.is-selected {
  border-color: var(--bp-accent);
  background: var(--bp-accent-tint);
  color: var(--bp-accent-strong);
}
/* selected: circled check reveals on the RIGHT (after the label) */
.bp-badge__check {
  flex: none;
  width: 0; opacity: 0; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  transition: width .22s var(--bp-ease-emphasized, ease), opacity .16s ease, margin .22s ease;
}
.bp-badge.is-selected .bp-badge__check { width: 18px; opacity: 1; margin-left: 2px; }
.bp-badge__check .bp-checkmark { width: 18px; height: 18px; }

/* ---------- numbered score (single select) ----------
   The row reads like a secondary button (white gradient, gray border,
   soft shadow, squircle); the selected cell reads like a primary
   (accent gradient + white). */
.bp-score { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.bp-score__row {
  display: flex;
  border: 1px solid #d7d7d3;
  border-radius: var(--bp-radius-btn); corner-shape: squircle;
  overflow: hidden;
  box-shadow: var(--bp-shadow-control);
}
.bp-score__cell {
  flex: 1; height: 40px;
  display: grid; place-items: center;
  border: none; border-right: 1px solid #e2e2de;
  background: linear-gradient(180deg, #ffffff, #f2f2ef);
  font: inherit; font-size: 14px; font-weight: 600; color: var(--bp-surface-foreground);
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.bp-score__cell:last-child { border-right: none; }
.bp-score__cell:hover { background: linear-gradient(180deg, #ffffff, #ececE8); }
.bp-score__cell.is-selected {
  color: var(--bp-accent-foreground);
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--bp-accent) 90%, white),
    color-mix(in srgb, var(--bp-accent) 90%, black));
}
.bp-score__ends, .bp-slider__ends {
  display: flex; justify-content: space-between;
  font-size: 12px; line-height: 18px; font-weight: 600; color: var(--bp-surface-foreground);
}

/* ---------- sentiment slider ---------- */
.bp-slider { width: 100%; display: flex; flex-direction: column; gap: 4px; }
.bp-slider__rail {
  position: relative; height: 34px;
  touch-action: none; cursor: pointer;
}
.bp-slider__track {
  position: absolute; left: 0; right: 0; top: 50%;
  transform: translateY(-50%);
  height: 6px; border-radius: 12px; background: #e9eaeb;
}
.bp-slider__fill {
  position: absolute; left: 0; top: 50%;
  transform: translateY(-50%);
  height: 6px; border-radius: 12px;
  background: var(--bp-slider-color, #d92d20);
  width: var(--bp-slider-val, 50%);
  transition: width .08s linear, background .12s linear;
}
.bp-slider__knob {
  position: absolute; top: 50%;
  left: var(--bp-slider-val, 50%);
  transform: translate(-50%, -50%);
  width: 34px; height: 34px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(10, 13, 18, .22), 0 0 0 1px rgba(10,13,18,.04);
  display: grid; place-items: center;
  font-size: 18px; line-height: 1; cursor: grab;
  transition: left .08s linear;
}
.bp-slider__knob:active { cursor: grabbing; }

/* ---------- plain slider (neutral scale, not sentiment) ----------
   For a NEUTRAL question — "do it myself" ↔ "get the result", "less" ↔
   "more" — where a red-to-green mood reading would be wrong. The fill is
   the brand accent, the knob carries no emoji, and an optional reading
   line under the rail shows the host-supplied label for the current value.
   widgets.js skips the sentiment colour/emoji when .bp-slider--plain is set;
   the host listens for bp:answer and writes the reading text itself. */
.bp-slider--plain .bp-slider__fill { background: var(--bp-accent); }
.bp-slider--plain .bp-slider__knob { font-size: 0; }
.bp-slider__read {
  margin-top: 8px; text-align: center;
  font-size: 13px; line-height: 18px; font-weight: 600; color: var(--bp-accent);
}

/* ---------- progress bar (a build / loading readout) ----------
   A labelled track that fills left→right while the agent is building something:
   a title row (label on the left, "N%" on the right) over a 12px track. The fill
   is the brand accent; at 100% add .is-complete to accent the percentage too. The
   host animates --the fill width and the % text. (Figma: track #e9eaeb, brand fill.) */
.bp-progress { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.bp-progress__head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 14px; line-height: 20px; font-weight: 600;
}
.bp-progress__label { min-width: 0; color: var(--bp-surface-foreground); }
.bp-progress__pct { flex: none; color: var(--bp-surface-muted); font-variant-numeric: tabular-nums; transition: color .2s ease; }
.bp-progress.is-complete .bp-progress__pct { color: var(--bp-accent); }
.bp-progress__track {
  height: 12px; border-radius: 12px; corner-shape: squircle;
  background: #e9eaeb; overflow: hidden;
}
.bp-progress__fill {
  height: 100%; width: 0; border-radius: 12px; corner-shape: squircle;
  background: var(--bp-accent); transition: width .18s linear;
}

/* ---------- answer-widget wrappers (layout under an agent bubble) ----------
   The .bp-answer box holds a widget; these modifiers lay out the pieces a widget
   needs BELOW its control (a full-width confirm CTA for the multi-select badges and
   the slider; a row of quiet "escape" buttons under the lettered choices). Used by
   BPConvo's inline widgets so the agent and any other chat surface lay out identically. */
.bp-escapes { display: flex; gap: 8px; margin-top: 10px; }
.bp-escapes .bp-btn { flex: 1 1 0; }
.bp-slider-wrap .bp-slider { margin-bottom: 2px; }
.bp-slider-wrap > .bp-btn { width: 100%; margin-top: 12px; }
/* multi-select: the confirm sits under the badges, full width, matching the slider's confirm */
.bp-badges-wrap > .bp-btn { width: 100%; margin-top: 12px; }
