Cardiff close gap on QPR with thrilling comeback win