fitna_of_al_andalus = {
	potential = {
		OR = {
			tag = CRD
			tag = ADU		#Andalusia
			was_tag = CRD
		}
		NOT = { has_country_flag = fitna_of_al_andalus_happened }
		normal_or_historical_nations = yes
		is_year = 800
		NOT = { started_in = 1011.1.1 } 
		num_of_owned_provinces_with = {
			value = 20
			region = iberia_region
		}
		OR = {
			government = monarchy
			government = theocracy
		}
	}
	
	can_start = {
		has_any_disaster = no
		NOT = { stability = 0 }
		num_of_owned_provinces_with = {
			value = 20
			region = iberia_region
		}
		OR = {
			government = monarchy
			government = theocracy
		}
		OR = {
			has_regency = yes
			NOT = { legitimacy = 50 }
			war_exhaustion = 15
			NOT = { stability = -2 }
			AND = {
				ai = yes
				NOT = { stability = -1 }
				is_great_power = yes
			}
		}
	}
	
	can_stop = {
		OR = {
			has_any_disaster = yes
			stability = 2
		}
	}
	
	progress = {
		modifier = {
			factor = 1
			num_of_loans = 5
		}
		modifier = {
			factor = 3
			num_of_loans = 10
		}
		modifier = {
			factor = 5
			is_bankrupt = yes
		}
		modifier = {
			factor = 2
			corruption = 5
			NOT = { corruption = 10 }
		}
		modifier = {
			factor = 5
			corruption = 10
		}
		modifier = {
			factor = 2
			NOT = { stability = 0 }
		}
		modifier = {
			factor = 5
			NOT = { stability = -1 }
		}
		modifier = {
			factor = 10
			NOT = { stability = -2 }
		}
		modifier = {
			factor = 10
			has_heir = no
		}
		modifier = {
			factor = 5
			heir_has_ruler_dynasty = no
		}
		modifier = {
			factor = 5
			OR = {
				NOT = { adm = 3 }
				NOT = { dip = 3 }
				NOT = { mil = 3 }
			}
		}
	}
	
	can_end = {
		stability = 3
		NOT = { num_of_rebel_armies = 1 }
		NOT = { num_of_rebel_controlled_provinces = 1 }
		had_country_flag = {
			flag = fitna_of_al_andalus_started_flag
			days = 1825
		}
	}
	
	modifier = {
		global_unrest = 8
		stability_cost_modifier = 0.1
		global_tax_modifier = -0.05
	}
	
	on_start = fitna_of_al_andalus.1		#The Fitna of al-Andalus
	on_end = fitna_of_al_andalus.2
	
	on_monthly = {
		events = {
			fitna_of_al_andalus.4		#Sulayman Rebels!
			fitna_of_al_andalus.9		#Hammudid Dynasty Claims the Throne
			fitna_of_al_andalus.16		#Governors Exert Regional Influence - Taifa gain cores
		}
		random_events = {
			2250 = 0
			50 = fitna_of_al_andalus.3		#Weary Soldiers Defect
			25 = fitna_of_al_andalus.5		#Confidant Assassinated!
			50 = fitna_of_al_andalus.6		#Umayyad Clan Dissatisfied
			50 = fitna_of_al_andalus.7		#Umayyad Pretender Claims the Throne
			5 = fitna_of_al_andalus.8		#Caliph Assassinated!
			150 = fitna_of_al_andalus.10	#Populace Demands Reduced Taxes
			100 = fitna_of_al_andalus.11	#Christian Mercenaries Hired by Rebels
			100 = fitna_of_al_andalus.12	#Noble Clans Rebel
			100 = fitna_of_al_andalus.13	#Berber Raiders Attack
			50 = fitna_of_al_andalus.14		#Catalonian Lords Support the Rebels
			20 = fitna_of_al_andalus.15		#The Guard Revolts in the Capital
			
			200 = fitna_of_al_andalus.17		#Seville Secession
			200 = fitna_of_al_andalus.18		#Badajoz Secession
			200 = fitna_of_al_andalus.19		#Toledo Secession
			200 = fitna_of_al_andalus.20		#Zaragoza Secession
			200 = fitna_of_al_andalus.21		#Denia Secedes
			200 = fitna_of_al_andalus.22		#Granada Secedes
		}
	}
}