﻿### TFE EDIT: Added a new type of Head of Faith

doctrine_marriage_type = {
	group = "marriage"
	doctrine_monogamy = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_monogamy }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
		parameters = {
			number_of_spouses = 1
			marriage_event = yes
			demd_meta_public_order_mult_5 = yes
			demd_meta_birth_rate_mult_3 = yes
			demd_meta_fervor_mult_300 = yes
		}
	}

	doctrine_polygamy = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_polygamy }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
		parameters = {
			number_of_spouses = 4
			spouse_piety_loss = yes
			demd_meta_public_order_multneg_5 = yes
			demd_meta_birth_rate_multneg_3 = yes
			demd_meta_fervor_multneg_300 = yes
		}
	}

	doctrine_concubines = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_concubines }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
		parameters = {
			number_of_spouses = 1
			number_of_consorts = 3
		}
	}
}

doctrine_divorce = {
	group = "marriage"
	doctrine_divorce_disallowed = {
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_divorce_disallowed }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_divorce_allowed }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}

		}
		parameters = {
			divorce_disallowed = yes
		}
	}
	doctrine_divorce_approval = {
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_divorce_approval }
				multiply = faith_unchanged_doctrine_cost_mult
			}

		}
		parameters = {
			divorce_approval = yes
		}
	}
	doctrine_divorce_allowed = {
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_divorce_allowed }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_divorce_disallowed }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			divorce_allowed = yes
		}
	}
}

doctrine_bastardry = {
	group = "marriage"
	doctrine_bastardry_none = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_bastardry_none }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_bastardry_all }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			bastards_none = yes
			demd_meta_fervor_multneg_300 = yes
		}
	}
	doctrine_bastardry_legitimization = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_bastardry_legitimization }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
		parameters = {
			bastards_legitimize = yes
		}
	}
	doctrine_bastardry_all = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_bastardry_all }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_bastardry_none }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			bastards_always = yes
		}
	}
}

doctrine_homosexuality = {
	group = "crimes"
	doctrine_homosexuality_crime = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_homosexuality_crime }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_homosexuality_accepted }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			homosexuality_illegal = yes
			demd_meta_fervor_mult_300 = yes
		}
	}
	doctrine_homosexuality_shunned = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_homosexuality_shunned }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
		parameters = {
			homosexuality_shunned = yes
		}
	}
	doctrine_homosexuality_accepted = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_homosexuality_accepted }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_homosexuality_crime }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			homosexuality_accepted = yes
			demd_meta_fervor_multneg_300 = yes
		}
	}
}

doctrine_deviancy = {
	group = "crimes"
	doctrine_deviancy_crime = {
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_deviancy_crime }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_deviancy_accepted }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			deviancy_illegal = yes
		}
	}
	doctrine_deviancy_shunned = {
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_deviancy_shunned }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
		parameters = {
			deviancy_shunned = yes
		}
	}
	doctrine_deviancy_accepted = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_deviancy_accepted }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_deviancy_crime }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			deviancy_accepted = yes
			demd_meta_fervor_multneg_300 = yes
		}
	}
}

doctrine_adultery_men = {
	group = "crimes"
	doctrine_adultery_men_crime = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_adultery_men_crime }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_adultery_men_accepted }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			adultery_male_crime = yes
		}
	}
	doctrine_adultery_men_shunned = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_adultery_men_shunned }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
		parameters = {
			adultery_male_shunned = yes
		}
	}
	doctrine_adultery_men_accepted = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_adultery_men_accepted }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_adultery_men_crime }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			adultery_male_accepted = yes
			demd_meta_fervor_multneg_300 = yes
		}
	}
}

doctrine_adultery_women = {
	group = "crimes"
	doctrine_adultery_women_crime = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_adultery_women_crime }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_adultery_women_accepted }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			adultery_female_crime = yes
		}
	}
	doctrine_adultery_women_shunned = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_adultery_women_shunned }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
		parameters = {
			adultery_female_shunned = yes
		}
	}
	doctrine_adultery_women_accepted = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_adultery_women_accepted }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_adultery_women_crime }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			adultery_female_accepted = yes
			demd_meta_fervor_multneg_300 = yes
		}
	}
}

