You act so smug, but you don't seem to realize that warehouse farming is already a thing. This isn't some personal utopian fantasy theory of mine, it's a thing that already exists and can be implemented at a larger scale to solve problems ranging from food deserts, malnutrition, transportation costs, winter spoilage, pests, water consumption, run-off, and habitat destruction due to the agricultural demands of feeding several billion people.
There are specific wavelengths of light that plants use to do photosynthesis. Those wavelengths can be isolated, and there are special LEDs designed specifically for this purpose. They're quite efficient. Or you can use fluorescent lights, albeit they're less efficient than LEDs. You don't need the full spectrum and intensity of direct sunlight, and in fact that can be harmful in hot/dry climates or during droughts, especially as global warming accelerates. Warehouse agriculture has much higher yields than outdoor farming because you can control the climate perfectly while keeping out pests and diseases.
As for fertilizers and compost, they can be used in warehouse agriculture with more efficiency and with less environmental impact than in conventional farm fields. So your chemical energy point is moot.
You talk to me of the engineering and math problems, but clearly you're the one who fails to understand them.
Don't you know how much environmental destruction is currently due to clearing more space for agriculture? And you think that won't get worse as the world population nearly doubles in size, unless we start doing multi-story warehouse farming to feed major population centers?