Explaining the states of matter