/* Texas Foreclosure Answers — home page chat widget (replaces the old iframe helper).
   All classes are namespaced tfa- to avoid collisions with site styles. */

.tfa-widget {
  padding-left: clamp(12px, 2.2vw, 30px);
  --tfa-maroon: #8f1d3c;
  --tfa-maroon-hover: #a72549;
  --tfa-card: #1c1a1f;
  --tfa-bar: #141317;
  --tfa-bot-bubble: #2b2830;
  --tfa-paper: #faf8f6;
  --tfa-ink-light: #f1edea;
  --tfa-ink-dark: #26232a;
  --tfa-muted: #9a93a2;
  --tfa-green: #3fce7c;
  font-family: "DM Sans", system-ui, sans-serif;
}

.tfa-card {
  display: flex;
  flex-direction: column;
  height: 584px;
  background: var(--tfa-card);
  color: var(--tfa-ink-light);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

/* ---- header bar ---- */
.tfa-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--tfa-bar);
  border-bottom: 1px solid #2c2930;
  flex: none;
}
.tfa-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--tfa-green);
  position: relative;
  flex: none;
  animation: tfa-dot 2.2s ease-in-out infinite;
}
.tfa-dot::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--tfa-green);
  opacity: 0;
  animation: tfa-ping 2.2s ease-out infinite;
}
@keyframes tfa-dot { 0%, 100% { transform: scale(0.55); } 50% { transform: scale(1.3); } }
@keyframes tfa-ping { 0% { transform: scale(0.4); opacity: 0.9; } 70% { transform: scale(1.35); opacity: 0; } 100% { opacity: 0; } }
.tfa-title {
  font-family: Oswald, system-ui, sans-serif;
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0.04em;
  color: var(--tfa-ink-light);
}
.tfa-status {
  margin-left: auto;
  font-size: 12px;
  color: #8f8a93;
  white-space: nowrap;
}
.tfa-tts {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #3b3742;
  background: transparent;
  color: #8f8a93;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tfa-tts { animation: tfa-tts-flicker 2s steps(1) infinite; }
@keyframes tfa-tts-flicker {
  0%, 100% { color: #8f8a93; border-color: #3b3742; }
  50% { color: #fff; border-color: #8f8a93; }
}
.tfa-tts:hover { animation: none; color: #fff; border-color: #8f8a93; }
.tfa-tts.tfa-on {
  animation: none;
  background: var(--tfa-maroon);
  border-color: var(--tfa-maroon);
  color: #fff;
}
.tfa-tts[hidden] { display: none; }
.tfa-tts.tfa-down {
  animation: none;
  opacity: 0.45;
  cursor: not-allowed;
  background: transparent;
  border-color: #3b3742;
  color: #5f5a66;
}

/* ---- message feed ---- */
.tfa-feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: #9a93a2 transparent;
}
.tfa-feed::-webkit-scrollbar { width: 8px; }
.tfa-feed::-webkit-scrollbar-track { background: transparent; }
.tfa-feed::-webkit-scrollbar-thumb {
  background: #9a93a2;
  border-radius: 4px;
}
.tfa-feed::-webkit-scrollbar-thumb:hover { background: #c5bfcb; }
.tfa-msg {
  max-width: 84%;
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.45s ease, transform 0.45s ease;
  overflow-wrap: anywhere;
}
.tfa-msg.tfa-show { opacity: 1; transform: none; }
.tfa-msg--user {
  align-self: flex-end;
  background: var(--tfa-maroon);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.tfa-msg--bot {
  align-self: flex-start;
  background: var(--tfa-bot-bubble);
  border-bottom-left-radius: 5px;
}
.tfa-msg .tfa-em {
  color: #d4577c; /* maroon, lightened enough to read on the dark bubble */
  font-weight: 700;
}

/* Long-form agent answers: full-width light "answer blocks", not bubbles */
.tfa-answer {
  align-self: stretch;
  max-width: none;
  background: var(--tfa-paper);
  color: var(--tfa-ink-dark);
  border-radius: 10px;
  padding: 12px 16px 14px;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.45s ease, transform 0.45s ease;
  overflow-wrap: anywhere;
}
.tfa-answer.tfa-show { opacity: 1; transform: none; }
.tfa-answer-label {
  display: block;
  font-family: Oswald, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tfa-maroon);
  margin-bottom: 6px;
  white-space: normal;
}
.tfa-answer--loading {
  color: #6d6660;
  font-style: italic;
  white-space: normal;
}

/* System notes (e.g., route switch) */
.tfa-note {
  align-self: center;
  max-width: 90%;
  text-align: center;
  font-size: 12.5px;
  font-style: italic;
  color: var(--tfa-muted);
}

/* Typing indicator */
.tfa-typing {
  align-self: flex-start;
  background: var(--tfa-bot-bubble);
  border-radius: 16px;
  border-bottom-left-radius: 5px;
  padding: 14px 18px;
  display: none;
  gap: 5px;
}
.tfa-typing.tfa-show { display: flex; }
.tfa-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tfa-muted);
  animation: tfa-bounce 0.9s ease-in-out infinite;
}
.tfa-typing i:nth-child(2) { animation-delay: 0.15s; }
.tfa-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes tfa-bounce { 0%, 100% { transform: translateY(0); opacity: 0.4; } 50% { transform: translateY(-5px); opacity: 1; } }

/* ---- route pick buttons (prelude CTA) ---- */
.tfa-picks {
  display: flex;
  gap: 10px;
  padding: 12px 16px 6px;
  min-height: 54px;
  flex: none;
}
.tfa-pick {
  flex: 1;
  border: 3px solid var(--tfa-maroon);
  border-radius: 10px;
  background: #fff;
  color: var(--tfa-maroon);
  cursor: pointer;
  font-family: Oswald, system-ui, sans-serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.03em;
  padding: 10px;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease, background 0.2s, color 0.2s;
}
.tfa-widget.tfa-show-picks .tfa-pick {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  animation: tfa-pick-flicker 7s steps(1) 0.5s infinite;
}
.tfa-widget.tfa-show-picks .tfa-pick:nth-child(2) { animation-delay: 4s; }
@keyframes tfa-pick-flicker {
  0%, 100% {
    background: #8f1d3c;
    color: #fff;
    box-shadow: 0 0 12px 2px rgba(220, 60, 105, 0.35);
  }
  50% { background: #fff; color: #8f1d3c; box-shadow: none; }
}
.tfa-pick:hover,
.tfa-widget.tfa-show-picks .tfa-pick:hover {
  animation: none;
  background: var(--tfa-maroon);
  color: #fff;
}
@keyframes tfa-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(143, 29, 60, 0); }
  50% { box-shadow: 0 0 14px 2px rgba(220, 60, 105, 0.4); }
}
.tfa-widget.tfa-chat-started .tfa-picks { display: none; }

/* ---- input area (hidden until a route is chosen) ---- */
.tfa-input-area {
  display: none;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 16px 6px;
  flex: none;
}
.tfa-widget.tfa-chat-started .tfa-input-area { display: flex; }
.tfa-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  min-width: 0;
}
.tfa-input {
  width: 100%;
  min-height: 68px;
  max-height: 130px;
  resize: none;
  background: #26232b;
  border: 1px solid #3b3742;
  border-radius: 12px;
  padding: 11px 14px;
  color: var(--tfa-ink-light);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.4;
}
.tfa-input:focus { outline: none; border-color: var(--tfa-maroon); }
.tfa-input-hint {
  position: absolute;
  left: 15px;
  right: 12px;
  top: 11px;
  color: var(--tfa-muted);
  font-size: 15px;
  line-height: 1.4;
  pointer-events: none;
}
.tfa-input-hint svg { vertical-align: -2px; margin: 0 1px; }
.tfa-input-hint.tfa-hide { display: none; }
.tfa-mic {
  flex: none;
  width: 46px;
  height: 46px;
  border: 1px solid #3b3742;
  border-radius: 12px;
  background: #26232b;
  color: var(--tfa-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tfa-mic { animation: tfa-mic-flicker 2s steps(1) infinite; }
@keyframes tfa-mic-flicker {
  0%, 100% { color: #9a93a2; border-color: #3b3742; }
  50% { color: #fff; border-color: #8f1d3c; }
}
.tfa-mic:hover { animation: none; color: #fff; border-color: var(--tfa-maroon); }
.tfa-mic.tfa-listening {
  background: var(--tfa-maroon);
  border-color: var(--tfa-maroon);
  color: #fff;
  animation: tfa-glow 1.4s ease-in-out infinite;
}
.tfa-mic[hidden] { display: none; }
.tfa-send {
  flex: none;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 12px;
  background: var(--tfa-maroon);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tfa-send:hover { background: var(--tfa-maroon-hover); }
.tfa-send:disabled { opacity: 0.55; cursor: default; }

/* ---- expert CTA button under an answer ---- */
.tfa-cta-row {
  margin-top: 12px;
  text-align: center;
  white-space: normal;
}
.tfa-cta {
  display: inline-block;
  border: 0;
  border-radius: 10px;
  background: var(--tfa-maroon);
  color: #fff !important;
  cursor: pointer;
  text-decoration: none;
  font-family: Oswald, system-ui, sans-serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.05em;
  padding: 11px 24px;
  animation: tfa-glow 2.2s ease-in-out infinite;
}
.tfa-cta:hover { background: var(--tfa-maroon-hover); }

/* ---- end-of-session card ---- */
.tfa-end {
  align-self: stretch;
  max-width: none;
  background: var(--tfa-paper);
  color: var(--tfa-ink-dark);
  border-radius: 10px;
  padding: 20px 16px;
  text-align: center;
  font-size: 15px;
  line-height: 1.5;
}
.tfa-end p { margin: 0 0 14px; }
.tfa-end .tfa-cta { animation: none; }
.tfa-end-no {
  display: inline-block;
  margin-left: 12px;
  border: 0;
  border-radius: 10px;
  background: #b9b3ac;
  color: #26232a;
  cursor: pointer;
  font-family: Oswald, system-ui, sans-serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.05em;
  padding: 11px 24px;
}

/* ---- footer / disclaimer ---- */
.tfa-trust {
  text-align: center;
  font-size: 12px;
  color: #8f8a93;
  padding: 8px 16px 14px;
  line-height: 1.5;
  flex: none;
}
.tfa-trust b { color: #c9c3cc; font-weight: 600; }
.tfa-trust a { color: #c9c3cc; text-decoration: underline; }
.tfa-trust a:hover { color: #fff; }

@media (max-width: 900px) {
  .tfa-card { height: 552px; }
  .tfa-title { font-size: 17px; }
}
@media (max-width: 760px) {
  .tfa-widget { padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .tfa-dot, .tfa-dot::after, .tfa-pick, .tfa-cta, .tfa-mic, .tfa-tts { animation: none !important; }
  .tfa-msg, .tfa-answer { opacity: 1; transform: none; transition: none; }
  .tfa-pick { opacity: 1; transform: none; pointer-events: auto; transition: none; }
}
