/* FastTrack chat bubble. House style only: square corners, 1px rules, navy accent,
   cyan as a mark and never as a fill. Tokens are redeclared here rather than
   inherited so the widget renders correctly on any page it is later gated onto. */

.ftc {
  --ftc-bg: oklch(0.985 0.003 258);
  --ftc-soft: oklch(0.97 0.004 258);
  --ftc-ink: oklch(0.14 0.012 258);
  --ftc-ink-soft: oklch(0.22 0.012 258);
  --ftc-muted: oklch(0.46 0.012 258);
  --ftc-muted-soft: oklch(0.62 0.008 258);
  --ftc-line: oklch(0.90 0.005 258);
  --ftc-line-soft: oklch(0.94 0.004 258);
  --ftc-accent: oklch(0.28 0.06 258);
  --ftc-accent-hover: oklch(0.22 0.07 258);
  --ftc-cyan: #00d0ff;
  --ftc-focus: oklch(0.55 0.18 258);
  --ftc-ease: cubic-bezier(0.23, 1, 0.32, 1);
  --ftc-serif: 'Source Serif 4', 'Source Serif Pro', Georgia, serif;
  --ftc-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --ftc-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --ftc-shadow: 0 12px 30px -14px oklch(0.14 0.012 258 / 0.55);

  /* Bottom offset. 20px on desktop, 20px plus the iOS home indicator on phones.
     Measured against the play disc and both fork CTAs at 375x812 and 393x852. */
  --ftc-gap: 20px;
}

/* ---------- launcher ---------- */

.ftc-bubble {
  position: fixed;
  right: var(--ftc-gap);
  bottom: calc(var(--ftc-gap) + env(safe-area-inset-bottom, 0px));
  z-index: 2147483000;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--ftc-accent);
  color: #fff;
  border: 1px solid var(--ftc-accent);
  border-radius: 0;
  cursor: pointer;
  box-shadow: var(--ftc-shadow);
  /* The launcher never changes position. It recedes in place when it crosses one of
     the page CTAs, so the two scale factors compose: the recede and the press. */
  transform-origin: 50% 50%;
  transform: scale(var(--ftc-recede, 1)) scale(var(--ftc-press, 1));
  transition: background 180ms var(--ftc-ease), transform 200ms var(--ftc-ease),
    opacity 200ms var(--ftc-ease);
}

@media (hover: hover) and (pointer: fine) {
  .ftc-bubble:hover { background: var(--ftc-accent-hover); }
}

.ftc-bubble:active { --ftc-press: 0.97; transition-duration: 80ms; }
.ftc-bubble:focus-visible { outline: 2px solid var(--ftc-focus); outline-offset: 4px; }
.ftc-bubble svg { width: 24px; height: 24px; display: block; }

/* The one circle the system allows here, alongside play discs and radio checks. */
.ftc-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ftc-cyan);
  opacity: 0;
  transition: opacity 200ms var(--ftc-ease);
}

.ftc-bubble[data-unread='1'] .ftc-dot { opacity: 1; }
.ftc[data-open='1'] .ftc-bubble { display: none; }


/* ---------- attention, until first open ---------- */

/* backwards, not both: with `both` the last keyframe stays applied for good and
   pins transform and opacity, which is exactly what the recede below needs to set. */
.ftc-bubble { animation: ftc-in 600ms var(--ftc-ease) backwards; animation-delay: 400ms; }

/* A square ring that grows out of the launcher every few seconds. Square, like
   every other edge on the site. Stops for good once the chat has been opened. */
.ftc-bubble::after {
  content: '';
  position: absolute;
  inset: -1px;
  border: 1px solid var(--ftc-cyan);
  opacity: 0;
  pointer-events: none;
}
.ftc-bubble::before {
  content: '';
  position: absolute;
  inset: -1px;
  border: 2px solid var(--ftc-cyan);
  opacity: 0;
  pointer-events: none;
}
/* Two rings on the same cycle, the second half a beat behind, so the launcher
   reads as pulsing rather than blinking once. Both stop after the first open. */
.ftc[data-seen='0'] .ftc-bubble::after  { animation: ftc-ring 2600ms ease-out 1200ms infinite; }
.ftc[data-seen='0'] .ftc-bubble::before { animation: ftc-ring 2600ms ease-out 1560ms infinite; }
/* One attention device at a time: while the label is out, the ring rests. */
.ftc[data-hint='1'] .ftc-bubble::after,
.ftc[data-hint='1'] .ftc-bubble::before { animation: none; }

