/* ZenithUI — ZenCommandPalette (skin-aware, direction-neutral by construction). */
@layer zenith-components {
  .zen-command-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--zen-overlay-scrim, rgb(0 0 0 / 45%));
  }

  .zen-command-palette {
    position: fixed;
    /* Anchored above centre: the eye lands here, and a centred panel jumps as the
       result list grows and shrinks under the cursor. */
    top: 12vh;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    width: min(640px, calc(100vw - 32px));
    max-height: min(60vh, 560px);
    overflow: hidden;
    background: var(--zen-bg-elevated);
    border: 1px solid var(--zen-border);
    border-radius: var(--zen-radius-card);
    box-shadow: var(--zen-elev-overlay);
    font-family: var(--zen-font-family);
    color: var(--zen-text-primary);
  }

  /* === Search === */
  .zen-command-search {
    display: flex;
    align-items: center;
    gap: var(--zen-space-2, 8px);
    padding: var(--zen-space-3, 12px) var(--zen-space-4, 16px);
    border-bottom: 1px solid var(--zen-border);
    flex-shrink: 0;
  }

  .zen-command-search__icon {
    display: flex;
    color: var(--zen-text-muted);
  }

  .zen-command-search__input {
    flex: 1;
    min-width: 0;
    border: none;
    background: none;
    color: inherit;
    font-family: inherit;
    font-size: var(--zen-font-size-md, 14px);
    outline: none;
  }

  .zen-command-search__input::placeholder {
    color: var(--zen-text-muted);
  }

  .zen-command-search__spinner {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    border: 2px solid var(--zen-border);
    border-top-color: var(--zen-accent);
    border-radius: var(--zen-radius-full);
    animation: zen-command-spin 700ms linear infinite;
  }

  @media (prefers-reduced-motion: reduce) {
    .zen-command-search__spinner {
      animation: none;
      /* Still legible as "busy" without motion: a solid ring in the accent. */
      border-color: var(--zen-accent);
      opacity: 0.5;
    }
  }

  @keyframes zen-command-spin {
    to { transform: rotate(360deg); }
  }

  .zen-command-search__hint,
  .zen-command-option__shortcut,
  .zen-command-footer kbd {
    padding: 1px 5px;
    border: 1px solid var(--zen-border);
    border-radius: var(--zen-radius-action);
    background: var(--zen-bg-sunken);
    color: var(--zen-text-muted);
    font-family: var(--zen-font-family-mono, monospace);
    font-size: var(--zen-font-size-xs, 11px);
    line-height: 1.5;
  }

  /* === Results === */
  .zen-command-results {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--zen-space-1, 4px);
  }

  .zen-command-group__label {
    padding: var(--zen-space-2, 8px) var(--zen-space-3, 12px) var(--zen-space-1, 4px);
    color: var(--zen-text-muted);
    font-size: var(--zen-font-size-xs, 11px);
    font-weight: var(--zen-font-weight-semibold, 600);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .zen-command-option {
    display: flex;
    align-items: center;
    gap: var(--zen-space-3, 12px);
    padding: var(--zen-space-2, 8px) var(--zen-space-3, 12px);
    border-radius: var(--zen-radius-action);
    cursor: pointer;
  }

  /* Driven by the active INDEX, not :hover — the keyboard is the primary input
     here, and a mouse resting over a different row must not look selected too. */
  .zen-command-option--active {
    background: var(--zen-bg-muted);
  }

  .zen-command-option__icon {
    display: flex;
    flex-shrink: 0;
    width: 16px;
    color: var(--zen-text-muted);
  }

  .zen-command-option__body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
  }

  .zen-command-option__title {
    font-size: var(--zen-font-size-sm, 13px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .zen-command-option__match {
    background: none;
    color: var(--zen-accent);
    font-weight: var(--zen-font-weight-semibold, 600);
  }

  .zen-command-option__description {
    color: var(--zen-text-muted);
    font-size: var(--zen-font-size-xs, 11px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .zen-command-option__shortcut {
    flex-shrink: 0;
  }

  /* === Empty and footer === */
  .zen-command-empty {
    padding: var(--zen-space-6, 24px) var(--zen-space-4, 16px);
    color: var(--zen-text-muted);
    font-size: var(--zen-font-size-sm, 13px);
    text-align: center;
  }

  .zen-command-footer {
    display: flex;
    gap: var(--zen-space-4, 16px);
    padding: var(--zen-space-2, 8px) var(--zen-space-4, 16px);
    border-top: 1px solid var(--zen-border);
    background: var(--zen-bg-sunken);
    color: var(--zen-text-muted);
    font-size: var(--zen-font-size-xs, 11px);
    flex-shrink: 0;
  }

  .zen-command-footer kbd {
    margin-inline-end: 4px;
  }

  @media (prefers-reduced-motion: no-preference) {
    .zen-command-palette {
      animation: zen-command-enter 120ms ease-out;
    }
  }

  @keyframes zen-command-enter {
    from {
      opacity: 0;
      transform: translateX(-50%) translateY(-6px);
    }
  }
}
