<?php
/**
 * Spacing.
 *
 * @package MadeByAura\Prime\Customizer\Fields\Content
 * @author  MadeByAura.com
 */

namespace MadeByAura\Prime\Customizer\Fields\Content;

use MadeByAura\Prime\Customizer\Modules\Add;
use MadeByAura\Prime\Customizer\Modules\Value;
use MadeByAura\Prime\Helpers\SingletonTrait;

defined( 'ABSPATH' ) || die();

/**
 * Spacing.
 */
class Spacing {
	use SingletonTrait;

	/**
	 * Constructor.
	 */
	protected function __construct() {
		add_action( 'after_setup_theme', [ __CLASS__, 'add_section' ] );
	}

	/**
	 * Add section.
	 */
	public static function add_section() {
		$section  = 'content_spacing';
		$priority = 10;

		// Section.
		Add::section(
			$section,
			[
				'title'    => esc_attr__( 'Spacing', 'aura-prime' ),
				'section'  => 'aura_section_content',
				'priority' => 0,
			],
		);

		// Gap - SM.
		$id       = 'gap_sm';
		$priority = Add::field(
			$section,
			$id,
			$priority,
			[
				'label'   => esc_attr__( 'Gap - SM', 'aura-prime' ),
				'type'    => 'dimensions',
				'default' => Value::get_default( $section, $id ),
				'choices' => [
					'labels' => [
						'top'    => esc_html__( 'Top', 'aura-prime' ),
						'bottom' => esc_html__( 'Bottom', 'aura-prime' ),
					],
				],
				'output'  => [
					[
						'choice'   => 'top',
						'element'  => ':root',
						'property' => '--aura-g-content-gap-top',
					],
					[
						'choice'   => 'bottom',
						'element'  => ':root',
						'property' => '--aura-g-content-gap-bottom',
					],
				],
			],
		);

		// Gap - MD.
		$id       = 'gap_md';
		$priority = Add::field(
			$section,
			$id,
			$priority,
			[
				'label'   => esc_attr__( 'Gap - MD', 'aura-prime' ),
				'type'    => 'dimensions',
				'default' => Value::get_default( $section, $id ),
				'choices' => [
					'labels' => [
						'top'    => esc_html__( 'Top', 'aura-prime' ),
						'bottom' => esc_html__( 'Bottom', 'aura-prime' ),
					],
				],
				'output'  => [
					[
						'choice'      => 'top',
						'media_query' => '@media (min-width: 768px)',
						'element'     => ':root',
						'property'    => '--aura-g-content-gap-top',
					],
					[
						'choice'      => 'bottom',
						'media_query' => '@media (min-width: 768px)',
						'element'     => ':root',
						'property'    => '--aura-g-content-gap-bottom',
					],
				],
			],
		);

		// Gap - LG.
		$id       = 'gap_lg';
		$priority = Add::field(
			$section,
			$id,
			$priority,
			[
				'label'   => esc_attr__( 'Gap - LG', 'aura-prime' ),
				'type'    => 'dimensions',
				'default' => Value::get_default( $section, $id ),
				'choices' => [
					'labels' => [
						'top'    => esc_html__( 'Top', 'aura-prime' ),
						'bottom' => esc_html__( 'Bottom', 'aura-prime' ),
					],
				],
				'output'  => [
					[
						'choice'      => 'top',
						'media_query' => '@media (min-width: 1024px)',
						'element'     => ':root',
						'property'    => '--aura-g-content-gap-top',
					],
					[
						'choice'      => 'bottom',
						'media_query' => '@media (min-width: 1024px)',
						'element'     => ':root',
						'property'    => '--aura-g-content-gap-bottom',
					],
				],
			],
		);

		// Gap - XL.
		$id       = 'gap_xl';
		$priority = Add::field(
			$section,
			$id,
			$priority,
			[
				'label'   => esc_attr__( 'Gap - XL', 'aura-prime' ),
				'type'    => 'dimensions',
				'default' => Value::get_default( $section, $id ),
				'choices' => [
					'labels' => [
						'top'    => esc_html__( 'Top', 'aura-prime' ),
						'bottom' => esc_html__( 'Bottom', 'aura-prime' ),
					],
				],
				'output'  => [
					[
						'choice'      => 'top',
						'media_query' => '@media (min-width: 1280px)',
						'element'     => ':root',
						'property'    => '--aura-g-content-gap-top',
					],
					[
						'choice'      => 'bottom',
						'media_query' => '@media (min-width: 1280px)',
						'element'     => ':root',
						'property'    => '--aura-g-content-gap-bottom',
					],
				],
			],
		);

		// Gap - 2XL.
		$id       = 'gap_2xl';
		$priority = Add::field(
			$section,
			$id,
			$priority,
			[
				'label'   => esc_attr__( 'Gap - 2XL', 'aura-prime' ),
				'type'    => 'dimensions',
				'default' => Value::get_default( $section, $id ),
				'choices' => [
					'labels' => [
						'top'    => esc_html__( 'Top', 'aura-prime' ),
						'bottom' => esc_html__( 'Bottom', 'aura-prime' ),
					],
				],
				'output'  => [
					[
						'choice'      => 'top',
						'media_query' => '@media (min-width: 1640px)',
						'element'     => ':root',
						'property'    => '--aura-g-content-gap-top',
					],
					[
						'choice'      => 'bottom',
						'media_query' => '@media (min-width: 1640px)',
						'element'     => ':root',
						'property'    => '--aura-g-content-gap-bottom',
					],
				],
			],
		);
	}
}
