/* =========================================================================
 * DriftSense -- help-tip system
 *
 * Usage in HTML:
 *
 *   <span class="ds-help"
 *         data-help-title="Change-frequency ranking"
 *         data-help-body="Top 20 files by change count over the last 30
 *                         days. Files that show up here are churny
 *                         'live-config' files. Pin them to a Named
 *                         Release to freeze their current-latest content."
 *         data-help-link="/pin_hotspots.cgi"
 *         data-help-link-label="Try bulk pinning &rarr;">
 *   </span>
 *
 * The <span> renders as a small teal "?" chip. On hover / focus, a
 * gorgeous dark popover fades in above the chip with title + body +
 * optional link. Pure CSS + tiny JS in ds_help.js.
 * ========================================================================= */

.ds-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(20, 184, 166, 0.14);
  color: var(--accent-hi);
  border: 1px solid rgba(20, 184, 166, 0.35);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 800;
  cursor: help;
  user-select: none;
  vertical-align: 2px;
  margin-left: 6px;
  transition: all .15s ease;
  outline: none;
}
.ds-help::before {
  content: '?';
}
.ds-help:hover,
.ds-help:focus {
  background: var(--accent);
  color: #0a1220;
  border-color: var(--accent);
  transform: scale(1.1);
  box-shadow: 0 0 12px rgba(20, 184, 166, 0.5);
}

/* The floating popover, positioned by ds_help.js */
.ds-help-popover {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -12px);
  transition: opacity .18s ease, transform .18s ease;
  max-width: 340px;
  background: linear-gradient(180deg, var(--bg-3, #1a2740), var(--bg-2, #131e30));
  border: 1px solid var(--accent, #14b8a6);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text, #e5edf5);
  font-family: var(--sans, 'Inter', -apple-system, BlinkMacSystemFont, sans-serif);
  font-size: 13px;
  line-height: 1.55;
  box-shadow:
    0 20px 45px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(20, 184, 166, 0.20),
    0 0 40px rgba(20, 184, 166, 0.10);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.ds-help-popover.on {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}
.ds-help-popover::before {
  /* Little arrow pointing down at the ? chip */
  content: '';
  position: absolute;
  left: 50%;
  bottom: -7px;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: var(--bg-2, #131e30);
  border-right: 1px solid var(--accent, #14b8a6);
  border-bottom: 1px solid var(--accent, #14b8a6);
}
.ds-help-popover .dsh-title {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent-hi, #2dd4bf);
  margin-bottom: 6px;
}
.ds-help-popover .dsh-body {
  color: var(--text, #e5edf5);
  font-size: 13px;
}
.ds-help-popover .dsh-body strong {
  color: #fff;
  font-weight: 700;
}
.ds-help-popover .dsh-body code {
  background: rgba(20, 184, 166, 0.12);
  color: var(--accent-hi, #2dd4bf);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(20, 184, 166, 0.20);
  font-size: 11.5px;
  font-family: var(--mono, 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace);
}
.ds-help-popover .dsh-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 5px 12px;
  background: rgba(20, 184, 166, 0.14);
  color: var(--accent-hi, #2dd4bf);
  border: 1px solid rgba(20, 184, 166, 0.40);
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  font-size: 11.5px;
  transition: all .15s ease;
}
.ds-help-popover .dsh-link:hover {
  background: var(--accent, #14b8a6);
  color: #0a1220;
  border-color: var(--accent, #14b8a6);
}

/* Below-flip variant: when the ? is near the top of the viewport, the
 * popover flips below the chip. JS toggles the .below class + arrow. */
.ds-help-popover.below {
  transform: translate(-50%, 12px);
}
.ds-help-popover.below.on {
  transform: translate(-50%, 0);
}
.ds-help-popover.below::before {
  bottom: auto;
  top: -7px;
  border-right: none;
  border-bottom: none;
  border-left: 1px solid var(--accent, #14b8a6);
  border-top: 1px solid var(--accent, #14b8a6);
}

/* Larger inline help block (for page-header-level guidance).
 * Renders as an amber "info" bar rather than a hover chip.
 */
.ds-guide {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 16px 12px 14px;
  background: linear-gradient(90deg, rgba(20, 184, 166, 0.08), transparent 65%);
  border-left: 3px solid var(--accent, #14b8a6);
  border-radius: 8px;
  margin: 12px 0 18px;
  color: var(--text-dim, #96a3b8);
  font-size: 13px;
  line-height: 1.6;
}
.ds-guide .dsg-icon {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: rgba(20, 184, 166, 0.14);
  border: 1px solid rgba(20, 184, 166, 0.35);
  display: grid;
  place-items: center;
  color: var(--accent-hi, #2dd4bf);
  font-weight: 800;
  font-size: 13px;
  margin-top: 1px;
}
.ds-guide .dsg-title {
  color: #fff;
  font-weight: 700;
  margin-right: 6px;
}
.ds-guide a {
  color: var(--accent-hi, #2dd4bf);
  text-decoration: none;
  font-weight: 600;
}
.ds-guide a:hover { text-decoration: underline; }
