From the Japan Cultural Expo (Agency for Cultural Affairs and Japan Arts Council).
In 784 the capital moved from Heijo-kyo (Nara) to Nagaoka-kyo. Only ten years later, in 794, it moved again to Heian-kyo, today’s Kyoto.
Apart from one short move, the capital stayed there for more than 1,100 years, until Tokyo became the capital in 1868.
At first the ritsuryo system, with the Emperor at its center, still worked. From the late 9th century, the Fujiwara family, related to the Emperor through their mothers, held real power as the Emperor’s advisers.
In the 11th century a court culture bloomed in the capital, shown in stories such as The Tale of Genji.
From the late 11th century, retired emperors ruled from behind the scenes.
In the 10th century, armed lords and fighters became strong in many regions.
The Imperial family and the Fujiwara built up warrior groups, the Taira and the Minamoto, as their own forces. In this way the warriors (samurai) came into politics, and the Taira took power in the late 12th century.
From then until the end of the Edo period, the warrior class in effect ruled Japan.
There is no single right answer. Talking it over with someone at home is a good way to learn.