/* Tooltip triggers (nolink legacy + generic markers) */
.wh_related_links a[data-scope="external"]:not([href]),
a.nolink,
*[outputclass~="nolink"],
/* New generic trigger classes / attributes */
.has-tooltip,
a.has-tooltip,
[data-tooltip],
[class*="ttip--"] {
  color: inherit;
  text-decoration: underline dotted currentColor; /* dotted underline for visual affordance */
  text-underline-offset: 2px;
  cursor: help;
  position: relative;
  transition: color 0.15s ease;
  border-bottom: none;
}

/* Hover / focus state */
.has-tooltip:hover,
a.has-tooltip:hover,
[data-tooltip]:hover,
[class*="ttip--"]:hover,
a.nolink:hover,
*[outputclass~="nolink"]:hover,
.wh_related_links a[data-scope="external"]:not([href]):hover,
.has-tooltip:focus,
a.has-tooltip:focus,
[data-tooltip]:focus,
[class*="ttip--"]:focus,
a.nolink:focus,
*[outputclass~="nolink"]:focus,
.wh_related_links a[data-scope="external"]:not([href]):focus {
  color: inherit;
  outline: none;
  text-decoration: underline dotted currentColor;
  border-bottom: none;
}

/* Tooltip container */
.tooltip {
  position: absolute;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
  transform: translateY(-8px);
}

.tooltip.show {
  opacity: 1;
  pointer-events: auto;
}

/* Tooltip bubble - based on Figma specs */
.tooltip-content {
  background: var(--white);
  border-radius: var(--border-radius-lg);
  padding: 14px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--black);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-width: 300px;
  width: max-content;
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Arrow (pseudo-element for seamless shape) */
.tooltip.tooltip-top .tooltip-content::after,
.tooltip.tooltip-bottom .tooltip-content::after {
  content: '';
  position: absolute;
  left: var(--arrow-left, 50%);
  transform: translateX(-50%);
  width: 0;
  height: 0;
}

/* Tooltip below trigger -> arrow points up (placed on top edge) */
.tooltip.tooltip-top .tooltip-content::after {
  top: -12px; /* equals arrow height */
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 12px solid var(--white);
  filter: drop-shadow(0 -1px 2px rgba(0,0,0,0.12));
}

/* Tooltip above trigger -> arrow points down (placed under bubble) */
.tooltip.tooltip-bottom .tooltip-content::after {
  bottom: -12px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 12px solid var(--white);
  filter: drop-shadow(0 -1px 2px rgba(0,0,0,0.12));
}

/* Support arrow horizontal alignment variants if classes remain in JS (fallback) */
.tooltip.tooltip-arrow-left .tooltip-content::after { left: 24px; transform: none; }
.tooltip.tooltip-arrow-right .tooltip-content::after { left: auto; right: 24px; transform: none; }

/* Responsive adjustments */
@media (max-width: 768px) {
  .tooltip-content {
    max-width: 160px;
    font-size: 11px;
    padding: 12px;
  }
}

/* Animation improvements */
@media (prefers-reduced-motion: reduce) {
  .tooltip {
    transition: none;
  }
}

/* High contrast support */
@media (prefers-contrast: high) {
  .tooltip-content {
    border: 2px solid #000000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
}

/* =====================================================
   ABBR TITLE TOOLTIP (lightweight variant)
   ===================================================== */
abbr[title] {
  text-decoration: underline dotted currentColor;
  cursor: help;
  text-underline-offset: 2px;
}

abbr[title][data-has-custom-abbr] { /* ensure same visual if JS removed title later */
  position: relative;
}

.abbr-tooltip {
  position: absolute;
  z-index: var(--z-tooltip, 1070);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  transform: translateY(-4px);
}

.abbr-tooltip.show { opacity: 1; transform: translateY(0); }

.abbr-tooltip__content {
  background: var(--white, #fff);
  color: var(--black, #303030);
  font-size: 12px;
  line-height: 1.3;
  font-family: 'Inter', sans-serif;
  padding: 8px 10px;
  border-radius: var(--border-radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  border: 1px solid rgba(0,0,0,0.12);
  max-width: 240px;
  position: relative;
}

.abbr-tooltip.pos-top .abbr-tooltip__content:after,
.abbr-tooltip.pos-bottom .abbr-tooltip__content:after {
  content:'';
  position:absolute;
  left:var(--arrow-left, 50%);
  transform:translateX(-50%);
  width:0;height:0;
}

.abbr-tooltip.pos-top .abbr-tooltip__content:after { /* arrow pointing down (tooltip above) */
  bottom:-10px;
  border-left:7px solid transparent;
  border-right:7px solid transparent;
  border-top:10px solid var(--white, #fff);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}
.abbr-tooltip.pos-bottom .abbr-tooltip__content:after { /* arrow pointing up (tooltip below) */
  top:-10px;
  border-left:7px solid transparent;
  border-right:7px solid transparent;
  border-bottom:10px solid var(--white, #fff);
  filter: drop-shadow(0 -1px 2px rgba(0,0,0,0.15));
}

/* Validation variant used by header search */
.title-tooltip[data-tooltip-variant="validation"] .abbr-tooltip__content {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 18px;
}

.title-tooltip[data-tooltip-variant="validation"] .title-tooltip__icon {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  display: inline-flex;
  margin-top: 2px;
}

.title-tooltip[data-tooltip-variant="validation"] .title-tooltip__icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.title-tooltip[data-tooltip-variant="validation"] .title-tooltip__text {
  display: block;
}
