/* =========================================================
   Info-tip: small circular `!` help button + tooltip bubble
   =========================================================

   Rolled out portal-wide next to dashboard widget headers,
   tab/tool titles, and field labels so new users can get a
   one-sentence explanation of what an element does.

   Design constraints (firm):
   - Light theme only — no dark backgrounds.
   - Must not disrupt flex/grid layouts — uses inline-flex.
   - Bubble must open on hover AND keyboard focus (a11y).
   - Button is 18–20 px so it reads as "help" not "delete".
*/

.info-tip-wrap {
  display: inline-flex;
  position: relative;
  vertical-align: middle;
  margin-left: 6px;
  line-height: 1;
}

.info-tip-wrap.is-open .info-tip {
  background: #0072BC;
  border-color: #0072BC;
  color: #ffffff;
}

.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid rgba(0, 114, 188, 0.35);
  border-radius: 50%;
  background: rgba(0, 114, 188, 0.08);
  color: #0072BC;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: background 150ms ease, border-color 150ms ease,
              color 150ms ease, box-shadow 150ms ease;
  flex-shrink: 0;
}

.info-tip:hover,
.info-tip:focus-visible {
  background: #0072BC;
  border-color: #0072BC;
  color: #ffffff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 114, 188, 0.20);
}

.info-tip > span {
  display: block;
  pointer-events: none;
}

/* ── Tooltip bubble ──────────────────────────────────────── */
.info-tip-bubble {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  min-width: 220px;
  max-width: 320px;
  padding: 10px 12px;
  background: #ffffff;
  color: #1A2035;
  border: 1px solid rgba(0, 59, 122, 0.14);
  border-radius: 8px;
  box-shadow: 0 12px 32px -8px rgba(0, 59, 122, 0.18),
              0 2px 8px -2px rgba(0, 59, 122, 0.10);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease,
              visibility 0s linear 160ms;
  z-index: 1200;
  white-space: normal;
}

/* `.is-open` is the CLICK state, set by shared_ui/js/info-tip.js. The bubble
   used to open on hover and keyboard focus only, so the `!` was a button that
   did nothing when pressed -- and on a touch screen, where there is no hover,
   it could not be opened at all. Clicking now pins it open until the next
   click outside or Escape. */
.info-tip-wrap.is-open .info-tip-bubble { pointer-events: auto; }

.info-tip-wrap.is-open .info-tip-bubble,
.info-tip-wrap:hover .info-tip-bubble,
.info-tip-wrap:focus-within .info-tip-bubble,
.info-tip:focus-visible + .info-tip-bubble {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  transition: opacity 160ms ease, transform 160ms ease,
              visibility 0s linear 0s;
}

/* The bubble stays pointer-transparent even while open. It is informational,
   and it overlaps whatever sits below the control it belongs to -- on the
   projects KPI strip an open Pipeline Value bubble covered the Tender Pipeline
   header beneath it, so that `!` could not be hovered at all. A tooltip must
   never intercept a pointer meant for something else. */

.info-tip-bubble strong {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  font-size: 12px;
  color: #003B7A;
  letter-spacing: 0.01em;
}

.info-tip-body {
  display: block;
  color: #475569;
  font-weight: 400;
  font-size: 12px;
  line-height: 1.5;
}

.info-tip-body--todo {
  color: #94A3B8;
  font-style: italic;
}

/* ── Arrow pointing up to the button ────────────────────── */
.info-tip-bubble::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: #ffffff;
  border-top: 1px solid rgba(0, 59, 122, 0.14);
  border-left: 1px solid rgba(0, 59, 122, 0.14);
}

/* ── Edge-collision fallback: near right edge, anchor right ─ */
.info-tip-wrap.info-tip-wrap--right .info-tip-bubble {
  left: auto;
  right: 0;
  transform: translateX(0) translateY(4px);
}

.info-tip-wrap.info-tip-wrap--right:hover .info-tip-bubble,
.info-tip-wrap.info-tip-wrap--right:focus-within .info-tip-bubble {
  transform: translateX(0) translateY(0);
}

.info-tip-wrap.info-tip-wrap--right .info-tip-bubble::before {
  left: auto;
  right: 8px;
  transform: rotate(45deg);
}

/* ── RTL support ─────────────────────────────────────────── */
[dir="rtl"] .info-tip-wrap {
  margin-left: 0;
  margin-right: 6px;
}

[dir="rtl"] .info-tip-bubble {
  text-align: right;
}

/* ── Print: hide the button, keep the semantics ─────────── */
@media print {
  .info-tip-wrap { display: none !important; }
}

/* ── Reduced-motion: no fade-in animation ───────────────── */
@media (prefers-reduced-motion: reduce) {
  .info-tip,
  .info-tip-bubble {
    transition: none;
  }
}


/* ── Edge collision: near the left edge, anchor left ─────── */
/* The mirror of --right, which shipped without a counterpart: a tip on the
   first column of a board centres a 220px bubble on a button ~60px from the
   panel edge, so the bubble started off-panel and was clipped. */
.info-tip-wrap.info-tip-wrap--left .info-tip-bubble {
  left: 0;
  right: auto;
  transform: translateX(0) translateY(4px);
}

.info-tip-wrap.info-tip-wrap--left:hover .info-tip-bubble,
.info-tip-wrap.info-tip-wrap--left:focus-within .info-tip-bubble {
  transform: translateX(0) translateY(0);
}

.info-tip-wrap.info-tip-wrap--left .info-tip-bubble::before {
  left: 8px;
  transform: rotate(45deg);
}

/* ── The bubble does not inherit its container's voice ───── */
/* A tip sits wherever the thing it explains sits: an uppercase eyebrow, a
   letter-spaced label, an italic caption. The bubble is a descendant of that
   element, so without this it renders its title in the container's styling --
   "YOUR NEXT ACTION" instead of "Your next action" on the My Day hero. It is
   a panel of reading text and always reads as one.

   NOT resettable this way: `opacity` on an ancestor, which creates a group a
   descendant cannot escape. A faded container needs its fade moved onto the
   text itself (see platform/tabs/_inbox_hero.html). */
.info-tip-bubble {
  text-transform: none;
  letter-spacing: normal;
  font-style: normal;
  font-weight: 400;
}

/* ── On a dark surface ───────────────────────────────────── */
/* The default `!` is brand blue on a pale blue wash, which all but vanishes
   on the inbox hero's dark blue gradient. The BUBBLE stays light — it is a
   panel of reading text and follows the project's no-dark-backgrounds rule;
   only the button itself inverts to sit on the card. */
.inbox-hero .info-tip {
  border-color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.inbox-hero .info-tip:hover,
.inbox-hero .info-tip:focus-visible,
.inbox-hero .info-tip-wrap.is-open .info-tip {
  background: #ffffff;
  border-color: #ffffff;
  color: var(--brand-secondary, #003B7A);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.28);
}

/* ── Containers that would clip their own tooltip ────────── */
/* A bubble is positioned against .info-tip-wrap but painted inside whatever
   ancestor clips. The board's phase columns set overflow:hidden for their
   rounded corners, which cut the column tooltip off at both edges. Their
   children never overflow, so visible costs nothing. */
.phase-col,
.pw-kpis,
.pw-pipeline {
  overflow: visible;
}
