/* The Talk to us sheet (phone), panel (desktop) and page (/agent).
   Colours come only from tokens.css. */

.talk {
  display: flex;
  flex-direction: column;
  min-height: 0;
  color: var(--fg);
  background: var(--surface);
  font-size: var(--t-body);
}
.talk[hidden], .talk-scrim[hidden], .talk [hidden] { display: none !important; }

/* ---- phone: a bottom sheet ---- */
.talk--sheet {
  position: fixed;
  z-index: 40;
  left: 0;
  right: 0;
  bottom: var(--talk-kb, 0px);
  /* as tall as its contents, up to 86svh: an empty sheet is only the
     intro, the chips, the field and the privacy line */
  max-height: min(86svh, calc(var(--talk-vh, 100svh) - 8px));
  padding: var(--s2) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-float);
  translate: 0 100%;
  transition: translate var(--dur-base) var(--ease-exit);
  overscroll-behavior: contain;
}
.talk--sheet.is-open { translate: 0 0; transition: translate var(--dur-sheet) var(--ease-out); }
.talk--sheet.is-dragging { transition: none; }
.talk-scrim {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: var(--scrim-sheet);
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-exit);
}
.talk-scrim.is-open { opacity: 1; transition: opacity var(--dur-sheet) var(--ease-out); }
html.talk-locked { overflow: hidden; }
/* the header stays above the scrim, undimmed */
html.talk-locked .top { z-index: 41; }

.talk-grab {
  flex: none;
  width: 36px;
  height: 4px;
  margin: 0 auto var(--s2);
  border-radius: var(--r-pill);
  background: var(--line-strong);
}
.talk--sheet .talk-grab, .talk--sheet .talk-head { touch-action: none; cursor: grab; }

/* ---- the head: the cycling phrase and the close button ---- */
.talk-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.talk-title { flex: 1; min-width: 0; margin: 0; font: 600 1.5rem/1.3 var(--display); letter-spacing: -0.02em; }
.talk-title .cycle-words { height: 1.3em; font: inherit; line-height: 1.3; }
.talk-title:focus { outline: none; }
.talk-still { display: none; }
.talk-intro { flex: none; margin-top: var(--s1); font-size: 0.9375rem; line-height: 1.4; color: var(--fg-2); max-width: 40ch; }

