{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gixo.ai/schemas/gixo-style-rules-v1.schema.json",
  "title": "Gixo Style Rules",
  "description": "Portable, deterministic brand and document style rules.",
  "type": "object",
  "additionalProperties": false,
  "required": ["$schema", "format", "version", "name", "typography", "colors", "terminology", "accessibility"],
  "properties": {
    "$schema": { "const": "https://gixo.ai/schemas/gixo-style-rules-v1.schema.json" },
    "format": { "const": "gixo-style-rules" },
    "version": { "const": "1.0.0" },
    "name": { "type": "string", "minLength": 1, "maxLength": 200 },
    "description": { "type": "string", "maxLength": 2000 },
    "typography": { "$ref": "#/$defs/typography" },
    "colors": {
      "type": "array", "maxItems": 40,
      "items": { "$ref": "#/$defs/color" }
    },
    "tone": {
      "type": "object", "additionalProperties": false,
      "properties": {
        "attributes": { "$ref": "#/$defs/shortStringList" },
        "avoid": { "$ref": "#/$defs/shortStringList" },
        "guidance": { "type": "string", "maxLength": 4000 }
      }
    },
    "terminology": { "$ref": "#/$defs/terminology" },
    "formatting": {
      "type": "object", "additionalProperties": false,
      "properties": {
        "dateFormat": { "type": "string", "maxLength": 100 },
        "numberFormat": { "type": "string", "maxLength": 100 },
        "headingCase": { "enum": ["sentence", "title", "upper", "unchanged"] },
        "serialComma": { "type": "boolean" },
        "maximumSentenceWords": { "type": "integer", "minimum": 5, "maximum": 100 }
      }
    },
    "accessibility": { "$ref": "#/$defs/accessibility" },
    "prohibitedPatterns": {
      "type": "array", "maxItems": 100,
      "items": {
        "type": "object", "additionalProperties": false,
        "required": ["name", "pattern", "message"],
        "properties": {
          "name": { "type": "string", "maxLength": 200 },
          "pattern": { "type": "string", "maxLength": 1000 },
          "message": { "type": "string", "maxLength": 1000 }
        }
      }
    }
  },
  "$defs": {
    "shortStringList": { "type": "array", "maxItems": 100, "items": { "type": "string", "maxLength": 500 } },
    "typography": {
      "type": "object", "additionalProperties": false,
      "required": ["headingFonts", "bodyFonts"],
      "properties": {
        "headingFonts": { "$ref": "#/$defs/shortStringList" },
        "bodyFonts": { "$ref": "#/$defs/shortStringList" },
        "minimumBodyPointSize": { "type": "number", "minimum": 6, "maximum": 72 },
        "minimumSlidePointSize": { "type": "number", "minimum": 8, "maximum": 96 }
      }
    },
    "color": {
      "type": "object", "additionalProperties": false,
      "required": ["name", "value", "usage"],
      "properties": {
        "name": { "type": "string", "maxLength": 100 },
        "value": { "type": "string", "pattern": "^#[0-9A-Fa-f]{6}$" },
        "usage": { "type": "string", "maxLength": 500 }
      }
    },
    "terminology": {
      "type": "object", "additionalProperties": false,
      "required": ["preferred", "prohibited"],
      "properties": {
        "preferred": {
          "type": "array", "maxItems": 200,
          "items": {
            "type": "object", "additionalProperties": false,
            "required": ["use", "insteadOf"],
            "properties": {
              "use": { "type": "string", "maxLength": 200 },
              "insteadOf": { "$ref": "#/$defs/shortStringList" }
            }
          }
        },
        "prohibited": { "$ref": "#/$defs/shortStringList" }
      }
    },
    "accessibility": {
      "type": "object", "additionalProperties": false,
      "required": ["minimumTextContrast", "minimumLargeTextContrast"],
      "properties": {
        "minimumTextContrast": { "type": "number", "minimum": 1, "maximum": 21 },
        "minimumLargeTextContrast": { "type": "number", "minimum": 1, "maximum": 21 },
        "requireAltText": { "type": "boolean" },
        "avoidColorOnlyMeaning": { "type": "boolean" }
      }
    }
  }
}
