/* TALK_WITH_CONNECT_V1 — the landing's floating assistant (talk-with-connect.js).
   Tokens only (src/site/connect-theme.css), so Day and Dark both come from the
   theme. Lengths that no token expresses are commented where they stand.
   Desktop: a panel at the bottom right. Compact (<= 640 px): a bottom sheet. */

.twc-launcher {
  position: fixed;
  right: max(var(--cx-space-5), env(safe-area-inset-right));
  bottom: max(var(--cx-space-5), env(safe-area-inset-bottom));
  z-index: 86; /* above the old caic launcher's 85, below the cira dialog */
  display: inline-flex;
  align-items: center;
  gap: var(--cx-space-2);
  min-height: 48px; /* comfortably above the 44 px touch standard */
  padding: var(--cx-space-2) var(--cx-space-4) var(--cx-space-2) var(--cx-space-2);
  border: 1px solid var(--cx-border-strong);
  border-radius: var(--cx-radius-pill);
  background: var(--cx-action);
  color: var(--cx-action-ink);
  box-shadow: var(--cx-shadow-3);
  font: 650 0.9375rem/1.2 var(--cx-font);
  cursor: pointer;
}
.twc-launcher[hidden] { display: none; }
.twc-launcher img {
  width: 30px;
  height: 30px;
  border-radius: var(--cx-radius-pill);
  background: var(--cx-surface);
}
@media (hover: hover) {
  .twc-launcher:hover { background: var(--cx-action-hover); }
}
.twc-launcher:focus-visible,
.twc :focus-visible {
  outline: 3px solid var(--cx-focus);
  outline-offset: 2px;
}
/* The open panel (and the phone sheet) covers the launcher; it is never hidden,
   so focus can always return to it when the panel closes. */

/* ---------- the panel ---------- */
.twc {
  position: fixed;
  inset: auto max(var(--cx-space-5), env(safe-area-inset-right)) max(var(--cx-space-5), env(safe-area-inset-bottom)) auto;
  z-index: 87;
  box-sizing: border-box;
  width: min(400px, calc(100vw - 2 * var(--cx-space-5)));
  height: min(620px, calc(100dvh - 104px)); /* 104 px keeps the header in view */
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--cx-border-strong);
  border-radius: var(--cx-radius-lg);
  background: var(--cx-surface);
  color: var(--cx-text);
  box-shadow: var(--cx-shadow-3);
  font: 400 0.9375rem/1.5 var(--cx-font);
  overflow: hidden;
}
.twc[open] { display: flex; flex-direction: column; }
.twc *, .twc *::before, .twc *::after { box-sizing: border-box; }
.twc::backdrop { background: var(--cx-overlay); }

.twc-head {
  display: flex;
  align-items: center;
  gap: var(--cx-space-3);
  flex: none;
  padding: var(--cx-space-3) var(--cx-space-3) var(--cx-space-3) var(--cx-space-4);
  border-bottom: 1px solid var(--cx-border);
}
.twc-head img { width: 32px; height: 32px; flex: none; }
.twc-id { flex: 1; min-width: 0; }
/* .connect-site h2 (experience.css, motion-preview.css) sets the page's display
   serif and size; the panel's title is interface text. */
.connect-site .twc .twc-title {
  margin: 0;
  max-width: none;
  font: 650 1.0625rem/1.25 var(--cx-font);
  letter-spacing: normal;
  color: var(--cx-text);
}
.twc-sub { margin: 0; font-size: 0.8125rem; color: var(--cx-text-3); }
.twc-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--cx-border);
  border-radius: var(--cx-radius-sm);
  background: var(--cx-surface);
  color: var(--cx-text);
  font: 600 1.125rem/1 var(--cx-font);
  text-decoration: none;
  cursor: pointer;
}
@media (hover: hover) { .twc-icon:hover { background: var(--cx-hover); } }

