/* ============================================================
   全局即时搜索（search-modal）
   设计令牌沿用 main.css（--surface / --line / --brand / --accent-soft 等），
   深浅色通过 :root[data-theme="dark"] 自动跟随。
   类型标签色相：由 JS 写入 --tag-h（与主题 jr_attr_hue 同源 crc32），
   保证同一类型每次同色，呼应「方案随机背景色 Label」风格。
   ============================================================ */

/* ---- 导航触发按钮 ---- */
.nav__search {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  /* 高度对齐 .lang-switch__btn / .theme-toggle / .nav__login 三件 30px */
  height: 30px;
  padding: 0 .5rem;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  font: inherit;
  line-height: 1;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.nav__search:hover { color: var(--brand); border-color: var(--accent-line); }
.nav__search svg { flex: 0 0 auto; }
.nav__search-kbd {
  font-family: var(--font-mono);
  font-size: .65rem;
  color: var(--text-faint);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: 0 4px;
  line-height: 1.6;
}
.nav__search:hover .nav__search-kbd { color: var(--brand); border-color: var(--accent-line); }

/* ---- 弹层 ---- */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(1rem, 9vh, 6rem) 1rem 1rem;
}
.search-modal[hidden] { display: none; }

.search-modal__backdrop {
  position: absolute;
  inset: 0;
  background: oklch(18% 0.02 262 / 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
:root[data-theme="dark"] .search-modal__backdrop { background: oklch(8% 0.01 262 / 0.66); }

.search-modal__panel {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--r-sm) * 2);
  box-shadow: 0 28px 70px -22px oklch(20% 0.03 262 / 0.5);
  display: flex;
  flex-direction: column;
  max-height: min(80vh, 720px);
  overflow: hidden;
}

.search-modal__form {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--line);
}
.search-modal__icon { color: var(--text-faint); flex: 0 0 auto; }
.search-modal__input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  outline: none;
}
.search-modal__input::placeholder { color: var(--text-faint); }
.search-modal__input::-webkit-search-cancel-button { display: none; }
.search-modal__clear {
  border: 0;
  background: transparent;
  color: var(--text-faint);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 .25rem;
  flex: 0 0 auto;
}
.search-modal__clear:hover { color: var(--text); }
.search-modal__hint {
  font-family: var(--font-mono);
  font-size: .68rem;
  color: var(--text-faint);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: 2px 6px;
  flex: 0 0 auto;
}

/* ---- 结果区 ---- */
.search-modal__results {
  overflow-y: auto;
  padding: var(--s-3) var(--s-4) var(--s-4);
  scrollbar-width: thin;
}
.search-modal__loading,
.search-modal__empty {
  padding: var(--s-8) var(--s-4);
  text-align: center;
  color: var(--text-faint);
}
.search-modal__tip { margin-top: .25rem; font-size: .85rem; color: var(--text-faint); }
.search-modal__tip kbd {
  font-family: var(--font-mono);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: 0 4px;
}

.search-group { padding: var(--s-2) 0; }
.search-group + .search-group { border-top: 1px solid var(--line); }
.search-group__head { display: flex; align-items: center; gap: .5rem; padding: .25rem .5rem .5rem; }
.search-group__pill {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .03em;
  padding: 2px 9px;
  border-radius: 999px;
  background: hsl(var(--tag-h, 286) 72% 93%);
  color: hsl(var(--tag-h, 286) 42% 34%);
}
.search-group__count { font-size: .72rem; color: var(--text-faint); }
:root[data-theme="dark"] .search-group__pill {
  background: hsl(var(--tag-h, 286) 40% 26%);
  color: hsl(var(--tag-h, 286) 60% 82%);
}

.search-group__list { display: flex; flex-direction: column; gap: 2px; }
.search-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: .55rem .6rem;
  border-radius: var(--r-sm);
  color: var(--text);
  text-decoration: none;
  transition: background var(--t-fast);
}
.search-item:hover,
.search-item.is-active { background: var(--accent-soft); }
.search-item__thumb {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-item__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.search-item__thumb--empty::after {
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: var(--accent-line);
}
.search-item__body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.search-item__title {
  font-weight: 500;
  font-size: .98rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-item__excerpt {
  font-size: .82rem;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
mark.search-hl {
  background: var(--accent-soft);
  color: var(--brand);
  padding: 0 .15em;
  border-radius: 3px;
  font-weight: 600;
}

.search-modal__foot {
  display: flex;
  gap: var(--s-5);
  padding: .5rem var(--s-5);
  border-top: 1px solid var(--line);
  font-size: .74rem;
  color: var(--text-faint);
}
.search-modal__foot kbd {
  font-family: var(--font-mono);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: 0 5px;
  margin-right: 2px;
}

@media (max-width: 560px) {
  .nav__search-kbd { display: none; }
  .search-modal__hint { display: none; }
  .search-modal__foot { display: none; }
}
