Preheat your oven to 400 degrees Fahrenheit (use 375 degrees if you don't have a convection option on your oven). Grease a large rectangular baking dish with cooking spray or butter and set it aside.
Wash and peel the potatoes and slice them about 1/4 inch thick using a mandoline slicer.
Peel the onions and slice them on the mandoline slicer to about 1/8 inch thick. Set the potatoes and onions aside in a bowl.
Heat a medium pot over medium heat on the stove and add the butter. Add the garlic once the butter is melted and let the garlic heat up in the butter.
Sprinkle the flour, salt and pepper over the garlic and butter and whisk everything together, letting the flour toast over the heat while you whisk almost constantly.
Slowly drizzle in the white wine (if using) after the flour has toasted for about 3 minutes, whisking constantly.
Drizzle in the milk in a slow, steady stream, whisking constantly until a smooth sauce forms.
Turn the heat to medium low and continue to cook, whisking regularly, as the sauce thickens.
Add a pinch of nutmeg, the paprika and thyme, and whisk until combined.
Switch to a wooden spoon or heat-safe spatula and add the cheese by the handful, stirring gently until the cheese has melted. RESERVE 1/2 cup cheddar and 1/4 cup Parmesan for sprinkling over the top of the scalloped potatoes.
Start assembling the casserole by layering one third of the potatoes, one third of the onions, and then one third of the sauce in the bottom of the dish. Repeat 2 more times, layering potatoes, onions, then sauce until the dish is full.
Smooth out the sauce over the top and push it into any cracks or gaps between the potatoes and onions.
Top with the remaining cheese and bake at 400 degrees Fahrenheit for about 1 hour or until the potatoes are fork tender and the cheese on top is browned and bubbly.
Let stand for about 5 minutes before serving.