- Make the caponata sauce: Heat olive oil in a sauté pan over medium heat, and sweat onion, fennel, and garlic until soft, about 10 minutes. Season with salt and pepper to taste. Add raisins, olives, za’atar, chile flakes, sugar, cocoa, thyme, and oregano. Sauté another 5 minutes. Deglaze with vinegar and add tomato puree and stock. Bring to a simmer. Taste and adjust for seasoning—the sauce should be a little sweet, a little sour, and a little salty. Puree in a blender or food processor until smooth.
- Make the eggplant: Preheat grill to high. Drizzle eggplant with olive oil and season with salt and pepper. Grill over high heat for 1 to 2 minutes on each side. The eggplant should be tender but not cooked completely through.
- Preheat oven to 425 degrees. Spread a thin layer of caponata sauce on bottom of large ovenproof dish. Alternate layering slices of eggplant, mozzarella, and tomato in a tight pattern until dish is full. Top with more sauce. Bake in oven until sauce is bubbling and cheese is melted, about 10 to 15 minutes. Sprinkle pistachios and herbs before serving.