How does the provided JavaScript and CSS code work together to create a responsive sliding navigation menu with an overlay effect that appears when the toggle button is clicked, and what are the key roles of the nav-open and active classes in achieving this behavior?