/* /connect demo: the widget (a07-widget; round two b4-widget). The YDO Connect chat in the business's colours, after
   src/templates/widget-desktop.html (900 and up: a 420-wide card above the bubble) and widget-mobile.html (below 900:
   the whole browser viewport, with its own close). Every colour is a token; the product's own colours map to the nearest
   (bot bubble #f0f4f8 -> --ground-2, system line #fff3cd/#856404/#ffeaa7 -> the --recall set, a person's bubble #2196F3
   -> --std-pill, the question pills' standard #2563eb -> --std-pill). Hover moves colour and border only and lives in
   (hover:hover); motion is opacity and transform only. Spacing on a 4px grid; the slot can be as short as ~280px, so the
   head and the composer step down with the slot's height (container queries on .dc-w-box). The transcript's top --w-pad
   is a fade (a row passing under it fades out, never a hard cut) and is where the widget seats the row it places. */

/* the slot: #dc-widget takes no press itself; neither does this box. Only the open chassis does. */
.dc-w-root { contain: layout; }
.dc-w-box { position: absolute; inset: 0; pointer-events: none; container-type: size; container-name: dc-w; }
.dc-w, .dc-w *, .dc-w *::before, .dc-w *::after { box-sizing: border-box; }
.dc-w [hidden] { display: none !important; }
.dc-w :where(h3, p, ul, li) { margin: 0; }
.dc-w button { font-family: var(--ff); cursor: pointer; }
.dc-w button:disabled { cursor: default; }

.dc-w {
  --w-head-h: 88px; --w-pad: 24px; --w-av: 48px; --w-gap: 12px; --w-compose-pad: 16px 24px; --w-field-h: 56px; --w-send: 44px;
  --w-fade: 20px;      /* the transcript's top fade = the line a placed row sits on (never deeper than the gap between rows) */
  position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); color: var(--navy); font-family: var(--ff); font-size: var(--widget-fs); line-height: 1.6;
  border-radius: var(--widget-r); box-shadow: 0 0 0 1px var(--line), var(--widget-shadow);
  opacity: 0; visibility: hidden; transform: translateY(var(--widget-travel)); pointer-events: none;
  transition: opacity var(--t-widget) var(--ease-out), transform var(--t-widget) var(--ease-out), visibility 0s linear var(--t-widget);
}
.dc-w.dc-w-open { opacity: 1; visibility: visible; transform: none; pointer-events: auto;
  transition: opacity var(--t-widget) var(--ease-out), transform var(--t-widget) var(--ease-out), visibility 0s; }

/* ---------- the business's logo (F.logo): the sun in --sun, the hedge in the business's navy; white on a dark ground ---------- */
.dc-w-logo { display: block; flex: none; }
.dc-w-logo-sun { fill: var(--sun); }
.dc-w-logo-ink { fill: var(--tenant); }
.dc-w-head .dc-w-logo-ink, .dc-w-human .dc-w-logo-ink { fill: var(--surface); }

/* ---------- the head: the business's logo and name, the status pill, the phone's close ---------- */
.dc-w-head { flex: none; display: flex; align-items: center; gap: 12px; min-height: var(--w-head-h); padding: 0 var(--w-pad); background: var(--tenant); color: var(--surface); }
.dc-w-brand { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 8px; }
.dc-w-mark { width: 28px; height: 28px; }
.dc-w-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 900; letter-spacing: -0.01em; line-height: 1.2; }
.dc-w-status { flex: none; display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 12px; border: 1px solid var(--tenant); border-radius: var(--r-pill); background: var(--surface); color: var(--tenant); font-size: 12px; font-weight: 700; line-height: 1; white-space: nowrap; }
.dc-w-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.dc-w-status.dc-w-connected { background: var(--std-pill); border-color: var(--std-pill); color: var(--std-pill-ink); }
/* the close is the phone's only way out (widget-mobile.html .mobile-close-btn); from 900 up the bubble closes the chat */
.dc-w-close { position: relative; flex: none; display: none; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: var(--surface); color: var(--tenant); box-shadow: var(--sh-raised); transition: background-color var(--t-hover) ease; }
.dc-w-close::after { content: ''; position: absolute; inset: -4px; }
@media (hover:hover){ .dc-w-close:hover{ background: var(--line-2); } }
.dc-w-head :focus-visible { outline-color: var(--sun); }

