You can’t go just by color. Most Wire colors are not mandated by code in most of the US, and people can and do use any color, especially if it’s getting towards the end of the day and there’s only one spool left in the toolbox. You have to map the circuits to see which wire is which.
If you live near a Home Depot, many of these offer a free class in installing a light switch. They won’t cover smart switches, but you will learn how to use the tools to map the circuits and some good basics about light switches.