/* ==========================================================================
   Financial Superhero — chat-widget.css
   Self-contained styles for the site chat assistant. No dependencies:
   carries its own tokens (--fsc-*) and font-face so it renders identically
   on the rebuilt pages and the legacy theme pages. All selectors are
   namespaced under .fsc-root.
   ========================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/site/inter-latin-400-700.woff2") format("woff2");
}

.fsc-root {
  /* tokens (mirror of the site design system, scoped) */
  --fsc-blue-50:  #eff7fc;
  --fsc-blue-100: #d8ecf8;
  --fsc-blue-500: #0088cc;
  --fsc-blue-600: #0074ae;
  --fsc-blue-700: #005e8e;
  --fsc-navy:     #0a2536;
  --fsc-amber:    #f5a623;
  --fsc-amber-hi: #ffbe4d;
  --fsc-ink:      #10293b;
  --fsc-body:     #3b586d;
  --fsc-line:     #d9e5ee;
  --fsc-line-strong: #7789a0;
  --fsc-wash:     #f2f7fb;
  --fsc-white:    #ffffff;
  --fsc-radius:   16px;
  --fsc-shadow:   0 4px 10px rgba(9, 75, 110, 0.10), 0 24px 56px rgba(9, 75, 110, 0.22);
  --fsc-font: "Inter", "Segoe UI", system-ui, sans-serif;

  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 99990;
  font-family: var(--fsc-font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--fsc-body);
}
.fsc-root *, .fsc-root *::before, .fsc-root *::after { box-sizing: border-box; }

.fsc-root :focus-visible {
  outline: 3px solid var(--fsc-blue-700);
  outline-offset: 2px;
}
.fsc-head :focus-visible,
.fsc-bubble:focus-visible { outline-color: var(--fsc-white); }

/* nudge the page's back-to-top buttons out of the bubble's corner */
html.fsc-active .to-top,
html.fsc-active #scrollUp { bottom: 6.25rem !important; }

/* ---- Bubble ------------------------------------------------------------- */
.fsc-bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.75rem;
  height: 3.75rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(150deg, var(--fsc-blue-500), var(--fsc-blue-700));
  color: var(--fsc-white);
  cursor: pointer;
  box-shadow: var(--fsc-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.fsc-bubble:hover { transform: translateY(-2px); }
.fsc-bubble svg { width: 1.75rem; height: 1.75rem; }
.fsc-bubble .fsc-ic-close { display: none; }
.fsc-root.is-open .fsc-bubble .fsc-ic-chat { display: none; }
.fsc-root.is-open .fsc-bubble .fsc-ic-close { display: block; }

/* ---- Panel ---------------------------------------------------------------- */
.fsc-panel {
  position: absolute;
  right: 0;
  bottom: 4.75rem;
  width: min(24rem, calc(100vw - 2.5rem));
  height: min(38rem, calc(100dvh - 7.5rem));
  display: flex;
  flex-direction: column;
  background: var(--fsc-white);
  border: 1px solid var(--fsc-line);
  border-radius: var(--fsc-radius);
  box-shadow: var(--fsc-shadow);
  overflow: hidden;
}
.fsc-panel[hidden] { display: none; }

@media (max-width: 480px) {
  .fsc-root { right: 0.75rem; bottom: 0.75rem; }
  .fsc-panel {
    position: fixed;
    inset: 0.75rem;
    width: auto;
    height: auto;
    bottom: 5.25rem;
  }
}

/* ---- Header ----------------------------------------------------------------- */
.fsc-head {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1rem;
  background: var(--fsc-navy);
  color: var(--fsc-white);
  flex-shrink: 0;
}
.fsc-head-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--fsc-amber-hi);
  flex-shrink: 0;
}
.fsc-head-icon svg { width: 1.2rem; height: 1.2rem; }
.fsc-head-titles { flex: 1; min-width: 0; }
.fsc-head-title {
  display: block;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.25;
}
.fsc-head-sub {
  display: block;
  font-size: 12px;
  color: var(--fsc-blue-100);
}
.fsc-head-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--fsc-white);
  cursor: pointer;
}
.fsc-head-btn:hover { background: rgba(255, 255, 255, 0.14); }
.fsc-head-btn svg { width: 1.1rem; height: 1.1rem; }

/* ---- Disclaimer (persistent) --------------------------------------------------- */
.fsc-disclaimer {
  padding: 0.5rem 1rem;
  background: var(--fsc-wash);
  border-bottom: 1px solid var(--fsc-line);
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--fsc-body);
  flex-shrink: 0;
}
.fsc-disclaimer a { color: var(--fsc-blue-700); }

/* ---- Transcript -------------------------------------------------------------------- */
.fsc-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.fsc-msg {
  max-width: 85%;
  padding: 0.625rem 0.875rem;
  border-radius: 14px;
  white-space: pre-line;
  overflow-wrap: break-word;
}
.fsc-msg a { color: inherit; font-weight: 600; }
.fsc-msg-bot {
  align-self: flex-start;
  background: var(--fsc-blue-50);
  color: var(--fsc-ink);
  border-bottom-left-radius: 4px;
}
.fsc-msg-bot a { color: var(--fsc-blue-700); }
.fsc-msg-user {
  align-self: flex-end;
  background: var(--fsc-blue-600);
  color: var(--fsc-white);
  border-bottom-right-radius: 4px;
}
.fsc-msg-error {
  align-self: center;
  background: #fdecec;
  color: #8c2f2f;
  font-size: 13px;
  border-radius: 10px;
}

