######################
# Legitimacy
######################

count_legitimacy = {
	is_valid = {
		OR = {
			highest_held_title_tier = tier_county
			government_has_flag = government_is_prepublic
			government_has_flag = government_is_urepublic
		}
		NOR = {
			government_allows = administrative
			government_has_flag = government_is_nomadic
			government_has_flag = government_is_mandala
		}
	}

	ai_expected_level = default_ai_legitimacy_expectation

	below_expectations_opinion = default_legitimacy_opinion_penalty

	max = legitimacy_max

	# Scales based on Tier and Era
	## A Tribal era Count requires 4x less than a Late Medieval era Emperor
	level = {
		threshold = legitimacy_level_1
		modifier = {
			short_reign_duration_mult = 0.25
			monthly_dynasty_prestige = -0.1
			county_opinion_add = -10
		}
		flag = reduced_marriage_acceptance
		flag = increased_claim_cb_cost
		flag = reduced_alliance_acceptance
		flag = reduced_vassalization_acceptance
		flag = reduced_tributarization_acceptance
		flag = increased_factions
	}
	# Gap of at least 50
	level = {
		threshold = legitimacy_level_2 # 50-200
		modifier = {
			short_reign_duration_mult = -0.1
		}
	}
	# Gap of at least 100
	level = {
		threshold = legitimacy_level_3 # 150-600
		modifier = {
			short_reign_duration_mult = -0.25
		}
		flag = reduced_claim_cb_cost
		flag = increased_marriage_acceptance
	}
	# Gap of at least 200
	level = {
		threshold = legitimacy_level_4 # 350-1400
		modifier = {
			short_reign_duration_mult = -0.5
			county_opinion_add = 10
		}
		flag = increased_marriage_acceptance
		flag = increased_alliance_acceptance
		flag = very_reduced_claim_cb_cost
		flag = reduced_factions
		flag = reduced_swing_scales_cost
		flag = reduced_title_creation_cost
	}
	# Gap of at least 350
	level = {
		threshold = legitimacy_level_5 # 700-2800
		modifier = {
			short_reign_duration_mult = -0.75
			monthly_dynasty_prestige = 0.25
			county_opinion_add = 20
		}
		flag = very_increased_marriage_acceptance
		flag = very_increased_alliance_acceptance
		flag = extra_reduced_claim_cb_cost
		flag = very_reduced_factions
		flag = very_reduced_swing_scales_cost
		flag = very_reduced_title_creation_cost
	}
	# Gap of at least 500
	level = {
		threshold = legitimacy_level_6 # 1200-4800
		modifier = {
			short_reign_duration_mult = -1
			monthly_dynasty_prestige = 0.5
			county_opinion_add = 30
		}
		flag = extra_increased_marriage_acceptance
		flag = extra_increased_alliance_acceptance
		flag = extra_reduced_claim_cb_cost
		flag = extra_reduced_factions
		flag = extra_swing_scales_cost
		flag = extra_reduced_title_creation_cost
	}
}

