A hidden Markov model for latent temporal clustering with application to ideological alignment in the U.S. Supreme Court