/* Glossary tooltip styles */
.glossary-term {
  position: relative;
  display: inline;
  cursor: help;
  border-bottom: 1px dotted #666;
  color: inherit;
  text-decoration: none;
}

.glossary-term:hover {
  border-bottom-color: #007acc;
}

/*
 * The tooltip is positioned via JavaScript (see static/js/glossary.js) using
 * `position: fixed`. This is necessary because the tooltip's natural ancestors
 * include things like `.table-wrapper { overflow-x: auto }` (see
 * layouts/_default/_markup/render-table.html), and any `overflow: auto|hidden|
 * scroll` ancestor clips absolutely-positioned descendants. A fixed-positioned
 * tooltip sits in the viewport, escaping every ancestor overflow context.
 *
 * JS sets `top`/`left` on hover/focus, then unsets them on leave/blur.
 */
.glossary-term > span {
  display: none;
  width: 280px;
  background-color: #fff;
  color: #333;
  text-align: left;
  border-radius: 6px;
  padding: 12px;
  position: fixed;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 1px solid #e1e5e9;
  pointer-events: none;
}

/* Tooltip arrow — JS sets `.tooltip-below` when the tooltip flips beneath
 * the term, in which case the arrow points up from the top edge instead of
 * down from the bottom edge.
 */
.glossary-term > span::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #fff transparent transparent transparent;
}

.glossary-term > span.tooltip-below::after {
  top: auto;
  bottom: 100%;
  border-color: transparent transparent #fff transparent;
}

/* Tooltip visibility is JS-driven. JS adds `.show-tooltip` after computing
 * fixed-position coords for the tooltip. This avoids a one-frame flash where
 * a hover-triggered CSS rule would reveal the tooltip at its un-positioned
 * static origin before the JS gets a chance to place it.
 */
.glossary-term.show-tooltip > span {
  display: block;
}

/* Style the content inside the tooltip */
.glossary-term > span strong {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #2c3e50;
  font-size: 1.1em;
}

.glossary-term > span span {
  margin: 0 0 8px 0;
  font-size: 0.9em;
  line-height: 1.4;
  display: block;
}

.glossary-term > span a {
  font-size: 0.85em;
  color: #007acc;
  text-decoration: none;
  display: inline-block;
  pointer-events: auto;
}

.glossary-term > span a:hover {
  text-decoration: underline;
}

/* Mobile styles */
@media (max-width: 768px) {
  .glossary-term > span {
    width: 250px;
  }
}

/* Missing term style */
.glossary-term.missing {
  border-bottom-color: #ff6b6b;
  color: #ff6b6b;
}


/* External term styling */
.glossary-term.external {
  border-bottom-color: #805ad5; /* Purple for external references */
}

.glossary-term.external:hover {
  border-bottom-color: #6b46c1;
}

/* External indicator in tooltip */
.glossary-term.external > .tooltip-content strong::after {
  content: " (External)";
  font-weight: normal;
  font-size: 0.8em;
  color: #805ad5;
}

/* Dark mode support — use .dark class to match site toggle, not OS preference */
.dark .glossary-term > span {
  background-color: #030712;
  color: #e5e5e5;
  border-color: #374151;
}

.dark .glossary-term > span::after {
  border-color: #030712 transparent transparent transparent;
}

.dark .glossary-term > span.tooltip-below::after {
  border-color: transparent transparent #030712 transparent;
}

.dark .glossary-term > span strong {
  color: #fff;
}

.dark .glossary-term > span a {
  color: #60a5fa;
}
