Direct observation of reversible oxygen migration and phase transitions in ferroelectric Hf0.5Zr0.5O2 thin-film devices