{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "video.dsl/template-binding/v1alpha1",
  "title": "Template Binding v1alpha1",
  "description": "将 Video DSL 中的 scene 绑定到模板的具体 slot，产出可供渲染的绑定结果。",
  "type": "object",
  "required": ["version", "dslVersion", "templateId", "bindings"],
  "properties": {
    "version": {
      "type": "string",
      "const": "v1alpha1"
    },
    "dslVersion": {
      "type": "string",
      "description": "对应的 Video DSL 版本"
    },
    "templateId": {
      "type": "string",
      "description": "选中的模板 ID"
    },
    "templateName": {
      "type": "string"
    },
    "matchScore": {
      "type": "number",
      "minimum": 0,
      "maximum": 1,
      "description": "模板匹配得分 0-1"
    },
    "matchReason": {
      "type": "string",
      "description": "匹配理由说明"
    },
    "alternatives": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "templateId": { "type": "string" },
          "templateName": { "type": "string" },
          "matchScore": { "type": "number" },
          "matchReason": { "type": "string" }
        }
      },
      "description": "备选模板列表"
    },
    "globalOverrides": {
      "type": "object",
      "description": "模板级全局覆写",
      "properties": {
        "typography": {
          "type": "object",
          "properties": {
            "titleFont": { "type": "string" },
            "bodyFont": { "type": "string" },
            "titleSize": { "type": "integer" },
            "bodySize": { "type": "integer" },
            "primaryColor": { "type": "string" },
            "secondaryColor": { "type": "string" }
          }
        },
        "motionPreset": {
          "type": "string",
          "enum": ["minimal", "smooth", "energetic", "cinematic"],
          "default": "smooth"
        },
        "colorScheme": {
          "type": "array",
          "items": { "type": "string" }
        }
      }
    },
    "bindings": {
      "type": "array",
      "items": { "$ref": "#/definitions/SceneBinding" },
      "minItems": 1
    }
  },
  "definitions": {
    "SceneBinding": {
      "type": "object",
      "required": ["sceneId", "slotId", "compositionId"],
      "properties": {
        "sceneId": {
          "type": "string",
          "description": "对应 DSL scene.id"
        },
        "slotId": {
          "type": "string",
          "description": "模板中的 slot 标识"
        },
        "compositionId": {
          "type": "string",
          "description": "Remotion Composition ID"
        },
        "layoutVariant": {
          "type": "string",
          "description": "该场景在模板中的布局变体"
        },
        "props": {
          "type": "object",
          "description": "传给 Remotion Composition 的场景级 props",
          "additionalProperties": true
        },
        "transitionIn": {
          "type": "object",
          "properties": {
            "type": { "type": "string" },
            "durationFrames": { "type": "integer" }
          }
        },
        "transitionOut": {
          "type": "object",
          "properties": {
            "type": { "type": "string" },
            "durationFrames": { "type": "integer" }
          }
        }
      }
    }
  }
}
