setup.applyLightStyle = function () {
	if(State.variables.settings.lightmode){
		$("body").addClass('lightMode');
		let tags = State.temporary.tags;

		let light;

		if(tags.includes('outdoors')){
			let light_sun = setup.get_light_sun();
			light = light_sun;
		}else if(tags.includes('indoors')){
			light = {
				hue: 0,
				light: 100,
				sat: 100
			}
		}else{
			light = {
				hue: 0,
				light: 0,
				sat: 0
			}
		}


		$("body").css("--bg_hue",light.hue);
		$("body").css("--bg_sat",light.sat+"%");
		$("body").css("--bg_light",light.light+"%");

		if(light.light > 50){
			$("body").addClass('light');
		}else{
			$("body").removeClass('light');
		}
	}else{
		$("body").removeClass('lightMode');
	}
}

setup.get_light_sun = function(){
	let sun_hue = 0;
	let sun_sat = 0;
	let sun_light = 0; //In Percent

	let time = State.variables.time;
	//let dayLength = time.dayLength;

	let dayStage = time.dayStage;

	//let curTimeSun = Math.abs(time.sunTime); //Minutes to or since midday, which is at 13:00

	let cTime = time.hour * 60 + time.minutes;

	let dayStagesStartEnd = time.dayStagesStartEnd;
	let cStageStartEnd = dayStagesStartEnd[dayStage];
	let cStageCompletion = (cTime - cStageStartEnd[0]) / (cStageStartEnd[1] - cStageStartEnd[0]); // Percentage

	let dayStage_hue, dayStage_sat, dayStage_lit;

	switch(dayStage){
		case 2:
			dayStage_hue = [33+360,33+360,33+360];
			dayStage_sat = [100,100,100];
			dayStage_lit = [100,100,100];
			break;
		case 5:
			dayStage_hue = [339,339,339];
			dayStage_sat = [59.4,59.4,59.4];
			dayStage_lit = [0,0,0];
			break;
		case 3:
			cStageCompletion = 1 - cStageCompletion;
		case 1:
			dayStage_hue = [353,33+360,33+360];
			dayStage_sat = [89.1,100,100];
			dayStage_lit = [36.1,36.7,100];
			break;
		case 4:
			cStageCompletion = 1 - cStageCompletion;
		case 6:
			dayStage_hue = [339,339,353];
			dayStage_sat = [59.4,59.4,89.1];
			dayStage_lit = [0,25.1,36.1];
			break;

	}

	let s = 0;
	let e = 1;
	let progressToSubStep = cStageCompletion * 2;
	if(cStageCompletion >= 0.5){
		s = 1;
		e = 2;
		progressToSubStep = (cStageCompletion - 0.5) * 2;
	}

	sun_hue 	= (dayStage_hue[e] * progressToSubStep + dayStage_hue[s] * (1 - progressToSubStep)) % 360;
	sun_light	= dayStage_lit[e] * progressToSubStep + dayStage_lit[s] * (1 - progressToSubStep);
	sun_sat 	= dayStage_sat[e] * progressToSubStep + dayStage_sat[s] * (1 - progressToSubStep);

	return {
		hue: sun_hue,
		light: sun_light,
		sat: sun_sat
	};
}
