############################################################
##                   Elite Recruitment                    ##
############################################################
##                                                        ##
## The Recruit an Elite Specialist decision. Opens the    ##
## ER.10/11/12 menu chain so the player picks the         ##
## recruit's sex and council role. Auto-skips the gender  ##
## picker when only one sex has any eligible role.        ##
##                                                        ##
############################################################

decisions = {
  recruit_elite_specialist = {
    ai = no

    potential = {
      elite_recruitment_enabled_trigger = yes
      OR = {
        elite_recruitment_any_male_role_eligible_trigger = yes
        elite_recruitment_any_female_role_eligible_trigger = yes
      }
    }

    allow = {
      in_seclusion = no
      # At least one specific (sex x role) combination must be both eligible
      # AND affordable. The combined triggers below mirror the per-option gates
      # in ER.11/ER.12 so the decision can never be clicked into an empty role
      # picker. The looser "any role affordable" check the decision used to
      # have here let the player into a dead-end menu when, e.g., Catholic +
      # Gender=All + only chaplain affordable: women satisfied SoW4 for the
      # eligibility union but female Catholic chaplain is faith-blocked, so
      # ER.12 surfaced zero options.
      OR = {
        elite_recruitment_any_male_role_eligible_and_affordable_trigger = yes
        elite_recruitment_any_female_role_eligible_and_affordable_trigger = yes
      }
    }

    effect = {
      custom_tooltip = {
        text = recruit_elite_specialist_TT

        # Route to the gender picker only when both sexes have an eligible AND
        # affordable role; otherwise auto-skip to whichever sex does. The
        # eligible-and-affordable triggers mirror the per-option gates inside
        # ER.11/12 so the routing matches the per-role visibility exactly.
        if = {
          limit = {
            elite_recruitment_any_male_role_eligible_and_affordable_trigger = yes
            elite_recruitment_any_female_role_eligible_and_affordable_trigger = yes
          }
          character_event = { id = ER.10 }
        }
        else_if = {
          limit = { elite_recruitment_any_male_role_eligible_and_affordable_trigger = yes }
          character_event = { id = ER.11 }
        }
        else = {
          character_event = { id = ER.12 }
        }
      }
    }

    ai_will_do = {
      factor = 0
    }
  }

}
