/* Shared help tooltip (window.FtgHelpTip) — the ONE tooltip of the GUI: every
   hover tooltip in the project renders through this gadget (delayed or
   instant). The "?" icon is rendered inline by FtgHelpTip.icon()/iconHtml();
   the tooltip body is a single element appended to <body> so it is never
   clipped by a modal scroll container. Visual language: ink border, hard
   shadow, card background. The .ftg-help-list block styles the trusted rich
   HTML bodies (data-ftg-html, e.g. the contracts widget-states list). */

/* The ONE circled "?" affordance: a green ring with a green glyph on a light
   green tint. The disc itself is drawn by CSS (the FontAwesome <i> stays in
   the page markup but is hidden) so the glyph is a crisp 11px "?" instead of
   the old 10px filled circle, and the size never follows the container's
   font-size (the .card-title i override used to make one icon bigger). */
.ftg-help-icon {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  /* Self-contained look: the icon must render identically wherever it is
     placed (e.g. inside italic console labels like .ug-flabel/.ftg-label) —
     never inherit the surrounding font style. */
  font-style: normal; font-weight: 400; text-transform: none; letter-spacing: normal;
  width: 18px; height: 18px; margin-left: 4px; border-radius: 9999px;
  border: 1.5px solid var(--m-forest);
  background: var(--m-forest-soft); color: var(--m-forest);
  font-size: 11px; font-weight: 700; line-height: 1;
  cursor: help; vertical-align: middle;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
  /* The icon often sits inside uppercase tracked labels (.kpi-label,
     .card-title): the inherited letter-spacing adds trailing space after the
     atomic glyph inside the inline-flex disc, shifting the "?" off the disc
     centre by half the tracking. Reset it so the glyph stays centered. */
  letter-spacing: normal;
}
.ftg-help-icon > i { display: none; }
.ftg-help-icon::before { content: "?"; }
/* Hover/focus keep the light-green tint (never the dark-on-accent fill): the
   affordance is the amber→green read state, not a filled disc. Only a faint
   ring + a keyboard focus halo mark the interaction. */
.ftg-help-icon:hover, .ftg-help-icon:focus {
  border-color: var(--m-forest-d);
  box-shadow: 0 0 0 2px var(--m-forest-soft);
  outline: none;
}
.ftg-help-icon:focus-visible {
  outline: 2px solid var(--m-forest);
  outline-offset: 2px;
}

/* First-adoption kickstart — SCOPED (opt-in) to the pages whose <body> carries
   the `ftg-help-kickstart` class (Dashboard, Sentiment, Competitors). An
   unread help icon pulses amber until its tooltip has been read once (the
   gadget marks the key in the `ft_help_seen` cookie after 1 s of continuous
   visibility, or at once on click). Off scope the same "?" keeps the plain
   green look above: no amber, no animation, no read tracking. */
body.ftg-help-kickstart .ftg-help-icon.is-unread {
  border-color: var(--m-amber);
  background: var(--m-amber-soft);
  color: var(--m-amber-fg);
  animation: ftg-help-pulse 1.8s ease-out infinite;
}
/* Hovering an unread icon deepens the amber instead of filling it solid: the
   amber fill would drop the contrast of the glyph in one of the two skins. */
body.ftg-help-kickstart .ftg-help-icon.is-unread:hover,
body.ftg-help-kickstart .ftg-help-icon.is-unread:focus {
  border-color: var(--m-amber-fg);
  color: var(--m-amber-fg);
  animation: none;
  box-shadow: 0 0 0 2px var(--m-amber-soft);
}
body.ftg-help-kickstart .ftg-help-icon.is-unread:focus-visible { outline-color: var(--m-amber); }
@keyframes ftg-help-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(216, 165, 40, .55); }
  70%  { box-shadow: 0 0 0 6px rgba(216, 165, 40, 0); }
  100% { box-shadow: 0 0 0 0 rgba(216, 165, 40, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .ftg-help-icon { transition: none; }
  body.ftg-help-kickstart .ftg-help-icon.is-unread { animation: none; }
}

.ftg-help-tip {
  position: fixed; display: none; z-index: 100002; width: 340px;
  max-width: calc(100vw - 20px);
  /* Long bodies (e.g. the contracts widget-states list) must stay fully
     readable on short screens: cap the bubble to the viewport and let it
     scroll internally (FtgFit positions the capped box). */
  max-height: calc(100vh - 20px); overflow-y: auto;
  padding: 12px 14px;
  border: 1.5px solid var(--m-ink); border-radius: 10px; background: var(--m-card);
  color: var(--m-text); box-shadow: 4px 4px 0 var(--m-border-d);
  /* Self-contained typography: the bubble never inherits the trigger's font
     style (size/spacing are the gadget's own, the rest stays neutral). */
  font-family: var(--font-sans); font-size: 12px; line-height: 1.45;
  font-style: normal; font-weight: 400;
  text-align: left; text-transform: none; letter-spacing: normal;
}
.ftg-help-tip .ftg-help-title {
  font-weight: 700; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--m-ink); margin-bottom: 4px;
}
.ftg-help-tip .ftg-help-body { margin: 0; color: var(--m-muted); font-size: 12px; white-space: pre-line; }
.ftg-help-tip .ftg-help-intro { margin: 0 0 8px; color: var(--m-muted); font-size: 12px; }
.ftg-help-tip .ftg-help-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.ftg-help-tip .ftg-help-list li { display: flex; gap: 8px; align-items: baseline; }
.ftg-help-tip .ftg-help-lvl { flex: 0 0 auto; min-width: 62px; font-weight: 700; }
.ftg-help-tip .ftg-help-lvl.lvl-active { color: var(--m-forest); }
.ftg-help-tip .ftg-help-lvl.lvl-reduced { color: var(--m-amber); }
.ftg-help-tip .ftg-help-lvl.lvl-demo { color: #b45309; }
.ftg-help-tip .ftg-help-lvl.lvl-hidden { color: #4b5563; }
[data-skin="night"] .ftg-help-tip .ftg-help-lvl.lvl-hidden { color: #9ca3af; }
.ftg-help-tip .ftg-help-desc { color: var(--m-text); }
/* Inline code chips inside rich bodies (e.g. the regex primer): monospace,
   nowrap so short patterns never break mid-token. */
.ftg-help-tip code { font-family: var(--font-mono); font-size: 11px; color: var(--m-ink);
  background: var(--m-border); border-radius: 5px; padding: 1px 5px; white-space: nowrap; }
/* Compact variant (opt-in via data-ftg-size="sm"): fits short title-only
   tooltips to their content instead of the default 340px bubble. */
.ftg-help-tip.ftg-help-sm { width: auto; padding: 6px 10px; }
.ftg-help-tip.ftg-help-sm .ftg-help-title { margin-bottom: 0; }
