{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://workspace.local/scripts/ids/schemas/lite_evaluator_input.schema.json",
  "title": "LayoutMeta",
  "description": "IDS Phase 0.5 Lite Evaluator 입력 계약. SSOT: target-audience.md §7.4 + mapping-tables.md #5-A. mappingVersion 미일치 시 evaluator 진입 차단.",
  "type": "object",
  "required": [
    "image_path",
    "themePreset",
    "targetPersona",
    "mappingVersion",
    "components",
    "safeArea",
    "grid",
    "canvas"
  ],
  "additionalProperties": false,
  "properties": {
    "image_path": {
      "type": "string",
      "minLength": 1,
      "description": "렌더링된 PNG 절대 경로 (PIL.Image.open 가능)."
    },
    "themePreset": {
      "type": "string",
      "enum": ["theme-fa-fintech", "theme-consumer-warm"],
      "description": "Phase 0 SSOT §7.1 정식 명명. theme-product-modern는 Phase 1 MVP 제외."
    },
    "targetPersona": {
      "type": "string",
      "enum": ["insurance-fa", "consumer", "hybrid"],
      "description": "보험 FA(insurance-fa) / 일반 소비자(consumer) / 양립(hybrid). 영문 표준화 SSOT."
    },
    "mappingVersion": {
      "type": "string",
      "pattern": "^v\\d+\\.\\d+$",
      "description": "Phase 0 mapping-tables.md SSOT 버전(v1.0). 미일치 시 SSotMismatchError."
    },
    "components": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["name", "role", "bbox", "fontSize", "fill"],
        "additionalProperties": false,
        "properties": {
          "name": {"type": "string", "minLength": 1},
          "role": {
            "type": "string",
            "enum": [
              "headline",
              "subhead",
              "body",
              "caption",
              "cta",
              "disclaimer",
              "logo",
              "icon",
              "decoration"
            ],
            "description": "역할 분류. dq-rules font_sizes 키와 1:1 매핑(headline/subhead/body/cta/disclaimer)."
          },
          "bbox": {
            "type": "array",
            "items": {"type": "number", "minimum": 0},
            "minItems": 4,
            "maxItems": 4,
            "description": "[x, y, w, h] 픽셀 좌표."
          },
          "fontSize": {"type": "number", "minimum": 0},
          "fill": {
            "type": "string",
            "pattern": "^#[0-9A-Fa-f]{6}$",
            "description": "텍스트 색상 hex(#RRGGBB)."
          },
          "fontFamily": {"type": "string"},
          "fontWeight": {"type": "integer", "minimum": 100, "maximum": 900},
          "letterSpacing": {"type": "number"},
          "lineHeight": {"type": "number", "minimum": 0},
          "isText": {"type": "boolean", "default": true}
        }
      }
    },
    "safeArea": {
      "type": "object",
      "required": ["top", "bottom", "left", "right"],
      "additionalProperties": false,
      "properties": {
        "top": {
          "type": "number",
          "minimum": 0,
          "description": "SSOT §7.3: 1080px 캔버스 → 72px(6.7%)."
        },
        "bottom": {"type": "number", "minimum": 0},
        "left":   {"type": "number", "minimum": 0},
        "right":  {"type": "number", "minimum": 0}
      }
    },
    "grid": {
      "type": "object",
      "required": ["baseline"],
      "additionalProperties": false,
      "properties": {
        "baseline": {
          "type": "integer",
          "enum": [4, 8],
          "description": "SSOT §7.3: 8px 표준. 4px는 sub-grid 화이트리스트(icon optical alignment 등)."
        },
        "columns": {"type": "integer", "minimum": 1},
        "gutter":  {"type": "integer", "minimum": 0}
      }
    },
    "background": {
      "type": "object",
      "required": ["type"],
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": "string",
          "enum": ["solid", "gradient", "photo"]
        },
        "data": {
          "description": "type=solid: hex 색. type=gradient: stops 배열. type=photo: 자유.",
          "oneOf": [
            {"type": "string"},
            {"type": "array"},
            {"type": "object"},
            {"type": "null"}
          ]
        }
      }
    },
    "canvas": {
      "type": "object",
      "required": ["width", "height"],
      "additionalProperties": false,
      "properties": {
        "width":  {"type": "integer", "minimum": 1},
        "height": {"type": "integer", "minimum": 1}
      }
    }
  }
}