duke_legitimacy = {
	is_valid = {
		highest_held_title_tier = tier_duchy
		NOR = {
			government_has_flag = government_is_prepublic
			government_has_flag = government_is_urepublic
		}
		NOR = {
			government_allows = administrative
			government_has_flag = government_is_nomadic
			government_has_flag = government_is_mandala
		}
	}

	ai_expected_level = default_ai_legitimacy_expectation

	below_expectations_opinion = default_legitimacy_opinion_penalty

	max = legitimacy_max

	# Scales based on Tier and Era
	## A Tribal era Count requires 4x less than a Late Medieval era Emperor
	level = {
		threshold = legitimacy_level_1
		modifier = {
			short_reign_duration_mult = 0.5
			monthly_dynasty_prestige = -0.1
			county_opinion_add = -10
		}
		flag = very_reduced_marriage_acceptance
		flag = very_increased_claim_cb_cost
		flag = very_reduced_alliance_acceptance
		flag = very_reduced_vassalization_acceptance
		flag = slightly_reduced_tributarization_acceptance
		flag = very_increased_factions
		flag = very_increased_swing_scales_cost
	}
	# Gap of at least 50
	level = {
		threshold = legitimacy_level_2 # 50-200
		modifier = {
			short_reign_duration_mult = 0.1
			county_opinion_add = -5
		}
		flag = reduced_marriage_acceptance
		flag = increased_claim_cb_cost
		flag = reduced_alliance_acceptance
		flag = reduced_vassalization_acceptance
		flag = reduced_tributarization_acceptance
		flag = increased_factions
		flag = increased_swing_scales_cost
	}
	# Gap of at least 100
	level = {
		threshold = legitimacy_level_3 # 150-600
		modifier = {
			short_reign_duration_mult = -0.15
		}
	}
	# Gap of at least 200
	level = {
		threshold = legitimacy_level_4 # 350-1400
		modifier = {
			short_reign_duration_mult = -0.35
		}
		flag = increased_marriage_acceptance
		flag = reduced_claim_cb_cost
		flag = increased_alliance_acceptance
		flag = increased_vassalization_acceptance
		flag = increased_tributarization_acceptance
		flag = reduced_factions
		flag = reduced_swing_scales_cost
		flag = reduced_title_creation_cost
	}
	# Gap of at least 350
	level = {
		threshold = legitimacy_level_5 # 700-2800
		modifier = {
			short_reign_duration_mult = -0.65
			county_opinion_add = 10
		}
		flag = very_increased_marriage_acceptance
		flag = very_reduced_claim_cb_cost
		flag = very_increased_alliance_acceptance
		flag = very_increased_vassalization_acceptance
		flag = very_increased_tributarization_acceptance
		flag = very_reduced_factions
		flag = very_reduced_swing_scales_cost
		flag = very_reduced_title_creation_cost
	}
	# Gap of at least 500
	level = {
		threshold = legitimacy_level_6 # 1200-4800
		modifier = {
			short_reign_duration_mult = -1
			monthly_dynasty_prestige = 0.25
			county_opinion_add = 20
		}
		flag = extra_increased_marriage_acceptance
		flag = extra_reduced_claim_cb_cost
		flag = extra_increased_alliance_acceptance
		flag = extra_increased_vassalization_acceptance
		flag = extra_increased_tributarization_acceptance
		flag = extra_reduced_factions
		flag = extra_reduced_swing_scales_cost
		flag = extra_reduced_title_creation_cost
	}
}

king_legitimacy = {
	is_valid = {
		highest_held_title_tier = tier_kingdom
		NOR = {
			government_has_flag = government_is_prepublic
			government_has_flag = government_is_urepublic
		}
		OR = {
			NOT = { government_allows = administrative }
			top_liege = this
		}
		NOR = { 
			government_has_flag = government_is_nomadic
			government_has_flag = government_is_mandala
		}
	}

	ai_expected_level = default_ai_legitimacy_expectation

	below_expectations_opinion = default_legitimacy_opinion_penalty

	max = legitimacy_max

	# Scales based on Tier and Era
	## A Tribal era Count requires 4x less than a Late Medieval era Emperor
	level = {
		threshold = legitimacy_level_1
		modifier = {
			short_reign_duration_mult = 0.75
			monthly_dynasty_prestige = -0.2
			county_opinion_add = -20
		}
		flag = very_reduced_marriage_acceptance
		flag = very_increased_claim_cb_cost
		flag = very_reduced_alliance_acceptance
		flag = very_reduced_vassalization_acceptance
		flag = reduced_tributarization_acceptance
		flag = very_increased_factions
		flag = very_increased_swing_scales_cost

	}
	# Gap of at least 50
	level = {
		threshold = legitimacy_level_2 # 50-200
		modifier = {
			short_reign_duration_mult = 0.5
			monthly_dynasty_prestige = -0.1
			county_opinion_add = -10
		}
		flag = reduced_marriage_acceptance
		flag = increased_claim_cb_cost
		flag = reduced_alliance_acceptance
		flag = reduced_vassalization_acceptance
		flag = slightly_reduced_tributarization_acceptance
		flag = increased_factions
		flag = increased_swing_scales_cost
	}
	# Gap of at least 100
	level = {
		threshold = legitimacy_level_3 # 150-600
		modifier = {
			short_reign_duration_mult = 0.25
		}
		flag = reduced_marriage_acceptance
		flag = reduced_vassalization_acceptance
		flag = increased_claim_cb_cost
	}
	# Gap of at least 200
	level = {
		threshold = legitimacy_level_4 # 350-1400
		modifier = {
			short_reign_duration_mult = -0.10
		}
	}
	# Gap of at least 350
	level = {
		threshold = legitimacy_level_5 # 700-2800
		modifier = {
			short_reign_duration_mult = -0.25
		}
		flag = increased_marriage_acceptance
		flag = reduced_claim_cb_cost
		flag = increased_alliance_acceptance
		flag = increased_vassalization_acceptance
		flag = increased_tributarization_acceptance
		flag = reduced_factions
		flag = reduced_swing_scales_cost
		flag = reduced_title_creation_cost
	}
	# Gap of at least 500
	level = {
		threshold = legitimacy_level_6 # 1200-4800
		modifier = {
			short_reign_duration_mult = -0.5
			county_opinion_add = 10
			monthly_dynasty_prestige = 0.25
		}
		flag = very_increased_marriage_acceptance
		flag = very_reduced_claim_cb_cost
		flag = very_increased_alliance_acceptance
		flag = very_increased_vassalization_acceptance
		flag = very_increased_tributarization_acceptance
		flag = very_reduced_factions
		flag = very_reduced_swing_scales_cost
		flag = very_reduced_title_creation_cost
	}
}