/* typing indicator */
.fsc-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 0.3rem;
  padding: 0.8rem 0.95rem;
  background: var(--fsc-blue-50);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.fsc-typing i {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: var(--fsc-blue-600);
  opacity: 0.4;
  animation: fscTyping 1.2s ease-in-out infinite;
}
.fsc-typing i:nth-child(2) { animation-delay: 0.18s; }
.fsc-typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes fscTyping {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ---- Quick replies ------------------------------------------------------------------- */
.fsc-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1rem 0.625rem;
  flex-shrink: 0;
}
.fsc-quick[hidden] { display: none; }
.fsc-quick button {
  font-family: var(--fsc-font);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fsc-blue-700);
  background: var(--fsc-white);
  border: 1.5px solid var(--fsc-line-strong);
  border-radius: 999px;
  padding: 0.375rem 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.fsc-quick button:hover { border-color: var(--fsc-blue-500); background: var(--fsc-blue-50); }

/* ---- Offline / status ------------------------------------------------------------------ */
.fsc-status {
  padding: 0.5rem 1rem;
  background: #fff7e6;
  border-top: 1px solid #f0dcb0;
  color: #7a5a12;
  font-size: 12.5px;
  flex-shrink: 0;
}
.fsc-status[hidden] { display: none; }

/* ---- Input row ---------------------------------------------------------------------------- */
.fsc-inputrow {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--fsc-line);
  background: var(--fsc-white);
  flex-shrink: 0;
}
.fsc-input {
  flex: 1;
  min-width: 0;
  font-family: var(--fsc-font);
  font-size: 15px;
  color: var(--fsc-ink);
  background: var(--fsc-white);
  border: 1.5px solid var(--fsc-line-strong);
  border-radius: 999px;
  padding: 0.55rem 1rem;
}
.fsc-input:focus { border-color: var(--fsc-blue-500); outline: none; }
.fsc-input:disabled { background: var(--fsc-wash); }
.fsc-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 999px;
  background: var(--fsc-amber);
  color: var(--fsc-navy);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}
.fsc-send:hover { background: var(--fsc-amber-hi); }
.fsc-send:disabled { background: var(--fsc-line); cursor: default; }
.fsc-send svg { width: 1.2rem; height: 1.2rem; }

/* sr-only live region */
.fsc-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Motion ---------------------------------------------------------------------------------- */
.fsc-panel { transform-origin: bottom right; }
@media (prefers-reduced-motion: no-preference) {
  .fsc-panel { animation: fscPop 0.22s ease; }
  @keyframes fscPop {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: none; }
  }
}
@media (prefers-reduced-motion: reduce) {
  .fsc-typing i { animation: none; opacity: 0.7; }
  .fsc-log { scroll-behavior: auto; }
}

/* ---- Attention: teaser pill (intro + hover tooltip) + bubble jiggle ------ */
.fsc-teaser {
  position: absolute;
  right: 4.5rem;
  bottom: 0.55rem;
  white-space: nowrap;
  font-family: var(--fsc-font);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fsc-ink);
  background: var(--fsc-white);
  border: 1px solid var(--fsc-line);
  border-radius: 999px;
  padding: 9.6px 16px;              /* px: immune to browser text scaling */
  max-width: calc(100vw - 88px);    /* never reach past the left edge */
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: var(--fsc-shadow);
  cursor: pointer;
  /* hidden by default; shown during the intro tease AND whenever the closed
     bubble is hovered or keyboard-focused */
  opacity: 0;
  pointer-events: none;
  transform: translateX(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.fsc-root.is-teasing .fsc-teaser,
.fsc-root:not(.is-open) .fsc-bubble:hover ~ .fsc-teaser,
.fsc-root:not(.is-open) .fsc-bubble:focus-visible ~ .fsc-teaser,
.fsc-root:not(.is-open) .fsc-teaser:hover {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}
.fsc-root.is-open .fsc-teaser { opacity: 0; pointer-events: none; }
/* The teaser is a fixed-width nowrap pill anchored to the right; on a Fold
   cover screen it ran off the left edge. The bubble itself still shows. */
@media (max-width: 400px) {
  .fsc-teaser { display: none; }
}
.fsc-teaser:hover { border-color: var(--fsc-blue-500); color: var(--fsc-blue-700); }

.fsc-bubble.is-jiggling { animation: fscJiggle 0.9s ease-in-out; }
@keyframes fscJiggle {
  0%, 100% { transform: rotate(0); }
  15% { transform: rotate(-14deg) scale(1.06); }
  30% { transform: rotate(11deg) scale(1.06); }
  45% { transform: rotate(-8deg) scale(1.04); }
  60% { transform: rotate(5deg) scale(1.02); }
  75% { transform: rotate(-2deg); }
}

@media (prefers-reduced-motion: reduce) {
  .fsc-bubble.is-jiggling { animation: none; }
  .fsc-teaser { animation: none; }
}
