namespace = qyv_guardian

# Quarterly: skilled characters proactively offer guardianship for matching wards
character_event = {
	id = qyv_guardian.0100
	hidden = yes

	trigger = { is_ruler = yes }

	immediate = {
		# For each child in realm needing education, seek a guardian in-court or vassals
		any_realm_courtier = {
			limit = { is_child = yes is_betrothed = no NOT = { has_guardian = yes } }
			save_scope_as = ward
			# Match by education focus
			random_realm_courtier = {
				limit = {
					is_adult = yes
					OR = {
						AND = { scope:ward = { has_education_focus = martial_education } martial >= 16 }
						AND = { scope:ward = { has_education_focus = stewardship_education } stewardship >= 16 }
						AND = { scope:ward = { has_education_focus = learning_education } learning >= 16 }
						AND = { scope:ward = { has_education_focus = diplomacy_education } diplomacy >= 16 }
						AND = { scope:ward = { has_education_focus = intrigue_education } intrigue >= 16 }
					}
				}
				save_scope_as = tutor
			}

			if = {
				limit = { exists = scope:tutor }
				qyv_send_guardianship_offer = { target = scope:ward.primary_caregiver ward = scope:ward }
			}
		}
	}
}
