Heat the oven: Set to 375°F (190°C). Grease a 9x13-inch baking dish with olive oil or nonstick spray.
Prep the potatoes: Peel and slice potatoes 1/8 inch thick.
Use a mandoline for even slices. Keep them in cold water to prevent browning, then pat dry before layering.
Make the base sauce: Melt butter in a wide saucepan over medium heat. Add the diced onion and cook 3–4 minutes until soft.
Stir in garlic and cook 30 seconds until fragrant.
Build the roux: Sprinkle in flour and whisk for 1 minute. The mixture will look pasty and smell slightly nutty.
Add dairy: Slowly whisk in warm milk, then the cream, smoothing out any lumps. Simmer 3–5 minutes, stirring, until the sauce thickens enough to coat a spoon.
Season and enrich: Stir in thyme, a pinch of nutmeg, 1 1/2 teaspoons salt, and 1/2 teaspoon pepper.
Remove from heat and add 1 cup cheddar and 1/2 cup Gruyère, whisking until melted and smooth.
Layer: Spread a thin layer of sauce in the baking dish. Arrange a single layer of potatoes, slightly overlapping. Spoon over more sauce and sprinkle with a little cheddar, Gruyère, and Parmesan.
Repeat layers until all potatoes are used, finishing with sauce and the remaining cheeses on top.
Cover and bake: Cover with foil (tent it so it doesn’t stick to the cheese). Bake 35 minutes until the potatoes are just tender.
Uncover and brown: Remove the foil and bake 20–25 minutes more until the top is golden and bubbling and a knife slides in easily.
Rest before serving: Let the dish sit 10–15 minutes. This helps the sauce set and makes cleaner slices.