emperor_legitimacy = {
	is_valid = {
		highest_held_title_tier = tier_empire
		NOR = {
			government_has_flag = government_is_prepublic
			government_has_flag = government_is_urepublic
		}
		NOR = { 
			government_has_flag = government_is_nomadic
			government_has_flag = government_is_mandala
		}
	}

	ai_expected_level = default_ai_legitimacy_expectation

	below_expectations_opinion = default_legitimacy_opinion_penalty

	max = legitimacy_max

	# Scales based on Tier and Era
	## A Tribal era Count requires 4x less than a Late Medieval era Emperor
	level = {
		threshold = legitimacy_level_1
		modifier = {
			short_reign_duration_mult = 1
			monthly_dynasty_prestige = -0.3
			county_opinion_add = -30
		}
		flag = massively_reduced_marriage_acceptance
		flag = massively_increased_claim_cb_cost
		flag = massively_reduced_vassalization_acceptance
		flag = massively_reduced_tributarization_acceptance
		flag = massively_reduced_alliance_acceptance
		flag = massively_increased_factions
		flag = massively_increased_swing_scales_cost
	}
	# Gap of at least 50
	level = {
		threshold = legitimacy_level_2 # 50-200
		modifier = {
			short_reign_duration_mult = 0.65
			monthly_dynasty_prestige = -0.2
			county_opinion_add = -20
		}
		flag = very_reduced_marriage_acceptance
		flag = very_increased_claim_cb_cost
		flag = very_reduced_alliance_acceptance
		flag = very_reduced_vassalization_acceptance
		flag = very_reduced_tributarization_acceptance
		flag = very_increased_factions
		flag = very_increased_swing_scales_cost
	}
	# Gap of at least 100
	level = {
		threshold = legitimacy_level_3 # 150-600
		modifier = {
			short_reign_duration_mult = 0.35
			monthly_dynasty_prestige = -0.1
			county_opinion_add = -10
		}
		flag = reduced_marriage_acceptance
		flag = reduced_alliance_acceptance
		flag = increased_claim_cb_cost
		flag = reduced_vassalization_acceptance
		flag = reduced_tributarization_acceptance
		flag = increased_factions
		flag = increased_swing_scales_cost
	}
	# Gap of at least 200
	level = {
		threshold = legitimacy_level_4 # 350-1400
		modifier = {
			short_reign_duration_mult = 0.15
		}
		flag = reduced_marriage_acceptance
		flag = reduced_vassalization_acceptance
		flag = slightly_reduced_tributarization_acceptance
		flag = increased_claim_cb_cost
	}
	# Gap of at least 350
	level = {
		threshold = legitimacy_level_5 # 700-2800
		modifier = {
			short_reign_duration_mult = -0.1
		}
	}
	# Gap of at least 500
	level = {
		threshold = legitimacy_level_6 # 1200-4800
		modifier = {
			short_reign_duration_mult = -0.25
			county_opinion_add = 10
		}
		flag = increased_marriage_acceptance
		flag = reduced_claim_cb_cost
		flag = increased_alliance_acceptance
		flag = increased_vassalization_acceptance
		flag = increased_tributarization_acceptance
		flag = reduced_factions
		flag = reduced_title_creation_cost
		flag = reduced_swing_scales_cost
	}
}

