/* css/glossary.css — 名词词典：虚下划线 + 悬浮卡 + 抽屉
   依赖：css/tokens.css 提供 --bg-*, --text-*, --line, --role, --fs-*, --sp-*
*/

/* ────────────────────────────────────────────────
   1. 词条标记：虚下划线，hover 高亮
   ──────────────────────────────────────────────── */
.gterm {
  border-bottom: 1px dashed rgba(120, 140, 200, 0.45);
  cursor: help;
  transition: color 0.15s ease, border-bottom-color 0.15s ease;
  text-decoration: none;
  outline: none;
}
.gterm:hover,
.gterm:focus-visible {
  color: var(--role, var(--info));
  border-bottom-color: var(--role, var(--info));
}

/* 在 button / 选项 / 操作 内部时，弱化下划线避免与按钮悬停态打架 */
.opt .gterm,
.action-btn .gterm,
button .gterm {
  border-bottom-color: rgba(120, 140, 200, 0.22);
  cursor: pointer;
}
.opt .gterm:hover,
.action-btn .gterm:hover,
button .gterm:hover {
  border-bottom-color: rgba(255, 255, 255, 0.45);
  color: inherit;
}

/* 指标 .k 标签里的术语：保持简洁，仅保留极淡的下划线 */
.metric .k .gterm {
  border-bottom-color: rgba(120, 140, 200, 0.18);
}
.metric .k .gterm:hover {
  color: var(--role, var(--info));
  border-bottom-color: var(--role, var(--info));
}

/* ────────────────────────────────────────────────
   2. Tooltip 悬浮卡
   ──────────────────────────────────────────────── */
.gtip {
  position: fixed;
  z-index: 9999;
  width: 340px;
  max-width: calc(100vw - 16px);
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4) var(--sp-3);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--text-1);
  line-height: 1.55;
  box-shadow:
    0 18px 48px -16px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(120, 140, 200, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition:
    opacity 0.16s ease,
    transform 0.16s ease,
    visibility 0s linear 0.16s;
  pointer-events: none;
  left: 0;
  top: 0;
}
.gtip.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition:
    opacity 0.16s ease,
    transform 0.16s ease,
    visibility 0s linear 0s;
  pointer-events: auto;
}

.gtip-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--line);
}
.gtip-term {
  font-size: var(--fs-h3);
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: 0.01em;
}
.gtip-cat {
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.gtip-def {
  color: var(--text-1);
  margin-bottom: var(--sp-2);
}

.gtip-row {
  display: flex;
  gap: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--text-2);
  margin-top: var(--sp-1);
  align-items: flex-start;
}
.gtip-row .k {
  flex-shrink: 0;
  color: var(--text-3);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  margin-top: 3px;
  width: 28px;
  text-align: right;
}

.gtip-more {
  display: block;
  margin-top: var(--sp-3);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
  color: var(--info);
  text-decoration: none;
  text-align: right;
  transition: color 0.15s;
}
.gtip-more:hover {
  color: var(--role, var(--info));
}

/* ────────────────────────────────────────────────
   3. 状态栏「术语库」按钮
   ──────────────────────────────────────────────── */
.statusbar .sb-glossary {
  background: rgba(120, 140, 200, 0.06);
  border: 1px solid var(--line);
  color: var(--text-2);
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.15s ease;
  text-transform: uppercase;
}
.statusbar .sb-glossary:hover {
  border-color: var(--role, var(--info));
  color: var(--role, var(--info));
  background: var(--role-soft, rgba(79, 195, 247, 0.08));
}

/* ────────────────────────────────────────────────
   4. 抽屉 — 术语库面板
   ──────────────────────────────────────────────── */
.gdrawer {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  visibility: hidden;
  transition: visibility 0s linear 0.32s;
}
.gdrawer.show {
  visibility: visible;
  transition: visibility 0s;
  pointer-events: auto;
}

.gdrawer-mask {
  position: absolute;
  inset: 0;
  background: rgba(7, 9, 15, 0.65);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.32s ease;
}
.gdrawer.show .gdrawer-mask {
  opacity: 1;
}

.gdrawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 440px;
  max-width: 92vw;
  background: var(--bg-1);
  border-left: 1px solid var(--line-strong);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: -16px 0 48px -16px rgba(0, 0, 0, 0.6);
}
.gdrawer.show .gdrawer-panel {
  transform: translateX(0);
}

.gdrawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  flex-shrink: 0;
}
.gdrawer-title {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
}
.gdrawer-title h3 {
  margin: 0;
  font-size: var(--fs-h2);
  color: var(--text-1);
  letter-spacing: 0.02em;
}
.gdrawer-count {
  font-size: var(--fs-xs);
  color: var(--text-3);
  letter-spacing: 0.05em;
}
.gdrawer-close {
  background: none;
  border: 1px solid var(--line);
  color: var(--text-2);
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gdrawer-close:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(239, 83, 80, 0.08);
}

.gdrawer-search {
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  flex-shrink: 0;
}
.gdrawer-input {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text-1);
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.gdrawer-input::placeholder {
  color: var(--text-3);
}
.gdrawer-input:focus {
  border-color: var(--role, var(--info));
  background: var(--bg-3);
}

.gdrawer-list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: var(--sp-5);
}
.gdrawer-list::-webkit-scrollbar { width: 8px; }
.gdrawer-list::-webkit-scrollbar-thumb {
  background: rgba(120, 140, 200, 0.18);
  border-radius: 4px;
}

.gdrawer-group {
  margin-top: var(--sp-2);
}
.gdrawer-cat {
  padding: var(--sp-2) var(--sp-5);
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}

.gdrawer-item {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line);
  transition: background 0.6s ease;
}
.gdrawer-item.flash {
  background: var(--role-soft, rgba(79, 195, 247, 0.14));
}
.gdrawer-term-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  flex-wrap: wrap;
}
.gdrawer-term-head h4 {
  margin: 0;
  font-size: var(--fs-h3);
  color: var(--text-1);
  letter-spacing: 0.01em;
}
.gdrawer-alias {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-family: var(--font-mono);
}
.gdrawer-def {
  margin: 0 0 var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-1);
  line-height: 1.6;
}
.gdrawer-row {
  display: flex;
  gap: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--text-2);
  margin-top: var(--sp-1);
  line-height: 1.55;
  align-items: flex-start;
}
.gdrawer-row b {
  flex-shrink: 0;
  color: var(--text-3);
  font-weight: 500;
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  margin-top: 3px;
  width: 28px;
  text-align: right;
}
.gdrawer-row span {
  flex: 1;
}

.gdrawer-empty {
  padding: var(--sp-7) var(--sp-5);
  text-align: center;
  color: var(--text-3);
  font-size: var(--fs-sm);
}

/* ────────────────────────────────────────────────
   5. 移动适配
   ──────────────────────────────────────────────── */
@media (max-width: 720px) {
  .gtip {
    width: calc(100vw - 16px);
    max-width: 360px;
    font-size: var(--fs-sm);
  }
  .gdrawer-panel {
    width: 100vw;
    max-width: 100vw;
  }
  .gdrawer-head { padding: var(--sp-3) var(--sp-4); }
  .gdrawer-search { padding: var(--sp-3) var(--sp-4); }
  .gdrawer-cat { padding: var(--sp-2) var(--sp-4); }
  .gdrawer-item { padding: var(--sp-3) var(--sp-4); }
}
