Tight correlation-function Bell inequality for multipartite d-dimensional systems