/* ==========================================================================
   Glossary Term Inline Linking
   Hand-drawn highlighter style with inline expand/collapse definitions
   ========================================================================== */

/* --- The glossary term (clickable word) --- */

glossary-term {
  display: inline;
  border-bottom: 2px dotted rgba(124, 58, 237, 0.5);
  padding-bottom: 1px;
  background-color: rgba(124, 58, 237, 0.04);
  cursor: pointer;
  border-radius: 2px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

glossary-term:hover,
glossary-term:focus-visible {
  background-color: rgba(124, 58, 237, 0.1);
  border-bottom-color: rgba(124, 58, 237, 0.75);
  outline: none;
}

glossary-term[aria-expanded="true"] {
  background-color: rgba(124, 58, 237, 0.12);
  border-bottom-color: rgba(124, 58, 237, 0.75);
}

/* --- The expanded definition block --- */

.glossary-definition {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease-out, opacity 0.2s ease-out, margin 0.2s ease-out;
  opacity: 0;
  margin: 0;
}

.glossary-definition[aria-hidden="false"] {
  max-height: 300px;
  opacity: 1;
  margin: 0.75rem 0;
}

.glossary-definition-inner {
  position: relative;
  border: 1px solid var(--color-border-light, #e5e7eb);
  border-left: 3px solid rgba(124, 58, 237, 0.3);
  border-radius: 0.5rem;
  background: rgba(124, 58, 237, 0.03);
  padding: 1rem 1.25rem;
  font-size: 0.9em;
  line-height: 1.6;
  max-width: 36rem;
}

.glossary-definition-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.glossary-definition-term {
  font-weight: 600;
  color: var(--color-text-primary, #1f2937);
}

.glossary-definition-pronunciation {
  font-size: 0.85em;
  color: var(--color-text-muted, #9ca3af);
  font-style: italic;
}

.glossary-definition-close {
  appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted, #9ca3af);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.25rem;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.25rem;
  transition: color 0.15s ease, background-color 0.15s ease;
  flex-shrink: 0;
}

.glossary-definition-close:hover,
.glossary-definition-close:focus-visible {
  color: var(--color-text-primary, #1f2937);
  background-color: rgba(0, 0, 0, 0.05);
}

.glossary-definition-text {
  color: var(--color-text-secondary, #4b5563);
  margin-bottom: 0.5rem;
}

.glossary-definition-example {
  color: var(--color-text-tertiary, #6b7280);
  font-style: italic;
  font-size: 0.9em;
  margin-bottom: 0.5rem;
}

.glossary-definition-footer {
  text-align: right;
  margin-top: 0.75rem;
}

.glossary-definition-link {
  font-size: 0.85em;
  color: var(--color-primary, #7c3aed);
  text-decoration: none;
  font-weight: 500;
}

.glossary-definition-link:hover {
  text-decoration: underline;
}

/* --- Reduced motion --- */

@media (prefers-reduced-motion: reduce) {
  glossary-term {
    transition: none;
  }

  .glossary-definition {
    transition: none;
  }
}