doctrine_kinslaying = {
	group = "crimes"
	doctrine_kinslaying_any_dynasty_member_crime = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_kinslaying_any_dynasty_member_crime }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_kinslaying_close_kin_crime }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
			else_if = {
				limit = { has_doctrine = doctrine_kinslaying_shunned }
				multiply = faith_changed_doctrine_cost_mult_three_step
			}
			else_if = {
				limit = { has_doctrine = doctrine_kinslaying_accepted }
				multiply = faith_changed_doctrine_cost_mult_four_step
			}
		}
		parameters = {
			kinslaying_any_dynasty_member_crime = yes
		}
	}
	doctrine_kinslaying_extended_family_crime = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_kinslaying_extended_family_crime }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_kinslaying_shunned }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
			else_if = {
				limit = { has_doctrine = doctrine_kinslaying_accepted }
				multiply = faith_changed_doctrine_cost_mult_three_step
			}
		}
		parameters = {
			kinslaying_extended_family_crime = yes
		}
	}
	doctrine_kinslaying_close_kin_crime = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_kinslaying_close_kin_crime }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = {
					OR = {
						has_doctrine = doctrine_kinslaying_accepted
						has_doctrine = doctrine_kinslaying_any_dynasty_member_crime
					}
				}
			}
			multiply = faith_changed_doctrine_cost_mult_two_step
		}
		parameters = {
			kinslaying_close_kin_crime = yes
		}
	}
	doctrine_kinslaying_shunned = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_kinslaying_shunned }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_kinslaying_extended_family_crime }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
			else_if = {
				limit = { has_doctrine = doctrine_kinslaying_any_dynasty_member_crime }
				multiply = faith_changed_doctrine_cost_mult_three_step
			}
		}
		parameters = {
			kinslaying_shunned = yes
		}
	}
	doctrine_kinslaying_accepted = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_kinslaying_accepted }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_kinslaying_close_kin_crime }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
			else_if = {
				limit = { has_doctrine = doctrine_kinslaying_extended_family_crime }
				multiply = faith_changed_doctrine_cost_mult_three_step
			}
			else_if = {
				limit = { has_doctrine = doctrine_kinslaying_any_dynasty_member_crime }
				multiply = faith_changed_doctrine_cost_mult_four_step
			}

		}
		parameters = {
			demd_meta_fervor_multneg_300 = yes
			kinslaying_accepted = yes
		}
	}
}

doctrine_witchcraft = {
	group = "crimes"
	doctrine_witchcraft_crime = {
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_witchcraft_crime }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_witchcraft_accepted }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			witchcraft_illegal = yes
		}
	}
	doctrine_witchcraft_shunned = {
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_witchcraft_shunned }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
		parameters = {
			witchcraft_shunned = yes
		}
	}
	doctrine_witchcraft_accepted = {
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_witchcraft_accepted }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_witchcraft_crime }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			demd_meta_fervor_multneg_300 = yes
			witchcraft_accepted = yes
		}
	}
}

doctrine_slavery = {
	group = "crimes"
	doctrine_slavery_faith = {
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_slavery_faith }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
		parameters = {
			slavery_faith = yes
		}
	}
	doctrine_slavery_accepted = {
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_slavery_accepted }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_slavery_crime }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			slavery_accepted = yes
		}
	}
	doctrine_slavery_heritage = {
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_slavery_heritage }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
		parameters = {
			slavery_heritage = yes
		}
	}	
	doctrine_slavery_crime = {
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_slavery_crime }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_slavery_accepted }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			slavery_illegal = yes
		}
	}
}


