# DO NOT ALTER THE NAME OR NUMBER OF THESE!

gender_laws = {
	agnatic_succession = {
		female_dynasty_opinion = -5

		potential = {
			holder_scope = {
				# Theocracies have to allow Male temple holders
				trigger_if = {
					limit = { is_theocracy = yes }

					religion_allows_male_temple_holders = yes
					religion_allows_female_temple_holders = no
				}
				# Matriarchal and Equal religions don't allow male-centric succession
				trigger_else = {
					NOR = {
						has_religion_feature = religion_matriarchal
						has_religion_feature = religion_equal
					}
				}
			}
		}

		pass_effect = {
			log = "agnatic_succession pass ([This.GetFullBaseName])"
		}

		effect = {
			log = "agnatic_succession ([This.GetFullBaseName])"
			gender_succ = agnatic
			law_set_allow_matrilineal_marriage = no
		}

		default_selection = {
			factor = 1

			trigger = {
				# Defaults to Agnatic-Cognatic with "All" gender gamerule.
				NOT = {
					has_game_rule = {
						name = gender
						value = all
					}
				}
			}

			mult_modifier = {
				factor = 100

				holder_scope = {
					NOR = {
						# Christian
						religion = cathar
						religion = bogomilist
						religion = messalian

						# Indian
						religion = buddhist

						# Pagan
						religion_openly_west_african_or_reformed_trigger = yes

						# Zoroastrian
						religion = mazdaki

						AND = {
							culture_group = tibetan_group

							NOR = {
								religion = taoist
								culture = tangut
							}
						}
					}

					NOR = {
						has_law = status_of_women_3
						has_law = status_of_women_4
					}
				}
			}
		}
	}

	cognatic_succession = { # agnatic-cognatic
		potential = {
			is_landless_type_title = no
			is_primary_type_title = no

			holder_scope = {
				is_theocracy = no

				trigger_if = {
					limit = { is_republic = yes }

					has_dlc = "Conclave"
					is_patrician = yes

					trigger_if = {
						limit = { independent = no }

						defacto_liege_title = {
							OR = {
								has_law = true_cognatic_succession
								has_law = cognatic_succession
							}
						}
					}
				}
				trigger_else_if = {
                    limit = {
                        OR = {
                            religion_group = muslim
							government = nomadic_tribal_government
                            has_horde_culture = yes
                            is_nomadic = yes
                            religion = aztec
                        }
                    }

                    has_dlc = "Conclave"
                }
				trigger_else_if = {
					limit = { government = order_government }
					independent = yes
				}

				# No exceptions
				NOR = {
					has_religion_feature = religion_matriarchal
                	has_religion_feature = religion_equal
				}
			}
		}

		allow = {
			holder_scope = {
				show_scope_change = no

				trigger_if = {
					limit = {
						has_dlc = "Conclave"

						OR = {
							religion_group = muslim
							government = nomadic_tribal_government
							has_horde_culture = yes
							has_religion_feature = religion_matriarchal
							has_religion_feature = religion_equal
							is_nomadic = yes
							religion = aztec
						}

						NOT = {
							has_game_rule = {
								name = gender
								value = all
							}
						}
					}

					OR = {
						has_law = status_of_women_3
						has_law = status_of_women_4
					}
				}
			}
		}

		pass_effect = {
			log = "cognatic_succession pass ([This.GetFullBaseName])"
		}

		effect = {
			log = "cognatic_succession ([This.GetFullBaseName])"
			gender_succ = cognatic
			law_set_allow_matrilineal_marriage = yes
		}

		default_selection = {
			factor = 10
		}
	}

	true_cognatic_succession = { # absolute cognatic
		male_dynasty_opinion = -5

		potential = {
			is_landless_type_title = no
			is_primary_type_title = no

			holder_scope = {
				trigger_if = {
					limit = { is_theocracy = yes }

					religion_allows_male_temple_holders = yes
					religion_allows_female_temple_holders = yes
				}

				# Equality gets a free pass
				trigger_else_if = {
					limit = {
						NOR = {
							has_religion_feature = religion_equal
							has_religion_feature = religion_feature_bon

							trigger_if = {
								limit = { has_dlc = "Conclave" }

								has_game_rule = {
									name = gender
									value = all
								}
							}
						}
					}

					# No Exceptions
					NOR = {
						has_religion_feature = religion_matriarchal
						has_religion_feature = religion_patriarchal
					}

					trigger_if = {
						limit = { is_republic = yes }

						has_dlc = "Conclave"
						is_patrician = yes

						trigger_if = {
							limit = { independent = no }

							defacto_liege_title = {
								OR = {
									has_law = true_cognatic_succession
									has_law = cognatic_succession
									has_law = enatic_cognatic_succession
								}
							}
						}
					}
					trigger_else_if = {
						limit = {
							OR = {
								religion_group = muslim
								government = nomadic_tribal_government
								has_horde_culture = yes
								is_nomadic = yes
								religion = aztec
							}
						}

						has_dlc = "Conclave"
					}
				}
			}
		}

		allow = {
            holder_scope = {
				show_scope_change = no

				trigger_if = {
					limit = {
						NOT = {
							has_game_rule = {
								name = gender
								value = all
							}
						}
					}

					OR = {
						culture = basque
						culture = zhangzhung
						culture = sumpa

						has_religion_feature = religion_equal
						has_religion_feature = religion_feature_bon

						religion = cathar
						religion = messalian
						religion = mazdaki

						trigger_if = {
							limit = { has_dlc = "Conclave"}
							has_law = status_of_women_4
						}
					}
				}
            }
		}

		pass_effect = {
			log = "true_cognatic_succession pass ([This.GetFullBaseName])"
		}

		effect = {
			log = "true_cognatic_succession ([This.GetFullBaseName])"
			gender_succ = true_cognatic
			law_set_allow_matrilineal_marriage = yes
		}

		default_selection = {
			factor = 1

			mult_modifier = {
				factor = 0.1

				holder_scope = {
					NOT = { has_religion_feature = religion_equal }
				}
			}

			mult_modifier = {
				factor = 100

				holder_scope = {
					has_religion_feature = religion_equal
				}
			}
		}
	}

	enatic_cognatic_succession = {
		male_dynasty_opinion = -10
		female_dynasty_opinion = 5

		potential = {
			is_landless_type_title = no
			is_primary_type_title = no

			holder_scope = {
				is_theocracy = no

				trigger_if = {
					limit = { is_republic = yes }

					has_dlc = "Conclave"
					is_patrician = yes

					trigger_if = {
						limit = { independent = no }

						defacto_liege_title = {
							OR = {
								has_law = true_cognatic_succession
								has_law = enatic_cognatic_succession
							}
						}
					}
				}

				OR = {
					has_religion_feature = religion_matriarchal

					any_owned_bloodline = {
						has_bloodline_flag = bloodline_enatic_cognatic
						bloodline_is_active_for = PREV
					}
				}
			}
		}

		pass_effect = {
			log = "enatic_cognatic_succession pass ([This.GetFullBaseName])"
		}

		effect = {
			log = "enatic_cognatic_succession ([This.GetFullBaseName])"
			gender_succ = enatic_cognatic
		}

		default_selection = {
			factor = 100
		}
	}

	enatic_succession = {
		male_dynasty_opinion = -10
		female_dynasty_opinion = 10

		potential = {
			is_landless_type_title = no

			holder_scope = {
				trigger_if = {
					limit = { is_theocracy = yes }

					religion_allows_male_temple_holders = no
					religion_allows_female_temple_holders = yes
				}
				trigger_else = {
					has_religion_feature = religion_matriarchal
				}
			}
		}

		pass_effect = {
			log = "enatic_succession pass ([This.GetFullBaseName])"
		}

		effect = {
			log = "enatic_succession ([This.GetFullBaseName])"
			gender_succ = enatic
		}

		default_selection = {
			factor = 1
		}
	}
}