/* The label to the left of the launcher. Appears after a few seconds, recedes with
   the launcher when it crosses a CTA, withdraws on its own after eight seconds and
   never comes back after first open. */
.ftc-hint {
  position: fixed;
  right: calc(var(--ftc-gap) + 55px);
  bottom: calc(var(--ftc-gap) + env(safe-area-inset-bottom, 0px));
  z-index: 2147483000;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  /* Same navy plate as the launcher, borders overlapping by 1px, so the two read
     as one deliberate object sitting on the page rather than as a label box
     punched into whatever paragraph happens to be underneath. */
  background: var(--ftc-accent);
  border: 1px solid var(--ftc-accent);
  color: #fff;
  box-shadow: var(--ftc-shadow);
  font-family: var(--ftc-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 320ms var(--ftc-ease), transform 320ms var(--ftc-ease);
  pointer-events: none;
}
.ftc[data-hint='1'][data-open='0'] .ftc-hint { opacity: 1; transform: none; pointer-events: auto; }

@keyframes ftc-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
/* One 700ms expansion, then two and a half seconds of nothing. A ring that
   lingers across the whole 3.2s cycle reads as pleading. */
@keyframes ftc-ring {
  0%   { opacity: 0.95; transform: scale(1); }
  55%  { opacity: 0; transform: scale(1.75); }
  100% { opacity: 0; transform: scale(1.75); }
}

@keyframes ftc-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .ftc-bubble, .ftc-bubble::after, .ftc-bubble::before { animation: none !important; }
  .ftc-hint { transition: none; }
}

/* ---------- panel ---------- */

.ftc-panel {
  position: fixed;
  right: var(--ftc-gap);
  bottom: calc(var(--ftc-gap) + env(safe-area-inset-bottom, 0px));
  z-index: 2147483001;
  width: 380px;
  height: 560px;
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--ftc-bg);
  border: 1px solid var(--ftc-line);
  border-radius: 0;
  box-shadow: 0 26px 64px -30px oklch(0.14 0.012 258 / 0.6);
  font-family: var(--ftc-sans);
  color: var(--ftc-ink);
  font-size: 15px;
  line-height: 1.55;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 240ms var(--ftc-ease), transform 240ms var(--ftc-ease);
}

.ftc[data-open='1'] .ftc-panel {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.ftc-panel[hidden] { display: none; }

.ftc-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  /* 10px + the 44px close control + 10px = a 64px bar. The close target sets the
     height, so the padding is as tight as it can go without shrinking it. */
  padding: 10px 8px 10px 18px;
  border-bottom: 1px solid var(--ftc-line);
  background: var(--ftc-soft);
}

.ftc-title {
  font-family: var(--ftc-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ftc-muted);
  margin: 0;
}

.ftc-close {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  border-radius: 0;
  color: var(--ftc-ink);
  cursor: pointer;
}

.ftc-close:focus-visible { outline: 2px solid var(--ftc-focus); outline-offset: -2px; }
.ftc-close svg { width: 18px; height: 18px; display: block; }

.ftc-thread {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 18px 18px 14px;
  display: flex;
  flex-direction: column;
  /* An answer belongs to the question above it, so the base gap is close. The
     turn break is put back by the margin on the visitor's own message below. */
  gap: 10px;
}

/* The empty state is one block: the greeting with the starters directly under it,
   both sitting under the header where the eye lands when the sheet opens. The
   spare room on a tall phone falls below them, in the direction the conversation
   will grow, rather than being split between a greeting at the top and chips
   docked at the bottom with a hole in between. */
.ftc-intro + .ftc-chips { margin-top: 4px; }

.ftc-msg { max-width: 100%; animation: ftc-rise 200ms var(--ftc-ease) both; }
.ftc-msg p { margin: 0 0 10px; white-space: pre-wrap; }
.ftc-msg p:last-child, .ftc-msg ul:last-child { margin-bottom: 0; }
.ftc-list { margin: 8px 0 10px; padding: 0; list-style: none; }
.ftc-list li { position: relative; padding-left: 14px; margin: 0 0 8px; }
.ftc-list li::before { content: ''; position: absolute; left: 0; top: 0.62em; width: 6px; height: 1px; background: var(--ftc-cyan); }
.ftc-list li:last-child { margin-bottom: 0; }
.ftc-msg strong { font-weight: 600; color: var(--ftc-ink); }

.ftc-msg-a { color: var(--ftc-ink-soft); }

.ftc-msg-u {
  align-self: flex-end;
  max-width: 86%;
  /* the turn break: 10px gap plus this, so a new question starts a new group */
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--ftc-soft);
  border: 1px solid var(--ftc-line);
  color: var(--ftc-ink);
}

