Income taxes - Schedule of Components of Income (Loss) Before Income Taxes (Details) - USD ($)
$ in Thousands
3 Months Ended 12 Months Ended
Dec. 31, 2016
Sep. 30, 2016
Jun. 30, 2016
Mar. 31, 2016
Dec. 31, 2015
Sep. 30, 2015
Jun. 30, 2015
Mar. 31, 2015
Dec. 31, 2016
Dec. 31, 2015
Dec. 31, 2014
Income Tax Disclosure [Abstract]                      
United States                 $ (129,864) $ (7,702) $ 84,161
Foreign                 60,258 19,122 42,990
Income (loss) before income taxes $ (26,642) $ (32,312) $ (106,582) $ (28,830) $ (22,443) $ (9,598) $ (14,630) $ 18,545 $ (69,606) $ 11,420 $ 127,151