First of all, Japan didn't want a large scale war in the Pacific.They were pushed into it by the U.S. who conditioned lifting the oil embargo by withdrawal from China. So Japan was left with 2 choices: becone a second grade power, or go to war. For anyone with some knowledge of Japanese code of honor and stuff the choice they would make was evident.
Secondly, the Japanese made no illusion they could totally defeat the U.S. Their operational plan in the Pacific was to occupy as many islands as possible in the South and Central area and create a defensive ring around Japan. They thought that, after some failed(and costly) attempts to breach it, the americans would be willing to negotiate peace on Japan's terms.
The Pearl Harbor operation was in fact a safety measure, to make sure the Pacific fleet would not interfere with Japanese landings in the Philipines.
The battle of Midway was in fact a very close affair(much closer than it looks). The decisive blow against the Japanese carriers was delivered by american dive bombers, which, after a long fruitless search, located their enemies just as they were launching what was meant to be the doom of the american fleet(an 104 aircraft strike force). Had the american bombers arrived about 10 minutes later, they would have probably lost the battle: the Japanese aircraft would have already left for their target and the damage to the japanese carriers would have been much less substantial(most of the damage was not done by the american bombs, but from their own planes with ammo and fuel blowing up).
As for the naval battles after Midway, Japanese were crippled by the lack of radar(which the Americans began to use to its full extent both for warning against air attacks and for artillery fire) and by the fact that, not planning a long war, they had organised no way of preparing replacement pilots for their airforce).