High-contrast gratings as generalized Fabry-Pérot interferometers