Why does the ground feel warmer underfoot than the air?

The short answer

Thermal lag. Dense materials — stone, brick, rammed earth — absorb solar energy all day and release it over hours. At midnight, the terrace tiles are still releasing heat absorbed at noon.

In the medina, the effect compounds. Streets are paved with packed earth or stone. Walls radiate stored heat from both sides. You're walking through a canyon of warm surfaces — heated from below, from both sides, and from above. Air temperature might read 30°C. Your body feels 38.