hegemon_legitimacy = {
	is_valid = {
		highest_held_title_tier = tier_hegemony
		NOR = {
			government_has_flag = government_is_prepublic
			government_has_flag = government_is_urepublic
		}
		NOT = { government_has_flag = government_is_mandala }
		NAND = {
			has_tgp_dlc_trigger = yes
			has_title = title:h_china
		}
		NOR = { 
			government_has_flag = government_is_nomadic
			government_has_flag = government_is_mandala
		}
	}

	ai_expected_level = default_ai_legitimacy_expectation

	below_expectations_opinion = default_legitimacy_opinion_penalty

	max = legitimacy_max

	# Scales based on Tier and Era
	## A Tribal era Count requires 4x less than a Late Medieval era Emperor
	level = {
		threshold = legitimacy_level_1
		modifier = {
			short_reign_duration_mult = 1.25
			monthly_dynasty_prestige = -0.4
			county_opinion_add = -40
		}
		flag = massively_reduced_marriage_acceptance
		flag = massively_increased_claim_cb_cost
		flag = massively_reduced_vassalization_acceptance
		flag = massively_reduced_tributarization_acceptance
		flag = massively_reduced_alliance_acceptance
		flag = massively_increased_factions
		flag = massively_increased_swing_scales_cost
	}
	# Gap of at least 50
	level = {
		threshold = legitimacy_level_2 # 50-200
		modifier = {
			short_reign_duration_mult = 0.75
			monthly_dynasty_prestige = -0.3
			county_opinion_add = -30
		}
		flag = very_reduced_marriage_acceptance
		flag = very_increased_claim_cb_cost
		flag = very_reduced_alliance_acceptance
		flag = very_reduced_vassalization_acceptance
		flag = very_reduced_tributarization_acceptance
		flag = very_increased_factions
		flag = very_increased_swing_scales_cost
	}
	# Gap of at least 100
	level = {
		threshold = legitimacy_level_3 # 150-600
		modifier = {
			short_reign_duration_mult = 0.5
			monthly_dynasty_prestige = -0.2
			county_opinion_add = -20
		}
		flag = reduced_marriage_acceptance
		flag = reduced_alliance_acceptance
		flag = increased_claim_cb_cost
		flag = reduced_vassalization_acceptance
		flag = reduced_tributarization_acceptance
		flag = increased_factions
		flag = increased_swing_scales_cost
	}
	# Gap of at least 200
	level = {
		threshold = legitimacy_level_4 # 350-1400
		modifier = {
			short_reign_duration_mult = 0.2
		}
		flag = reduced_marriage_acceptance
		flag = reduced_vassalization_acceptance
		flag = slightly_reduced_tributarization_acceptance
		flag = increased_claim_cb_cost
	}
	# Gap of at least 350
	level = {
		threshold = legitimacy_level_5 # 700-2800
	}
	# Gap of at least 500
	level = {
		threshold = legitimacy_level_6 # 1200-4800
		modifier = {
			short_reign_duration_mult = -0.25
			county_opinion_add = 10
		}
		flag = increased_marriage_acceptance
		flag = reduced_claim_cb_cost
		flag = increased_alliance_acceptance
		flag = increased_vassalization_acceptance
		flag = increased_tributarization_acceptance
		flag = reduced_factions
		flag = reduced_title_creation_cost
		flag = reduced_swing_scales_cost
	}
}

