Recreating a menu comparable to Mac OS

Hi all, I am trying to recreate a menu similar to the Mac OS menu, but I am struggling with the animations and assume it is a case for custom code.

The behaviour should be like this:

  1. I click a menu item, the dropdown opens
  2. I hover over a second item, the dropdown changes
  3. I click outside or a link within the dropdown, the active dropdown closes

If there is a code wizard out there who could tell me if and how this is possible I would be eternally grateful!

Best regards,