{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://huecodex.com/json/hue-codex-portable-color.schema.json",
  "title": "Hue Codex portable color record schema",
  "description": "Schema for compact single-color Hue Codex handoff records with name, value, type, optional color-space metadata, contrast summary, source, and caveats.",
  "$ref": "#/$defs/portableColorRecord",
  "$defs": {
    "portableColorRecord": {
      "type": "object",
      "required": ["name", "value", "type"],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "value": { "$ref": "#/$defs/colorValue" },
        "type": {
          "type": "string",
          "minLength": 1,
          "examples": ["color"]
        },
        "space": {
          "type": "string",
          "minLength": 1,
          "examples": ["srgb", "oklch", "display-p3"]
        },
        "contrast": { "$ref": "#/$defs/contrastSummary" },
        "source": {
          "type": "string",
          "minLength": 1
        },
        "caveats": {
          "type": "array",
          "items": { "type": "string" }
        }
      },
      "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)"]
    },
    "contrastSummary": {
      "type": "object",
      "description": "Displayed and raw contrast values when a Hue Codex export includes contrast context.",
      "properties": {
        "ratio": { "type": "number" },
        "rawRatio": { "type": "number" },
        "againstWhite": { "type": "number" },
        "againstWhiteRaw": { "type": "number" },
        "againstBlack": { "type": "number" },
        "againstBlackRaw": { "type": "number" },
        "badge": { "type": "string" },
        "summary": { "type": "string" },
        "aaNormalText": { "type": "boolean" },
        "normalAA": { "type": "boolean" },
        "normalAAA": { "type": "boolean" },
        "largeAA": { "type": "boolean" },
        "largeAAA": { "type": "boolean" },
        "uiAA": { "type": "boolean" },
        "uiComponent": { "type": "boolean" }
      },
      "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" }
        }
      ]
    }
  }
}
