https://en.wikipedia.org/wiki/Mihaly_Csikszentmihalyi is considered the originator of the flow concept: "a highly focused mental state conducive to creativity", it's applied to other fields such as music. Definitely worth going down the rabbit hole.
https://en.wikipedia.org/wiki/Flow_(psychology)
https://www.sciencedirect.com/science/article/pii/S002839322...