mandate_legitimacy = {
	is_valid = {
		highest_held_title_tier = tier_hegemony
		NOR = {
			government_has_flag = government_is_prepublic
			government_has_flag = government_is_urepublic
		}
		has_tgp_dlc_trigger = yes
		has_title = title:h_china
	}

	# must be equal to the dynastic_cycle_legitimacy_expectation script value and not dependent on vassal scopes
	ai_expected_level = dynastic_cycle_legitimacy_expectation 

	below_expectations_opinion = default_legitimacy_opinion_penalty

	max = mandate_legitimacy_max

	# Scales based on Tier and Era
	## A Tribal era Count requires 4x less than a Late Medieval era Emperor
	level = {
		threshold = legitimacy_level_1
		on_level_entered = {
			situation:dynastic_cycle ?= {
				if = {
					limit = {
						situation_top_has_catalyst = catalyst_hegemon_lost_mandate_of_heaven
						months_from_game_start > 0 # We check this to avoid potentially triggering this immediately on game start
					}
					trigger_situation_catalyst = catalyst_hegemon_lost_mandate_of_heaven
				}
			}
		}
		on_level_entered_desc = {
			desc = legitimacy_on_entered_lost_mandate
		}
		modifier = {
			short_reign_duration_mult = 1.25
			monthly_dynasty_prestige = -0.4
			county_opinion_add = -40
		}
		flag = massively_reduced_marriage_acceptance
		flag = massively_increased_claim_cb_cost
		flag = massively_reduced_vassalization_acceptance
		flag = massively_reduced_tributarization_acceptance
		flag = massively_reduced_alliance_acceptance
		flag = massively_increased_factions
		flag = massively_increased_swing_scales_cost
	}
	# Gap of at least 50
	level = {
		threshold = legitimacy_level_2 # 50-200
		modifier = {
			short_reign_duration_mult = 0.75
			monthly_dynasty_prestige = -0.3
			county_opinion_add = -30
		}
		flag = very_reduced_marriage_acceptance
		flag = very_increased_claim_cb_cost
		flag = very_reduced_alliance_acceptance
		flag = very_reduced_vassalization_acceptance
		flag = very_reduced_tributarization_acceptance
		flag = very_increased_factions
		flag = very_increased_swing_scales_cost
	}
	# Gap of at least 100
	level = {
		threshold = legitimacy_level_3 # 150-600
		modifier = {
			short_reign_duration_mult = 0.5
			monthly_dynasty_prestige = -0.2
			county_opinion_add = -20
		}
		flag = reduced_marriage_acceptance
		flag = reduced_alliance_acceptance
		flag = increased_claim_cb_cost
		flag = reduced_vassalization_acceptance
		flag = reduced_tributarization_acceptance
		flag = increased_factions
		flag = increased_swing_scales_cost
	}
	# Gap of at least 200
	level = {
		threshold = legitimacy_level_4 # 350-1400
		modifier = {
			short_reign_duration_mult = 0.2
		}
		flag = reduced_marriage_acceptance
		flag = reduced_vassalization_acceptance
		flag = slightly_reduced_tributarization_acceptance
		flag = increased_claim_cb_cost
	}
	# Gap of at least 350
	level = {
		threshold = legitimacy_level_5 # 700-2800
	}
	# Gap of at least 500
	level = {
		threshold = legitimacy_level_6 # 1200-4800
		modifier = {
			short_reign_duration_mult = -0.25
			county_opinion_add = 10
		}
		flag = reduced_claim_cb_cost
		flag = increased_marriage_acceptance
		flag = increased_tributarization_acceptance
		flag = reduced_factions
		flag = reduced_title_creation_cost
		flag = reduced_swing_scales_cost
	}
	level = {
		threshold = legitimacy_level_7 # 1650-6600
		modifier = {
			tributary_opinion = 20
			county_opinion_add = 20
			monthly_dynasty_prestige = 0.15
		}
		flag = very_reduced_claim_cb_cost
		flag = very_increased_marriage_acceptance
		flag = extra_increased_tributarization_acceptance
		flag = reduced_factions
		flag = reduced_title_creation_cost
		flag = reduced_swing_scales_cost
	}
	level = {
		threshold = legitimacy_level_8
		modifier = {
			tributary_opinion = 30
			county_opinion_add = 25
			monthly_dynasty_prestige = 0.25
		}
		flag = very_reduced_claim_cb_cost
		flag = very_increased_marriage_acceptance
		flag = extra_increased_tributarization_acceptance
		flag = reduced_factions
		flag = reduced_title_creation_cost
		flag = reduced_swing_scales_cost
	}
}