doctrine_gender = {
	group = "main_group"

	doctrine_gender_male_dominated = {
		is_shown = {
			NOT = { has_game_rule = full_gender_equality }
		}
		piety_cost = {
			value = faith_doctrine_cost_high
			if = {
				limit = { has_doctrine = doctrine_gender_male_dominated }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_gender_female_dominated }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			male_dominated_law = yes
			female_claims_are_weak = yes
			women_cannot_inherit_implicit_claims = yes
			women_cannot_be_granted_titles = yes
			male_dominated_council = yes
			combatant_must_be_male_if_no_roco = yes
			demd_meta_fervor_mult_500 = yes
		}
		character_modifier = {
			name = female_ruler_male_dominant
			opinion_of_female_rulers = -10
		}

		can_pick = {
			NAND = {
				exists = religious_head
				religious_head.culture = { has_cultural_parameter = female_only_inheritance }
			}
		}
	}
	doctrine_gender_equal = {
		piety_cost = {
			value = faith_doctrine_cost_high
			if = {
				limit = { has_doctrine = doctrine_gender_equal }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
		parameters = {
			gender_equal_law = yes
			combatant_can_be_either_gender_if_no_roco = yes
			demd_meta_birth_rate_multneg_10 = yes
			demd_meta_fervor_multneg_500 = yes
		}
	}
	doctrine_gender_female_dominated = {
		is_shown = {
			NOT = { has_game_rule = full_gender_equality }
		}
		piety_cost = {
			value = faith_doctrine_cost_high
			if = {
				limit = { has_doctrine = doctrine_gender_female_dominated }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_gender_male_dominated }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			female_dominated_law = yes
			male_claims_are_weak = yes
			men_cannot_inherit_implicit_claims = yes
			men_cannot_be_granted_titles = yes
			female_dominated_council = yes
			combatant_must_be_female_if_no_roco = yes
			demd_meta_birth_rate_multneg_15 = yes
			demd_meta_fervor_multneg_1000 = yes
		}
		character_modifier = {
			name = male_ruler_female_dominant
			opinion_of_male_rulers = -10
		}
	}
}

doctrine_consanguinity = {
	group = "marriage"
	doctrine_consanguinity_restricted = {
		piety_cost = {
			value = faith_doctrine_cost_high
			if = {
				limit = { has_doctrine = doctrine_consanguinity_restricted }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_consanguinity_aunt_nephew_and_uncle_niece }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
			else_if = {
				limit = { has_doctrine = doctrine_consanguinity_unrestricted }
				multiply = faith_changed_doctrine_cost_mult_three_step
			}
		}
		parameters = {
			consanguinity_restricted_marriage = yes
			consanguinity_restricted_close_kin_incest = yes
		}
	}
	doctrine_consanguinity_cousins = {
		piety_cost = {
			value = faith_doctrine_cost_high
			if = {
				limit = { has_doctrine = doctrine_consanguinity_cousins }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_consanguinity_unrestricted }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			consanguinity_cousins_marriage = yes
			consanguinity_cousins_incest = yes
			allows_cousin_marriage = yes
		}
	}
	doctrine_consanguinity_aunt_nephew_and_uncle_niece = {
		piety_cost = {
			value = faith_doctrine_cost_high
			if = {
				limit = { has_doctrine = doctrine_consanguinity_aunt_nephew_and_uncle_niece }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_consanguinity_restricted }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			consanguinity_aunt_nephew_and_uncle_niece_marriage = yes
			consanguinity_aunt_nephew_and_uncle_niece_incest = yes
			allows_cousin_marriage = yes
			allows_aunt_nephew_and_uncle_niece_marriage = yes
			demd_meta_birth_rate_multneg_2 = yes
			demd_meta_fervor_multneg_300 = yes
		}
	}
	doctrine_consanguinity_unrestricted = {
		piety_cost = {
			value = faith_doctrine_cost_high
			if = {
				limit = { has_doctrine = doctrine_consanguinity_unrestricted }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_consanguinity_cousins }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
			else_if = {
				limit = { has_doctrine = doctrine_consanguinity_restricted }
				multiply = faith_changed_doctrine_cost_mult_three_step
			}
		}
		parameters = {
			consanguinity_unrestricted_marriage = yes
			consanguinity_unrestricted_incest = yes
			allows_cousin_marriage = yes
			allows_aunt_nephew_and_uncle_niece_marriage = yes
			allows_unrestricted_marriage = yes
			demd_meta_birth_rate_multneg_5 = yes
			demd_meta_fervor_multneg_600 = yes
		}
	}
}

doctrine_pluralism = {
	group = "main_group"

	doctrine_pluralism_fundamentalist = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_pluralism_fundamentalist }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_pluralism_pluralistic }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			hostility_towards_us_mult = 2
			demd_meta_fervor_mult_500 = yes
			increased_vigor_loss_from_religious_disunity = yes
			pluralism_fundamentalist_proselytization_bonus = yes
			pluralism_fundamentalist_faction_join_chance = yes
			pluralism_fundamentalist_vulnerable_to_heresy = yes
			pluralism_fundamentalist_revocation_tyranny_minimal = yes
		}
	}
	doctrine_pluralism_righteous = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_pluralism_righteous }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
		parameters = {
			hostility_towards_us_mult = 1
			pluralism_righteous_revocation_tyranny_reduced = yes
			
		}
	}
	doctrine_pluralism_pluralistic = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_pluralism_pluralistic }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_pluralism_fundamentalist }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}

		can_pick = {
			custom_description = {
				text = incompatible_tenet_pentarchy_trigger
				NOT = { flag:tenet_pentarchy = { is_in_list = selected_doctrines } }
			}
		}

		parameters = {
			demd_meta_fervor_multneg_500 = yes
			reduced_vigor_loss_from_religious_disunity = yes
			hostility_towards_us_mult = 0.5
			pluralism_pluralistic_proselytization_penalty = yes
			pluralism_pluralistic_faction_join_chance = yes
			pluralism_pluralistic_resistant_to_heresy = yes
			pluralism_pluralistic_holy_wars_preserve_vassals = yes
			
		}
	}
}

