LOS ANGELES—A judge on Thursday ruled that Kevin Spacey and his production companies must pay the makers of “House of Cards” nearly $31 million because of losses brought on by his 2017 firing for the sexual harassment of crew members. The ruling from Los Angeles Superior Court Judge Mel Red Recana gives the force of…