/* Canonical (i) tooltip — pair with app/templates/includes/info_hint.html.
   CSS-only hover + focus-visible. */

.info-hint {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  vertical-align: middle;
  cursor: help;
  outline: none;
  isolation: isolate;
  flex-shrink: 0;
}

/* Canonical (i) — gray/white circle, italic serif "i" (the distinctive info glyph). */
.info-hint-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #b8bbc4;
  font-size: 11px;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1;
  user-select: none;
  transition: background 120ms ease, color 120ms ease;
}

.info-hint:hover .info-hint-icon,
.info-hint:focus-visible .info-hint-icon {
  background: rgba(99, 162, 255, 0.18);
  color: #ffffff;
}

.info-hint:hover,
.info-hint:focus-visible {
  z-index: 20000;
}

.info-hint:focus-visible {
  box-shadow: 0 0 0 2px rgba(99, 162, 255, 0.45);
  border-radius: 50%;
}

/* Dark slate panel, neutral border. */
.info-hint-bubble {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  min-width: 220px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 14px;
  background: #1F2937;
  color: #E5E7EB;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  font-size: 11px;
  line-height: 1.6;
  text-align: left;
  font-style: normal;
  font-weight: 400;
  font-family: inherit;
  white-space: normal;
  word-wrap: break-word;
  max-height: min(360px, 60vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
  z-index: 20001;
}

.info-hint-bubble strong {
  display: block;
  margin-bottom: 6px;
  color: #ffffff;
  font-weight: 600;
}

.info-hint-body {
  display: block;
  color: #E5E7EB;
}

/* Multi-item bodies (migrated from technical.html .info-tooltip-item). */
.info-hint-item + .info-hint-item {
  margin-top: 10px;
}
.info-hint-item strong {
  display: block;
  margin-bottom: 6px;
  color: #ffffff;
  font-weight: 600;
}

/* Rich body_html: headings, paragraphs, inline code (migrated from backtester's
   .race-info-tooltip / .bt-info-tip). A <p> wrapper keeps its own <strong> inline —
   the bare-strong title rule above only blocks direct-child / info-hint-item strongs. */
.info-hint-bubble h4 {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
}
.info-hint-bubble h4:not(:first-child) {
  margin-top: 12px;
}
.info-hint-bubble p {
  margin: 0 0 6px;
}
.info-hint-bubble p:last-child {
  margin-bottom: 0;
}
.info-hint-bubble p strong {
  display: inline;
  margin: 0;
}
.info-hint-bubble code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.85em;
  color: #a78bfa;
}

.info-hint:hover .info-hint-bubble,
.info-hint:focus-visible .info-hint-bubble {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.info-hint-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1F2937;
}

/* ── JS-assisted absolute placement (app/static/js/info_hint.js) ──
   Stays position:absolute so it is immune to ancestor transform / backdrop-filter
   (which break position:fixed). Classes flip the bubble below / anchor it sideways
   when a centered, upward bubble would clip against the viewport. */
.info-hint.info-hint-below .info-hint-bubble {
  bottom: auto;
  top: calc(100% + 8px);
}
.info-hint.info-hint-below .info-hint-bubble::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #1F2937;
}
.info-hint.info-hint-align-right .info-hint-bubble {
  left: auto;
  right: 0;
  transform: translateX(0) translateY(4px);
}
.info-hint.info-hint-align-left .info-hint-bubble {
  left: 0;
  right: auto;
  transform: translateX(0) translateY(4px);
}
.info-hint.info-hint-align-right:hover .info-hint-bubble,
.info-hint.info-hint-align-right:focus-visible .info-hint-bubble,
.info-hint.info-hint-align-left:hover .info-hint-bubble,
.info-hint.info-hint-align-left:focus-visible .info-hint-bubble {
  transform: translateX(0) translateY(0);
}
.info-hint.info-hint-align-right .info-hint-bubble::after {
  left: auto;
  right: 5px;
  transform: none;
}
.info-hint.info-hint-align-left .info-hint-bubble::after {
  left: 5px;
  transform: none;
}

/* ── Portaled bubble (app/static/js/info_hint.js moves it to <body>) ──
   Rendered fixed and above the sticky header, and interactive so the user can move
   onto it and scroll long content. JS sets left/top and --info-hint-arrow. */
.info-hint-bubble.info-hint-bubble--portal {
  position: fixed !important;
  left: 0;
  top: 0;
  right: auto;
  bottom: auto;
  margin: 0;
  transform: none !important;
  opacity: 0;
  pointer-events: none;
  z-index: 2147483600;
  transition: opacity 120ms ease;
}
.info-hint-bubble.info-hint-bubble--portal.info-hint-bubble--show {
  opacity: 1;
  pointer-events: auto;
}
.info-hint-bubble.info-hint-bubble--portal::after {
  top: 100%;
  bottom: auto;
  left: var(--info-hint-arrow, 50%);
  right: auto;
  transform: translateX(-50%);
  border-top-color: #1F2937;
  border-bottom-color: transparent;
}
.info-hint-bubble.info-hint-bubble--portal.info-hint-bubble--below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #1F2937;
}

/* NOTE: the legacy .info-hint-floating rules (position:fixed bubble driven by page-local
   JS) were removed — position:fixed resolves against any ancestor with backdrop-filter/
   transform (CSS containing-block rule), which misplaced/clipped bubbles inside blurred
   cards (the screener bug). The class is now inert; the shared portal script
   (js/info_hint.js, loaded globally via includes/app_sidebar.html) owns floating
   placement by portaling the bubble to <body>. */

@media (max-width: 480px) {
  .info-hint-bubble {
    min-width: 180px;
    max-width: calc(100vw - 32px);
    font-size: 11px;
  }
}
