<?php
/**
 * Recipe Schema Type — guided field definitions.
 *
 * Server-authoritative form metadata. Emission remains gated by readiness.
 *
 * @package SEOvaultSEO\Schema\Types
 */

namespace SEOvaultSEO\Schema\Types;

use SEOvaultSEO\Schema\SchemaBase;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class Recipe extends SchemaBase {

	public function schema_data() {
		return array(
			'title'   => 'Recipe',
			'type'    => 'Recipe',
			'show_on' => array(
				'rules'        => array( 'post|post' ),
				'specific'     => array(),
				'specificText' => array(),
			),
			'fields'  => $this->parse_fields( $this->get() ),
		);
	}

	public function get() {
		return apply_filters(
			'seovaultseo_schema_type_recipe',
			array(
				array(
					'id'      => 'schema_name',
					'label'   => __( 'Schema Title', 'seovault-ai' ),
					'show'    => true,
					'default' => true,
					'type'    => 'Title',
					'std'     => 'Recipe',
				),
				array(
					'id'       => '@id',
					'type'     => 'Hidden',
					'std'      => '%current.url%#recipe',
					'required' => true,
					'default'  => true,
					'show'     => true,
				),
				array(
					'id'       => 'name',
					'label'    => __( 'Recipe Name', 'seovault-ai' ),
					'desc'     => __( 'The recipe title as it appears on this page. Do not rely on auto-filled post tokens.', 'seovault-ai' ),
					'required' => true,
					'std'      => '',
					'type'     => 'Text',
					'default'  => true,
					'show'     => true,
				),
				array(
					'id'      => 'description',
					'label'   => __( 'Description', 'seovault-ai' ),
					'desc'    => __( 'Optional short summary of the dish. Leave blank if you do not have a real summary.', 'seovault-ai' ),
					'default' => true,
					'show'    => true,
					'std'     => '',
					'type'    => 'Textarea',
				),
				array(
					'id'       => 'image',
					'label'    => __( 'Image', 'seovault-ai' ),
					'desc'     => __( 'Required. A real photo of the finished dish shown on this page.', 'seovault-ai' ),
					'required' => true,
					'std'      => '',
					'type'     => 'Image',
					'default'  => true,
					'show'     => true,
				),
				array(
					'id'      => 'author',
					'label'   => __( 'Author', 'seovault-ai' ),
					'desc'    => __( 'Optional. Who created the recipe. Recommended for richer results.', 'seovault-ai' ),
					'type'    => 'Group',
					'default' => true,
					'show'    => true,
					'fields'  => array(
						array(
							'id'      => '@type',
							'type'    => 'Hidden',
							'std'     => 'Person',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'      => 'name',
							'label'   => __( 'Author Name', 'seovault-ai' ),
							'desc'    => __( 'Name of the recipe author.', 'seovault-ai' ),
							'std'     => '',
							'type'    => 'Text',
							'default' => true,
							'show'    => true,
						),
					),
				),
				array(
					'id'      => 'prepTime',
					'label'   => __( 'Prep Time', 'seovault-ai' ),
					'desc'    => __( 'Optional ISO-8601 duration (for example PT20M). Leave blank if unknown.', 'seovault-ai' ),
					'default' => true,
					'show'    => true,
					'std'     => '',
					'type'    => 'Text',
				),
				array(
					'id'      => 'cookTime',
					'label'   => __( 'Cook Time', 'seovault-ai' ),
					'desc'    => __( 'Optional ISO-8601 duration (for example PT45M). Leave blank if unknown.', 'seovault-ai' ),
					'default' => true,
					'show'    => true,
					'std'     => '',
					'type'    => 'Text',
				),
				array(
					'id'      => 'totalTime',
					'label'   => __( 'Total Time', 'seovault-ai' ),
					'desc'    => __( 'Optional ISO-8601 duration for prep plus cook time.', 'seovault-ai' ),
					'default' => true,
					'show'    => true,
					'std'     => '',
					'type'    => 'Text',
				),
				array(
					'id'      => 'recipeYield',
					'label'   => __( 'Yield', 'seovault-ai' ),
					'desc'    => __( 'Optional servings or quantity (for example 4 servings).', 'seovault-ai' ),
					'default' => true,
					'show'    => true,
					'std'     => '',
					'type'    => 'Text',
				),
				array(
					'id'      => 'recipeIngredient',
					'label'   => __( 'Ingredients', 'seovault-ai' ),
					'desc'    => __( 'Optional list of real ingredients. One ingredient per line.', 'seovault-ai' ),
					'default' => true,
					'show'    => true,
					'std'     => '',
					'type'    => 'Text',
				),
				array(
					'id'       => 'recipeInstructions',
					'label'    => __( 'Instructions', 'seovault-ai' ),
					'desc'     => __( 'Required. At least one real cooking step. Do not use placeholders.', 'seovault-ai' ),
					'required' => true,
					'default'  => true,
					'show'     => true,
					'std'      => '',
					'type'     => 'Text',
				),
				array(
					'id'      => 'nutrition',
					'label'   => __( 'Nutrition', 'seovault-ai' ),
					'desc'    => __( 'Optional. Only fill in real nutrition facts. Leave blank if unknown — empty nutrition shells are not published.', 'seovault-ai' ),
					'type'    => 'Group',
					// Keep out of factory schema_data() so empty NutritionInformation shells are never shipped by default.
					'default' => false,
					'show'    => true,
					'fields'  => array(
						array(
							'id'      => '@type',
							'type'    => 'Hidden',
							'std'     => 'NutritionInformation',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'      => 'calories',
							'label'   => __( 'Calories', 'seovault-ai' ),
							'desc'    => __( 'Only when you have a real calorie value (for example 250 kcal).', 'seovault-ai' ),
							'std'     => '',
							'type'    => 'Text',
							'default' => true,
							'show'    => true,
						),
					),
				),
			)
		);
	}
}
