Fundamental limits to single-photon detection determined by quantum coherence and backaction