Molecular optics approach to electromagnetic wave interactions with stratified media