/* ---- the thread ---- */
.talk-body { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: var(--s3) calc(var(--s4) * -1) 0; padding: var(--s2) var(--s4) var(--s4); }
.talk--sheet.talk-empty .talk-body { margin-top: 0; padding-block: 0; }
.talk-thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s3); }
.talk-msg { font-size: 0.9375rem; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; }
.talk-me {
  align-self: flex-end;
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 18px 18px 6px 18px;
  background: var(--fg);
  color: var(--bg);
}
.talk-me.talk-unsent { opacity: 0.55; }
.talk-us { align-self: flex-start; max-width: 92%; }
.talk-us a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.talk-note { align-self: flex-start; font-size: var(--t-small); color: var(--fg-2); }
.talk-error { color: var(--accent-text); }
.talk-sentmark::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--accent); vertical-align: 0.1em; }
.talk-retry {
  font: 600 var(--t-small)/1 var(--text);
  color: var(--fg);
  background: none;
  border: 0;
  padding: 4px 0;
  margin-left: 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* three 4px dots while we compose */
.talk-dots { align-self: flex-start; display: flex; gap: 5px; padding: 8px 0; }
.talk-dots > span:not(.sr-only) { width: 4px; height: 4px; border-radius: 50%; background: var(--fg-2); animation: talk-breathe 1.2s var(--ease-in-out) infinite both; }
.talk-dots > span:nth-child(2) { animation-delay: 0.16s; }
.talk-dots > span:nth-child(3) { animation-delay: 0.32s; }
@keyframes talk-breathe { 0%, 70%, 100% { opacity: 0.25; } 35% { opacity: 1; } }

/* ---- chips and the composer ---- */
.talk-chips { flex: none; display: flex; flex-wrap: wrap; gap: var(--s2); padding-top: var(--s3); }
.talk-chip {
  font: 500 var(--t-small)/1 var(--text);
  color: var(--fg);
  background: transparent;
  border: 0;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  cursor: pointer;
  transition: box-shadow var(--dur-quick) var(--ease-out), scale var(--dur-press) var(--ease-out);
}
.talk-chip:active { scale: 0.97; }
.talk-chip-yes { background: var(--accent); color: var(--on-accent); box-shadow: none; font-weight: 600; }
@media (hover: hover) { .talk-chip:not(.talk-chip-yes):hover { box-shadow: inset 0 0 0 1px var(--fg-2); } }
.talk-compose { flex: none; margin-top: var(--s3); background: var(--bg); }
.talk-compose .btn:disabled { opacity: 0.55; cursor: default; }
.talk-fine { flex: none; margin-top: var(--s2); font-size: var(--t-fine); line-height: 1.4; color: var(--fg-2); }
.talk-fine a { color: inherit; text-underline-offset: 3px; }

/* ---- the details form and the fallback form ---- */
.talk-details, .talk-fallback { margin-top: var(--s4); }
.talk-details, .talk-fb-form { display: grid; gap: var(--s3); }
.talk-details { padding-top: var(--s4); border-top: 1px solid var(--line); }
.talk-in { display: grid; gap: 6px; }
.talk-in label { font: 600 var(--t-label)/1.2 var(--text); color: var(--fg-2); }
.talk-in input, .talk-in textarea {
  width: 100%;
  font: 400 1rem/1.4 var(--text);
  color: var(--fg);
  background: var(--bg);
  border: 0;
  border-radius: var(--r-pill);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  height: 44px;
  padding: 0 16px;
  outline: none;
}
.talk-in textarea { height: auto; min-height: 104px; padding: 10px 16px; border-radius: var(--r-surface); resize: vertical; }
.talk-in input:focus-visible, .talk-in textarea:focus-visible { box-shadow: inset 0 0 0 1.5px var(--fg-2); outline: 2px solid var(--accent-text); outline-offset: 2px; }
.talk-in [aria-invalid="true"] { box-shadow: inset 0 0 0 1.5px var(--accent-text); }
.talk-err { font-size: var(--t-small); color: var(--accent-text); }
.talk-hint { font-size: var(--t-small); color: var(--fg-2); }
.talk-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
.talk-fb-lead { margin-bottom: var(--s4); font-size: 0.9375rem; line-height: 1.45; }
.talk-fb-done { font-size: 0.9375rem; line-height: 1.45; }
.talk-fb-done a { color: var(--accent-text); text-underline-offset: 3px; }
.talk-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ---- desktop: a panel beside the page ---- */
@media (min-width: 1100px) {
  .talk--sheet {
    left: auto;
    right: 16px;
    top: 88px;
    bottom: 16px;
    width: 440px;
    height: auto;
    max-height: none;
    padding: var(--s5);
    border-radius: var(--r-surface);
    translate: 24px 0;
    opacity: 0;
    transition: translate var(--dur-quick) var(--ease-exit), opacity var(--dur-quick) var(--ease-exit);
  }
  .talk--sheet.is-open { translate: 0 0; opacity: 1; transition: translate var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out); }
  .talk--sheet .talk-grab { display: none; }
  .talk--sheet .talk-head { touch-action: auto; cursor: auto; }
  .talk--sheet .talk-body { flex: 1 1 auto; }
  .talk-body { margin: var(--s4) calc(var(--s5) * -1) 0; padding: var(--s2) var(--s5) var(--s4); }
  /* the phrase holds on "Talk to us" while the panel is open */
  .talk--sheet .talk-cycle { display: none; }
  .talk--sheet .talk-still { display: inline; }
}

/* ---- /agent: the same contents in the page ---- */
.talk--page {
  max-width: 44rem;
  margin: 0 auto;
  height: calc(100svh - 56px);
  padding: var(--s5) var(--gutter) var(--s4);
  background: transparent;
}
.talk--page .talk-body { flex: 1 1 auto; }
.talk--page .talk-compose { background: var(--surface); }
.talk--page .talk-title { font-size: var(--t-h2); }
@media (min-width: 1100px) { .talk--page { height: calc(100svh - 72px); } }

/* ---- low motion: a 200ms fade, no slide, no blur ---- */
:root[data-motion="low"] .talk--sheet,
:root[data-motion="low"] .talk-scrim { translate: none; opacity: 0; transition: opacity 200ms linear; }
:root[data-motion="low"] .talk--sheet.is-open,
:root[data-motion="low"] .talk-scrim.is-open { opacity: 1; transition: opacity 200ms linear; }
:root[data-motion="low"] .talk-dots > span:not(.sr-only) { animation-duration: 2.4s; }
@media (prefers-reduced-motion: reduce) {
  .talk--sheet, .talk-scrim { translate: none; opacity: 0; transition: opacity 200ms linear; }
  .talk--sheet.is-open, .talk-scrim.is-open { opacity: 1; transition: opacity 200ms linear; }
  .talk-chip:active { scale: none; }
}
