/* glossary.css
 *
 * Styling for the automatic glossary filter (glossary.lua).
 *
 * - .glossary-term: marked occurrences in the body text.
 *   Underlined, with a pure-CSS tooltip on hover/focus showing the
 *   full definition from the `data-definition` attribute.
 * - #glossary-list: the full glossary rendered wherever
 *   `::: {#glossary-list}` was placed in the qmd.
 */

.glossary-term {
  position: relative;
  cursor: help;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, currentColor 50%, transparent);
}

/* Let keyboard users reach the tooltip too. */
.glossary-term:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  border-radius: 2px;
}

.glossary-term::after {
  content: attr(data-definition);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 9px);
  transform: translateX(-50%) translateY(4px);
  width: max-content;
  max-width: 22em;
  padding: 0.5em 0.75em;
  border-radius: 6px;
  background: #1f1f1f;
  color: #f5f5f5;
  font-size: 0.85em;
  font-weight: normal;
  text-decoration: none;
  line-height: 1.4;
  white-space: normal;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 20;
}

/* Small arrow pointing down at the marked term. */
.glossary-term::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 3px);
  transform: translateX(-50%);
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: #1f1f1f transparent transparent transparent;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 20;
}

.glossary-term:hover::after,
.glossary-term:hover::before,
.glossary-term:focus-visible::after,
.glossary-term:focus-visible::before {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .glossary-term::after,
  .glossary-term::before {
    transition: none;
  }
}

@media (max-width: 600px) {
  .glossary-term::after {
    max-width: 16em;
  }
}

/* --- Glossary listing (full list, alphabetical, one paragraph per term) --- */

#glossary-list p {
  margin: 0 0 0.9em 0;
  line-height: 1.5;
}

#glossary-list p:last-child {
  margin-bottom: 0;
}

#glossary-list strong {
  font-weight: 600;
}
