/* Kestrel chat widget + subscribe popup — styles for chat.js.
   A separate file because chat.js runs on every page, including the
   archived brief pages, which are rendered emails and do NOT load
   style.css. The tokens below mirror style.css :root so the widget looks
   the same on both; scoped to the widget roots so they cannot leak into the
   email markup. Keep them in step with style.css when the palette changes. */

#k-chat-root, #k-popup {
  --navy:        #2F364A;
  --violet-dark: #6451B3;
  --grey:        #EDECEF;
  --grey-mid:    #CDD0DF;
  --angle-bg:    #EFEAF8;
  --white:       #FFFFFF;
  --body:        #2F364A;
  --muted:       #6A7188;
  --radius:      4px;
  --radius-lg:   6px;
  --font:        'Archivo', system-ui, sans-serif;
  --font-display:'Space Grotesk', 'Archivo', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', ui-monospace, monospace;
  --shadow-lg:   0 8px 28px rgba(47,54,74,.14);
  font-family: var(--font);
  color: var(--body);
  line-height: 1.55;
  text-align: left;
}
/* style.css resets box-sizing globally; the email pages do not, and a
   width:100% field with padding would overflow the popup without it. */
#k-chat-root, #k-chat-root *, #k-popup, #k-popup * { box-sizing: border-box; }
#k-chat-root p, #k-popup p { margin: 0; }

/* The site's shared button and status rules, scoped to the widget so the
   popup's Subscribe button and form status render on the email pages too. */
#k-chat-root .btn-primary, #k-popup .btn-primary {
  width: 100%;
  height: 42px;
  padding: 0 24px;
  background: var(--violet-dark);
  color: var(--white);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background .12s ease-out;
}
#k-chat-root .btn-primary:hover, #k-popup .btn-primary:hover { background: #57459E; }
#k-chat-root .btn-primary:disabled, #k-popup .btn-primary:disabled { opacity: .45; cursor: not-allowed; }
#k-chat-root .form-status, #k-popup .form-status {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  display: none;
}
#k-chat-root .form-status.success, #k-popup .form-status.success { background: #3B3558; color: #D8CDF0; display: block; }
#k-chat-root .form-status.error, #k-popup .form-status.error   { background: #462E31; color: #D98A90; display: block; }

/* ── Chat widget + subscribe popup (chat.js) ───────────────
   Mobile-first: most visitors arrive from a LinkedIn link on a phone, so the
   panel is a full-width bottom sheet by default and only becomes a floating
   desktop card above 640px. Both sit below .modal-overlay (z-index 1000) and
   well above .site-nav (200). */
.k-honeypot { position: absolute; left: -9999px; height: 0; width: 0; border: 0; padding: 0; }

#k-chat-launcher {
  position: fixed;
  bottom: 16px; right: 16px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--violet-dark);
  color: var(--white);
  border: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  z-index: 900;
  transition: background .12s ease-out;
}
#k-chat-launcher:hover { background: #57459E; }

#k-chat-panel {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: min(80vh, 600px);
  background: var(--white);
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow-lg);
  z-index: 950;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* The ID selector above beats the UA default [hidden]{display:none} on
   specificity alone, so the panel would render open on every page load
   without this — hidden state needs its own, more specific rule. */
#k-chat-panel[hidden] { display: none; }
#k-chat-panel header {
  flex: 0 0 auto;
  background: var(--navy);
  color: var(--white);
  padding: 14px 8px 14px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
#k-chat-panel header strong { display: block; font-family: var(--font-display); font-size: 15px; }
#k-chat-panel header span { display: block; font-size: 11px; color: rgba(255,255,255,.65); margin-top: 2px; }
#k-chat-close {
  background: none; border: none; color: var(--white);
  font-size: 22px; line-height: 1; cursor: pointer;
  min-width: 40px; min-height: 40px;
}

#k-chat-msgs {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 16px;
  background: var(--grey);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.k-msg { max-width: 85%; padding: 9px 12px; border-radius: 10px; font-size: 13.5px; line-height: 1.45; }
.k-msg.bot { align-self: flex-start; background: var(--white); border: 1px solid var(--grey-mid); color: var(--body); }
.k-msg.user { align-self: flex-end; background: var(--violet-dark); color: var(--white); }
.k-msg--wide { max-width: 100%; }
.k-chat-lead { margin: 0 0 8px; font-size: 13px; color: var(--muted); }

#k-chat-chips {
  flex: 0 0 auto;
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 0 16px 12px;
  background: var(--grey);
}
.k-chip {
  border: 1px solid var(--violet-dark);
  background: var(--white);
  color: var(--violet-dark);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  min-height: 32px;
}
.k-chip:hover { background: var(--violet-dark); color: var(--white); }

#k-chat-form {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--grey-mid);
  background: var(--white);
}
#k-chat-input {
  flex: 1;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--grey-mid);
  border-radius: var(--radius);
  font-size: 16px; /* 16px stops iOS Safari zooming in on focus */
  font-family: var(--font);
}
.k-chat-send {
  height: 40px;
  padding: 0 16px;
  background: var(--violet-dark);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.k-chat-subscribe-form input[type="email"] {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--grey-mid);
  border-radius: var(--radius);
  font-size: 16px;
  margin-bottom: 8px;
  font-family: var(--font);
}
.k-chat-subscribe-form .btn-primary { height: 40px; font-size: 14px; }
.k-chat-subscribe-form .turnstile-slot { margin: 4px 0 8px; }
.k-chat-subscribe-form .form-status { margin-top: 8px; }

@keyframes k-pop-in {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

#k-popup {
  position: fixed;
  left: 12px; right: 12px; bottom: 84px;
  z-index: 940;
  background: var(--white);
  border: 1px solid var(--grey-mid);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  animation: k-pop-in .25s ease-out;
}
#k-popup-close {
  position: absolute;
  top: 6px; right: 6px;
  width: 36px; height: 36px;
  background: none; border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}
.k-popup__badge {
  width: 56px; height: 56px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--angle-bg) 0%, var(--grey) 100%);
  box-shadow: 0 6px 16px rgba(100,81,179,.28);
  display: flex;
  align-items: center;
  justify-content: center;
}
.k-popup__badge img { width: 30px; height: 30px; display: block; }
.k-popup__phrase {
  min-height: 16px;
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--violet-dark);
  text-align: center;
  transition: opacity .2s ease;
}
.k-popup__phrase.k-fade-out { opacity: 0; }
.k-popup__headline {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--navy);
  text-align: center;
}
.k-popup__form input[type="email"] {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--grey-mid);
  border-radius: var(--radius);
  font-size: 16px;
  margin-bottom: 10px;
  font-family: var(--font);
}
.k-popup__form .btn-primary { width: 100%; height: 44px; }
.k-popup__form .turnstile-slot { margin: 6px 0; }
.k-popup__note { margin: 10px 0 0; font-size: 11px; color: var(--muted); text-align: center; }

@media (min-width: 641px) {
  #k-chat-panel {
    left: auto;
    right: 20px; bottom: 84px;
    width: 360px; height: 520px;
    border-radius: var(--radius-lg);
  }
  #k-popup { left: auto; right: 20px; width: 340px; }
}

@media (prefers-reduced-motion: reduce) {
  #k-popup { animation: none; }
  .k-popup__phrase { transition: none; }
}
