{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://vclaw.dev/schemas/video/artifacts/reference-sheets.schema.json",
  "title": "ReferenceSheetsArtifact",
  "type": "object",
  "required": ["schemaVersion", "sheets"],
  "additionalProperties": false,
  "properties": {
    "schemaVersion": { "const": 1 },
    "sheets": {
      "type": "array",
      "items": { "$ref": "#/definitions/ReferenceSheet" }
    }
  },
  "definitions": {
    "ReferenceSheet": {
      "type": "object",
      "required": ["id", "type", "name", "references", "bindings", "createdAt", "updatedAt"],
      "additionalProperties": false,
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "type": { "enum": ["identity", "outfit-material", "environment", "motion-camera", "palette-mood"] },
        "name": { "type": "string", "minLength": 1 },
        "description": { "type": "string" },
        "characterName": { "type": "string" },
        "references": {
          "type": "array",
          "items": { "$ref": "#/definitions/ReferenceEntry" }
        },
        "bindings": {
          "type": "object",
          "required": ["sceneIndices"],
          "additionalProperties": false,
          "properties": {
            "sceneIndices": { "type": "array", "items": { "type": "integer", "minimum": 0 } }
          }
        },
        "createdAt": { "type": "string", "format": "date-time" },
        "updatedAt": { "type": "string", "format": "date-time" }
      }
    },
    "ReferenceRole": {
      "enum": [
        "identity", "wardrobe", "silhouette", "age-reference",
        "outfit", "material", "accessory", "texture",
        "product-hero", "product-variant", "product-in-use", "packaging",
        "location", "set-dressing", "weather", "time-of-day",
        "motion-rhythm", "camera-behavior", "blocking", "shot-framing",
        "palette", "composition", "mood", "lighting-reference"
      ]
    },
    "ReferenceEntry": {
      "oneOf": [
        {
          "type": "object",
          "required": ["path", "role"],
          "additionalProperties": false,
          "properties": {
            "path": { "type": "string", "minLength": 1 },
            "role": { "$ref": "#/definitions/ReferenceRole" },
            "note": { "type": "string" }
          }
        },
        {
          "type": "object",
          "required": ["gbRef", "role"],
          "additionalProperties": false,
          "properties": {
            "gbRef": {
              "type": "object",
              "required": ["kind", "id"],
              "additionalProperties": false,
              "properties": {
                "kind": { "enum": ["character", "product", "scene", "style-preset", "reference-group"] },
                "id": { "type": "integer", "minimum": 1 }
              }
            },
            "role": { "$ref": "#/definitions/ReferenceRole" },
            "note": { "type": "string" }
          }
        }
      ]
    }
  }
}
