Well, technically, never. Since the shogun always was at least formally appointed by the emperor, in terms of status, the emperor always was above the shogun. However, in terms of actual political power, that was not the case.
Now, the short answer to your question is “its complicated.” laughs
The long answer is that I would suggest it’s the result of many developments within society over a very long span of time, so here’s my personal (and rather selective!) take on the first half of the question, that of “why did the shogun eclipse the emperor”:
In ancient Japan, the emergent Japanese state can be conceived as a sort of tribal confederation, with the various tribes—or clans (uji, one translation is as questionable as the other)—acknowledging the supremacy of the imperial house, and thus being subsumed into what became the imperial state; their chieftains were effectively transformed into nobles within the imperial system. This state adapted political thought from T’ang China, as well as the religion of Buddhism. The system adapted from the continent introduced a bureaucratic administration and centralized the state, strengthening the position of the imperial court; we call this system the ritsuryō state, and its codes remained in effect until the first years of the Meiji period! As a result, many of these old clans, effectively lost power over time, and the imperial court became the arena of constant power struggles between the nobles, who staffed the bureaucracy, and the emperor. One of the results of this power struggle during this period was that many new offices, which were not part of the original bureaucratic design, and thus could be placed directly under the emperor’s control, emerged (such as the kebiishi, effectively the imperial capital’s police). However, over time, these offices tended to become, again, integrated into the imperial bureaucracy dominated by the nobles (the last few sentences are pretty much ripping off Satō Shin’ichi's Nihon no chūsei kokka). From around the eight century onward, many of the old noble families stemming from the old system were displaced by four great houses: the Fujiwara, Minamoto, Taira, and Tachibana, who monopolized all positions within the higher nobility and central bureaucracy. Two of these—the Minamoto and Taira—are actually multiple lineages descended from several dozen imperial princes (31 and 4, to be exact).
Around the early tenth century, a change within society emerged: the land was originally all under possession of the emperor and divided into several administrative units (provinces, and within provinces districts and so on). However, at first in order to provide funding for great Buddhist monasteries, estates were created which were exempt from taxes, corvée labour, and so on, and thus no longer under the control of provincial governors. This practice spread beyond Buddhist monasteries, and local managers of districts or the like—who incidentally happened to predominantly be professional warriors—made contact not only with these religious institutions, but also with powerful nobles at court that were of higher rank than provincial governors and therefore could guarantee tax exemptions and other privileges versus the provincial representants of the state, in return for a share of the now-exempt taxes. Thus, the “imperial” land was infringed on by a new form of “private” property, which, in time, transformed even the provincial lands to be managed as if it, too, were estates. This constitutes the fundamental social system of medieval Japan.
The emergence of this estate system was accompanied by the emergence of professional warriors: the imperial court had abandoned the idea of a conscript army, since it proved more expensive than it effective, which led to a privatization of the military sphere in the hands of the aforementioned professionals (see, for example, William Wayne Farris and Karl Friday’s various works on this development). That these were often landholding local elites is no surprise, since it required financial resources to not only afford a horse, but also dedicate time to master the arts of riding and archery—both, especially at the same time—being highly specialist skills.
The problem, now, is that the one who suffered the most from this development was the emperor himself. He technically "owned" all the land, so it made no sense for him to secure such special rights over his own land. This might serve as the economic argument for the emergence of the dominant political system within the imperial court of the early medieval period until the late 14th century: retired emperorship.
By abdicating the throne, it became possible for an emperor to act no longer as the symbolic embodiment of the state, but as a “private” person, like any other noble. The first to do so was (Retired) Emperor Shirakawa in 1086. The imperial family (because who else is more exalted?) became the “biggest” player in the new game of amassing estates, which it mostly managed through newly established Buddhist monasteries under their control (so-called goganji, "votive temples") and by huge swaths of land under control of imperial spouses [a digression: one of the reasons why many women during this time were often very influential in politics is that they controlled huge economic resources!].
Around this time, another development slowly encroached upon society: the emergence of the ie (family, or house). Offices became hereditary, as became professions: commoners always had the same job; warriors had the same job (i.e., were always officials of the same district or village and, well, warriors); nobles had the same job (or rather: only a small handful of nobles were now qualified to ascend to a specific office, instead of, in theory, everyone). Therefore, positions of authority became crystalized within family lineages, which led to this “smaller” kinship unit becoming more important than the large clans of yore. This development would have completed its permeation of society around the mid-13th century.
This is roughly the situation in the twelfth century when warriors emerged as a force in politics. Several political crises occurred in the twelfth century which could not be solved without the use of armed force. These, the Hōgen and Heiji and Incidents (or Insurrections, or Disturbances) from 1156 and 1160, were struggles over the imperial succession. The former pitted members of branches (families) of the aforementioned Minamoto and Taira lineages, who had become professional warriors generations ago, against each other. The result was the destruction of the Minamoto side, and the ascension of the Taira branch under Taira no Kiyomori to the highest ranks and offices at court. Kiyomori had autocratic ambitions, married his daughter to the emperor, made his grandson emperor, and locked up the retired emperor (the actual power at court). However, survivors of the previous conflict rose in rebellion; the ensuing Genpei War from 1180–1185 led to the almost complete extinction of the Taira ie under Kiyomori.
Minamoto no Yoritomo, the first shogun as we understand the term today and founder of the Kamakura shogunate, made an arrangement with the imperial court. To simplify matters, this first shogunate was only dominating the East of Japan, restricting its authority to direct vassals of the shogun, and formally acknowledging the supremacy of the imperial polity. It acted as the police and military of the court, if the need arose. However, in 1221, retired emperor Gotoba (who in pop-history and especially Wikipedia is inexplicably described as weak, despite having been the last truly powerful autocrat at court until the 1330s) challenged the shogunate, which fell into crisis after the assassination of the third shogun, Minamoto no Sanetomo, and the resulting end of the Minamoto lineage. Gotoba decisively lost the ensuing Jōkyū Disturbance (or War) of 1221, as a result vowing that the court from now on would abstain from the use of armed force. He and his descendants were banished from the capital, and his nephew became the new emperor; also, a huge amount of shogunate vassals were now placed in the West of Japan, which was relatively untouched by shogunate authority until this point, being placed in the former lands of Gotoba and his supporters.