{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://quailpages.com/schema/qp.theme-extension.schema.json",
  "title": "Quail Pages Theme Extension Contract",
  "type": "object",
  "additionalProperties": false,
  "required": ["version", "description", "variables"],
  "properties": {
    "version": { "const": 1 },
    "description": { "type": "string", "minLength": 1 },
    "excludeEnums": {
      "type": "array",
      "items": { "type": "string", "pattern": "^--qp-[a-z0-9_-]+$" },
      "uniqueItems": true
    },
    "variables": {
      "type": "object",
      "propertyNames": { "pattern": "^--(?:qp|theme)-[a-z0-9_-]+$" },
      "additionalProperties": {
        "oneOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "required": ["kind", "value"],
            "properties": {
              "kind": { "enum": ["override", "remap"] },
              "value": { "type": "string", "minLength": 1 }
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": ["kind", "description", "variableType", "designType", "value"],
            "properties": {
              "kind": { "const": "theme-owned" },
              "description": { "type": "string", "minLength": 1 },
              "variableType": { "enum": ["system", "enum", "root", "derived", "inherited"] },
              "designType": { "enum": ["background", "color", "spacing", "font-family", "font-size", "font-weight", "line-height", "radius", "border", "border-width", "size", "shadow", "layer", "layout", "effect"] },
              "value": { "type": "string", "minLength": 1 },
              "derivedFrom": { "oneOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" }, "minItems": 1, "uniqueItems": true }] },
              "inheritsFrom": { "type": "string" }
            }
          }
        ]
      }
    }
  }
}
