refactor hidden menu script

- hide menu on click anywhere
- refactor toggle code to reevaluate every time whether menu is showing
Backward-compatible update to include new syntax

Included new classes based on latest CSS3 flexbox draft
Retained existing classes for backward-compatibility
updated demo to use new classes