je_research_center_site = {
	icon = "gfx/interface/icons/event_icons/innovation.dds"
	group = je_group_technology
	on_monthly_pulse = {
		effect = {
			change_variable = {
				name = research_center_var
				add = 1
			}
		}
	}
	complete = {
		scope:journal_entry = {
			is_goal_complete = yes
		}
		# There should be a state like that, despite research center will always be built in capital
		any_scope_state = {
			is_incorporated = yes
			is_split_state = no
			any_scope_building = {
				is_building_type = building_urban_center
				level >= 50
			}
			any_scope_building = {
				is_building_type = building_university
				level >= 5
			}
		}
	}
	on_complete = {
		#remove_modifier = research_center_survey
		trigger_event = {
			id = ztr_technology.1
		}
		# site found
	}
	invalid = {
		NOT = {
			any_scope_state = {
				is_incorporated = yes
				is_split_state = no
				any_scope_building = {
					is_building_type = building_urban_center
					level >= 50
				}
				any_scope_building = {
					is_building_type = building_university
					level >= 5
				}
			}
		}
	}
	on_invalid = {
		remove_modifier = research_center_survey
		remove_variable = research_center_var
	}
	current_value = {
		value = root.var:research_center_var
	}
	goal_add_value = {
		value = 24
	}
	progressbar = yes
	weight = 10
	should_be_pinned_by_default_uninvolved_or_context = yes
}

je_research_center_construction = {
	icon = "gfx/interface/icons/event_icons/academia.dds"
	group = je_group_technology
	complete = {
		scope:target = {
			has_research_center_target = yes
		}
	}
	on_yearly_pulse = {
		effect = {
			if = {
				limit = {
					# This will be removed when dev will resolve AI not building great buildings while being in deficit
					capital = {
						NOR = {
							any_scope_building = {
								is_building_type = building_research_center
								is_under_construction = no
							}
							any_scope_building = {
								is_building_type = building_research_center
								is_under_construction = yes
							}
						}
					}
					is_ai = yes
				}
				capital = {
					create_building = {
						building = building_research_center
						level = 1
					}
				}
				# random_scope_state = {
				# 	limit = {
				# 		is_capital = yes
				# 	}
				# 	create_building = {
				# 		building = building_research_center
				# 		level = 1
				# 	}
				# }
			}
		}
	}
	fail = {
		NOT = {
			any_scope_state = {
				has_modifier = research_center_site
			}
		}
	}
	on_fail = {
		remove_variable = research_center_var
	}
	on_complete = {
		trigger_event = {
			id = ztr_technology.2
		}
		remove_variable = research_center_var
		scope:target = {
			remove_modifier = research_center_site
		}
	}
	should_be_pinned_by_default_uninvolved_or_context = yes
}

# National Electricity System Journal Entries
je_national_electric_system = {
	icon = "gfx/interface/icons/goods_icons/electrical_generation.dds"
	group = je_group_technology

	possible = {
		#JE
		has_variable = national_electric_system_started
	}

	immediate = {
		ztr_update_national_electric_system_progress = yes
	}

	on_monthly_pulse = {
		effect = {
			ztr_update_national_electric_system_progress = yes
		}
	}

	on_yearly_pulse = {
		effect = {
			if = {
				limit = {
					is_ai = yes
				}
				every_scope_state = {
					limit = {
						NOR = {
							has_building = building_power_grid_station
							any_scope_building = {
								is_building_type = building_power_grid_station
								is_under_construction = yes
							}
						}
					}
					create_building = {
						building = building_power_grid_station
						level = 1
					}
				}
			}
		}
	}

	complete = {
		any_scope_state = {
			filter = {
				is_incorporated = yes
			}
			custom_tooltip = {
				text = je_national_electric_system_complete_tt
				has_building = building_power_grid_station
			}
			percent = 1
		}
	}

	on_complete = {
		ztr_update_national_electric_system_progress = yes
		add_modifier = {
			name = national_electric_system_transition_boost
			years = 10
			is_decaying = yes
		}
		activate_law = law_type:law_national_electric_system
		ztr_clear_national_electric_system_progress = yes
		remove_variable = national_electric_system_started
	}

	status_desc = {
		first_valid = {
			triggered_desc = {
				desc = je_national_electric_system_status
				trigger = {
					always = yes
				}
			}
		}
	}

	current_value = {
		value = var:ztr_nes_states_with_grid_var
	}
	goal_add_value = {
		value = var:ztr_nes_states_total_var
	}

	weight = 100
	should_be_pinned_by_default_uninvolved_or_context = yes
	transferable = no
	progressbar = yes
}

# Fusion Reactor Journal Entries
je_fusion_reactor_research = {
	icon = "gfx/interface/icons/event_icons/innovation.dds"
	group = je_group_technology
	on_monthly_pulse = {
		effect = {
			# Progress depends on nation's development indicators
			change_variable = {
				name = fusion_reactor_var
				add = 0.25
			}
			# GDP per capita bonus: wealthy nations progress faster
			if = {
				limit = {
					gdp > 1000000000
				}
				change_variable = {
					name = fusion_reactor_var
					add = 0.25
				}
			}
			if = {
				limit = {
					gdp > 705032704
				}
				change_variable = {
					name = fusion_reactor_var
					add = 0.5
				}
			}
			# Literacy bonus: highly educated populace accelerates R&D
			if = {
				limit = {
					literacy_rate > 0.95
				}
				change_variable = {
					name = fusion_reactor_var
					add = 0.25
				}
			}
			# Major population bonus: large labor pool of scientists
			if = {
				limit = {
					total_population > 50000000
				}
				change_variable = {
					name = fusion_reactor_var
					add = 0.25
				}
			}
			if = {
				limit = {
					total_population > 500000000
				}
				change_variable = {
					name = fusion_reactor_var
					add = 0.25
				}
			}
		}
	}
	complete = {
		scope:journal_entry = {
			is_goal_complete = yes
		}
	}
	on_complete = {
		trigger_event = {
			id = ztr_technology.10
		}
		# fusion reactor first breakthrough
	}
	invalid = {
		OR = {
			NOT = {
				has_technology_researched = smart_energy_grid
			}
			NOT = {
				has_technology_researched = third_nuclear_reactor
			}
			NOT = {
				has_research_center = yes
			}
		}
	}
	on_invalid = {
		remove_variable = fusion_reactor_var
	}
	current_value = {
		value = root.var:fusion_reactor_var
	}
	goal_add_value = {
		value = 100
	}
	progressbar = yes
	weight = 10
	should_be_pinned_by_default_uninvolved_or_context = yes
	modifiers_while_active = {
		fusion_reactor_research
	}
}

je_fusion_reactor_construction = {
	icon = "gfx/interface/icons/event_icons/academia.dds"
	group = je_group_technology
	complete = {
		scope:target = {
			has_fusion_reactor_target = yes
		}
	}
	fail = {
		NOT = {
			any_scope_state = {
				has_modifier = fusion_reactor_site
			}
		}
	}
	on_fail = {
		remove_variable = fusion_reactor_var
	}
	on_complete = {
		trigger_event = {
			id = ztr_technology.11
		}
		remove_variable = fusion_reactor_var
		scope:target = {
			remove_modifier = fusion_reactor_site
		}
	}
	should_be_pinned_by_default_uninvolved_or_context = yes
}