/* Stamped once, on the first reply. chat.js adds .ftc-vh to every later one, so
   the speaker still reaches a screen reader on every turn. */
.ftc-from {
  display: block;
  font-family: var(--ftc-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ftc-muted);
  margin-bottom: 6px;
}

/* caret while a reply streams */
.ftc-caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.12em;
  background: var(--ftc-cyan);
  animation: ftc-blink 900ms steps(2, start) infinite;
}

@keyframes ftc-blink { 50% { opacity: 0; } }

/* three marks while the model thinks, replaced by the text on the first token */
.ftc-think {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 12px;
  padding-top: 6px;
}

.ftc-think .ftc-mark {
  display: block;
  width: 11px;
  height: 2px;
  background: var(--ftc-cyan);
  opacity: 0.4;
  transform-origin: 50% 100%;
  animation: ftc-step 1080ms steps(1, end) infinite;
}

.ftc-think .ftc-mark:nth-child(2) { animation-delay: 180ms; }
.ftc-think .ftc-mark:nth-child(3) { animation-delay: 360ms; }

/* steps(), so the marks click over rather than breathe */
@keyframes ftc-step {
  0%   { opacity: 1; transform: scaleY(4); }
  33%  { opacity: 0.4; transform: scaleY(1); }
  100% { opacity: 0.4; transform: scaleY(1); }
}

.ftc-vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.ftc-error {
  font-size: 13.5px;
  color: #c0392b;
  border-top: 1px solid var(--ftc-line-soft);
  padding-top: 10px;
}

/* ---------- starter chips ---------- */

.ftc-chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 2px;
}

.ftc-chip {
  animation: ftc-rise 200ms var(--ftc-ease) both;
  min-height: 44px;
  padding: 11px 14px;
  text-align: left;
  font-family: var(--ftc-sans);
  font-size: 15px;
  line-height: 1.4;
  color: var(--ftc-ink);
  background: var(--ftc-bg);
  border: 1px solid var(--ftc-line);
  border-radius: 0;
  cursor: pointer;
  transition: border-color 160ms var(--ftc-ease);
}

@media (hover: hover) and (pointer: fine) {
  .ftc-chip:hover { border-color: var(--ftc-ink-soft); }
}

.ftc-chip:focus-visible { outline: 2px solid var(--ftc-focus); outline-offset: 2px; }

.ftc-chip:nth-child(1) { animation-delay: 80ms; }
.ftc-chip:nth-child(2) { animation-delay: 140ms; }
.ftc-chip:nth-child(3) { animation-delay: 200ms; }
.ftc-chip:nth-child(4) { animation-delay: 260ms; }

/* ---------- next-step card ---------- */
/* One component for all five cards: the four that send the visitor somewhere,
   and the follow-up request. Square corners, 1px rules, navy button, cyan only
   as the short mark on the label. */

.ftc-card {
  animation: ftc-rise 200ms var(--ftc-ease) both;
  /* Bled out to the panel edge so the two rules run the full width of the sheet.
     It reads as a band, the way a ruled section does on the site, rather than as
     one more paragraph with lines around it. */
  margin: 6px -18px 0;
  border-top: 1px solid var(--ftc-line);
  border-bottom: 1px solid var(--ftc-line);
  background: var(--ftc-soft);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ftc-card-label {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ftc-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ftc-muted);
}

/* the one cyan mark on the card */
.ftc-card-label::before {
  content: '';
  flex: none;
  width: 14px;
  height: 1px;
  background: var(--ftc-cyan);
}

/* The h3 role from the design system, 22/1.3/500, stepped down one to sit inside a
   380px panel. A clear step above the 15px sans body, which is what makes the card
   read as its own block without raising its voice. */
.ftc-card-line {
  margin: 0;
  font-family: var(--ftc-serif);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.012em;
  color: var(--ftc-ink);
}

.ftc-card input,
.ftc-card textarea {
  width: 100%;
  min-width: 0;
  min-height: 54px;
  padding: 15px 16px;
  font-family: var(--ftc-sans);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ftc-ink);
  background: var(--ftc-bg);
  border: 1px solid var(--ftc-line);
  border-radius: 0;
}

.ftc-card textarea {
  /* one line to start with, grown by chat.js as it is typed into */
  min-height: 54px;
  /* four lines plus the padding. chat.js caps the inline height at the same
     118px, so the field and its box stop at the same place. */
  max-height: 118px;
  resize: none;
  overflow-y: auto;
}

