/* ── Help tips — the one help-popup skin for the whole app ────────────────────
 *
 * See int_lms/app_root/UI.md § "Help text — one popup, one shape" for the rule this
 * implements. Nothing here is per-screen: a help popup looks identical on the lesson
 * editor, the gradebook setup and every screen added after them, because there is one
 * stylesheet and one script and no call site is allowed its own.
 *
 * Everything is expressed through Bootstrap's own --bs-popover-* custom properties
 * rather than by overriding .popover rules. Overriding would put us in a specificity
 * argument with Bootstrap on every release; setting its variables is the supported
 * seam, and it means the arrow, the radius and the header divider all follow without
 * a rule each.
 */

/* ── The trigger ─────────────────────────────────────────────────────────────
   Built by help-tip.js, never hand-written — see the script for why. Sized to the
   surrounding text (1em) so it sits on the baseline of whatever label it follows,
   with a 24px hit area: WCAG 2.2 §2.5.8 asks for 24×24 and the glyph alone is 16. */
.help-tip {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.help-tip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  min-height: 1.5rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-muted-fg);
  font-size: 1em;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: color var(--duration-fast) var(--easing-standard);
}

.help-tip-btn:hover,
.help-tip-btn[aria-describedby] {  /* Bootstrap stamps this while the popup is open */
  color: var(--color-help-header);
}

.help-tip-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* .help-tip-content needs no rule: it is a <template>, which the parser puts in a
   separate fragment — never laid out, never read aloud, and valid inside the <span>
   trigger where a <ul> would not be. See help-tip.js for how it is read back. */

/* ── The popup ───────────────────────────────────────────────────────────────
   Muted green header bar, the same green as the border, black on a light grey
   content well, lifted off the page by a shadow. */
.help-popover {
  --bs-popover-max-width: 22rem;
  --bs-popover-font-size: var(--font-size-sm);
  --bs-popover-bg: var(--color-help-surface);
  --bs-popover-body-color: var(--color-help-fg);
  --bs-popover-border-width: 1px;
  --bs-popover-border-color: var(--color-help-header);
  --bs-popover-border-radius: var(--radius-lg);
  --bs-popover-inner-border-radius: calc(var(--radius-lg) - 1px);
  --bs-popover-box-shadow: var(--elevation-4);
  --bs-popover-header-bg: var(--color-help-header);
  --bs-popover-header-color: var(--color-help-header-fg);
  --bs-popover-header-font-size: var(--font-size-sm);
  --bs-popover-header-padding-x: 0.75rem;
  --bs-popover-header-padding-y: 0.5rem;
  --bs-popover-body-padding-x: 0.75rem;
  --bs-popover-body-padding-y: 0.625rem;
  --bs-popover-arrow-border: var(--color-help-header);
}

.help-popover .popover-header {
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

/* "No title ⇒ no header bar" needs no rule at all, and that is deliberate: Bootstrap's
   TemplateFactory REMOVES .popover-header from the template when the title is empty,
   and .popover-body is transparent over the already-rounded .popover. A short tip is
   therefore the same component with one field left out, not a second code path. */

/* The arrow is filled with --bs-popover-bg, which is right on three sides and wrong on
   the one where it meets the header: a popup placed BELOW its trigger points up into
   the green bar and a grey tip there reads as a rendering fault. Keyed off
   data-popper-placement (Popper stamps it on the popover element) and off the
   --titled class, because an untitled popup has no header for the arrow to match. */
.help-popover.help-popover--titled[data-popper-placement^="bottom"] .popover-arrow::after {
  border-bottom-color: var(--color-help-header);
}

/* ── Content ────────────────────────────────────────────────────────────────
   Authors write a <ul>; these rules are what stop it looking like a document. */
.help-popover .popover-body > :last-child {
  margin-bottom: 0;
}

.help-popover .popover-body ul,
.help-popover .popover-body ol {
  margin-bottom: 0.5rem;
  padding-left: 1.1rem;
}

.help-popover .popover-body li + li {
  margin-top: 0.3rem;
}

.help-popover .popover-body ul ul,
.help-popover .popover-body ol ol {
  margin-top: 0.3rem;
  margin-bottom: 0;
}

.help-popover .popover-body code {
  color: var(--color-help-fg);
  background: rgba(0, 0, 0, 0.06);
  padding: 0.05rem 0.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}

.help-popover .popover-body a {
  color: var(--color-help-header);
  text-underline-offset: 0.15em;
}