nomadic_legitimacy = {
	is_valid = {
		has_mpo_dlc_trigger = yes
		NOR = {
			government_has_flag = government_is_prepublic
			government_has_flag = government_is_urepublic
		}
		government_has_flag = government_is_nomadic
	}

	ai_expected_level = default_ai_legitimacy_expectation

	below_expectations_opinion = default_legitimacy_opinion_penalty

	max = legitimacy_max

	# Scales based on Tier and Era
	## A Tribal era Count requires 4x less than a Late Medieval era Emperor
	level = {
		threshold = legitimacy_level_1
		modifier = {
			short_reign_duration_mult = 0.75
			county_opinion_add = -10
			herd_gain_mult = -0.05
			dread_baseline_add = -30
		}
		flag = very_reduced_marriage_acceptance
		flag = very_reduced_alliance_acceptance
		flag = very_reduced_vassalization_acceptance
		flag = very_reduced_tributarization_acceptance
		flag = very_reduced_confederation_acceptance
		flag = reduced_obedience_acceptance

	}
	# Gap of at least 50
	level = {
		threshold = legitimacy_level_2 # 50-200
		modifier = {
			short_reign_duration_mult = 0.5
			county_opinion_add = -5
			dread_baseline_add = -15
		}
		flag = reduced_marriage_acceptance
		flag = reduced_alliance_acceptance
		flag = reduced_vassalization_acceptance
		flag = reduced_tributarization_acceptance
		flag = reduced_confederation_acceptance
		flag = reduced_obedience_acceptance
	}
	# Gap of at least 100
	level = {
		threshold = legitimacy_level_3 # 150-600
		modifier = {
			short_reign_duration_mult = 0.25
			dread_baseline_add = -5
		}
		flag = reduced_marriage_acceptance
		flag = reduced_vassalization_acceptance
		flag = reduced_obedience_acceptance
	}
	# Gap of at least 200
	level = {
		threshold = legitimacy_level_4 # 350-1400
		modifier = {
			tributary_opinion = 5
			herd_gain_mult = 0.05
		}
		flag = increased_obedience_acceptance
	}
	# Gap of at least 350
	level = {
		threshold = legitimacy_level_5 # 700-2800
		modifier = {
			tributary_opinion = 10
			herd_gain_mult = 0.15
		}
		flag = increased_marriage_acceptance
		flag = increased_alliance_acceptance
		flag = increased_vassalization_acceptance
		flag = increased_tributarization_acceptance
		flag = increased_confederation_acceptance
		flag = reduced_factions
		flag = reduced_swing_scales_cost
		flag = increased_obedience_acceptance
	}
	# Gap of at least 500
	level = {
		threshold = legitimacy_level_6 # 1200-4800
		modifier = {
			tributary_opinion = 15
			county_opinion_add = 10
			monthly_dynasty_prestige = 0.25
			herd_gain_mult = 0.30
		}
		flag = very_increased_marriage_acceptance
		flag = very_increased_alliance_acceptance
		flag = very_increased_vassalization_acceptance
		flag = very_increased_tributarization_acceptance
		flag = very_increased_confederation_acceptance
		flag = very_reduced_factions
		flag = very_reduced_swing_scales_cost
		flag = increased_obedience_acceptance
	}
}

