/* LaunchGate Glossary Tooltip — Shared Component
 * Provides hover/tap tooltips for technical terms on landing pages.
 * Works with glossary.js + LG_I18N for translated definitions.
 */

/* ---- Term styling ---- */
.glossary-term {
  position: relative;
  cursor: help;
  border-bottom: 1.5px dotted rgba(79, 70, 229, 0.5);
  color: inherit;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.glossary-term:hover,
.glossary-term.glossary-active {
  border-bottom-color: var(--brand, #4f46e5);
  color: var(--brand, #4f46e5);
}

/* ---- Tooltip container ---- */
.glossary-tooltip {
  position: absolute;
  z-index: 9999;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 300px;
  padding: 12px 16px;
  background: rgba(17, 24, 39, 0.95);
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  font-size: 0.85rem;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* Visible state */
.glossary-tooltip.glossary-visible {
  opacity: 1;
  visibility: visible;
}

/* ---- Arrow (pointing down to term) ---- */
.glossary-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(17, 24, 39, 0.95);
}

/* ---- Edge repositioning ---- */
.glossary-tooltip.glossary-align-left {
  left: 0;
  transform: translateX(0);
}
.glossary-tooltip.glossary-align-left::after {
  left: 16px;
  transform: translateX(0);
}

.glossary-tooltip.glossary-align-right {
  left: auto;
  right: 0;
  transform: translateX(0);
}
.glossary-tooltip.glossary-align-right::after {
  left: auto;
  right: 16px;
  transform: translateX(0);
}

/* When there is no room above, show below */
.glossary-tooltip.glossary-below {
  bottom: auto;
  top: calc(100% + 10px);
}
.glossary-tooltip.glossary-below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: rgba(17, 24, 39, 0.95);
}

/* ---- Inner elements ---- */
.glossary-fullform {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
  color: #e0e7ff;
}

.glossary-explanation {
  color: #d1d5db;
  font-size: 0.82rem;
}

.glossary-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.78rem;
  color: #a5b4fc;
  text-decoration: none;
  transition: color 0.15s ease;
}
.glossary-link:hover {
  color: #c7d2fe;
  text-decoration: underline;
}

/* ---- Animation: fade in ---- */
@keyframes glossaryFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.glossary-tooltip.glossary-visible {
  animation: glossaryFadeIn 0.2s ease forwards;
}
.glossary-tooltip.glossary-align-left.glossary-visible,
.glossary-tooltip.glossary-align-right.glossary-visible {
  animation: none; /* transform differs, just use opacity transition */
}

/* ---- Mobile: slightly wider padding, larger tap target ---- */
@media (max-width: 640px) {
  .glossary-term {
    padding: 2px 0;
  }
  .glossary-tooltip {
    max-width: 260px;
    font-size: 0.82rem;
    padding: 10px 14px;
  }
}
