Genetic variation in pan species is shaped by demographic history and harbors lineage-specific functions