/* Qualification chat widget.
   Uses the site's existing tokens so it reads as part of the page, not bolted on.
   Back-to-top sits at bottom:2rem right:1rem, so the launcher stacks above it. */

#hlChatLauncher {
  position: fixed;
  bottom: 2rem;
  right: 5.5rem;                 /* clear of #backToTop */
  height: 56px;
  padding: 0 1.35rem;
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  background: var(--accent, #6b4fa3);
  color: #fff;
  border: none;
  border-radius: 28px;
  font-family: 'Sora', sans-serif;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 6px 20px rgba(107, 79, 163, .45);
  transition: transform .2s ease, box-shadow .2s ease;
}
#hlChatLauncher:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(107,79,163,.55); }
#hlChatLauncher[hidden] { display: none; }
#hlChatLauncher .dot {
  width: 8px; height: 8px; border-radius: 50%; background: #7ef0c0;
  box-shadow: 0 0 0 0 rgba(126,240,192,.7); animation: hlPulse 2.4s infinite;
}
@keyframes hlPulse {
  0%   { box-shadow: 0 0 0 0 rgba(126,240,192,.7); }
  70%  { box-shadow: 0 0 0 9px rgba(126,240,192,0); }
  100% { box-shadow: 0 0 0 0 rgba(126,240,192,0); }
}

