Prep the dish: Heat oven to 375°F (190°C). Butter a 9x13-inch baking dish.
If you like, cut a garlic clove in half and rub it all over the dish for extra aroma.
Slice the potatoes: Peel and slice the potatoes very thinly (about 1/8 inch). A mandoline helps keep slices even. Keep slices in a bowl of cold water while you prep the rest to slow browning, then drain and pat dry.
Cook the spinach: In a large skillet, melt 1 tablespoon butter with 1 tablespoon olive oil over medium heat.
Add onion and cook until soft and translucent, 5–7 minutes. Stir in minced garlic and cook 30 seconds.
Wilt and season: Add spinach in batches, stirring until just wilted. Season with a pinch of salt and pepper.
Transfer to a colander and press gently to remove excess moisture.
Warm the cream: In a small saucepan, combine heavy cream, milk, thyme, nutmeg, 1 teaspoon salt, and 1/2 teaspoon pepper. Warm over low heat until steaming (do not boil). Taste and adjust seasoning.
Add red pepper flakes if using.
Layer the gratin: Lay a third of the potato slices in the dish, slightly overlapping. Spoon over a third of the spinach-onion mixture. Sprinkle with a third of the Gruyère and a little Parmesan.
Repeat two more times for three total layers.
Add the cream: Slowly pour the warm cream mixture evenly over the layered potatoes and spinach. Tilt the dish gently so the liquid distributes through the layers.
Cover and bake: Cover tightly with foil and bake for 35–40 minutes, until the potatoes are starting to turn tender when pierced.
Uncover and brown: Remove foil, add remaining Parmesan if you held some back, and bake another 20–25 minutes, until the top is golden and the edges are bubbly.
Rest and serve: Let the gratin rest 10–15 minutes before cutting. This helps the layers set so slices come out neat.