/* ═══════════════════════════════════════════════════════════════════════════
   Cmd+K command palette - overlay panel + toolbar button.
   Scope: .cmdk-* classes only.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Nav "Find anything" button ─────────────────────────────────────────────
   Dark-theme search affordance living in the navy #nav strip. Sole entry
   point for the cmd palette (the prior toolbar-mounted twin was removed -
   one global affordance avoids the "which search does which" confusion).
   `margin-left: auto` groups it with the right-side affordances (role
   context wrap) so it doesn't sit flush against the last chapter tab. */
.cmdk-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--nav-muted);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.cmdk-nav-btn:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}
.cmdk-nav-btn:focus-visible {
  outline: none;
  border-color: var(--orange-bright);
  box-shadow: 0 0 0 3px rgba(255, 106, 19, 0.18);
}
.cmdk-nav-btn-icon {
  font-size: 12px;
  opacity: 0.85;
}
.cmdk-nav-btn-label {
  white-space: nowrap;
}
.cmdk-nav-btn-kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 4px;
  color: var(--nav-muted);
  letter-spacing: 0.02em;
}
/* Collapse the label below ~1280px so the search affordance stays in the
   nav strip without pushing the role-context wrap onto a second row. The
   icon + kbd chip remain visible - that's enough to teach the shortcut. */
@media (max-width: 1280px) {
  .cmdk-nav-btn-label { display: none; }
}
/* Mobile (≤840px) - the bottom-tab nav owns navigation; hide this control
   to avoid two competing search affordances. */
@media (max-width: 840px) {
  .cmdk-nav-btn { display: none; }
}

/* ── Overlay ─────────────────────────────────────────────────────────────── */
#cmdk-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  animation: cmdkOverlayIn 0.16s ease-out;
}
#cmdk-overlay.hidden { display: none; }
@keyframes cmdkOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Panel ───────────────────────────────────────────────────────────────── */
.cmdk-panel {
  width: min(640px, 90vw);
  max-height: 70vh;
  background: #FFFFFF;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  box-shadow: 0 24px 60px -12px rgba(15, 23, 42, 0.45),
              0 0 0 1px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  animation: cmdkPanelIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes cmdkPanelIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Top accent stripe - matches OrgFoundry brand idiom */
.cmdk-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #FF5A00 0%, #FF8C42 100%);
}

/* ── Search row ─────────────────────────────────────────────────────────── */
.cmdk-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid #F3F4F6;
}
.cmdk-search-icon {
  font-size: 16px;
  color: #6B7280;
  flex: 0 0 auto;
}
#cmdk-input {
  flex: 1;
  border: 0;
  background: transparent;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 15px;
  color: #111827;
  outline: none;
  letter-spacing: -0.01em;
}
#cmdk-input::placeholder {
  color: #9CA3AF;
  font-weight: 400;
}
.cmdk-search-hint {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

/* ── Results list ────────────────────────────────────────────────────────── */
.cmdk-results {
  flex: 1;
  overflow-y: auto;
  padding: 6px 6px;
}

.cmdk-group-head {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #9CA3AF;
  padding: 10px 12px 4px;
  position: sticky;
  top: 0;
  background: #FFFFFF;
}

.cmdk-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.08s ease;
  border: 1px solid transparent;
}
.cmdk-row-selected {
  background: #FFFBEB;
  border-color: #FED7AA;
}
.cmdk-row-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: #F3F4F6;
  color: #4B5563;
  font-size: 11px;
  font-weight: 800;
  flex: 0 0 22px;
}
.cmdk-row-selected .cmdk-row-icon {
  background: #FF5A00;
  color: #FFFFFF;
}
.cmdk-row-body {
  flex: 1;
  min-width: 0;
}
.cmdk-row-label {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.cmdk-row-sub {
  font-size: 11px;
  color: #6B7280;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmdk-row mark {
  background: #FEF3C7;
  color: #92400E;
  padding: 0 1px;
  border-radius: 2px;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.cmdk-empty {
  text-align: center;
  padding: 36px 20px;
  color: #6B7280;
}
.cmdk-empty-icon {
  font-size: 32px;
  color: #D1D5DB;
  margin-bottom: 10px;
}
.cmdk-empty-msg {
  font-size: 13px;
  font-weight: 700;
  color: #111827;
}
.cmdk-empty-sub {
  font-size: 11px;
  color: #9CA3AF;
  margin-top: 4px;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.cmdk-foot {
  display: flex;
  gap: 16px;
  padding: 8px 18px;
  border-top: 1px solid #F3F4F6;
  background: #FAFAFA;
  font-size: 10.5px;
  color: #6B7280;
}
.cmdk-foot span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ── Kbd chip ────────────────────────────────────────────────────────────── */
.cmdk-kbd {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  background: #FFFFFF;
  color: #4B5563;
  border: 1px solid #E5E7EB;
  border-radius: 3px;
  letter-spacing: 0.02em;
  vertical-align: middle;
  line-height: 1.4;
}
.cmdk-kbd-cmd {
  font-size: 11px;
}
.cmdk-foot .cmdk-kbd {
  background: #FFFFFF;
  border-color: #D1D5DB;
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #cmdk-overlay { padding-top: 8vh; }
  .cmdk-panel { width: calc(100vw - 16px); max-height: 80vh; }
  .cmdk-toolbar-btn { min-width: 0; }
  .cmdk-toolbar-btn-label { display: none; }
}
