{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://huecodex.com/json/hue-codex-token-style.schema.json",
  "title": "Hue Codex token-style JSON schema",
  "description": "Strict schema for Hue Codex practical token-style JSON containers. Token leaves require both $type and $value. This is not a Design Tokens Format Module conformance claim.",
  "$ref": "#/$defs/tokenStyleExport",
  "$defs": {
    "tokenStyleExport": {
      "type": "object",
      "description": "Hue Codex practical token-style JSON container. It uses familiar $type and $value fields, but does not claim Design Tokens Format Module conformance.",
      "properties": {
        "$schema": {
          "type": "string",
          "description": "Optional identifier for the Hue Codex token-style JSON schema. It does not claim Design Tokens Format Module conformance."
        },
        "$extensions": { "$ref": "#/$defs/extensions" },
        "color": { "$ref": "#/$defs/tokenGroup" },
        "dimension": { "$ref": "#/$defs/tokenGroup" }
      },
      "additionalProperties": { "$ref": "#/$defs/tokenGroup" },
      "anyOf": [
        { "required": ["color"] },
        { "required": ["dimension"] }
      ]
    },
    "tokenGroup": {
      "type": "object",
      "description": "Recursive group of token leaves or nested token groups.",
      "additionalProperties": {
        "oneOf": [
          { "$ref": "#/$defs/tokenGroup" },
          { "$ref": "#/$defs/tokenLeaf" }
        ]
      }
    },
    "tokenLeaf": {
      "type": "object",
      "required": ["$type", "$value"],
      "properties": {
        "$type": {
          "type": "string",
          "minLength": 1,
          "examples": ["color", "dimension"]
        },
        "$value": {
          "oneOf": [
            { "$ref": "#/$defs/colorValue" },
            { "type": "number" }
          ]
        },
        "$description": {
          "type": "string"
        },
        "$extensions": { "$ref": "#/$defs/extensions" },
        "role": {
          "type": "string"
        },
        "accessibility": {
          "type": "object",
          "additionalProperties": { "$ref": "#/$defs/jsonValue" }
        }
      },
      "additionalProperties": { "$ref": "#/$defs/jsonValue" }
    },
    "colorValue": {
      "type": "string",
      "minLength": 1,
      "description": "A Hue Codex color value string such as uppercase HEX, rgb(), hsl(), lab(), lch(), oklab(), oklch(), color(), color-mix(), light-dark(), or a CSS variable reference.",
      "examples": ["#0EA5E9", "#0EA5E980", "rgb(14 165 233)", "oklch(68.56% 0.147 237.32)", "var(--hc-primary)"]
    },
    "extensions": {
      "type": "object",
      "additionalProperties": { "$ref": "#/$defs/jsonValue" },
      "properties": {
        "hueCodex": {
          "type": "object",
          "additionalProperties": { "$ref": "#/$defs/jsonValue" }
        }
      }
    },
    "jsonValue": {
      "oneOf": [
        { "type": "string" },
        { "type": "number" },
        { "type": "integer" },
        { "type": "boolean" },
        { "type": "null" },
        {
          "type": "array",
          "items": { "$ref": "#/$defs/jsonValue" }
        },
        {
          "type": "object",
          "additionalProperties": { "$ref": "#/$defs/jsonValue" }
        }
      ]
    }
  }
}
