{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Onboarding Quiz Funnel Configuration",
  "description": "Schema for defining a highly-converting, behaviorally-driven onboarding quiz funnel.",
  "type": "object",
  "required": ["funnelId", "screens"],
  "properties": {
    "funnelId": {
      "type": "string",
      "description": "Unique identifier for this onboarding funnel."
    },
    "defaultMascotId": {
      "type": "string",
      "description": "ID of the default mascot to use if a screen doesn't override it."
    },
    "screens": {
      "type": "array",
      "description": "An ordered array of screens the user will navigate through.",
      "items": {
        "$ref": "#/definitions/Screen"
      }
    }
  },
  "definitions": {
    "Screen": {
      "type": "object",
      "required": ["id", "phase", "type", "title"],
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique identifier for the screen."
        },
        "phase": {
          "type": "string",
          "enum": ["hook", "therapy", "objection", "labor_illusion", "reveal", "paywall"],
          "description": "The psychological phase this screen belongs to."
        },
        "type": {
          "type": "string",
          "enum": ["intro", "single_choice", "multi_choice", "slider", "loading_simulation", "summary", "paywall"],
          "description": "The functional UI type of the screen."
        },
        "title": {
          "type": "string",
          "description": "Main heading or question displayed to the user."
        },
        "subtitle": {
          "type": "string",
          "description": "Secondary text providing context or reassurance."
        },
        "mascotState": {
          "type": "string",
          "enum": ["none", "greeting", "thinking", "encouraging", "empathizing", "analyzing", "presenting", "celebrating", "idle"],
          "description": "The emotional state of the virtual coach to display."
        },
        "progressSpeed": {
          "type": "string",
          "enum": ["fast", "normal", "slow", "jump"],
          "description": "Manipulative progress bar speed for this screen."
        },
        "options": {
          "type": "array",
          "description": "Choices presented to the user (for single_choice or multi_choice types).",
          "items": {
            "$ref": "#/definitions/Option"
          }
        },
        "loadingConfiguration": {
          "type": "object",
          "description": "Configuration specifically for labor_illusion screens.",
          "properties": {
            "durationMs": { "type": "integer" },
            "fakeSteps": {
              "type": "array",
              "items": { "type": "string" }
            }
          }
        }
      }
    },
    "Option": {
      "type": "object",
      "required": ["id", "label"],
      "properties": {
        "id": {
          "type": "string"
        },
        "label": {
          "type": "string",
          "description": "The text displayed on the button."
        },
        "icon": {
          "type": "string",
          "description": "Optional icon identifier for the option."
        },
        "tagsToApply": {
          "type": "array",
          "description": "List of tags to assign to the user if they select this option.",
          "items": { "type": "string" }
        },
        "reinforcementMessage": {
          "type": "string",
          "description": "An intermittent reinforcement message to show after selecting this option (e.g., '70% of our users feel the same way.')."
        }
      }
    }
  }
}
