Heat the butter in a saucepan, then add the flour and whisk for 1 minute. Whisk in the milk a little at a time until smooth. Add the grated nutmeg and thicken, whisking, for 2 minutes.
Preheat the oven to 200˚C/fan 180˚C/gas mark 6. Meanwhile, place the spinach in a large saucepan and add a splash of water. Cook over a medium-high heat for 2-3 minutes until wilted. You may need to do this in batches. Tip into a colander to drain and, when cool enough to handle, squeeze out all the excess moisture and roughly chop.
Place the pine nuts in a medium saucepan and carefully toast over a low heat. Set to one side. In the same pan, heat the oil. Add the onion and gently cook for 5 minutes until softened. Add the garlic and cook for a further 2 minutes. Place the spinach in a bowl, then add the onion mixture, ricotta and half the parmesan. Season with black pepper and combine well.
Place a third of the courgettes in the base of a 2-litre baking dish. Add a third of the white sauce and half the spinach mixture. Scatter with half the pine nuts and add another third of courgettes. Add another third of white sauce and the remaining spinach mixture. Scatter with the remaining pine nuts and add the remaining courgette. Finally, add the remaining white sauce and finish with the remaining parmesan. Bake for 45 minutes until golden and bubbling.