<?php
/**
 * Style Manager Lab runtime contract catalog.
 *
 * @package Style Manager
 * @license GPL-2.0-or-later
 */

declare ( strict_types = 1 );

namespace Pixelgrade\StyleManager\Lab;

final class ContractCatalog {
	private const DEFAULT_ID = 'active-palette';

	public static function all(): array {
		return [
			[
				'id'               => 'active-palette',
				'label'            => 'Active palette runtime',
				'maturity'         => 'available',
				'visual_behavior'  => '12-grade role rail resolves current surface, accent, and text roles.',
				'consume_today'    => '--sm-current-* CSS variables, .sm-palette-* classes, .sm-variation-* classes',
				'proposed_api'     => '--sm-surface, --sm-text-primary, --sm-accent',
				'pixelgrade_proof' => 'Anima theme semantics',
				'snippet'          => '.component { background: var(--sm-current-bg-color); color: var(--sm-current-fg1-color); }',
			],
			[
				'id'               => 'contextual-palette',
				'label'            => 'Contextual palettes',
				'maturity'         => 'available',
				'visual_behavior'  => 'Source color becomes scoped 12-grade roles with contrast readouts.',
				'consume_today'    => 'style_manager/runtime_palettes filter, data-palette scopes, contextual Lab runtime CSS',
				'proposed_api'     => '--sm-context-surface, --sm-context-accent-safe, contextual palette REST payload',
				'pixelgrade_proof' => 'project/post local color contexts',
				'snippet'          => 'add_filter( \'style_manager/runtime_palettes\', static fn( $palettes ) => $palettes );',
			],
			[
				'id'               => 'color-signal',
				'label'            => 'Color Signal',
				'maturity'         => 'reference',
				'visual_behavior'  => 'None, Low, Medium, and High signal levels shift nested variation relative to parent context.',
				'consume_today'    => 'data-palette, data-palette-variation, data-color-signal, sm-color-signal-*',
				'proposed_api'     => 'block support schema for signal-aware palette inheritance',
				'pixelgrade_proof' => 'Nova Blocks signal behavior',
				'snippet'          => '<section data-palette="1" data-palette-variation="1" data-color-signal="2"></section>',
			],
			[
				'id'               => 'dark-mode',
				'label'            => 'Dark mode parity',
				'maturity'         => 'available',
				'visual_behavior'  => 'The same palette contract resolves through dark variations and is-dark scope.',
				'consume_today'    => '.is-dark, darkVariations, runtime palette CSS',
				'proposed_api'     => '--sm-surface-dark, --sm-text-primary-dark, theme/editor parity helpers',
				'pixelgrade_proof' => 'Anima and editor dark-mode synchronization',
				'snippet'          => '.is-dark .component { background: var(--sm-current-bg-color); }',
			],
			[
				'id'               => 'safe-semantic-roles',
				'label'            => 'Safe semantic roles',
				'maturity'         => 'proposed',
				'visual_behavior'  => 'Minimum grade distance and contrast rescue pick safe adjacent roles for local contexts.',
				'consume_today'    => 'internal prototype direction only',
				'proposed_api'     => '--sm-accent-safe, --sm-text-safe, contrast target metadata',
				'pixelgrade_proof' => 'future contextual palette safety layer',
				'snippet'          => '.cta { color: var(--sm-accent-safe, var(--sm-current-accent-color)); }',
			],
			[
				'id'               => 'wordpress-bridge',
				'label'            => 'WordPress bridge',
				'maturity'         => 'proposed',
				'visual_behavior'  => 'Style Manager roles project into WordPress preset surfaces without exposing palette machinery.',
				'consume_today'    => 'theme-owned bridge code today',
				'proposed_api'     => 'theme.json projection, REST token endpoint, block editor token sync',
				'pixelgrade_proof' => 'Anima theme.json and editor integration direction',
				'snippet'          => '{ "settings": { "color": { "palette": "generated by Style Manager" } } }',
			],
			[
				'id'               => 'ai-tool-export',
				'label'            => 'AI/tool export',
				'maturity'         => 'proposed',
				'visual_behavior'  => 'Portable design-system bundle exposes runtime decisions to agents and design tools.',
				'consume_today'    => 'manual docs and private design-system notes',
				'proposed_api'     => 'SKILL.md, manifest.json, tokens.json, palette/context examples',
				'pixelgrade_proof' => 'future builder SDK and AI design-system bundle',
				'snippet'          => '{ "styleManager": { "tokens": "tokens.json", "contracts": "manifest.json" } }',
			],
		];
	}

	public static function by_id( string $id ): array {
		foreach ( self::all() as $row ) {
			if ( $row['id'] === $id ) {
				return $row;
			}
		}

		return self::by_id( self::DEFAULT_ID );
	}
}
