Context. The NGC 1333 IRAS 4A and IRAS 4B sources are among the most well-studied Stage 0 low-mass protostars, which drive prominent bipolar outflows. Spectrally resolved molecular emission lines provide crucial information about the physical and chemical structure of the circumstellar material as well as the dynamics of the different components. Most studies have so far concentrated on the colder parts (T ≤ 30 K) of these regions. Aims. The aim is to characterize the warmer parts of the protostellar envelope using the new generation of submillimeter instruments. This will allow us to quantify the feedback of the protostars on their surroundings in terms of shocks, ultraviolet (UV) heating, photodissociation, and outflow dispersal. Methods. The dual frequency 2 × 7 pixel 650/850 GHz array receiver CHAMP + mounted on APEX was used to obtain a fully sampled, large-scale ∼4 × 4 map at 9 resolution of the IRAS 4A/4B region in the 12 CO J = 6-5 line. Smaller maps were observed in the 13 CO 6-5 and [C i] J = 2-1 lines. In addition, a fully sampled 12 CO J = 3-2 map made with HARP-B on the JCMT is presented and deep isotopolog observations are obtained at selected outflow positions to constrain the optical depth. Complementary Herschel-HIFI and ground-based lines of CO and its isotopologs, from J = 1-0 up to 10-9 (E u /k ≈ 300 K), are collected at the source positions and used to construct velocity-resolved CO ladders and rotational diagrams. Radiative-transfer models of the dust and lines are used to determine the temperatures and masses of the outflowing and photon-heated gas and infer the CO abundance structure. Results. Broad CO emission-line profiles trace entrained shocked gas along the outflow walls, which have an average temperature of ∼100 K. At other positions surrounding the outflow and the protostar, the 6-5 line profiles are narrow indicating UV excitation. The narrow 13 CO 6-5 data directly reveal the UV heated gas distribution for the first time. The amount of UV-photon-heated gas and outflowing gas are quantified from the combined 12 CO and 13 CO 6-5 maps and found to be comparable within a 20 radius around IRAS 4A, which implies that UV photons can affect the gas as much as the outflows. Weak [C I] emission throughout the region indicates that there is a lack of CO dissociating photons. Our modeling of the C 18 O lines demonstrates the necessity of a "drop" abundance profile throughout the envelopes where the CO freezes out and is reloaded back into the gas phase through grain heating, thus providing quantitative evidence of the CO ice evaporation zone around the protostars. The inner abundances are less than the canonical value of CO/H 2 = 2.7 × 10 −4 , however, implying that there is some processing of CO into other species on the grains. The implications of our results for the analysis of spectrally unresolved Herschel data are discussed.