/* Smart Menu Rounding
   by nerdywhiteguy
   Designed for Nasa Night Launch theme. */

/* anything you're gonna see in a menu should get rounded */

menu, menuitem
{
  -moz-border-radius: 3.5px !important;
  -moz-border-radius-bottomright: 8px !important;
  -moz-border-radius-topright: 8px !important;
}

/* Round menubar-menus even more */

menubar > menu
{
  -moz-border-radius: 10px !important;
}

/* Give menubar-menus and buttons-that-expand-into-menus a flat bottom when expanded
   to make them look almost like tabs */

menubar > menu[open="true"], toolbarbutton[open="true"], button[open="true"] > hbox
{
  -moz-border-radius-bottomleft: 0px !important;
  -moz-border-radius-bottomright: 0px !important;
}

/* Round the menu's container */

menupopup, popup
{
  -moz-border-radius: 15px !important;
}

/* If we aren't in a menubar, make the top of the first element (in the therefor vertical list)
   more rounded to match the rounding of it's container */

:not(menubar) > menu:first-child, :not(menubar) > menuitem:first-child
{
  -moz-border-radius-topleft: 12px !important;
  -moz-border-radius-topright: 12px !important;
}

/* Also, make the last thing's bottom be more rounded.
   (Note that these don't work half of the time due to hidden elements.) */

:not(menubar) > menu:last-child, :not(menubar) > menuitem:last-child
{
  -moz-border-radius-bottomleft: 12px !important;
  -moz-border-radius-bottomright: 12px !important;
}

/* However, if the menu is from a menubar, it's top-left corner should be left un-rounded so that it lines up right */

menubar > menu > menupopup, toolbarbutton > menupopup, button > menupopup
{
  -moz-border-radius-topleft: 0px !important;
}

/* Now that we have done that, the top-left corner of the first choice in that menu shouldn't be rounded either so that it matches */

menubar > menu > menupopup > :first-child, toolbarbutton > menupopup > :first-child, button > menupopup > :first-child
{
  -moz-border-radius-topleft: 0px !important;
}

/* However, if we are in a sub-menu, due to the way NNL positions sub-menus relative to their container,
   we should round it's upper-right corner ever so slightly so that it lines up nicely. */

menupopup > menu > menupopup, popup > menu > menupopup
{
  -moz-border-radius-topleft: 4px !important;
}

/* Then round the first choice in that sub-menu just a teeny-tiny bit */

menupopup > menu > menupopup > :first-child, popup > menu > menupopup > :first-child
{
  -moz-border-radius-topleft: 1px !important;
}

/* If we aren't in a menubar (and are therefor in a vertical list) and the menu is expanded,
   make it's right side (the side the menu will likely be on) not be rounded
   so that it doesn't start to "pinch off" just before the expanded menu */

:not(menubar) > menu[open="true"]
{
  -moz-border-radius-topright: 0px !important;
  -moz-border-radius-bottomright: 0px !important;
}