<?php
/**
 * Dynamic CSS - Backwards Compatibility Wrapper
 *
 * @package Brandy
 * @deprecated Use Brandy\DynamicCss\DynamicCssOrchestrator directly
 */

namespace Brandy;

use Brandy\DynamicCss\DynamicCssOrchestrator;
use Brandy\Traits\SingletonTrait;

/**
 * Dynamic CSS generation class
 *
 * This class now delegates to DynamicCssOrchestrator for all functionality.
 * Maintained for backwards compatibility with existing code.
 *
 * @deprecated Use DynamicCssOrchestrator directly for new code
 */
class DynamicCss {

	use SingletonTrait;

	/**
	 * Orchestrator instance
	 *
	 * @var DynamicCssOrchestrator
	 */
	private DynamicCssOrchestrator $orchestrator;

	/**
	 * Constructor
	 */
	protected function __construct() {
		$this->orchestrator = new DynamicCssOrchestrator();
		add_action( 'wp_print_scripts', [ $this, 'wp_print_scripts' ] );
	}

	/**
	 * Print dynamic styles and scripts
	 *
	 * @return void
	 */
	public function wp_print_scripts(): void {
		$this->orchestrator->wp_print_scripts();
	}

	/**
	 * Process printing builder dynamic styles
	 *
	 * @return void
	 */
	public function print_dynamic_css(): void {
		$this->orchestrator->print_dynamic_css();
	}

	/**
	 * Render element variables CSS
	 *
	 * @param array $input_data        Element configuration.
	 * @param array $components        Component definitions.
	 * @param array $available_devices Devices to generate CSS for.
	 * @return void
	 */
	public function render_element_variables( array $input_data, array $components, array $available_devices = [ 'desktop', 'tablet', 'mobile' ] ): void {
		$this->orchestrator->render_element_variables( $input_data, $components, $available_devices );
	}

	/**
	 * Get CSS variables based on variable type
	 *
	 * @param array  $variable_data Variable configuration.
	 * @param string $type          Variable type.
	 * @return array Device-keyed CSS variables
	 */
	public function get_variables( array $variable_data, string $type = '' ): array {
		return $this->orchestrator->get_variables( $variable_data, $type );
	}

	/**
	 * Wrap CSS in tablet media query
	 *
	 * @param string $css CSS content to wrap.
	 * @return string CSS wrapped in tablet media query
	 */
	public static function wrap_tablet_responsive( string $css ): string {
		return '@media screen and (min-width: ' . ( BRANDY_MOBILE_MAX_WIDTH + 1 ) . 'px) and (max-width: ' . BRANDY_TABLET_MAX_WIDTH . 'px) {' . $css . '}';
	}

	/**
	 * Wrap CSS in mobile media query
	 *
	 * @param string $css CSS content to wrap.
	 * @return string CSS wrapped in mobile media query
	 */
	public static function wrap_mobile_responsive( string $css ): string {
		return '@media screen and (max-width: ' . BRANDY_MOBILE_MAX_WIDTH . 'px) {' . $css . '}';
	}
}
