/* ============================================================
   Hoverable Definition Tooltips
   Usage: <span class="def" data-def="..." data-link="optional">Term</span>
   JS (publish.js) appends tooltips to body and positions via fixed coords.
   ============================================================ */

.def {
  cursor: help;
  border-bottom: 1.5px dashed currentColor;
  position: relative;
  display: inline;
}

/* Tooltip container — appended to body, positioned by JS */
.def-tooltip {
  position: fixed;

  background: #1a1a2e;
  color: #e0e0e0;
  font-size: 0.82em;
  line-height: 1.6;
  font-family: var(--font-interface, system-ui, sans-serif);
  font-style: normal;
  font-weight: normal;
  text-align: left;

  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06);
  max-width: 340px;
  width: max-content;
  white-space: normal;
  z-index: 9999;
  pointer-events: auto;

  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

/* Arrow — default: bottom-center, pointing down toward the term */
.def-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: var(--arrow-x, 50%);
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: #1a1a2e;
}

/* Flip arrow to top when tooltip is below the term */
.def-tooltip.tooltip-below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #1a1a2e;
}

/* Show state (toggled by JS) */
.def-tooltip.visible {
  opacity: 1;
  visibility: visible;
}

/* Inner content */
.def-tooltip-header {
  margin: 0 0 6px;
  font-size: 0.9em;
  color: #a0a8c0;
  letter-spacing: 0.01em;
}
.def-tooltip-header strong {
  color: #ffffff;
  font-weight: 600;
}

.def-tooltip-body {
  margin: 0;
  color: #d8d8e8;
}

.def-tooltip-link {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.def-tooltip-link a {
  color: #7eb8f7;
  text-decoration: underline;
  text-decoration-color: rgba(126, 184, 247, 0.4);
}
.def-tooltip-link a:hover {
  color: #a8d0ff;
  text-decoration-color: rgba(168, 208, 255, 0.6);
}