doctrine_theocracy = {
	group = "main_group"
	doctrine_theocracy_temporal = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_theocracy_temporal }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_theocracy_lay_clergy }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		
		can_pick = {
			custom_description = {
				text = incompatible_doctrine_theocracy_temporal_trigger
				NOT = { flag:doctrine_temporal_head = { is_in_list = selected_doctrines } }
			}
		}

		parameters = {
			theocracy_temple_lease = yes
			demd_meta_fervor_mult_200 = yes
		}
	}
	doctrine_theocracy_lay_clergy = {
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_theocracy_lay_clergy }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_theocracy_temporal }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}

		parameters = {
			theocracy_temple_ownership = yes
			lay_clergy = yes
			allowed_holding_type_church_holding = yes
		}
	}
}

doctrine_head_of_faith = {
	group = "main_group"

	doctrine_no_head = {
		visible = no
		piety_cost = {
			value = faith_doctrine_cost_mid
			if = {
				limit = { has_doctrine = doctrine_no_head }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
		parameters = {
			no_head_of_faith = yes
			minimum_fervor = 25
		}
	}
	doctrine_spiritual_head = {
		visible = no
		piety_cost = {
			value = faith_doctrine_cost_high
			if = {
				limit = { has_doctrine = doctrine_spiritual_head }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
		parameters = {
			spiritual_head_of_faith = yes
			spiritual_head_of_faith_claims = yes
			spiritual_head_of_faith_gold = yes
			demd_meta_fervor_mult_200 = yes
		}
	}
	doctrine_temporal_head = {
		visible = no
		piety_cost = {
			value = faith_doctrine_cost_massive
			if = {
				limit = { has_doctrine = doctrine_temporal_head }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
		can_pick = {
			custom_description = {
				text = incompatible_doctrine_theocracy_temporal_trigger
				NOT = { flag:doctrine_theocracy_temporal = { is_in_list = selected_doctrines } }
			}
			custom_description = {
				text = incompatible_doctrine_spiritual_appointment_temporal_trigger
				NOR = {
					flag:doctrine_clerical_succession_spiritual_appointment = { is_in_list = selected_doctrines }
					flag:doctrine_clerical_succession_spiritual_fixed_appointment = { is_in_list = selected_doctrines }
				}
			}
		}

		parameters = {
			temporal_head_of_faith = yes
			temporal_head_of_faith_directed_holy_wars = yes
		}
	}
	
	### Imperial Head of Faith, where the head of faith is the Emperor of an Empire that made it its Official Imperial Faith
	doctrine_imperial_head = {
		visible = no
		piety_cost = {
			value = faith_doctrine_cost_massive
			if = {
				limit = { has_doctrine = doctrine_imperial_head }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
		can_pick = {
			custom_description = {
				text = only_hellenic_or_kushitism
				OR = {
					religion_tag = hellenism_religion
					religion_tag = kushitism_religion 
				}
			}
		}

		parameters = {
			imperial_head_of_faith_empire_oif = yes
			imperial_head_of_faith_destroyed_no_empire_oif = yes
			imperial_head_of_faith_hof_imperial_cult_government = yes
		}
	}
}

doctrine_clerical_function = {
	group = "clergy"
	doctrine_clerical_function_taxation = {
		clergy_modifier = {
			#monthly_county_control_change_add_even_if_baron = 0.2
			monthly_county_control_change_factor_even_if_baron = 0.2
		}
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_clerical_function_taxation }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
	}
	doctrine_clerical_function_alms_and_pacification = {
		clergy_modifier = {
			county_opinion_add_even_if_baron = 10
			domain_tax_mult_even_if_baron = -0.05
		}
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_clerical_function_alms_and_pacification }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
	}
	doctrine_clerical_function_recruitment = {
		clergy_modifier = {
			domain_tax_same_faith_mult_even_if_baron = -0.03
			levy_reinforcement_rate_same_faith_even_if_baron = 0.3
			prowess = 4
		}
		parameters = {
			clergy_can_fight = yes
			demd_meta_manpower_mult_5 = yes
		}
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_clerical_function_recruitment }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}
	}
}

doctrine_clerical_gender = {
	group = "clergy"
	doctrine_clerical_gender_male_only = {
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_clerical_gender_male_only }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_clerical_gender_female_only }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			clergy_must_be_male = yes
			demd_meta_fervor_mult_300 = yes
		}
	}
	doctrine_clerical_gender_female_only = {
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_clerical_gender_female_only }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_clerical_gender_male_only }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		parameters = {
			clergy_must_be_female = yes
			
		}
	}
	doctrine_clerical_gender_either = {
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_clerical_gender_either }
				multiply = faith_unchanged_doctrine_cost_mult
			}
		}

		parameters = {
			clergy_can_be_either_gender = yes
			demd_meta_fervor_multneg_300 = yes
		}
	}
}

