The decision is a loss for the Justice Department, which argued that a 1964 civil rights law doesn’t protect gay workers.