Double-layered dynamics: A unified theory of projected dynamical systems and evolutionary variational inequalities