/* Based on https://css-tricks.com/targetting-menu-elements-submenus-navigation-bar/ */
nav {
  display: block;
  text-align: center;
  margin-bottom: 10px;
  /* margin-top: 20px; */
}
nav ul {
  margin: 0;
  padding:0;
  list-style: none;
  text-align: left;
}
.nav a {
  background: #B9C9FE;
  border: 1px solid #039;
  color: #039;
  display:block; 
  padding: 0.8em 1.8em;
  position: relative;
  text-decoration: none;
}
.nav{  
  vertical-align: top; 
  display: inline-block;
  border-radius: 6px;
}
.nav li {
  position: relative;
}
.nav > li { 
  float: left; 
  border-bottom: 4px #039 solid;
  margin-right: 1px; 
} 
.nav > li > a { 
  margin-bottom: 1px;
}
.nav > li:hover, 
.nav > li:hover > a { 
  border-bottom-color: #B9C9FE;
}
.nav li:hover > a { 
  background: #039;
  color: #B9C9FE;
}
.nav > li:first-child { 
  border-radius: 4px 0 0 4px;
} 
.nav > li:first-child > a { 
  border-radius: 4px 0 0 0;
}
.nav > li:last-child { 
  border-radius: 0 0 4px 0; 
  margin-right: 0;
} 
.nav > li:last-child > a { 
  border-radius: 0 4px 0 0;
}
.nav li li a { 
  margin-top: 1px;
}
.nav li a:first-child:nth-last-child(2):before { 
  content: ""; 
  position: absolute; 
  height: 0; 
  width: 0; 
  border: 5px solid transparent; 
  top: 50% ;
  right:5px;  
 }
 /* submenu positioning*/
 .nav ul {
   position: absolute;
   white-space: nowrap;
   z-index: 1;
   left: -99999em;
 }
 .nav > li:hover > ul {
   left: auto;
   min-width: 100%;
 }
 .nav > li li:hover > ul { 
   left: 100%;
   margin-left: 1px;
   top: -1px;
 }
 /* arrow hover styling */
 .nav > li > a:first-child:nth-last-child(2):before { 
   border-top-color: #039; 
 }
 .nav > li:hover > a:first-child:nth-last-child(2):before {
   border: 5px solid transparent; 
   border-bottom-color: #B9C9FE; 
   margin-top: -5px;
 }
 .nav li li > a:first-child:nth-last-child(2):before {  
   border-left-color: #039; 
   margin-top: -5px;
 }
 .nav li li:hover > a:first-child:nth-last-child(2):before {
   border: 5px solid transparent; 
   border-right-color: #039;
   right: 10px; 
}