{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://opengastronomy.org/schema/v0.1/beverage.schema.json",
  "title": "OGS Beverage",
  "description": "A beverage entity with type, structural attributes, sensory profile, and provenance.",
  "type": "object",
  "required": ["id", "ogs_version", "name", "type", "sensory_profile"],
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^ogs:[a-z0-9-]+:beverage:[a-z0-9-]+$",
      "description": "OGS identifier in the format ogs:<namespace>:beverage:<id>"
    },
    "ogs_version": {
      "type": "string",
      "const": "0.1.0",
      "description": "OGS specification version"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "description": "Human-readable beverage name"
    },
    "description": {
      "type": "string",
      "description": "Longer description of the beverage"
    },
    "type": {
      "type": "string",
      "enum": ["wine", "beer", "spirit", "cider", "sake", "other"],
      "description": "Broad beverage category"
    },
    "subtype": {
      "type": "string",
      "description": "Specific subtype (e.g., red, white, sparkling, rosé, ipa, stout)"
    },
    "grape_varieties": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Grape varieties used (for wine)"
    },
    "vintage": {
      "type": "integer",
      "description": "Harvest year"
    },
    "region": {
      "type": "string",
      "description": "Production region"
    },
    "appellation": {
      "type": "string",
      "description": "Official appellation or denomination"
    },
    "producer": {
      "type": "string",
      "description": "Producer or winery name"
    },
    "abv": {
      "type": "number",
      "minimum": 0,
      "maximum": 100,
      "description": "Alcohol by volume (percentage)"
    },
    "residual_sugar": {
      "type": "number",
      "minimum": 0,
      "description": "Residual sugar in g/L"
    },
    "sensory_profile": {
      "$ref": "#/$defs/sensory_profile",
      "description": "Complete sensory profile of the beverage"
    },
    "notes": {
      "type": "string",
      "description": "Additional tasting notes or comments"
    },
    "metadata": {
      "$ref": "#/$defs/metadata"
    }
  },
  "additionalProperties": true,
  "$defs": {
    "sensory_profile": {
      "type": "object",
      "properties": {
        "basic_tastes": {
          "$ref": "#/$defs/basic_tastes"
        },
        "structural": {
          "$ref": "#/$defs/structural"
        },
        "aromatics": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/aromatic_entry"
          }
        },
        "texture": {
          "type": "array",
          "items": { "type": "string" }
        },
        "finish_length": {
          "type": "number",
          "minimum": 0,
          "maximum": 10
        },
        "complexity": {
          "type": "number",
          "minimum": 0,
          "maximum": 10
        }
      },
      "additionalProperties": true
    },
    "basic_tastes": {
      "type": "object",
      "properties": {
        "sweet": { "$ref": "#/$defs/intensity_value" },
        "sour": { "$ref": "#/$defs/intensity_value" },
        "salty": { "$ref": "#/$defs/intensity_value" },
        "bitter": { "$ref": "#/$defs/intensity_value" },
        "umami": { "$ref": "#/$defs/intensity_value" }
      },
      "additionalProperties": false
    },
    "structural": {
      "type": "object",
      "properties": {
        "body": { "$ref": "#/$defs/intensity_value" },
        "acidity_perception": { "$ref": "#/$defs/intensity_value" },
        "tannin": { "$ref": "#/$defs/intensity_value" },
        "astringency": { "$ref": "#/$defs/intensity_value" },
        "alcohol_heat": { "$ref": "#/$defs/intensity_value" },
        "effervescence": { "$ref": "#/$defs/intensity_value" }
      },
      "additionalProperties": false
    },
    "intensity_value": {
      "type": "number",
      "minimum": 0,
      "maximum": 10
    },
    "aromatic_entry": {
      "type": "object",
      "required": ["family", "group", "item", "intensity"],
      "properties": {
        "family": {
          "type": "string",
          "enum": [
            "fruit", "floral", "herbal", "spice", "earth", "wood",
            "dairy", "savory", "confection", "vegetal", "marine"
          ]
        },
        "group": { "type": "string" },
        "item": { "type": "string" },
        "qualifier": {
          "type": "string",
          "enum": ["fresh", "dried", "cooked", "candied", "fermented", "zest", "overripe"]
        },
        "intensity": { "$ref": "#/$defs/intensity_value" }
      },
      "additionalProperties": false
    },
    "metadata": {
      "type": "object",
      "properties": {
        "created": { "type": "string", "format": "date-time" },
        "updated": { "type": "string", "format": "date-time" },
        "source": { "type": "string" },
        "license": { "type": "string" }
      },
      "additionalProperties": true
    }
  }
}
