/* C05 桌面命令面板（2026-11-07）
   ==========================================================================

   侧栏多一个「搜索页面」入口（Ctrl/⌘ + K），打开一个居中面板：输入即过滤、
   ↑↓ 选择、回车跳转、Esc 关闭并把焦点交回入口。

   只做桌面：入口在 `.desktop-nav` 里，而侧栏在 900px 以下本来就是 `display:none`
   （`graphite.css`）。因此手机上这个面板既没有入口也不会被快捷键打开 ——
   `command-palette.js` 在 `open()` 里用 `offsetParent` 再挡一道，避免出现
   「面板开了但父级是 display:none，屏幕上什么都没有」的死状态。

   为什么选择器都带 `.ui-reference`：这份样式表在 `base.html` 里排在
   `graphite.css` / `ui-reference.css` / `surface-rhythm.css` **之后**，
   但仍按项目惯例显式提高权重，避免以后调整加载顺序时被无声覆盖。
   ========================================================================== */

/* -- 入口 ---------------------------------------------------------------- */

.ui-reference .desktop-nav__search {
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  width: calc(100% - 20px);
  min-height: 40px;
  margin: 0 10px 18px;
  padding: 8px 10px;
  border: 1px solid var(--line-soft, #e6e0d8);
  border-radius: 10px;
  background: var(--bg-card, #fbfaf7);
  color: var(--text-secondary, #6c645c);
  font: inherit;
  font-size: .875rem;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
}
.ui-reference .desktop-nav__search .ui-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}
.ui-reference .desktop-nav__search span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ui-reference .desktop-nav__search:hover {
  color: var(--text-primary, #171717);
  border-color: var(--line-subtle, #efeae4);
}
.ui-reference .desktop-nav__search:focus-visible {
  outline: 2px solid var(--accent-dark, #4b4036);
  outline-offset: 2px;
}
.ui-reference .desktop-nav__kbd {
  margin-left: auto;
  padding: 1px 6px;
  border: 1px solid var(--line-soft, #e6e0d8);
  border-radius: 5px;
  background: var(--bg-page, #f7f6f2);
  color: var(--text-tertiary, #a49b92);
  font-family: inherit;
  font-size: .6875rem;
  line-height: 1.6;
  white-space: nowrap;
}

/* -- 面板 ---------------------------------------------------------------- */

.ui-reference .command-palette {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: 12vh 20px 20px;
}
.ui-reference .command-palette__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 23, 23, .32); /* 「轻压暗」：能看出底下的页面还在，但不抢注意力 */
}
.ui-reference .command-palette__panel {
  position: relative;
  width: min(560px, 100%);
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-soft, #e6e0d8);
  border-radius: 16px;
  background: var(--bg-card, #fbfaf7);
  box-shadow: 0 24px 60px rgba(23, 23, 23, .18);
  overflow: hidden;
}
.ui-reference .command-palette__field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft, #e6e0d8);
}
.ui-reference .command-palette__input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text-primary, #171717);
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
  outline: none;
}
.ui-reference .command-palette__input::placeholder {
  color: var(--text-tertiary, #a49b92);
}
.ui-reference .command-palette__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-tertiary, #a49b92);
  cursor: pointer;
}
.ui-reference .command-palette__close .ui-icon {
  width: 18px;
  height: 18px;
}
.ui-reference .command-palette__close:hover {
  color: var(--text-primary, #171717);
  background: var(--bg-card-soft, #eae6e0);
}
.ui-reference .command-palette__close:focus-visible {
  outline: 2px solid var(--accent-dark, #4b4036);
  outline-offset: 2px;
}
.ui-reference .command-palette__list {
  flex: 1 1 auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  overflow-y: auto;
}
.ui-reference .command-palette__option {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--text-primary, #171717);
  font-size: .9375rem;
  line-height: 1.4;
  cursor: pointer;
}
.ui-reference .command-palette__option.is-active {
  background: var(--bg-card-soft, #eae6e0);
}
/* 匹配高亮：不用浏览器默认的荧光黄 —— 这个面板是暖中性色，荧光黄会像一处错误。
   加粗 + 下划线既保留「这几个字命中了」的语义，也不破坏配色。 */
.ui-reference .command-palette__option mark {
  background: transparent;
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.ui-reference .command-palette__empty {
  margin: 0;
  padding: 18px 16px;
  color: var(--text-secondary, #6c645c);
  font-size: .875rem;
  line-height: 1.6;
}
.ui-reference .command-palette__hint {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 10px 14px;
  border-top: 1px solid var(--line-soft, #e6e0d8);
  color: var(--text-tertiary, #a49b92);
  font-size: .75rem;
  line-height: 1.6;
}
.ui-reference .command-palette__hint kbd {
  padding: 1px 5px;
  border: 1px solid var(--line-soft, #e6e0d8);
  border-radius: 5px;
  background: var(--bg-page, #f7f6f2);
  font-family: inherit;
  font-size: .6875rem;
  line-height: 1.6;
}

/* 面板打开时锁住页面滚动：否则滚轮会把底下的列表一起滚走。 */
body.command-palette-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: no-preference) {
  .ui-reference .command-palette__panel {
    animation: command-palette-in .12s ease-out both;
  }
  @keyframes command-palette-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

/* ---------------------------------------------------------------------------
 * 面板住在侧栏里，而侧栏是 `position: sticky` —— sticky 会建立自己的层叠上下文，
 * 所以面板的 `z-index: 80` 只在侧栏内部有效。侧栏本身 `z-index: auto`，在根层叠
 * 顺序里排在 `<main>` 之前，于是 `<main>` 里任何定位元素都会盖住面板：
 * 趋势 / 任务页那块大图 `.ui-page-scene`（`position: relative`）就是实测的一例
 * —— 面板被页面标题和照片压住，只有列表下半截看得见（2026-11-07 截图发现）。
 *
 * 给侧栏一个显式层级即可，不动面板自己的 z-index，也不动 `<main>`。
 * ------------------------------------------------------------------------ */
.ui-reference .desktop-nav {
  z-index: 70;
}
