Electromagnetic waves in stratified media