Complementary genomic and epigenomic adaptation to environmental heterogeneity