doctrine_clerical_marriage = {
	group = "clergy"
	doctrine_clerical_marriage_allowed = {
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_clerical_marriage_allowed }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_clerical_marriage_disallowed }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}
		
		parameters = {
			clergy_can_marry = yes
		}
	}
	doctrine_clerical_marriage_disallowed = {
		piety_cost = {
			value = faith_doctrine_cost_low
			if = {
				limit = { has_doctrine = doctrine_clerical_marriage_disallowed }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else_if = {
				limit = { has_doctrine = doctrine_clerical_marriage_allowed }
				multiply = faith_changed_doctrine_cost_mult_two_step
			}
		}

		parameters = {
			clergy_can_marry = no
		}
	}
}

doctrine_clerical_succession = {
	group = "clergy"
	doctrine_clerical_succession_temporal_appointment = { # Temporal, Free
		piety_cost = {
			value = faith_doctrine_cost_high
			if = {
				limit = { has_doctrine = doctrine_clerical_succession_temporal_appointment }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else = {
				if = {
					limit = {
						OR = { # Was Spiritual
							has_doctrine = doctrine_clerical_succession_spiritual_fixed_appointment
							has_doctrine = doctrine_clerical_succession_spiritual_appointment
						}
					}
					multiply = faith_changed_doctrine_cost_mult_two_step
				}
				if = {
					limit = {
						OR = {	# Was Fixed
							has_doctrine = doctrine_clerical_succession_spiritual_fixed_appointment
							has_doctrine = doctrine_clerical_succession_temporal_fixed_appointment
						}
					}
					multiply = faith_changed_doctrine_cost_mult_two_step
				}
			}
			# Round up to the nearest multiple of 25
			divide = 25
			ceiling = yes
			multiply = 25
		}

		parameters = {
			clerical_appointment_ruler = yes
			clerical_appointment_fixed = no
		}
	}
	doctrine_clerical_succession_spiritual_appointment = { # Spiritual, Free
		piety_cost = {
			value = faith_doctrine_cost_high
			if = {
				limit = { has_doctrine = doctrine_clerical_succession_spiritual_appointment }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else = {
				if = {
					limit = {
						OR = { # Was Temporal
							has_doctrine = doctrine_clerical_succession_temporal_fixed_appointment
							has_doctrine = doctrine_clerical_succession_temporal_appointment
						}
					}
					multiply = faith_changed_doctrine_cost_mult_two_step
				}
				if = {
					limit = {
						OR = {	# Was Fixed
							has_doctrine = doctrine_clerical_succession_spiritual_fixed_appointment
							has_doctrine = doctrine_clerical_succession_temporal_fixed_appointment
						}
					}
					multiply = faith_changed_doctrine_cost_mult_two_step
				}	
			}
			# Round up to the nearest multiple of 25
			divide = 25
			ceiling = yes
			multiply = 25
		}

		can_pick = {
			custom_description = {
				text = incompatible_doctrine_spiritual_appointment_temporal_trigger
				NOT = { flag:doctrine_temporal_head = { is_in_list = selected_doctrines } }
			}
		}		

		parameters = {
			clerical_appointment_head_of_faith = yes
			clerical_appointment_fixed = no
			demd_meta_fervor_mult_300 = yes
		}
	}
	doctrine_clerical_succession_temporal_fixed_appointment = { # Temporal, Fixed
		piety_cost = {
			value = faith_doctrine_cost_high
			if = {
				limit = { has_doctrine = doctrine_clerical_succession_temporal_fixed_appointment }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else = {
				if = {
					limit = {
						OR = { # Was Spiritual
							has_doctrine = doctrine_clerical_succession_spiritual_fixed_appointment
							has_doctrine = doctrine_clerical_succession_spiritual_appointment
						}
					}
					multiply = faith_changed_doctrine_cost_mult_two_step
				}
				if = {
					limit = {
						OR = {	# Was free
							has_doctrine = doctrine_clerical_succession_spiritual_appointment
							has_doctrine = doctrine_clerical_succession_temporal_appointment
						}
					}
					multiply = faith_changed_doctrine_cost_mult_two_step
				}
			}
			# Round up to the nearest multiple of 25
			divide = 25
			ceiling = yes
			multiply = 25
		}
		parameters = {
			clerical_appointment_ruler = yes
			clerical_appointment_fixed = yes
		}
	}
	doctrine_clerical_succession_spiritual_fixed_appointment = { # Spiritual, Fixed
		piety_cost = {
			value = faith_doctrine_cost_high
			if = {
				limit = { has_doctrine = doctrine_clerical_succession_spiritual_fixed_appointment }
				multiply = faith_unchanged_doctrine_cost_mult
			}
			else = {
				if = {
					limit = {
						OR = { # Was Temporal
							has_doctrine = doctrine_clerical_succession_temporal_fixed_appointment
							has_doctrine = doctrine_clerical_succession_temporal_appointment
						}
					}
					multiply = faith_changed_doctrine_cost_mult_two_step
				}
				if = {
					limit = {
						OR = {	# Was Free
							has_doctrine = doctrine_clerical_succession_spiritual_appointment
							has_doctrine = doctrine_clerical_succession_temporal_appointment
						}
					}
					multiply = faith_changed_doctrine_cost_mult_two_step
				}
			}
			# Round up to the nearest multiple of 25
			divide = 25
			ceiling = yes
			multiply = 25
		}

		can_pick = {
			custom_description = {
				text = incompatible_doctrine_spiritual_appointment_temporal_trigger
				NOT = { flag:doctrine_temporal_head = { is_in_list = selected_doctrines } }
			}
		}

		parameters = {
			clerical_appointment_head_of_faith = yes
			clerical_appointment_fixed = yes
		}
	}
}
