A motivic approach to phase transitions in Potts models