When you are fully immersed in an activity. Scientist have tried to quantify this feeling. They found that to achieve a state of flow, a task must be roughly 4 percent beyond your current ability.
In real life it’s typically not feasible to quantify the difficulty of an action in this way, but the core idea of the Goldilocks Rule remains: working on challenges of just manageable difficulty – something on the perimeter of your ability – seems crucial for maintaining motivation.
-Atomic Habits, p.233