/* ===== Google Font import for hand-drawn look ===== */
@import url('https://fonts.googleapis.com/css2?family=Architects+Daughter&display=swap');

/* Glossary tooltip — hand-drawn sketch style
   Transforms native title="" tooltips on glossary links into
   stylized popups that match the mermaid handDrawn aesthetic. */

/* ===== Glossary link styling ===== */
a[href^='#glossary-'] {
  color: #c2185b;
  text-decoration: none;
  border-bottom: 1.5px dashed #c2185b;
  cursor: help;
  transition:
    color 0.2s,
    border-color 0.2s;
}

a[href^='#glossary-']:hover {
  color: #e91e63;
  border-bottom-color: #e91e63;
}

/* ===== Tooltip container ===== */
.glossary-tooltip {
  position: fixed;
  z-index: 10000;
  max-width: 340px;
  padding: 14px 18px 14px 18px;
  /* Hand-drawn feel: warm off-white, slightly irregular border */
  background: #fffef7;
  border: 2px solid #c2185b;
  border-radius: 4px 12px 4px 12px; /* asymmetric = sketchy */
  box-shadow:
    3px 3px 0 rgba(194, 24, 91, 0.1),
    0 4px 16px rgba(0, 0, 0, 0.12);
  /* Pencil-style font */
  font-family: 'Architects Daughter', 'Segoe Print', 'Comic Neue', cursive, sans-serif;
  font-size: 0.92em;
  line-height: 1.55;
  color: #2d2d2d;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px) rotate(-0.3deg);
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
  /* Subtle paper texture edge */
  outline: 1px solid rgba(0, 0, 0, 0.04);
  outline-offset: -1px;
}

.glossary-tooltip.visible {
  opacity: 1;
  transform: translateY(0) rotate(-0.3deg);
}

/* ===== Term title (bold, colored) ===== */
.glossary-tooltip .tooltip-term {
  display: block;
  font-weight: 700;
  font-size: 1.05em;
  color: #c2185b;
  margin-bottom: 4px;
  /* Slight hand-underline effect */
  border-bottom: 1.5px solid rgba(194, 24, 91, 0.25);
  padding-bottom: 4px;
}

/* ===== Description text ===== */
.glossary-tooltip .tooltip-desc {
  display: block;
  color: #3a3a3a;
  font-size: 0.95em;
}

/* ===== Decorative corner marks (sketch feel) ===== */
.glossary-tooltip::before,
.glossary-tooltip::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border-color: #c2185b;
  border-style: solid;
  opacity: 0.35;
}

.glossary-tooltip::before {
  top: 4px;
  left: 4px;
  border-width: 2px 0 0 2px;
  border-radius: 2px 0 0 0;
}

.glossary-tooltip::after {
  bottom: 4px;
  right: 4px;
  border-width: 0 2px 2px 0;
  border-radius: 0 0 2px 0;
}

/* ===== Arrow / pointer ===== */
.glossary-tooltip .tooltip-arrow {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fffef7;
  border-left: 2px solid #c2185b;
  border-top: 2px solid #c2185b;
  transform: rotate(225deg); /* points down by default */
  top: -7px;
  left: 24px;
}

.glossary-tooltip.arrow-bottom .tooltip-arrow {
  top: auto;
  bottom: -7px;
  transform: rotate(45deg); /* points up */
}

/* ===== Chapter preview variant ===== */
.glossary-tooltip.chapter-preview {
  max-width: 420px;
}

.glossary-tooltip.chapter-preview .tooltip-term {
  font-size: 0.92em;
  letter-spacing: 0.01em;
}

.glossary-tooltip.chapter-preview .tooltip-desc {
  font-style: italic;
  font-size: 0.88em;
  line-height: 1.5;
  opacity: 0.92;
}

/* ===== Dark mode adjustments ===== */
@media (prefers-color-scheme: dark) {
  a[href^='#glossary-'] {
    color: #f48fb1;
    border-bottom-color: #f48fb1;
  }

  a[href^='#glossary-']:hover {
    color: #f8bbd0;
    border-bottom-color: #f8bbd0;
  }

  .glossary-tooltip {
    background: #2a2520;
    color: #e8e0d4;
    border-color: #f48fb1;
    box-shadow:
      3px 3px 0 rgba(244, 143, 177, 0.12),
      0 4px 16px rgba(0, 0, 0, 0.35);
    outline-color: rgba(255, 255, 255, 0.04);
  }

  .glossary-tooltip .tooltip-term {
    color: #f48fb1;
    border-bottom-color: rgba(244, 143, 177, 0.3);
  }

  .glossary-tooltip .tooltip-desc {
    color: #d4cab8;
  }

  .glossary-tooltip::before,
  .glossary-tooltip::after {
    border-color: #f48fb1;
  }

  .glossary-tooltip .tooltip-arrow {
    background: #2a2520;
    border-left-color: #f48fb1;
    border-top-color: #f48fb1;
  }
}

/* ===== Flex theme dark class ===== */
.dark a[href^='#glossary-'],
[data-theme='dark'] a[href^='#glossary-'] {
  color: #f48fb1;
  border-bottom-color: #f48fb1;
}

.dark .glossary-tooltip,
[data-theme='dark'] .glossary-tooltip {
  background: #2a2520;
  color: #e8e0d4;
  border-color: #f48fb1;
  box-shadow:
    3px 3px 0 rgba(244, 143, 177, 0.12),
    0 4px 16px rgba(0, 0, 0, 0.35);
}

.dark .glossary-tooltip .tooltip-term,
[data-theme='dark'] .glossary-tooltip .tooltip-term {
  color: #f48fb1;
  border-bottom-color: rgba(244, 143, 177, 0.3);
}

.dark .glossary-tooltip .tooltip-desc,
[data-theme='dark'] .glossary-tooltip .tooltip-desc {
  color: #d4cab8;
}

.dark .glossary-tooltip::before,
.dark .glossary-tooltip::after,
[data-theme='dark'] .glossary-tooltip::before,
[data-theme='dark'] .glossary-tooltip::after {
  border-color: #f48fb1;
}

.dark .glossary-tooltip .tooltip-arrow,
[data-theme='dark'] .glossary-tooltip .tooltip-arrow {
  background: #2a2520;
  border-left-color: #f48fb1;
  border-top-color: #f48fb1;
}