/* ---------- the transcript ---------- */
/* position: relative makes the log every row's offsetParent (the widget places rows by their offsetTop); the browser's
   own scroll anchoring is off (the widget places the log itself). The top --w-pad fades: a row the log has scrolled
   past fades out under it instead of meeting the head as a hard edge (--w-fade: the gap between rows, so the row above a
   placed one is never seen). */
.dc-w-log { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; overflow-anchor: none; padding: var(--w-pad); background: var(--surface);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, var(--navy) var(--w-fade)); mask-image: linear-gradient(to bottom, transparent 0, var(--navy) var(--w-fade)); }
/* the room below the last row that lets the widget seat a whole row at the top edge (never content) */
.dc-w-space { display: block; height: 0; pointer-events: none; }
/* the transcript takes the focus only when nothing else can (a phone, a person typing on the other side): a keyboard
   sees where it is, a finger sees nothing */
.dc-w-log:focus { outline: none; }
.dc-w-log:focus-visible { outline: 2px solid var(--orange-ink); outline-offset: -2px; }
.dc-w-welcome { margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--line); text-align: center; }
.dc-w-welcome-t { font-size: 20px; font-weight: 700; line-height: 1.3; color: var(--tenant); }
.dc-w-rows { display: flex; flex-direction: column; }
.dc-w-unit + .dc-w-unit { margin-top: 20px; }
.dc-w-rows:not(:empty) + .dc-w-typing { margin-top: 20px; }
.dc-w-msg { display: flex; align-items: flex-start; gap: var(--w-gap); }
.dc-w-msg.dc-w-user { justify-content: flex-end; }
.dc-w-av { flex: none; width: var(--w-av); height: var(--w-av); border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--sun-tint); box-shadow: inset 0 0 0 1px var(--sun-tint-line); }
.dc-w-av-logo { width: 60%; height: 60%; }
.dc-w-human .dc-w-av { background: var(--std-pill); box-shadow: none; }
.dc-w-bubble { min-width: 0; max-width: 75%; padding: 12px 16px; border-radius: var(--widget-bubble-r); overflow-wrap: anywhere; }
.dc-w-bot .dc-w-bubble { background: var(--ground-2); color: var(--navy); border-bottom-left-radius: var(--r-nested); }
.dc-w-human .dc-w-bubble { background: var(--std-pill); color: var(--std-pill-ink); border-bottom-left-radius: var(--r-nested); }
.dc-w-user .dc-w-bubble { background: var(--tenant); color: var(--surface); border-bottom-right-radius: var(--r-nested); }
.dc-w-bubble.dc-w-flat { padding: 0; background: transparent; border-radius: 0; }
.dc-w-bubble p + p, .dc-w-bubble p + ul, .dc-w-bubble ul + p { margin-top: 8px; }
.dc-w-bubble ul { margin: 8px 0; padding-left: 20px; }
.dc-w-bubble ul:first-child { margin-top: 0; }
.dc-w-bubble ul:last-child { margin-bottom: 0; }
.dc-w-bubble li + li { margin-top: 4px; }
.dc-w-bubble strong { font-weight: 700; }

/* the answer card (renderAnswerBlock): a white card, heading over a rule in the business's colour, the list, then the tail */
.dc-w-ab { padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--sh-raised); }
.dc-w-ab-h { font-weight: 700; line-height: 1.4; }
.dc-w-ab-lead { line-height: 1.5; }
.dc-w-ab-rule { width: 44px; height: 2px; margin: 8px 0; background: var(--tenant); }
.dc-w-bubble .dc-w-ab-items { margin: 0; padding-left: 20px; }
.dc-w-ab-items li { line-height: 1.5; }
.dc-w-ab-pre { margin-bottom: 8px; }
.dc-w-ab-tail { margin-top: 8px; }

/* the on-open page card and the welcome-back card (renderIntroCard): heading, rule, bullets, the question chips */
.dc-w-icard { padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--sh-raised); }
.dc-w-icard-h { font-size: 15px; font-weight: 700; line-height: 1.35; }
.dc-w-icard-rule { width: 44px; height: 2px; margin: 8px 0; background: var(--tenant); }
.dc-w-bubble .dc-w-icard-b { margin: 0 0 8px; padding-left: 20px; }
.dc-w-icard-b li { font-size: 13px; line-height: 1.5; }
/* the bullet that is the visitor's own last topic: its highlight box is always there (transparent), only its colour moves */
.dc-w-icard-b li.dc-w-flash { margin-left: -4px; padding: 0 4px; border-radius: var(--r-nested); }