#hlChatPanel {
  position: fixed;
  bottom: 2rem; right: 1rem;
  width: min(420px, calc(100vw - 2rem));
  height: min(640px, calc(100vh - 4rem));
  background: var(--white, #fff);
  border: 1px solid var(--border, #e8e6e2);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.18);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 1001;
  font-family: 'Sora', sans-serif;
}
#hlChatPanel[hidden] { display: none; }

.hl-head {
  display: flex; align-items: center; gap: .75rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border, #e8e6e2);
  background: var(--bg, #faf8f5);
}
.hl-head h3 {
  margin: 0; font-family: 'Instrument Serif', serif;
  font-size: 1.1rem; color: var(--primary, #1a1a1a); flex: 1; line-height: 1.2;
}
.hl-head p { margin: .1rem 0 0; font-size: .72rem; color: var(--text-secondary,#666); }
.hl-close {
  background: none; border: none; font-size: 1.3rem; line-height: 1;
  cursor: pointer; color: var(--text-light,#999); padding: .25rem .4rem; border-radius: 6px;
}
.hl-close:hover { background: rgba(0,0,0,.05); color: var(--primary,#1a1a1a); }

.hl-progress { height: 3px; background: var(--border,#e8e6e2); }
.hl-progress span {
  display: block; height: 100%; width: 0;
  background: var(--accent,#6b4fa3); transition: width .4s ease;
}

.hl-log { flex: 1; overflow-y: auto; padding: 1.1rem; display: flex; flex-direction: column; gap: .85rem; }

.hl-msg { max-width: 88%; padding: .7rem .9rem; border-radius: 12px; font-size: .9rem; line-height: 1.55; white-space: pre-wrap; }
.hl-msg.bot  { background: var(--bg-light,#f5f3f0); color: var(--text-primary,#2a2a2a); border-bottom-left-radius: 4px; align-self: flex-start; }
.hl-msg.user { background: var(--accent,#6b4fa3); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.hl-hint { font-size: .75rem; color: var(--text-secondary,#666); align-self: flex-start; margin: -.5rem 0 0 .2rem; }

.hl-typing { display: flex; gap: 4px; padding: .8rem .9rem; align-self: flex-start; }
.hl-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-light,#999); animation: hlBounce 1.2s infinite; }
.hl-typing i:nth-child(2) { animation-delay: .15s; }
.hl-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes hlBounce { 0%,60%,100% { transform: translateY(0); opacity:.4 } 30% { transform: translateY(-5px); opacity:1 } }

.hl-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .2rem; }
.hl-chip {
  padding: .45rem .75rem; border: 1px solid var(--border,#e8e6e2);
  background: #fff; border-radius: 18px; font-size: .8rem;
  font-family: 'Sora', sans-serif; cursor: pointer; color: var(--text-primary,#2a2a2a);
  transition: all .15s ease; text-align: left;
}
.hl-chip:hover { border-color: var(--accent,#6b4fa3); }
.hl-chip[aria-pressed="true"] { background: rgba(107,79,163,.1); border-color: var(--accent,#6b4fa3); font-weight: 600; }
.hl-group { width: 100%; font-size: .68rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-light,#999); margin-top: .5rem; }

.hl-fields { display: flex; flex-direction: column; gap: .6rem; margin-top: .3rem; }
.hl-field label { display: block; font-size: .78rem; color: var(--text-secondary,#666); margin-bottom: .2rem; }
.hl-field input {
  width: 100%; padding: .55rem .65rem; border: 1px solid var(--border,#e8e6e2);
  border-radius: 6px; font-family: 'Sora', sans-serif; font-size: .88rem; color: var(--text-primary,#2a2a2a);
}
.hl-field input:focus { outline: 2px solid rgba(107,79,163,.35); outline-offset: 1px; border-color: var(--accent,#6b4fa3); }
.hl-field .note { font-size: .7rem; color: var(--accent,#6b4fa3); margin-top: .15rem; }
.hl-yesno { display: flex; gap: .4rem; }

.hl-consent { display: flex; gap: .5rem; align-items: flex-start; font-size: .76rem; color: var(--text-secondary,#666); line-height: 1.45; margin-top: .4rem; }
.hl-consent input { margin-top: .18rem; flex-shrink: 0; }

.hl-foot { border-top: 1px solid var(--border,#e8e6e2); padding: .7rem; display: flex; gap: .5rem; align-items: flex-end; background: #fff; }
.hl-foot textarea {
  flex: 1; resize: none; border: 1px solid var(--border,#e8e6e2); border-radius: 8px;
  padding: .55rem .7rem; font-family: 'Sora', sans-serif; font-size: .88rem;
  max-height: 90px; min-height: 40px; color: var(--text-primary,#2a2a2a);
}
.hl-foot textarea:focus { outline: 2px solid rgba(107,79,163,.35); outline-offset: 1px; }
.hl-send {
  background: var(--accent,#6b4fa3); color: #fff; border: none;
  border-radius: 8px; padding: .6rem .9rem; cursor: pointer; font-size: .95rem; font-weight: 600;
}
.hl-send:disabled { opacity: .45; cursor: not-allowed; }

.hl-primary {
  width: 100%; padding: .65rem; margin-top: .5rem;
  background: var(--accent,#6b4fa3); color: #fff; border: none; border-radius: 8px;
  font-family: 'Sora', sans-serif; font-size: .88rem; font-weight: 600; cursor: pointer;
}
.hl-primary:disabled { opacity: .45; cursor: not-allowed; }

/* Summary reveal - the payoff */
.hl-summary { background: var(--bg,#faf8f5); border: 1px solid var(--border,#e8e6e2); border-radius: 10px; padding: 1rem; font-size: .84rem; }
.hl-summary h4 { margin: 0 0 .6rem; font-family: 'Instrument Serif', serif; font-size: 1.05rem; color: var(--primary,#1a1a1a); }
.hl-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: .7rem 0; }
.hl-stat { background: #fff; border: 1px solid var(--border,#e8e6e2); border-radius: 8px; padding: .55rem; text-align: center; }
.hl-stat b { display: block; font-size: 1.15rem; color: var(--accent,#6b4fa3); line-height: 1.2; }
.hl-stat span { font-size: .68rem; color: var(--text-secondary,#666); }
.hl-summary ul { margin: .4rem 0 0; padding-left: 1.1rem; color: var(--text-secondary,#666); }
.hl-summary li { margin-bottom: .25rem; }
.hl-check { display: flex; gap: .45rem; align-items: flex-start; margin-bottom: .3rem; font-size: .8rem; }
.hl-check .m { flex-shrink: 0; font-weight: 700; }
.hl-check.pass .m   { color: var(--success,#10b981); }
.hl-check.blocker .m{ color: #c0392b; }
.hl-check.warn .m, .hl-check.verify .m { color: #d97706; }
.hl-disclaimer { font-size: .68rem; color: var(--text-light,#999); line-height: 1.45; margin-top: .7rem; padding-top: .6rem; border-top: 1px solid var(--border,#e8e6e2); }

.hl-error { background: #fdecea; border: 1px solid #f5c6c2; color: #a02622; padding: .6rem .75rem; border-radius: 8px; font-size: .82rem; }

@media (max-width: 520px) {
  /* Pin all four edges rather than setting width/height. 100vw resolves against
     the layout viewport while right:0 anchors to the containing block; when a
     page scrolls horizontally or is zoomed those differ and the panel hangs off
     the screen. Pinning edges cannot disagree with itself. */
  #hlChatPanel {
    top: 0; right: 0; bottom: 0; left: 0;
    width: auto; height: auto;
    max-width: none; max-height: none;
    border-radius: 0; border: none;
  }
  /* On a phone, sitting 5.5rem in to dodge the back-to-top button parks the
     launcher mid-screen over the copy. Hug the right edge instead; the page
     stacks the back-to-top button above it. */
  #hlChatLauncher { right: 1rem; bottom: 1rem; padding: 0 1rem; font-size: .88rem; }
  .hl-stats { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  #hlChatLauncher, .hl-progress span, .hl-chip { transition: none; }
  #hlChatLauncher .dot, .hl-typing i { animation: none; }
}

/* HumanLed AI logo in launcher + header */
#hlChatLauncher .hl-launcher-logo {
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
#hlChatLauncher .hl-launcher-logo img { width: 18px; height: 18px; object-fit: contain; }
.hl-head-logo { width: 30px; height: 30px; object-fit: contain; flex-shrink: 0; }

/* "Try me" attention animation — a slow breathing pulse that draws the eye
   without nagging. Pauses on hover, and respects reduced-motion. */
#hlChatLauncher { animation: hlBreathe 3s ease-in-out infinite; }
#hlChatLauncher:hover { animation: none; }
@keyframes hlBreathe {
  0%, 100% { transform: translateY(0) scale(1); box-shadow: 0 6px 20px rgba(107,79,163,.45); }
  50%      { transform: translateY(-3px) scale(1.03); box-shadow: 0 12px 30px rgba(107,79,163,.6); }
}
#hlChatLauncher .hl-launcher-logo { animation: hlLogoBob 3s ease-in-out infinite; }
@keyframes hlLogoBob {
  0%, 100% { transform: rotate(0deg); }
  50%      { transform: rotate(-6deg); }
}
@media (prefers-reduced-motion: reduce) {
  #hlChatLauncher, #hlChatLauncher .hl-launcher-logo { animation: none; }
}
