/* ==========================================================================
   COMPONENTS · TERM — the inline glossary anchor materialised into a report
   body (glossary inline-linking, delta #7). Its reader-facing behaviour is
   driven ENTIRELY by the `data-term-generated` attribute the offline
   materialiser bakes into `content_html` — pure CSS attribute selectors, no
   per-request logic.

     * default `.op-term` (a term whose entry isn't generated yet) — visually
       identical to body text, silent and inert. The anchor is in the markup but
       reads as ordinary prose; nothing links a term before its entry exists.
     * `.op-term[data-term-generated="true"]` — ink text under a wavy rubric
       underline (the house link idiom, never blue; cf. the dotted `<abbr>`),
       clickable to the term page, with a hover/focus tooltip carrying the
       definition when the materialiser baked one in (`data-term-def`).

   The tooltip is CSS-only and degrades to a plain wavy link with no JS (the
   sidenote popover is the in-house no-JS-popover precedent).
   ========================================================================== */

/* — Default: an ungenerated term is body text. Reset the element-level `a`
     underline + ink link colour (04-elements/_links.css matches every <a>) and
     make it inert, so a not-yet-generated anchor is indistinguishable from the
     prose around it. — */
.op-term {
  color: inherit;
  text-decoration: none;
  cursor: inherit;
  pointer-events: none;
}

/* — Generated: ink text under a wavy rubric underline (the abbr[title] /
     house-link idiom), live and clickable. — */
.op-term[data-term-generated="true"] {
  color: var(--link);
  cursor: pointer;
  pointer-events: auto;
  text-decoration: underline wavy;
  text-decoration-color: var(--link-underline);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
  text-decoration-skip-ink: auto;
  transition: var(--transition-ink);
}
.op-term[data-term-generated="true"]:hover {
  color: var(--link-hover);
  text-decoration-color: var(--link-hover);
}
.op-term[data-term-generated="true"]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* — The tooltip: a CSS-only definition popover, shown on hover/focus, reading
     the definition the materialiser stored in `data-term-def`. With scripting
     off — or the attribute absent (a generated term with no definition yet) —
     the anchor is simply a wavy link. Modelled on the sidenote popover's surface
     (raised leaf, hairline, keyline, pop shadow) in the quiet furniture
     register. — */
.op-term[data-term-generated="true"][data-term-def] {
  position: relative;
}
.op-term[data-term-generated="true"][data-term-def]::after {
  content: attr(data-term-def);
  position: absolute;
  left: 0;
  bottom: calc(100% + var(--space-2xs));
  z-index: 20;
  inline-size: max-content;
  max-inline-size: min(22rem, 70vw);
  padding: var(--space-2xs) var(--space-xs);
  font-family: var(--font-furniture);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--text-secondary);
  text-align: left;
  white-space: normal;
  background: var(--surface-raised);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent-keyline);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-pop);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-fast) var(--ease-standard);
}
.op-term[data-term-generated="true"][data-term-def]:hover::after,
.op-term[data-term-generated="true"][data-term-def]:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

@media (prefers-reduced-motion: reduce) {
  .op-term[data-term-generated="true"][data-term-def]::after { transition: none; }
}
