{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://taste-hq.vercel.app/schema/brand-style-v2.json",
  "title": "tasteHQ Brand Style Schema v2.0",
  "description": "Schema for a single brand-style entry. v2 adds an optional `grammar` block — 30 atomic taste axes that make brands comparable, composable, and machine-reasonable. v2 is additive over v1; entries without a `grammar` block remain fully valid.",
  "type": "object",
  "required": ["name", "signature_move"],
  "properties": {
    "name": {
      "type": "string",
      "description": "Display name of the brand"
    },
    "slug": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]*$",
      "description": "URL-safe identifier"
    },
    "source": { "type": "string", "format": "uri" },
    "refero_id": { "type": ["string", "null"] },
    "official_url": { "type": ["string", "null"], "format": "uri" },
    "docs_url": { "type": ["string", "null"], "format": "uri" },
    "tier": {
      "enum": ["reference", "verified", "community", "unrated"],
      "description": "Curation tier — reference is hand-crafted Golden Set, verified is pipeline-extracted + validated, community is legacy, unrated is awaiting review"
    },
    "provenance": {
      "enum": ["hand-crafted", "pipeline-v1", "pipeline-v2", "imported", "composed"],
      "description": "How the entry was produced. `composed` marks a hybrid generated via /api/compose."
    },
    "generated_at": { "type": "string", "format": "date" },
    "theme": { "enum": ["light", "dark", "mixed"] },
    "era": {
      "type": "array",
      "items": { "type": "string", "minLength": 6 },
      "minItems": 1,
      "description": "Specific movements/decades/designers/publications — NOT generic adjectives like 'minimalist'. Each tag must name a real lineage."
    },
    "mood": {
      "type": "array",
      "items": {
        "enum": [
          "editorial", "scholarly", "technical", "playful", "restrained",
          "industrial", "organic", "futurist", "polished", "corporate",
          "intimate", "theatrical", "raw", "exuberant", "brutalist", "retro",
          "monochrome", "vibrant"
        ]
      },
      "minItems": 1,
      "maxItems": 5
    },
    "density": { "enum": ["low", "medium", "high"] },
    "signature_move": {
      "type": "string",
      "minLength": 30,
      "maxLength": 200,
      "description": "The single most-recognizable design decision in ≤200 chars. Pull-quote test: would this stand alone as a designer's quote about this brand?"
    },
    "voice": {
      "type": "object",
      "properties": {
        "persona": { "type": "string", "description": "Occupational noun-phrase, e.g. 'research librarian'" },
        "active_voice_pct": { "type": "number", "minimum": 0, "maximum": 100 },
        "avg_sentence_words": { "type": "number", "minimum": 0 },
        "uses_second_person": { "type": "boolean" },
        "google_rubric_score": { "type": "number", "minimum": 0, "maximum": 100 },
        "google_rubric_version": { "type": "string" }
      }
    },

    "grammar": {
      "$ref": "#/$defs/grammar",
      "description": "Optional 30-axis taste grammar (v2). See docs/GRAMMAR.md for axis specifications and judging rubrics."
    }
  },
  "additionalProperties": true,
  "$defs": {
    "grammar": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "surface": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "ground":     { "enum": ["white", "cream", "gray-light", "gray-dark", "black", "warm-tinted", "cool-tinted"] },
            "radius":     { "enum": ["0px", "4-6px", "8-10px", "12-16px", "pill"] },
            "borders":    { "enum": ["none", "hairline", "medium", "heavy"] },
            "shadows":    { "enum": ["none", "subtle", "layered", "dramatic"] },
            "texture":    { "enum": ["flat", "grain", "gradient", "mesh", "photo"] },
            "dark_mode":  { "enum": ["none", "inversion", "custom-palette", "dark-first"] }
          }
        },
        "palette": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "strategy":   { "enum": ["mono", "mono+1", "duotone", "triadic", "full-spectrum"] },
            "saturation": { "enum": ["desaturated", "muted", "balanced", "vivid", "neon"] },
            "warmth":     { "enum": ["cool", "neutral", "warm", "mixed"] },
            "accent_use": { "enum": ["rare-signal", "recurring", "pervasive"] },
            "contrast":   { "enum": ["low", "medium", "high", "extreme"] }
          }
        },
        "type": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "pairing":        { "enum": ["serif/sans", "sans/sans", "sans/mono", "serif/grotesque", "grotesque/mono", "single-family"] },
            "heading_weight": { "enum": ["ultralight", "light", "regular", "medium", "bold", "black"] },
            "body_size":      { "enum": ["small", "regular", "large"] },
            "display_scale":  { "enum": ["compact", "balanced", "oversized"] },
            "tracking":       { "enum": ["negative", "tight", "normal", "loose"] }
          }
        },
        "emphasis": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "mechanism":       { "enum": ["weight", "color", "underline", "scale", "spacing"] },
            "cta_treatment":   { "enum": ["filled-solid", "filled-gradient", "outlined", "text-link", "underline-only"] },
            "density_signals": { "enum": ["dividers", "whitespace", "borders", "grouping-cards"] }
          }
        },
        "whitespace": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "discipline":  { "enum": ["dense", "medium", "generous", "extreme"] },
            "section_gap": { "enum": ["compact", "balanced", "grand"] },
            "element_gap": { "enum": ["tight", "medium", "airy"] }
          }
        },
        "voice": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "archetype":       { "enum": ["librarian", "engineer", "artist", "friend", "concierge", "curator", "challenger"] },
            "formality":       { "enum": ["casual", "conversational", "professional", "formal"] },
            "hedging":         { "enum": ["none", "low", "medium", "high"] },
            "sentence_length": { "enum": ["terse", "balanced", "flowing"] }
          }
        },
        "motion": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "budget":    { "enum": ["none", "accent", "recurring", "pervasive"] },
            "character": { "enum": ["mechanical", "smooth", "playful", "cinematic"] },
            "trigger":   { "enum": ["hover-only", "scroll", "autonomous", "gesture"] }
          }
        },
        "imagery": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "strategy": { "enum": ["none", "photographic", "illustration", "abstract", "mixed"] }
          }
        }
      }
    }
  }
}
