Electrodynamics for nanophotonics