{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://decantr.ai/schemas/essence.v3.json",
  "title": "Decantr Essence v3",
  "description": "Design intent specification with DNA/Blueprint/Meta split",
  "type": "object",
  "required": ["version", "dna", "blueprint", "meta"],
  "additionalProperties": false,
  "properties": {
    "$schema": { "type": "string" },
    "version": { "type": "string", "enum": ["3.0.0", "3.1.0"] },
    "dna": { "$ref": "#/$defs/DNA" },
    "blueprint": { "$ref": "#/$defs/Blueprint" },
    "meta": { "$ref": "#/$defs/Meta" },
    "_impression": { "$ref": "#/$defs/Impression" }
  },
  "$defs": {
    "DNA": {
      "type": "object",
      "required": ["theme", "spacing", "typography", "color", "radius", "elevation", "motion", "accessibility", "personality"],
      "additionalProperties": false,
      "properties": {
        "theme": { "$ref": "#/$defs/Theme" },
        "spacing": { "$ref": "#/$defs/Spacing" },
        "typography": { "$ref": "#/$defs/Typography" },
        "color": { "$ref": "#/$defs/Color" },
        "radius": { "$ref": "#/$defs/Radius" },
        "elevation": { "$ref": "#/$defs/Elevation" },
        "motion": { "$ref": "#/$defs/Motion" },
        "accessibility": { "$ref": "#/$defs/AccessibilityV3" },
        "personality": { "type": "array", "items": { "type": "string" }, "minItems": 1 }
      }
    },
    "Theme": {
      "type": "object",
      "required": ["id", "mode"],
      "additionalProperties": false,
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "mode": { "type": "string", "enum": ["light", "dark", "auto"] },
        "shape": { "type": "string", "enum": ["sharp", "rounded", "pill"] }
      }
    },
    "Spacing": {
      "type": "object",
      "required": ["base_unit", "scale", "density", "content_gap"],
      "additionalProperties": false,
      "properties": {
        "base_unit": { "type": "number", "minimum": 1 },
        "scale": { "type": "string", "minLength": 1 },
        "density": { "type": "string", "enum": ["compact", "comfortable", "spacious"] },
        "content_gap": { "type": "string", "minLength": 1 }
      }
    },
    "Typography": {
      "type": "object",
      "required": ["scale", "heading_weight", "body_weight"],
      "additionalProperties": false,
      "properties": {
        "scale": { "type": "string", "minLength": 1 },
        "heading_weight": { "type": "number", "minimum": 100, "maximum": 900 },
        "body_weight": { "type": "number", "minimum": 100, "maximum": 900 }
      }
    },
    "Color": {
      "type": "object",
      "required": ["palette", "accent_count", "cvd_preference"],
      "additionalProperties": false,
      "properties": {
        "palette": { "type": "string", "minLength": 1 },
        "accent_count": { "type": "number", "minimum": 0 },
        "cvd_preference": { "type": "string" }
      }
    },
    "Radius": {
      "type": "object",
      "required": ["philosophy", "base"],
      "additionalProperties": false,
      "properties": {
        "philosophy": { "type": "string", "minLength": 1 },
        "base": { "type": "number", "minimum": 0 }
      }
    },
    "Elevation": {
      "type": "object",
      "required": ["system", "max_levels"],
      "additionalProperties": false,
      "properties": {
        "system": { "type": "string", "minLength": 1 },
        "max_levels": { "type": "number", "minimum": 0 }
      }
    },
    "Motion": {
      "type": "object",
      "required": ["preference", "duration_scale", "reduce_motion"],
      "additionalProperties": false,
      "properties": {
        "preference": { "type": "string", "minLength": 1 },
        "duration_scale": { "type": "number", "minimum": 0 },
        "reduce_motion": { "type": "boolean" }
      }
    },
    "AccessibilityV3": {
      "type": "object",
      "required": ["wcag_level", "focus_visible", "skip_nav"],
      "additionalProperties": false,
      "properties": {
        "wcag_level": { "type": "string", "enum": ["none", "A", "AA", "AAA"] },
        "focus_visible": { "type": "boolean" },
        "skip_nav": { "type": "boolean" }
      }
    },
    "Blueprint": {
      "type": "object",
      "required": ["features"],
      "additionalProperties": false,
      "anyOf": [
        { "required": ["shell", "pages"] },
        { "required": ["sections"] }
      ],
      "properties": {
        "shell": { "type": "string", "minLength": 1 },
        "pages": { "type": "array", "items": { "$ref": "#/$defs/BlueprintPage" }, "minItems": 1 },
        "sections": { "type": "array", "items": { "$ref": "#/$defs/BlueprintSection" }, "minItems": 1 },
        "features": { "type": "array", "items": { "type": "string" } },
        "routes": {
          "type": "object",
          "additionalProperties": { "$ref": "#/$defs/RouteEntry" }
        },
        "icon_style": { "type": "string" },
        "avatar_style": { "type": "string" }
      }
    },
    "BlueprintPage": {
      "type": "object",
      "required": ["id", "layout"],
      "additionalProperties": false,
      "properties": {
        "id": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" },
        "route": { "type": "string", "minLength": 1 },
        "shell_override": { "oneOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }] },
        "layout": { "type": "array", "items": { "$ref": "#/$defs/LayoutItem" }, "minItems": 1 },
        "dna_overrides": { "$ref": "#/$defs/DNAOverrides" },
        "surface": { "type": "string" }
      }
    },
    "BlueprintSection": {
      "type": "object",
      "required": ["id", "role", "shell", "features", "description", "pages"],
      "additionalProperties": false,
      "properties": {
        "id": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" },
        "role": { "type": "string", "enum": ["primary", "gateway", "public", "auxiliary"] },
        "shell": { "type": "string", "minLength": 1 },
        "features": { "type": "array", "items": { "type": "string" } },
        "description": { "type": "string", "minLength": 1 },
        "pages": { "type": "array", "items": { "$ref": "#/$defs/BlueprintPage" }, "minItems": 1 },
        "dna_overrides": { "$ref": "#/$defs/DNAOverrides" }
      }
    },
    "RouteEntry": {
      "type": "object",
      "required": ["section", "page"],
      "additionalProperties": false,
      "properties": {
        "section": { "type": "string", "minLength": 1 },
        "page": { "type": "string", "minLength": 1 }
      }
    },
    "DNAOverrides": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "density": { "type": "string", "enum": ["compact", "comfortable", "spacious"] },
        "mode": { "type": "string", "enum": ["light", "dark", "auto"] }
      }
    },
    "LayoutItem": {
      "oneOf": [
        { "type": "string", "minLength": 1 },
        { "$ref": "#/$defs/PatternRef" },
        { "$ref": "#/$defs/ColumnLayout" }
      ]
    },
    "PatternRef": {
      "type": "object",
      "required": ["pattern"],
      "additionalProperties": false,
      "properties": {
        "pattern": { "type": "string", "minLength": 1 },
        "preset": { "type": "string" },
        "as": { "type": "string" }
      }
    },
    "ColumnLayout": {
      "type": "object",
      "required": ["cols"],
      "additionalProperties": false,
      "properties": {
        "cols": { "type": "array", "items": { "type": "string" }, "minItems": 2 },
        "at": { "type": "string", "enum": ["sm", "md", "lg", "xl", "2xl"] },
        "span": { "type": "object", "additionalProperties": { "type": "number", "minimum": 1 } },
        "breakpoints": { "type": "array", "items": { "type": "object", "required": ["at", "cols"], "properties": { "at": { "type": "string" }, "cols": { "type": "number" } } } },
        "responsive": { "type": "string", "enum": ["viewport", "container"] }
      }
    },
    "Meta": {
      "type": "object",
      "required": ["archetype", "target", "platform", "guard"],
      "additionalProperties": false,
      "properties": {
        "archetype": { "type": "string", "minLength": 1 },
        "target": { "type": "string", "minLength": 1 },
        "platform": { "$ref": "#/$defs/Platform" },
        "guard": { "$ref": "#/$defs/GuardV3" },
        "seo": { "$ref": "#/$defs/SeoHints" },
        "navigation": { "$ref": "#/$defs/NavigationHints" }
      }
    },
    "Platform": {
      "type": "object",
      "required": ["type", "routing"],
      "additionalProperties": false,
      "properties": {
        "type": { "type": "string", "enum": ["spa", "ssr", "static"] },
        "routing": { "type": "string", "enum": ["hash", "history"] }
      }
    },
    "GuardV3": {
      "type": "object",
      "required": ["mode", "dna_enforcement", "blueprint_enforcement"],
      "additionalProperties": false,
      "properties": {
        "mode": { "type": "string", "enum": ["creative", "guided", "strict"] },
        "dna_enforcement": { "type": "string", "enum": ["error", "warn", "off"] },
        "blueprint_enforcement": { "type": "string", "enum": ["warn", "off"] }
      }
    },
    "SeoHints": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "schema_org": { "type": "array", "items": { "type": "string", "minLength": 1 } },
        "meta_priorities": { "type": "array", "items": { "type": "string", "minLength": 1 } }
      }
    },
    "NavigationHints": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "hotkeys": { "type": "array", "items": { "$ref": "#/$defs/NavigationHotkey" } },
        "command_palette": { "type": "boolean" }
      }
    },
    "NavigationHotkey": {
      "type": "object",
      "required": ["key", "label"],
      "additionalProperties": false,
      "properties": {
        "key": { "type": "string", "minLength": 1 },
        "label": { "type": "string", "minLength": 1 },
        "route": { "type": "string", "minLength": 1 },
        "action": { "type": "string", "minLength": 1 }
      }
    },
    "Impression": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "vibe": { "type": "array", "items": { "type": "string" } },
        "references": { "type": "array", "items": { "type": "string" } },
        "density_intent": { "type": "string" },
        "layout_intent": { "type": "string" },
        "novel_elements": { "type": "array", "items": { "type": "string" } }
      }
    }
  }
}
