/**
 * lic-ask.css — "Ask Life in Costa" concierge (EX-2).
 *
 * Component shapes mirror Lyra in the eVoost B2B platform (b2b_platform,
 * branch AI-LYRA, components/ai-assistant.tsx): brand-gradient launcher,
 * rounded panel with avatar header, typing dots, suggestion chips, rich
 * result cards and a bordered input row — restyled to the Life in Costa
 * brand (ink + gold, Outfit/Cormorant) instead of the Partners palette.
 *
 * Two deliberate divergences from Partners:
 *   • The launcher keeps a visible label on desktop. Partners is a logged-in
 *     tool where a bare icon is discoverable; this sits on a public site
 *     where the affordance has to say what it is. It collapses to a round
 *     icon on mobile, where the label costs more than it earns.
 *   • The rich result cards are SOURCES, not developments — Ask exists to
 *     move readers into our guides.
 */

.lic-ask-widget,
.lic-ask-page {
  /* Brand tokens, scoped so the concierge never leaks styles into the theme. */
  --lic-ink: #2e2e2e;
  --lic-ink-deep: #1c1c1c;
  --lic-gold: #d7a341;
  --lic-gold-deep: #b8862f;
  --lic-cream: #fbf3e2;
  --lic-line: #e9e9e9;
  --lic-muted: #6b6b6b;
  --lic-surface: #fff;
  --lic-surface-alt: #f6f6f6;
  --lic-radius: 16px;
  --lic-font: "Outfit", system-ui, -apple-system, sans-serif;
  --lic-display: "Cormorant Garamond", Georgia, serif;
}

.lic-ask-widget {
  position: fixed;
  /* Left of the eVoost WhatsApp column (#evoost-wa-float: 60px wide, right 30px,
     bottom 30px, 115px tall) so the two never overlap. */
  right: 100px;
  bottom: 30px;
  z-index: 9999;
  font-family: var(--lic-font);
}

/* ── Launcher (brand-gradient FAB) ─────────────────────────────────────── */
.lic-ask-launcher {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 13px 20px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--lic-gold) 0%, var(--lic-gold-deep) 100%);
  color: var(--lic-ink-deep);
  font-family: var(--lic-font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
  transition: transform .15s ease, box-shadow .15s ease;
}
.lic-ask-launcher:hover { transform: scale(1.04); box-shadow: 0 10px 28px rgba(0, 0, 0, .28); }
.lic-ask-launcher:focus-visible { outline: 3px solid var(--lic-ink); outline-offset: 2px; }
.lic-ask-launcher__icon { display: inline-flex; }
.lic-ask-widget.is-open .lic-ask-launcher { display: none; }
/* The panel stays in the DOM once built (toggle() only flips the class),
   so it has to be hidden explicitly when the widget is closed. */
.lic-ask-widget:not(.is-open) .lic-ask-panel { display: none; }
/* With the panel open the launcher is gone, so the panel can take the corner. */
.lic-ask-widget.is-open { right: 20px; }

.lic-ask-spark { width: 20px; height: 20px; display: block; }

