/* =========================================
   Glossary Tooltip System
   For PeptideLibraryHub
   ========================================= */

/* Glossary term styling */
.glossary-term {
  border-bottom: 1.5px dotted var(--gray-400, #9ca3af);
  cursor: help;
  position: relative;
  transition: border-color 0.2s ease;
}

.glossary-term:hover {
  border-bottom-color: var(--blue-accent, #3b82f6);
}

/* Tooltip container */
.glossary-tooltip {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--navy, #1e293b);
  color: var(--white, #ffffff);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.5;
  max-width: 280px;
  word-wrap: break-word;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  white-space: normal;
}

/* Tooltip arrow pointing down */
.glossary-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--navy, #1e293b);
}

/* Show tooltip on hover */
.glossary-term:hover .glossary-tooltip {
  opacity: 1;
  visibility: visible;
}

/* Tooltip active state (for mobile tap) */
.glossary-tooltip.active {
  opacity: 1;
  visibility: visible;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .glossary-tooltip {
    font-size: 0.75rem;
    padding: 8px 12px;
    max-width: 240px;
  }

  /* On mobile, allow tooltips to appear below if near top */
  .glossary-term.tooltip-below .glossary-tooltip {
    bottom: auto;
    top: calc(100% + 8px);
  }

  .glossary-term.tooltip-below .glossary-tooltip::after {
    top: auto;
    bottom: 100%;
    border: 5px solid transparent;
    border-bottom-color: var(--navy, #1e293b);
  }
}

/* Prevent tooltips in certain contexts */
h1 .glossary-term,
h2 .glossary-term,
h3 .glossary-term,
h4 .glossary-term,
h5 .glossary-term,
h6 .glossary-term,
a .glossary-term,
button .glossary-term,
code .glossary-term,
pre .glossary-term,
nav .glossary-term,
footer .glossary-term {
  border-bottom: none;
  cursor: auto;
}

h1 .glossary-term:hover,
h2 .glossary-term:hover,
h3 .glossary-term:hover,
h4 .glossary-term:hover,
h5 .glossary-term:hover,
h6 .glossary-term:hover {
  border-bottom: none;
}
