Depolarization of synchrotron radiation in a multilayer magneto-ionic medium