/* ── Panel ─────────────────────────────────────────────────────────────── */
.lic-ask-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(390px, calc(100vw - 32px));
  height: min(72vh, 540px);
  display: flex;
  flex-direction: column;
  background: var(--lic-surface);
  border: 1px solid var(--lic-line);
  border-radius: var(--lic-radius);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .26);
  overflow: hidden;
}
.lic-ask-panel__head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--lic-line);
  background: var(--lic-ink);
  color: #fff;
}
.lic-ask-panel__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--lic-gold) 0%, var(--lic-gold-deep) 100%);
  color: var(--lic-ink-deep);
}
.lic-ask-panel__titles { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.lic-ask-panel__title { font-size: 15px; font-weight: 600; line-height: 1.2; }
.lic-ask-panel__subtitle { font-size: 11.5px; color: rgba(255, 255, 255, .66); line-height: 1.3; }
.lic-ask-panel__close {
  background: none; border: none; color: rgba(255, 255, 255, .8);
  font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.lic-ask-panel__close:hover { color: #fff; }

/* ── Thread ────────────────────────────────────────────────────────────── */
.lic-ask-thread {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 120px;
  background: var(--lic-surface);
}
.lic-ask-msg { max-width: 92%; }
.lic-ask-msg--user { align-self: flex-end; }
.lic-ask-msg--agent { align-self: flex-start; }
.lic-ask-msg__body {
  padding: 10px 13px;
  border-radius: 13px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.lic-ask-msg--user .lic-ask-msg__body {
  background: linear-gradient(135deg, var(--lic-gold) 0%, var(--lic-gold-deep) 100%);
  color: var(--lic-ink-deep);
  border-bottom-right-radius: 4px;
}
.lic-ask-msg--agent .lic-ask-msg__body {
  background: var(--lic-surface-alt);
  color: #232323;
  border-bottom-left-radius: 4px;
}

/* Rich answer body: real blocks instead of a pre-wrapped blob. */
.lic-ask-msg__body--rich { white-space: normal; }
.lic-ask-msg__p { margin: 0 0 9px; }
.lic-ask-msg__p:last-child { margin-bottom: 0; }
.lic-ask-msg__p strong { font-weight: 600; color: var(--lic-ink-deep); }
.lic-ask-msg__list { margin: 4px 0 9px; padding-left: 20px; }
.lic-ask-msg__list:last-child { margin-bottom: 0; }
.lic-ask-msg__list li { margin: 2px 0; }
.lic-ask-code {
  background: rgba(0, 0, 0, .07);
  border-radius: 4px;
  padding: 1px 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .88em;
}

/* Typing indicator — dead air reads as a broken widget. */
.lic-ask-dots { display: inline-flex; gap: 4px; align-items: center; padding: 3px 0; }
.lic-ask-dots i {
  width: 6px; height: 6px; border-radius: 999px;
  background: var(--lic-muted);
  animation: lic-ask-bounce 1.2s infinite ease-in-out;
}
.lic-ask-dots i:nth-child(2) { animation-delay: .16s; }
.lic-ask-dots i:nth-child(3) { animation-delay: .32s; }
@keyframes lic-ask-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40%           { transform: translateY(-4px); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .lic-ask-dots i { animation: none; opacity: .6; }
  .lic-ask-launcher:hover { transform: none; }
}

/* ── Inline source marker: the clickable [N] inside the answer ─────────── */
.lic-ask-ref {
  display: inline-block;
  min-width: 15px;
  margin: 0 1px;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--lic-gold);
  color: var(--lic-ink-deep);
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  text-decoration: none;
  vertical-align: super;
}
.lic-ask-ref:hover, .lic-ask-ref:focus { background: var(--lic-ink); color: #fff; }

/* Provenance note on extractive (quoted, not written) answers. */
.lic-ask-msg__mode {
  margin-top: 6px;
  font-size: 11px;
  font-style: italic;
  color: #9a9a9a;
}

/* ── Sources as cards ──────────────────────────────────────────────────── */
.lic-ask-cites { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.lic-ask-cites__label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #9a9a9a;
}
.lic-ask-cite {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--lic-line);
  border-radius: 11px;
  background: var(--lic-surface);
  color: inherit;
  text-decoration: none;
  transition: border-color .15s ease, background .15s ease;
}
a.lic-ask-cite:hover { border-color: var(--lic-gold); background: var(--lic-cream); }
.lic-ask-cite__n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px; flex: 0 0 24px;
  border-radius: 7px;
  background: rgba(215, 163, 65, .18);
  color: var(--lic-gold-deep);
  font-size: 11.5px;
  font-weight: 700;
}
.lic-ask-cite__main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.lic-ask-cite__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--lic-ink-deep);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lic-ask-cite__snippet {
  font-size: 11.5px;
  color: var(--lic-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lic-ask-cite__chev { color: #bbb; font-size: 17px; line-height: 1; }
a.lic-ask-cite:hover .lic-ask-cite__chev { color: var(--lic-gold-deep); }

/* ── Suggestion chips (cold start) ─────────────────────────────────────── */
.lic-ask-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.lic-ask-chip {
  padding: 6px 12px;
  border: 1px solid var(--lic-line);
  border-radius: 999px;
  background: var(--lic-surface);
  color: var(--lic-muted);
  font-family: var(--lic-font);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.lic-ask-chip:hover { border-color: var(--lic-gold); background: var(--lic-cream); color: var(--lic-ink-deep); }

/* ── Form ──────────────────────────────────────────────────────────────── */
.lic-ask-form {
  display: flex;
  gap: 8px;
  padding: 11px 14px;
  border-top: 1px solid var(--lic-line);
  background: var(--lic-surface);
}
.lic-ask-form__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 13px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-family: var(--lic-font);
  font-size: 14px;
  color: var(--lic-ink-deep);
}
.lic-ask-form__input:focus { outline: 2px solid var(--lic-gold); border-color: var(--lic-gold); }
.lic-ask-form__send {
  padding: 10px 17px;
  border: none;
  border-radius: 10px;
  background: var(--lic-ink);
  color: #fff;
  font-family: var(--lic-font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
}
.lic-ask-form__send:hover { background: var(--lic-ink-deep); }
.lic-ask-form__send:disabled { opacity: .5; cursor: default; }

/* ── Soft gate ─────────────────────────────────────────────────────────── */
.lic-ask-gate {
  margin-top: 4px;
  padding: 12px;
  border-radius: 12px;
  background: var(--lic-cream);
  border: 1px solid #ecd9ac;
}
.lic-ask-gate__prompt { margin: 0 0 8px; font-size: 13px; color: #5a4a1e; }
.lic-ask-gate__form { display: flex; gap: 8px; }
.lic-ask-gate__email {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid #ddc98f;
  border-radius: 9px;
  font-family: var(--lic-font);
  font-size: 14px;
}
.lic-ask-gate__btn {
  padding: 9px 14px;
  border: none;
  border-radius: 9px;
  background: var(--lic-ink);
  color: #fff;
  font-family: var(--lic-font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.lic-ask-gate__btn:disabled { opacity: .6; cursor: default; }
.lic-ask-gate__thanks { margin: 0; font-size: 14px; color: var(--lic-ink); }
/* Name (optional) shares the row with the email; wraps on narrow panels. */
.lic-ask-gate__form { flex-wrap: wrap; }
.lic-ask-gate__name {
  flex: 1 1 120px;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid #ddc98f;
  border-radius: 9px;
  font-family: var(--lic-font);
  font-size: 14px;
}
.lic-ask-gate__email { flex: 2 1 160px; }
/* GDPR consent: required before a lead is created (server enforces it too). */
.lic-ask-gate__consent {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: #5a4a1e;
  cursor: pointer;
}
.lic-ask-gate__consent input { margin-top: 2px; flex: 0 0 auto; width: 16px; height: 16px; }
.lic-ask-gate__error { margin: 8px 0 0; font-size: 12px; color: #b23a3a; }

/* ── Inline "Ask about this" button (single guides) ────────────────────── */
.lic-ask-inline { margin: 28px 0 8px; }
.lic-ask-inline__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border: 1px solid var(--lic-ink);
  border-radius: 999px;
  background: #fff;
  color: var(--lic-ink);
  font-family: var(--lic-font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.lic-ask-inline__btn:hover { background: var(--lic-ink); color: #fff; }

/* ── Embedded console at the end of a guide (scope guides-inline) ──────── */
.lic-ask-embed {
  --lic-ink: #2e2e2e; --lic-ink-deep: #1c1c1c; --lic-gold: #d7a341; --lic-gold-deep: #b8862f;
  --lic-cream: #fbf3e2; --lic-line: #e9e9e9; --lic-muted: #6b6b6b; --lic-surface: #fff;
  --lic-surface-alt: #f6f6f6; --lic-radius: 16px;
  --lic-font: "Outfit", system-ui, -apple-system, sans-serif;
  --lic-display: "Cormorant Garamond", Georgia, serif;
  margin: 48px 0 16px;
  padding-top: 32px;
  border-top: 1px solid var(--lic-line);
  font-family: var(--lic-font);
}
.lic-ask-embed__head { margin-bottom: 18px; }
/* On the guides hub (wide grid) keep the console at reading width. */
.lic-gh .lic-ask-embed { max-width: 760px; margin-left: auto; margin-right: auto; }
.lic-ask-embed__title { font-family: var(--lic-display); font-size: 30px; font-weight: 500; margin: 6px 0 8px; color: var(--lic-ink); }
.lic-ask-embed__lead { margin: 0; color: var(--lic-muted); font-size: 15px; }
.lic-ask-embed__console .lic-ask-thread { min-height: 200px; max-height: 50vh; }

/* ── /ask/ page ────────────────────────────────────────────────────────── */
.lic-ask-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 20px 80px;
  font-family: var(--lic-font);
}
.lic-ask-page__title {
  font-family: var(--lic-display);
  font-size: 42px;
  line-height: 1.1;
  margin: 0 0 12px;
  color: var(--lic-ink);
}
.lic-ask-page__intro { font-size: 16px; color: var(--lic-muted); margin: 0 0 28px; max-width: 60ch; }
.lic-ask-page__console {
  border: 1px solid var(--lic-line);
  border-radius: var(--lic-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .05);
}
.lic-ask-page__console .lic-ask-thread { min-height: 260px; max-height: 60vh; }

@media (max-width: 600px) {
  .lic-ask-widget { right: 96px; bottom: 30px; }
  .lic-ask-widget.is-open { right: 12px; }
  /* Label costs more than it earns on a small viewport — icon only. */
  .lic-ask-launcher { padding: 0; width: 54px; height: 54px; justify-content: center; }
  .lic-ask-launcher__label { display: none; }
  .lic-ask-panel { width: calc(100vw - 24px); height: min(78vh, 560px); }
  .lic-ask-page__title { font-size: 32px; }
}
