The decision is a rare win for trans rights at the Supreme Court.