.ftc-card input::placeholder,
.ftc-card textarea::placeholder { color: var(--ftc-muted-soft); }
.ftc-card input:focus,
.ftc-card textarea:focus { outline: none; border-color: var(--ftc-ink); }
.ftc-card input[aria-invalid='true'] { border-color: #c0392b; }

.ftc-consent {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ftc-muted);
}

.ftc-card-btn {
  width: 100%;
  min-height: 54px;
  padding: 14px 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  font-family: var(--ftc-sans);
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  background: var(--ftc-accent);
  border: 1px solid var(--ftc-accent);
  border-radius: 0;
  cursor: pointer;
  text-decoration: none;
  transition: background 180ms var(--ftc-ease), transform 120ms var(--ftc-ease);
}

@media (hover: hover) and (pointer: fine) {
  .ftc-card-btn:hover { background: var(--ftc-accent-hover); }
}

.ftc-card-btn:active:not([disabled]) { transform: scale(0.985); transition-duration: 80ms; }
.ftc-card-btn:focus-visible { outline: 2px solid var(--ftc-focus); outline-offset: 3px; }
.ftc-card-btn[disabled] { opacity: 0.35; cursor: not-allowed; }
.ftc-card-btn .ftc-arrow { font-family: var(--ftc-mono); }

/* ---------- composer ---------- */

.ftc-composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 0;
  border-top: 1px solid var(--ftc-line);
  background: var(--ftc-bg);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transition: border-color 160ms var(--ftc-ease);
}

/* The field has no border of its own, so the composer rule is the focus state: a
   textarea with outline:none and nothing else leaves a keyboard user with no idea
   where they are. */
.ftc-composer:focus-within { border-top-color: var(--ftc-ink); }

.ftc-composer textarea {
  flex: 1 1 auto;
  min-height: 54px;
  /* four lines at 16px/1.4 plus the 16px padding. chat.js caps the inline
     height at the same 122px, so the two never disagree. */
  max-height: 122px;
  resize: none;
  padding: 16px;
  font-family: var(--ftc-sans);
  font-size: 16px;
  line-height: 1.4;
  color: var(--ftc-ink);
  background: transparent;
  border: 0;
  border-radius: 0;
}

.ftc-composer textarea::placeholder { color: var(--ftc-muted-soft); }
.ftc-composer textarea:focus { outline: none; }

.ftc-send {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ftc-accent);
  color: #fff;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  transition: background 180ms var(--ftc-ease), transform 120ms var(--ftc-ease);
}

@media (hover: hover) and (pointer: fine) {
  .ftc-send:hover { background: var(--ftc-accent-hover); }
}

.ftc-send:active:not([disabled]) {
  background: var(--ftc-accent-hover);
  transform: scale(0.94);
  transition-duration: 80ms;
}

.ftc-send:focus-visible { outline: 2px solid var(--ftc-focus); outline-offset: -3px; }
.ftc-send[disabled] { opacity: 0.35; cursor: not-allowed; }
.ftc-send svg { width: 18px; height: 18px; display: block; }

/* ---------- phone: full height sheet ---------- */

@media (max-width: 599px) {
  .ftc-panel {
    right: 0;
    bottom: 0;
    left: 0;
    top: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-left: 0;
    border-right: 0;
    border-top: 0;
    /* visualViewport keeps the composer above the iOS keyboard: chat.js writes
       --ftc-kb, which is the height the keyboard is covering. */
    padding-bottom: var(--ftc-kb, 0px);
    /* a sheet, so it comes up from the edge it is attached to */
    opacity: 1;
    transform: translateY(100%);
    transition: transform 360ms var(--ftc-ease);
  }

  .ftc[data-open='1'] .ftc-panel { transform: none; }
  .ftc-thread { padding: 16px 20px 14px; }
  .ftc-head { padding: 8px 8px 8px 20px; }
  .ftc-card { margin-left: -20px; margin-right: -20px; padding-left: 20px; padding-right: 20px; }
  .ftc-composer { padding-bottom: max(env(safe-area-inset-bottom, 0px), 0px); }
}

@media (prefers-reduced-motion: reduce) {
  .ftc-panel,
  .ftc-bubble,
  .ftc-msg,
  .ftc-chip,
  .ftc-card,
  .ftc-card-btn,
  .ftc-send {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
  }

  /* these two loop forever, so zero them out rather than run them at 0.01ms */
  .ftc-caret { animation: none !important; opacity: 1; }
  .ftc-think .ftc-mark { animation: none !important; opacity: 1; }
}
