/* ── TERM TOOLTIP COMPONENT ──────────────────────────────────
   Usage:
   <span class="term-tip" data-term="ai-debt">AI debt</span>

   The JS reads data-term, looks it up in GLOSSARY_TERMS,
   and shows a tooltip on hover (desktop) or tap (mobile).
   Each tooltip links to the full glossary entry.
──────────────────────────────────────────────────────────── */

/* ── CSS ── */
.term-tip {
  border-bottom: 1px dotted var(--color-accent-deep, #C1440E);
  cursor: help;
  position: relative;
  transition: border-color 0.2s ease;
}
.term-tip:hover {
  border-bottom-style: solid;
}

/* Icon variant — for use inside styled containers (pills, badges) where
   a dotted underline would look out of place. Renders as a small ⓘ glyph. */
.term-tip--icon,
.term-tip--icon:hover {
  border-bottom: none;
}
.term-tip--icon {
  margin-left: 0.3rem;
  font-size: 0.85em;
  opacity: 0.6;
  vertical-align: middle;
  transition: opacity 0.2s ease;
}
.term-tip--icon:hover {
  opacity: 1;
}

.term-tip__popup {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  background: #fff;
  border: 1px solid var(--border-dark, #C8C5CE);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  box-shadow: 0 8px 30px -12px rgba(20, 50, 52, 0.18);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: translateX(-50%) translateY(4px);
  /* Reset inherited text styling so the popup renders the same regardless
     of where the trigger lives (pills, headings, mono blocks, etc.). */
  text-transform: none;
  letter-spacing: normal;
  font-style: normal;
  font-weight: normal;
  text-align: left;
}

.term-tip__popup.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* Arrow */
.term-tip__popup::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #fff;
}
.term-tip__popup::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: var(--border-dark, #C8C5CE);
}

.term-tip__popup-term {
  font-family: var(--font-display, Georgia);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink, #1C1C1E);
  margin-bottom: 0.4rem;
}

.term-tip__popup-def {
  font-family: var(--font-body, sans-serif);
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--muted, #6B7280);
  margin-bottom: 0.5rem;
}

.term-tip__popup-link {
  font-family: var(--font-body, sans-serif);
  font-size: 0.72rem;
  color: var(--color-accent-deep, #C1440E);
  text-decoration: none;
  font-weight: 500;
}
.term-tip__popup-link:hover {
  text-decoration: underline;
}

/* Mobile: position below instead of above */
@media (max-width: 600px) {
  .term-tip__popup {
    bottom: auto;
    top: calc(100% + 10px);
    width: 280px;
  }
  .term-tip__popup::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #fff;
  }
  .term-tip__popup::before {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: var(--border-dark, #C8C5CE);
  }
}