/* the "Read more" chip (renderSourceChip) */
.dc-w-source { position: relative; display: inline-flex; align-items: center; max-width: 100%; height: 28px; margin-top: 8px; padding: 0 12px; border: 1px solid var(--mute); border-radius: var(--r-pill); background: var(--surface); color: var(--tenant); font-size: 12px; font-weight: 700; line-height: 1; transition: border-color var(--t-hover) ease; }
.dc-w-source::after { content: ''; position: absolute; inset: -9px 0; }
.dc-w-source-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (hover:hover){ .dc-w-source:hover{ border-color: var(--tenant); } }
.dc-w-bubble:not(.dc-w-flat) > .dc-w-source { display: flex; width: max-content; }

/* thumbs (buildFeedbackBar): quiet until the answer is pointed at; the pressed one in the business's colour, both locked */
.dc-w-fb { display: flex; gap: 12px; margin-top: 8px; transition: opacity var(--t-hover) ease; }
.dc-w-fb-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 28px; padding: 0; border: 0; border-radius: var(--r-nested); background: transparent; color: var(--meta); transition: background-color var(--t-hover) ease, color var(--t-hover) ease; }
.dc-w-fb-btn::after { content: ''; position: absolute; inset: -8px -6px; }
.dc-w-fb-btn .dc-w-down { transform: rotate(180deg); }
/* on touch the source chip's and the thumbs' 44 px targets do not overlap (a14 measured the chip at 35) */
@media (pointer: coarse) { .dc-w-source + .dc-w-fb { margin-top: 18px; } }
/* ...nor do the thumbs' and the question chips' under them (i2 measured 43 and 38): a 46 px chip, 16 px between */
@media (pointer: coarse) { .dc-w-msg + .dc-w-chips { margin-top: 16px; } }
.dc-w-fb-btn.dc-w-sel { color: var(--tenant); background: var(--line); }
.dc-w-fb-btn:disabled:not(.dc-w-sel) { opacity: .4; }
@media (hover:hover){
  .dc-w-fb { opacity: .6; }
  .dc-w-bubble:hover .dc-w-fb, .dc-w-fb:focus-within, .dc-w-fb:has(.dc-w-sel) { opacity: 1; }
  .dc-w-fb-btn:not(:disabled):hover { background: var(--line); color: var(--tenant); }
}

/* question chips (addIntroChips): the product's standard blue outline pill on white, inverting on hover */
.dc-w-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0 calc(var(--w-av) + var(--w-gap)); }
.dc-w-chips.dc-w-chips-in { margin: 4px 0 0; }
.dc-w-chip { position: relative; max-width: 100%; min-width: 0; min-height: 32px; padding: 6px 12px; border: 1px solid var(--std-pill); border-radius: var(--r-card); background: var(--surface); color: var(--std-pill); font-size: 12px; font-weight: 700; line-height: 1.35; text-align: left; white-space: normal; overflow-wrap: anywhere; transition: background-color var(--t-hover) ease, color var(--t-hover) ease; }
.dc-w-chip::after { content: ''; position: absolute; inset: -6px 0; }
@media (pointer: coarse) { .dc-w-chip::after { inset: -8px 0; } }   /* 30 px inside the border + 16: 44 to a finger (i2 measured 38) */
@media (hover:hover){ .dc-w-chip:hover{ background: var(--std-pill); color: var(--std-pill-ink); } }

/* system lines (addSystemMessage): centred, the product's amber note */
.dc-w-sys { padding: 0 20px; text-align: center; }
.dc-w-sys > span { display: inline-block; max-width: 85%; padding: 8px 16px; border: 1px solid var(--recall-line); border-radius: var(--r-small); background: var(--recall-tint); color: var(--recall); font-size: 12px; font-style: italic; line-height: 1.5; }
/* a line that takes a leaving card's place (the join line after the waiting card) keeps that card's height (c1-10) */
.dc-w-unit.dc-w-takes { display: flex; flex-direction: column; justify-content: center; }

/* a card from flows.js placed centred (the waiting timer) */
.dc-w-center { display: flex; justify-content: center; }
.dc-w-cardbox { max-width: 80%; }

