/* Floating mortgage-Q&A chat widget. Uses the design tokens from styles.css. */

.c2chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  height: 60px;
  min-width: 60px;
  padding: 0 22px 0 18px;
  border-radius: 999px;
  background: var(--navy);
  color: var(--cream);
  border: none;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  z-index: 999;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}
.c2chat-launcher:hover {
  transform: scale(1.05);
  background: var(--blue);
}
.c2chat-launcher.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
  visibility: hidden; /* out of the Tab order while the chat is open */
}
.c2chat-launcher-label {
  font-family: var(--sans);
  font-size: 14.7px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* One-time attention pulse on first load per browser session — draws the eye
   to the launcher, then stops so it isn't a permanent distraction. */
.c2chat-launcher.pulse::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--navy);
  z-index: -1;
  animation: c2chat-pulse 1.8s ease-out 3;
}
@keyframes c2chat-pulse {
  0% { transform: scale(1); opacity: 0.55; }
  100% { transform: scale(1.35); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .c2chat-launcher.pulse::before { animation: none; }
}

.c2chat-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 640px;
  max-height: calc(100vh - 48px);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  /* hidden (not just transparent) when closed, so keyboard users can't Tab into it */
  visibility: hidden;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
}
.c2chat-panel.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s;
}

.c2chat-header {
  background: var(--navy);
  color: var(--cream);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.c2chat-title {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.2;
}
.c2chat-subtitle {
  font-family: var(--sans);
  font-size: 14.7px;
  opacity: 0.75;
  margin-top: 2px;
}
.c2chat-close {
  background: none;
  border: none;
  color: var(--cream);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 10px 12px;
  margin: -8px -8px -8px 0;
}

.c2chat-disclaimer {
  font-family: var(--sans);
  font-size: 14.7px;
  line-height: 1.4;
  color: var(--ink-faint);
  background: var(--bg-alt);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.c2chat-disclaimer a {
  color: var(--brass-dark);
}
.c2chat-license {
  margin-top: 6px;
  font-size: 14.7px;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  opacity: 0.85;
}

.c2chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: var(--sans);
  font-size: 14.7px;
}

.c2chat-msg {
  max-width: 85%;
  padding: 9px 12px;
  border-radius: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.c2chat-msg--assistant {
  background: var(--bg-alt);
  color: var(--ink);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}
.c2chat-msg--user {
  background: var(--navy);
  color: var(--cream);
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}
.c2chat-msg--thinking {
  opacity: 0.55;
  font-style: italic;
}
.c2chat-msg-link {
  color: var(--brass-dark);
  font-weight: 600;
  text-decoration: underline;
}
.c2chat-msg--user .c2chat-msg-link {
  color: #fff;
}

.c2chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.c2chat-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 9px 14px;
  font-family: var(--sans);
  font-size: 14.7px;
  outline: none;
  background: var(--card);
  color: var(--ink);
}
.c2chat-input:focus {
  border-color: var(--brass);
}
.c2chat-input:focus-visible {
  box-shadow: 0 0 0 2px var(--brass);
}
.c2chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--brass);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.c2chat-send:hover {
  background: var(--brass-dark);
}
.c2chat-send:disabled,
.c2chat-input:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Below 680px the site shows a fixed call/book bar (~62px + safe-area) along
   the bottom — keep the widget above it instead of overlapping. */
@media (max-width: 680px) {
  .c2chat-input { font-size: 16px; }
  .c2chat-launcher { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transition: bottom 0.3s ease, background 0.2s ease, color 0.2s ease; }
  /* The call bar only slides up once the hero has scrolled away (js/main.js) */
  body.cta-bar-on .c2chat-launcher {
    bottom: calc(62px + env(safe-area-inset-bottom, 0px) + 12px);
  }
  .c2chat-panel {
    bottom: calc(62px + env(safe-area-inset-bottom, 0px) + 16px);
    max-height: calc(100vh - 62px - env(safe-area-inset-bottom, 0px) - 32px);
  }
}

@media (max-width: 480px) {
  .c2chat-panel {
    right: 16px;
    left: 16px;
    width: auto;
  }
  .c2chat-launcher {
    right: 16px;
    min-width: 44px;
    width: 44px;
    height: 44px;
    padding: 0;
  }
  .c2chat-launcher-label {
    display: none;
  }
}

/* ---------- Architectural refresh: a small, quiet launcher ---------- */
/* Square, paper-colored, a 1px navy line; no pulse, no shadow, no grow on hover. */
.c2chat-launcher {
  height: 44px; min-width: 44px; padding: 0 16px 0 14px; gap: 9px;
  border-radius: 2px; border: 1px solid var(--navy-dark);
  background: var(--bg); color: var(--navy-dark); box-shadow: none;
}
.c2chat-launcher:hover { transform: none; background: var(--navy-dark); color: var(--cream); }
.c2chat-launcher svg { width: 18px; height: 18px; stroke-width: 1.6; }
.c2chat-launcher-label { font-size: 0.74rem; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; }
.c2chat-launcher.pulse::before { content: none; animation: none; }
.c2chat-launcher.is-hidden { transform: none; }
.c2chat-panel { border-radius: 2px; box-shadow: 0 0 0 1px var(--hair, rgba(21, 48, 79, 0.14)); }
@media (max-width: 480px) {
  .c2chat-launcher { padding: 0; width: 44px; }
}

/* Phones: the chat button waits until the opening section has scrolled away, so it never
   covers hero buttons; it appears together with the call bar. */
@media (max-width: 680px) {
  body:not(.cta-bar-on) .c2chat-launcher:not([aria-expanded="true"]) { opacity: 0; pointer-events: none; }
  .c2chat-launcher { transition: opacity 0.3s ease, bottom 0.3s ease, background 0.2s ease, color 0.2s ease; }
}
