/* ============================================================
   command-palette.css — refined for a minimal, classy feel.

   Design notes:
   - Layered shadow (ambient + edge + lift) instead of one heavy
     drop shadow — feels lighter, more refined.
   - Backdrop: stronger blur + saturation = frosted-glass without
     visual heaviness.
   - Per-row "COMMAND / FILE / DRAFT" badge is visually hidden
     (sr-only). The group heading + subtitle already communicate
     type; the badge text became redundant noise on every row.
     Grid restructured from 4 to 3 columns to absorb the slot.
   - Typography: titles shed weight (600 → 500) and gain micro
     letter-spacing; small caps headers tighten and shrink.
   - Active-row transition is short and silky.
   ============================================================ */

.command-palette {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: grid;
  place-items: start center;
  padding: min(12vh, 96px) 18px 18px;
  background: rgba(15, 18, 25, 0.3);
  color: var(--fg-default);
  font-family: var(--font-sans);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
}

:root[data-theme="dark"] .command-palette {
  background: rgba(0, 0, 0, 0.55);
}

.command-palette[hidden] {
  display: none;
}

.command-palette__panel {
  width: min(640px, 100%);
  overflow: hidden;
  border: 1px solid var(--border-default);
  border-radius: 14px;
  background: var(--bg-canvas);
  /* Layered shadows — ambient + edge + lift */
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 8px 24px rgba(0, 0, 0, 0.08),
    0 32px 96px rgba(0, 0, 0, 0.18);
}

:root[data-theme="dark"] .command-palette__panel {
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.2),
    0 8px 24px rgba(0, 0, 0, 0.3),
    0 32px 96px rgba(0, 0, 0, 0.5);
}

/* ─── Search ─── */
.command-palette__search {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.command-palette__search-icon,
.command-palette-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-subtle);
  flex-shrink: 0;
}

.command-palette__search-icon svg,
.command-palette-btn-icon svg {
  width: 16px;
  height: 16px;
}

.command-palette__input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--fg-default);
  font: inherit;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: -0.005em;
  line-height: 1.4;
}

.command-palette__input::placeholder {
  color: var(--fg-subtle);
  letter-spacing: 0;
}

/* ─── Meta line (count / hint) ─── */
.command-palette__meta {
  min-height: 26px;
  padding: 12px 18px 4px;
  color: var(--fg-subtle);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ─── List & groups ─── */
.command-palette__list {
  max-height: min(58vh, 520px);
  overflow: auto;
  padding: 4px 8px 14px;
}

.command-palette__group {
  padding: 14px 12px 6px;
  color: var(--fg-subtle);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ─── Rows ─── */
.command-palette__row {
  display: grid;
  /* Was 4 cols (badge + text + shortcut + disabled). Badge is now
     sr-only and out of flow → 3 cols. */
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--fg-muted);
  cursor: pointer;
  transition:
    background-color 100ms ease,
    color 100ms ease;
}

.command-palette__row[aria-selected="true"] {
  background: var(--bg-subtle);
  color: var(--fg-default);
}

.command-palette__row[data-disabled="true"] {
  cursor: default;
  opacity: 0.45;
}

.command-palette__row[data-disabled="true"][aria-selected="true"] {
  opacity: 0.62;
}

/* Badge: visually hidden, retained for screen readers.
   The group heading and subtitle already communicate type. */
.command-palette__badge {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.command-palette__text {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.command-palette__title,
.command-palette__subtitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-palette__title {
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: inherit;
}

.command-palette__subtitle {
  font-size: 11.5px;
  color: var(--fg-subtle);
  letter-spacing: 0;
}

.command-palette__disabled {
  max-width: 220px;
  overflow: hidden;
  color: var(--fg-subtle);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.85;
}

.command-palette__shortcut {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  background: var(--bg-subtle);
  color: var(--fg-subtle);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.02em;
  line-height: 1.4;
  white-space: nowrap;
  opacity: 0.85;
}

/* Match highlights on search */
.command-palette mark {
  padding: 0;
  background: color-mix(in srgb, var(--accent-fg) 22%, transparent);
  color: inherit;
  border-radius: 3px;
}

/* ─── Empty state ─── */
.command-palette__empty {
  padding: 52px 18px 60px;
  color: var(--fg-subtle);
  font-size: 13px;
  text-align: center;
  letter-spacing: 0.01em;
}

/* ─── Toolbar trigger active state ─── */
#commandPaletteBtn[aria-expanded="true"] {
  background: var(--bg-subtle);
  color: var(--fg-default);
}

/* ─── Mobile ─── */
@media (max-width: 640px) {
  .command-palette {
    padding: 12px;
    place-items: start stretch;
    backdrop-filter: blur(8px) saturate(120%);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
  }

  .command-palette__panel {
    width: 100%;
    border-radius: 12px;
  }

  .command-palette__list {
    max-height: calc(100dvh - 168px);
  }

  .command-palette__row {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .command-palette__badge,
  .command-palette__shortcut,
  .command-palette__disabled {
    max-width: none;
  }
}
