/* ==========================================================================
   DESK Tooltip System
   Dark tooltip with dotted underline trigger. Works on hover, tap, focus.
   ========================================================================== */

/* The trigger: a term wrapped in <span class="term">.
   Uses a dotted underline to signal "definable term" without shouting. */
.term {
  position: relative;
  border-bottom: 1px dotted currentColor;
  cursor: help;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.term:hover,
.term:focus-visible,
.term.is-open {
  color: #3b82f6; /* accent blue */
  border-bottom-color: #3b82f6;
  outline: none;
}

.term:focus-visible {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
  border-radius: 2px;
}

/* The tooltip itself — rendered dynamically by tooltip.js.
   Absolutely positioned to the body so it can escape overflow:hidden parents. */
.desk-tooltip {
  position: absolute;
  z-index: 9999;
  max-width: 320px;
  min-width: 200px;
  padding: 12px 14px;
  background: #1a1a1a;
  color: #e5e5e5;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.3),
    0 10px 15px -3px rgba(0, 0, 0, 0.2);
  font-size: 14px;
  line-height: 1.5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.desk-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto; /* allow clicking close button on mobile */
}

.desk-tooltip-term {
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.desk-tooltip-category {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.desk-tooltip-definition {
  color: #d4d4d4;
}

/* Close button — only shown on touch devices */
.desk-tooltip-close {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: #a0a0a0;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  border-radius: 4px;
}

.desk-tooltip-close:hover {
  color: #ffffff;
  background: #2a2a2a;
}

/* Arrow pointer */
.desk-tooltip::before {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  transform: rotate(45deg);
}

.desk-tooltip[data-position="top"]::before {
  bottom: -5px;
  left: 50%;
  margin-left: -4px;
  border-top: none;
  border-left: none;
}

.desk-tooltip[data-position="bottom"]::before {
  top: -5px;
  left: 50%;
  margin-left: -4px;
  border-bottom: none;
  border-right: none;
}

/* Mobile: make tooltips larger, show close button, prevent overflow */
@media (max-width: 640px), (hover: none) {
  .desk-tooltip {
    max-width: calc(100vw - 32px);
    font-size: 15px;
    padding: 16px 18px 14px;
  }

  .desk-tooltip-close {
    display: block;
  }

  .desk-tooltip-term {
    padding-right: 28px; /* space for close button */
  }
}

/* ==========================================================================
   Glossary page styles
   ========================================================================== */

.glossary-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px 96px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: #1a1a1a;
  line-height: 1.6;
}

.glossary-page h1 {
  font-size: 36px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}

.glossary-page .subtitle {
  font-size: 17px;
  color: #666;
  margin: 0 0 32px;
}

.glossary-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 32px;
  position: sticky;
  top: 0;
  background: white;
  padding: 16px 0;
  z-index: 10;
  border-bottom: 1px solid #e5e5e5;
}

.glossary-search {
  flex: 1;
  min-width: 240px;
  padding: 10px 14px;
  font-size: 15px;
  border: 1px solid #d4d4d4;
  border-radius: 6px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

.glossary-search:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.glossary-filter {
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid #d4d4d4;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-family: inherit;
}

.glossary-category {
  margin-bottom: 36px;
}

.glossary-category-name {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #3b82f6;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e5e5e5;
}

.glossary-entry {
  padding: 16px 0;
  border-bottom: 1px solid #f0f0f0;
}

.glossary-entry:last-child {
  border-bottom: none;
}

.glossary-entry-term {
  font-size: 18px;
  font-weight: 600;
  color: #1a1a1a;
  margin: 0 0 4px;
}

.glossary-entry-aliases {
  font-size: 13px;
  color: #999;
  margin: 0 0 8px;
  font-style: italic;
}

.glossary-entry-definition {
  font-size: 15px;
  color: #333;
  margin: 0;
}

.glossary-empty {
  text-align: center;
  padding: 48px 16px;
  color: #999;
  font-size: 15px;
}

/* Hidden state for filtering */
.glossary-entry[hidden],
.glossary-category[hidden] {
  display: none;
}