.twc-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--cx-space-4);
  display: flex;
  flex-direction: column;
  gap: var(--cx-space-3);
}
.twc-msg { display: flex; max-width: 100%; }
.twc-msg-visitor { justify-content: flex-end; }
.twc-msg-visitor .twc-text {
  max-width: 85%;
  padding: var(--cx-space-2) var(--cx-space-3);
  border-radius: var(--cx-radius);
  background: var(--cx-action-soft);
}
.twc-body { display: flex; flex-direction: column; align-items: flex-start; gap: var(--cx-space-2); min-width: 0; }
.twc-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.twc-badge {
  padding: 2px var(--cx-space-2);
  border-radius: var(--cx-radius-pill);
  background: var(--cx-success-soft);
  color: var(--cx-success-text);
  font-size: 0.75rem;
  font-weight: 600;
}
.twc-sources { display: flex; flex-direction: column; gap: var(--cx-space-1); font-size: 0.8125rem; }
.twc-sources a, .twc-foot a { color: var(--cx-link); }
.twc-card {
  width: 100%;
  padding: var(--cx-space-3);
  border: 1px solid var(--cx-border);
  border-radius: var(--cx-radius);
  background: var(--cx-surface-2);
  display: flex;
  flex-direction: column;
  gap: var(--cx-space-2);
}
.twc-card-title { margin: 0; font-weight: 650; }
.twc-note { margin: 0; font-size: 0.8125rem; color: var(--cx-text-3); }
.twc-card dl { display: grid; grid-template-columns: auto 1fr; gap: var(--cx-space-1) var(--cx-space-3); margin: 0; font-size: 0.875rem; }
.twc-card dt { color: var(--cx-text-3); }
.twc-card dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.twc-chips, .twc-row { display: flex; flex-wrap: wrap; gap: var(--cx-space-2); }
.twc-chip, .twc-btn {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: var(--cx-space-2) var(--cx-space-3);
  border: 1px solid var(--cx-border-strong);
  border-radius: var(--cx-radius-pill);
  background: var(--cx-surface);
  color: var(--cx-text);
  font: 550 0.875rem/1.25 var(--cx-font);
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}
@media (hover: hover) { .twc-chip:hover, .twc-btn:hover { background: var(--cx-hover); } }
.twc-btn-primary { background: var(--cx-action); border-color: var(--cx-action); color: var(--cx-action-ink); }
@media (hover: hover) { .twc-btn-primary:hover { background: var(--cx-action-hover); } }
.twc-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cx-space-2);
  padding: var(--cx-space-3);
  border-radius: var(--cx-radius);
  background: var(--cx-danger-soft);
  color: var(--cx-danger-text);
}
.twc-status { min-height: 1.25em; margin: 0; padding: 0 var(--cx-space-4); font-size: 0.8125rem; color: var(--cx-text-3); }

/* ---------- next step, composer, footnote ---------- */
.twc-next {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cx-space-2);
  flex: none;
  padding: var(--cx-space-2) var(--cx-space-4);
  border-top: 1px solid var(--cx-border);
}
.twc-form {
  display: flex;
  align-items: flex-end;
  gap: var(--cx-space-2);
  flex: none;
  padding: var(--cx-space-2) var(--cx-space-4);
}
.twc-form textarea {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 132px;
  padding: var(--cx-space-2) var(--cx-space-3);
  border: 1px solid var(--cx-border-strong);
  border-radius: var(--cx-radius);
  background: var(--cx-input);
  color: var(--cx-text);
  font: 400 1rem/1.4 var(--cx-font); /* 16 px: iOS does not zoom the page */
  resize: none;
}
.twc-send {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--cx-radius-pill);
  background: var(--cx-action);
  color: var(--cx-action-ink);
  font: 700 1.125rem/1 var(--cx-font);
  cursor: pointer;
}
.twc-send[hidden] { display: none; }
.twc-send:disabled { background: var(--cx-control); color: var(--cx-text-disabled); cursor: not-allowed; }
.twc-foot { flex: none; margin: 0; padding: 0 var(--cx-space-4) var(--cx-space-3); font-size: 0.75rem; color: var(--cx-text-3); }
.twc-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- compact: a bottom sheet ---------- */
@media (max-width: 640px) {
  .twc-launcher {
    right: max(var(--cx-space-3), env(safe-area-inset-right));
    bottom: max(var(--cx-space-3), env(safe-area-inset-bottom));
  }
  .twc {
    inset: auto 0 0 0;
    width: 100%;
    height: min(88dvh, 720px); /* the sheet leaves the page visible above it */
    border-width: 1px 0 0;
    border-radius: var(--cx-radius-lg) var(--cx-radius-lg) 0 0;
  }
  .twc-foot { padding-bottom: max(var(--cx-space-3), env(safe-area-inset-bottom)); }
  .twc-chip, .twc-btn { min-height: 44px; }
}

@media (prefers-reduced-motion: no-preference) {
  .twc[open] { animation: twc-in var(--cx-fast) var(--cx-ease); }
}
@keyframes twc-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
