/**
 * CmdKButton — Phase 8 shim for the top-strip command palette trigger.
 *
 * Renders the ⌘K keyboard glyph and, when clicked, dispatches a synthetic
 * Meta+K keydown event on `document`. The existing CommandPalette component
 * in ui/src/components/CommandPalette.tsx installs a document-level keydown
 * listener for Meta+K (see its useEffect at lines 42-51) and opens itself
 * when that key is pressed, so the synthetic event reaches it without
 * needing a refactor to share state.
 *
 * Phase 14 of docs/specs/2026-04-11-nexus-layout-overhaul.md replaces this
 * shim with a proper command-palette context and globalizes the palette's
 * search index. This file will either be deleted or gutted at that point.
 */
export function CmdKButton() {
  const handleClick = () => {
    const event = new KeyboardEvent("keydown", {
      key: "k",
      metaKey: true,
      bubbles: true,
      cancelable: true,
    });
    document.dispatchEvent(event);
  };

  return (
    <button
      type="button"
      onClick={handleClick}
      aria-label="Open command palette"
      title="Open command palette (⌘K)"
      className="inline-flex h-8 items-center gap-2 rounded-[4px] border border-border bg-card px-2 text-[12px] font-medium text-muted-foreground transition-colors hover:text-primary hover:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background"
    >
      <kbd className="font-mono text-[12px]">⌘K</kbd>
    </button>
  );
}
