Preheat oven to 350°F (177°C) and line a 12-cup muffin pan with cupcake liners. Place the rack in the center of the oven for even baking.
In a large bowl, whisk together all dry ingredients (flour, cocoa powder, baking powder, baking soda, salt, and espresso powder if using) until fully combined and no lumps remain.
In a separate bowl, whisk eggs, granulated sugar, and brown sugar until smooth and slightly thickened. Add oil and vanilla extract, then mix until fully combined and glossy.
Pour the wet mixture into the dry ingredients and gently mix until just combined. Avoid overmixing, as this can make the cupcakes dense instead of soft and fluffy.
Slowly add buttermilk and stir until the batter becomes smooth and slightly thin in texture. This helps create moist cupcakes with a tender crumb.
Divide the batter evenly into cupcake liners, filling each about 2/3 full to allow room for rising without overflowing.
Bake for 18–20 minutes, or until a toothpick inserted in the center comes out clean or with a few moist crumbs. Avoid overbaking to keep them soft.
Let cupcakes cool in the pan for about 10 minutes, then transfer to a wire rack to cool completely before adding frosting. Frosting too early can cause it to melt and slide off.