Have you ever seen a rainbow in a bubble or a soap film? That's because light reflects and refracts off the thin layers of soap or water molecules in the film!
This is called thin-film interference. When light hits a thin layer of material, some of the light reflects off the top layer while some of it continues to pass through and reflect off the bottom layer. These reflections interfere with each other, causing some colors to cancel out and others to become more intense.
This is similar to when you combine two waves in a pool – sometimes they cancel out and create a smaller wave, but other times they add together to create a bigger wave.
Thin-film interference is why oil slicks on water appear to have rainbow colors, and why some sunglasses have a rainbow tint when viewed in certain angles. It's also used in technology like anti-reflective coatings on glasses and computer screens.
So whenever you see colorful reflections on a surface, remember it's because of thin-film interference!