Hostile online politics and waning civic engagement — plus the substantial time commitment — have discouraged people from seeking office.