/* the typing dots */
.dc-w-dots { display: inline-flex; align-items: center; gap: 4px; padding: 16px 20px; }
.dc-w-dots > span { width: 6px; height: 6px; border-radius: 50%; background: var(--ctl-line); animation: dc-w-typing 1.4s infinite ease-in-out; }
.dc-w-dots > span:nth-child(1) { animation-delay: -0.32s; }
.dc-w-dots > span:nth-child(2) { animation-delay: -0.16s; }
@keyframes dc-w-typing { 0%, 80%, 100% { transform: scale(.8); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }

/* ---------- a fresh live row arrives in reading order (answer-arrival) ----------
   Each part carries its own moment (--d, set by widget.js; --d0 = the widget's opening when it opens with the row):
   the card at 0, its rule drawing at 80, the items 70 apart from 160 (the welcome-back bullets 180 apart), then the tail,
   the source chip, the thumbs and the question chips, 80 apart. Opacity and transform only; the end state is the part's
   own style (no fill after the end), so the thumbs keep their quiet opacity. Reduced motion: tokens.css cuts it to 0. */
@keyframes dc-w-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes dc-w-draw { from { transform: scaleX(0); } }
@keyframes dc-w-flash { from { background-color: var(--connect-tint); color: var(--connect-ink); } }
.dc-w-play .dc-w-seq { animation: dc-w-in 300ms var(--ease-out) backwards; animation-delay: calc(var(--d0, 0ms) + var(--d, 0ms)); }
.dc-w-play .dc-w-ab-rule, .dc-w-play .dc-w-icard-rule { transform-origin: left center; animation: dc-w-draw 200ms var(--ease-out) backwards; animation-delay: calc(var(--d0, 0ms) + var(--d, 0ms)); }
/* the visitor's own last topic: it lands, then turns Connect green for a moment and settles (colour only) */
.dc-w-play .dc-w-seq.dc-w-flash { animation: dc-w-in 300ms var(--ease-out) backwards, dc-w-flash var(--w-flash, 900ms) ease-in;
  animation-delay: calc(var(--d0, 0ms) + var(--d, 0ms)), calc(var(--d0, 0ms) + var(--d2, 0ms)); }
/* the taught answer: once it is up, its ink swells to Connect green and back (colour only; reduced motion: none) */
@keyframes dc-w-taught { 40% { color: var(--connect-ink); } }
.dc-w-play .dc-w-bubble.dc-w-taught { animation: dc-w-taught var(--w-flash, 900ms) var(--ease-std) var(--d2, 0ms); }

/* ---------- the composer: the box, and the send button that appears when there is something to send ---------- */
.dc-w-compose { flex: none; padding: var(--w-compose-pad); background: var(--track); border-top: 1px solid var(--line-2); }
.dc-w-field { display: flex; align-items: center; gap: 8px; height: var(--w-field-h); padding: 0 4px 0 0; border: 2px solid var(--ctl-line); border-radius: var(--r-pill); background: var(--surface); transition: border-color var(--t-hover) ease, background-color var(--t-hover) ease; }
/* the box in use: its own border turns the focus colour (one ring, not a border inside an outline) */
.dc-w-field:focus-within { border-color: var(--orange-ink); }
.dc-w-field:has(.dc-ring) { outline: 2px solid var(--orange); outline-offset: 2px; box-shadow: 0 0 0 6px rgba(255,122,26,.18); }
/* held by a card (the product's rule): greyed, still takes a press and a key (the card's way out is ringed) */
.dc-w-field.dc-w-locked { border-color: var(--line); background: var(--line-2); cursor: default; }
/* the held box keeps the one focus colour (i2: focused and held, it showed no focus at all) */
.dc-w-field.dc-w-locked:focus-within { border-color: var(--orange-ink); }
.dc-w-input { flex: 1; min-width: 0; height: 100%; padding: 0 20px; border: 0; background: transparent; color: var(--navy); font-size: 14px; outline: none; }
.dc-w-input.dc-ring { outline: none !important; box-shadow: none !important; }
.dc-w-input:focus-visible { outline: none; }
.dc-w-input::placeholder { color: var(--meta); opacity: 1; }
.dc-w-input:disabled, .dc-w-input[aria-disabled="true"] { color: var(--meta); cursor: default; }
.dc-w-send { position: relative; flex: none; display: flex; align-items: center; justify-content: center; width: var(--w-send); height: var(--w-send); padding: 0; border: 0; border-radius: 50%; background: var(--tenant); color: var(--surface); visibility: hidden; transition: background-color var(--t-hover) ease; }
.dc-w-send.dc-w-go { visibility: visible; }
.dc-w-send::after { content: ''; position: absolute; inset: calc((var(--w-send) - 44px) / 2); }
.dc-w-send svg { margin-left: 2px; }
.dc-w-send.dc-pressed { --dc-press-ink: transparent; background: var(--tenant-2); }
@media (hover:hover){ .dc-w-send.dc-w-go:hover{ background: var(--tenant-2); } }
/* the held composer's answer to a press or a key: the card's way out takes the stage's ring (colour only) */
.dc-w .dc-w-nudge { outline: 2px solid var(--orange); outline-offset: 2px; box-shadow: 0 0 0 6px rgba(255,122,26,.18); }
/* c3-p6: the visitor's own lines the team's summary was built from light once as it lands on the phone (the
   director sets .dc-pulse for 600 ms; never under reduced motion). Colour only: the visitor's navy turns Connect green. */
.dc-w-user .dc-w-bubble { transition: background-color 200ms var(--ease-out); }
.dc-w-unit.dc-pulse .dc-w-user .dc-w-bubble { background-color: var(--connect-ink); }

/* ---------- the slot's height: the head and the composer give their room to the transcript ---------- */
@container dc-w (max-height: 559.98px) {
  .dc-w { --w-head-h: 64px; --w-pad: 20px; --w-compose-pad: 12px 20px; --w-field-h: 52px; }
  .dc-w-welcome { margin-bottom: 20px; padding-bottom: 16px; }
  .dc-w-welcome-t { font-size: 18px; }
}
@container dc-w (max-height: 379.98px) {
  .dc-w { --w-head-h: 56px; --w-pad: 16px; --w-av: 40px; --w-compose-pad: 8px 16px; --w-field-h: 48px; --w-send: 40px; --w-fade: 16px; }
  .dc-w-welcome { margin-bottom: 16px; padding-bottom: 12px; }
}
/* a narrow chat: the name keeps its room (the avatar beside every answer already carries the logo) */
@container dc-w (max-width: 399.98px) {
  .dc-w-mark { display: none; }
}
@container dc-w (max-width: 379.98px) {
  .dc-w { --w-pad: 16px; --w-av: 40px; --w-gap: 8px; --w-fade: 16px; }
  .dc-w-head { gap: 8px; }
  .dc-w-name { font-size: 15px; }
  .dc-w-bubble { max-width: 80%; }
}

/* ---------- below 900: the phone template (widget-mobile.html) — full screen, its own close, no welcome title ---------- */
@media (max-width: 899.98px) {
  .dc-w { --w-head-h: 64px; --w-pad: 16px; --w-av: 36px; --w-gap: 8px; --w-compose-pad: 8px 12px; --w-field-h: 52px; --w-send: 40px;
    --w-fade: 16px; border-radius: 0; box-shadow: none; }
  .dc-w-head { gap: 8px; padding: 0 12px 0 16px; }
  .dc-w-brand { justify-content: flex-start; }
  .dc-w-name { font-size: 15px; }
  /* widget-mobile.html's smaller pill (11px, 5px 10px) */
  .dc-w-status { height: 24px; padding: 0 8px; gap: 6px; font-size: 11px; }
  .dc-w-dot { width: 6px; height: 6px; }
  .dc-w-close { display: flex; }
  .dc-w-welcome { display: none; }
  .dc-w-unit + .dc-w-unit, .dc-w-rows:not(:empty) + .dc-w-typing { margin-top: 16px; }
  .dc-w-bubble { max-width: 80%; }
  .dc-w-cardbox { max-width: 86%; }
  .dc-w-field { border-width: 1px; border-color: var(--mute); }
  .dc-w-input { padding: 0 16px; font-size: 16px; }
}
@media (max-width: 359.98px) {
  .dc-w-name { font-size: 14px; }
}
/* a phone under 380: beside the status pill and the close the name may not fit on one line; it takes two in the
   64px head, never an ellipsis */
@media (max-width: 379.98px) {
  .dc-w-name { white-space: normal; line-height: 1.15; text-wrap: balance; }
}