mandala_legitimacy = {
	is_valid = {
		has_tgp_dlc_trigger = yes
		NOR = {
			government_has_flag = government_is_prepublic
			government_has_flag = government_is_urepublic
		}
		government_has_flag = government_is_mandala
	}

	ai_expected_level = default_ai_mandala_legitimacy_expectation

	below_expectations_opinion = default_legitimacy_opinion_penalty

	max = mandala_legitimacy_max

	# Scales based on Tier and Era
	## A Tribal era Count requires 4x less than a Late Medieval era Emperor
	level = {
		threshold = mandala_legitimacy_level_1
		modifier = {
			short_reign_duration_mult = 0.75
			county_opinion_add = -10
			monthly_piety_gain_mult = -0.05
		}
		flag = massively_increased_claim_cb_cost
		flag = massively_reduced_marriage_acceptance
		flag = massively_reduced_alliance_acceptance
		flag = massively_reduced_vassalization_acceptance
		flag = slightly_reduced_tributarization_acceptance
		flag = very_increased_factions

	}
	# Gap of at least 200
	level = {
		threshold = mandala_legitimacy_level_2 # 200-800
		modifier = {
			short_reign_duration_mult = 0.5
			county_opinion_add = -5
		}
		flag = very_increased_claim_cb_cost
		flag = very_reduced_marriage_acceptance
		flag = very_reduced_alliance_acceptance
		flag = very_reduced_vassalization_acceptance
		flag = slightly_reduced_tributarization_acceptance
		flag = increased_factions
	}
	# Gap of at least 220
	level = {
		threshold = mandala_legitimacy_level_3 # 420-1680
		modifier = {
			short_reign_duration_mult = 0.25
		}
		flag = increased_claim_cb_cost
		flag = reduced_marriage_acceptance
		flag = reduced_alliance_acceptance
		flag = reduced_vassalization_acceptance
		flag = increased_factions
	}
	# Gap of at least 220
	level = {
		threshold = mandala_legitimacy_level_4 # 640-2560
		modifier = {
			tributary_opinion = 5
			monthly_piety_gain_mult = 0.05
		}
		flag = reduced_vassalization_acceptance
	}
	# Gap of at least 270
	level = {
		threshold = mandala_legitimacy_level_5 # 910-3640
		modifier = {
			tributary_opinion = 10
			monthly_piety_gain_mult = 0.15
		}
		flag = reduced_claim_cb_cost
		flag = increased_marriage_acceptance
		flag = increased_alliance_acceptance
		flag = increased_tributarization_acceptance
		flag = reduced_factions
		flag = reduced_swing_scales_cost
	}
	# Gap of at least 330
	level = {
		threshold = mandala_legitimacy_level_6 # 1240-4960
		modifier = {
			tributary_opinion = 15
			county_opinion_add = 10
			monthly_piety_gain_mult = 0.2
			monthly_dynasty_prestige = 0.15
		}
		flag = reduced_claim_cb_cost
		flag = increased_marriage_acceptance
		flag = increased_alliance_acceptance
		flag = very_increased_tributarization_acceptance
		flag = reduced_factions
		flag = reduced_swing_scales_cost
	}
	# Gap of at least 550
	level = {
		threshold = mandala_legitimacy_level_7 # 1650-6600
		modifier = {
			tributary_opinion = 20
			county_opinion_add = 20
			monthly_piety_gain_mult = 0.3
			monthly_dynasty_prestige = 0.15
		}
		flag = very_reduced_claim_cb_cost
		flag = very_increased_marriage_acceptance
		flag = very_increased_alliance_acceptance
		flag = extra_increased_tributarization_acceptance
		flag = very_reduced_factions
		flag = very_reduced_swing_scales_cost
	}
	# Gap of at least 550
	level = {
		threshold = mandala_legitimacy_level_8 # 2200-8800
		modifier = {
			tributary_opinion = 30
			county_opinion_add = 25
			monthly_piety_gain_mult = 0.35
			monthly_dynasty_prestige = 0.25
			faith_conversion_piety_cost_mult = -0.15
		}
		flag = very_reduced_claim_cb_cost
		flag = very_increased_marriage_acceptance
		flag = very_increased_alliance_acceptance
		flag = increased_vassalization_acceptance
		flag = extra_increased_tributarization_acceptance
		flag = very_reduced_factions
		flag = very_reduced_swing_scales_cost
	}
	# Gap of at least 700
	level = {
		threshold = mandala_legitimacy_level_9 # 3000-12000
		modifier = {
			tributary_opinion = 35
			county_opinion_add = 35
			monthly_piety_gain_mult = 0.4
			monthly_dynasty_prestige = 0.3
			faith_conversion_piety_cost_mult = -0.3
		}
		flag = extra_reduced_claim_cb_cost
		flag = extra_increased_marriage_acceptance
		flag = extra_increased_alliance_acceptance
		flag = very_increased_vassalization_acceptance
		flag = extra_increased_tributarization_acceptance
		flag = extra_reduced_factions
		flag = extra_reduced_swing_scales_cost
	}
}
