<?php
/**
 * Value.
 *
 * @package MadeByAura\Prime\Customizer\Modules
 * @author  MadeByAura.com
 */

namespace MadeByAura\Prime\Customizer\Modules;

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

use MadeByAura\Prime\Modules\Button;

/**
 * Value.
 */
class Value {
	/**
	 * Get default mod.
	 *
	 * @param string $section  Section ID.
	 * @param string $id       Mod ID.
	 * @return mixed $value
	 */
	public static function get( $section, $id ) {
		return get_theme_mod(
			"aura_{$section}_{$id}",
			self::get_default( $section, $id )
		);
	}

	/**
	 * Get default mod.
	 *
	 * @param string $section  Section ID.
	 * @param string $id       Mod ID.
	 * @return mixed $value
	 */
	public static function get_default( $section, $id ) {
		$values = self::get_defaults();

		return $values[ "{$section}_{$id}" ];
	}

	/**
	 * Get default mods.
	 *
	 * @return mixed $values
	 */
	public static function get_defaults() {
		static $values;

		if ( ! $values ) {
			$colors = [
				'title_text'       => '#111',
				'body_text'        => '#333',
				'body_link'        => '#0274be',
				'body_hover'       => '#111',
				'body_light'       => '#999',
				'body_muted'       => '#bbb',
				'body_background'  => '#fff',
				'light_background' => '#f2f2f2',
				'modal_background' => 'rgba(0, 0, 0, 0.9)',
				'border'           => '#ddd',
			];

			/*
			 * Colors.
			 */
			foreach ( $colors as $color_name => $color_value ) {
				$values[ "color_{$color_name}" ] = $color_value;
			}

			/*
			 * Typography.
			 */
			// Body.
			$values['typography_body']['font-family']    = 'Inter';
			$values['typography_body']['variant']        = 'regular';
			$values['typography_body']['font-size']      = '16px';
			$values['typography_body']['line-height']    = '1.6';
			$values['typography_body']['letter-spacing'] = '0px';
			// Headings.
			$values['typography_headings']['font-family'] = 'Inter';
			$values['typography_headings']['variant']     = '700';

			/*
			 * Buttons.
			 */
			foreach ( Button::get_types() as $id => $label ) {
				$values = self::add_button_defaults( "button_$id", $values );
				$values = self::add_button_defaults( "button_$id", $values );
				$values = self::add_button_defaults( "button_$id", $values );
				$values = self::add_button_defaults( "button_$id", $values );
				$values = self::add_button_defaults( "button_$id", $values );
				$values = self::add_button_defaults( "button_$id", $values );
			}

			/*
			 * Forms > Form.
			 */
			$values['form_fieldsets_gap']        = '28px';
			$values['form_fields_gap']['column'] = '12px';
			$values['form_fields_gap']['row']    = '12px';

			/*
			 * Forms > Placeholders.
			 */
			$values['placeholder_color']      = '#bbb';
			$values['placeholder_font_style'] = 'normal';

			/*
			 * Forms > Legend.
			 */
			$values['legend_color'] = '#333';
			// Typography.
			$values['legend_typography']['font-family']    = '';
			$values['legend_typography']['variant']        = 'regular';
			$values['legend_typography']['font-size']      = '20px';
			$values['legend_typography']['line-height']    = '1.2';
			$values['legend_typography']['letter-spacing'] = 'inherit';
			// Gap.
			$values['legend_fields_gap'] = '12px';

			/*
			 * Forms > Description.
			 */
			$values['description_color'] = '#333';
			// Typography.
			$values['description_typography']['font-family']    = '';
			$values['description_typography']['variant']        = 'regular';
			$values['description_typography']['font-size']      = '14px';
			$values['description_typography']['line-height']    = '1.2';
			$values['description_typography']['letter-spacing'] = 'inherit';
			// Gap.
			$values['description_label_gap'] = '2px';

			/*
			 * Forms > Labels.
			 */
			$values['label_color'] = '#333';
			// Typography.
			$values['label_typography']['font-family']    = '';
			$values['label_typography']['variant']        = 'regular';
			$values['label_typography']['font-size']      = '14px';
			$values['label_typography']['line-height']    = '1.2';
			$values['label_typography']['letter-spacing'] = 'inherit';
			// Gap.
			$values['label_field_gap'] = '8px';

			/*
			 * Forms > Fields.
			 */
			// Colors.
			$values['field_color']                  = '#333';
			$values['field_background_color']       = '#fff';
			$values['field_border_color']           = '#ddd';
			$values['field_focus_color']            = '#333';
			$values['field_focus_background_color'] = '#fff';
			$values['field_focus_border_color']     = '#ddd';
			// Typography.
			$values['field_typography']['font-family']    = '';
			$values['field_typography']['variant']        = 'regular';
			$values['field_typography']['font-size']      = 'inherit';
			$values['field_typography']['line-height']    = '1.2';
			$values['field_typography']['letter-spacing'] = 'inherit';
			// Padding.
			$values['field_padding']['top']    = '8px';
			$values['field_padding']['right']  = '12px';
			$values['field_padding']['bottom'] = '8px';
			$values['field_padding']['left']   = '12px';
			// Border width.
			$values['field_border_width']['top']    = '1px';
			$values['field_border_width']['right']  = '1px';
			$values['field_border_width']['bottom'] = '1px';
			$values['field_border_width']['left']   = '1px';
			// Border radius.
			$values['field_border_radius']['top-left']     = '4px';
			$values['field_border_radius']['top-right']    = '4px';
			$values['field_border_radius']['bottom-right'] = '4px';
			$values['field_border_radius']['bottom-left']  = '4px';

			/*
			 * Forms > Checkbox.
			 */
			$values['checkbox_accent_color']        = '#3498db';
			$values['checkbox_size']['width']       = '16px';
			$values['checkbox_size']['offset_y']    = '0.125em';
			$values['checkbox_label_gap']           = '10px';
			$values['checkbox_group_gap']['column'] = '28px';
			$values['checkbox_group_gap']['row']    = '8px';

			/*
			 * Forms > Submit.
			 */
			// Colors.
			$values['submit_color']                  = '#fff';
			$values['submit_background_color']       = '#1ab625';
			$values['submit_border_color']           = '#1ab625';
			$values['submit_hover_color']            = '#fff';
			$values['submit_hover_background_color'] = '#333';
			$values['submit_hover_border_color']     = '#333';
			// Typography.
			$values['submit_typography']['font-family']    = '';
			$values['submit_typography']['variant']        = 'regular';
			$values['submit_typography']['font-size']      = '18px';
			$values['submit_typography']['line-height']    = '1.2';
			$values['submit_typography']['letter-spacing'] = 'inherit';
			// Padding.
			$values['submit_padding']['top']    = '19px';
			$values['submit_padding']['right']  = '30px';
			$values['submit_padding']['bottom'] = '19px';
			$values['submit_padding']['left']   = '30px';
			// Border width.
			$values['submit_border_width']['top']    = '0';
			$values['submit_border_width']['right']  = '0';
			$values['submit_border_width']['bottom'] = '0';
			$values['submit_border_width']['left']   = '0';
			// Border radius.
			$values['submit_border_radius']['top-left']     = '3px';
			$values['submit_border_radius']['top-right']    = '3px';
			$values['submit_border_radius']['bottom-right'] = '3px';
			$values['submit_border_radius']['bottom-left']  = '3px';
			// Icon.
			$values['submit_icon_location'] = 'none';
			// Icon image.
			$values['submit_icon_image'] = '';
			// Icon colors.
			$values['submit_icon_color']       = '#fff';
			$values['submit_icon_hover_color'] = '#fff';
			// Icon size.
			$values['submit_icon_size']['width']  = '15px';
			$values['submit_icon_size']['height'] = '13px';
			// Icon position.
			$values['submit_icon_position']['gap']    = '7px';
			$values['submit_icon_position']['offset'] = '0px';

			/*
			 * Forms > Back button.
			 */
			// Colors.
			$values['form_back_button_color']                  = '#475569';
			$values['form_back_button_background_color']       = '#e2e8f0';
			$values['form_back_button_border_color']           = '#e2e8f0';
			$values['form_back_button_hover_color']            = '#fff';
			$values['form_back_button_hover_background_color'] = '#333';
			$values['form_back_button_hover_border_color']     = '#333';
			// Typography.
			$values['form_back_button_typography']['font-family']    = '';
			$values['form_back_button_typography']['variant']        = 'regular';
			$values['form_back_button_typography']['font-size']      = '18px';
			$values['form_back_button_typography']['line-height']    = '1.2';
			$values['form_back_button_typography']['letter-spacing'] = 'inherit';
			// Padding.
			$values['form_back_button_padding']['top']    = '19px';
			$values['form_back_button_padding']['right']  = '30px';
			$values['form_back_button_padding']['bottom'] = '19px';
			$values['form_back_button_padding']['left']   = '30px';
			// Border width.
			$values['form_back_button_border_width']['top']    = '0';
			$values['form_back_button_border_width']['right']  = '0';
			$values['form_back_button_border_width']['bottom'] = '0';
			$values['form_back_button_border_width']['left']   = '0';
			// Border radius.
			$values['form_back_button_border_radius']['top-left']     = '3px';
			$values['form_back_button_border_radius']['top-right']    = '3px';
			$values['form_back_button_border_radius']['bottom-right'] = '3px';
			$values['form_back_button_border_radius']['bottom-left']  = '3px';
			// Icon.
			$values['form_back_button_icon_location'] = 'none';
			// Icon image.
			$values['form_back_button_icon_image'] = '';
			// Icon colors.
			$values['form_back_button_icon_color']       = '#fff';
			$values['form_back_button_icon_hover_color'] = '#fff';
			// Icon size.
			$values['form_back_button_icon_size']['width']  = '15px';
			$values['form_back_button_icon_size']['height'] = '13px';
			// Icon position.
			$values['form_back_button_icon_position']['gap']    = '7px';
			$values['form_back_button_icon_position']['offset'] = '0px';

			/*
			 * Content > Spacing.
			 */
			// Gap - SM.
			$values['content_spacing_gap_sm']['top']    = '48px';
			$values['content_spacing_gap_sm']['bottom'] = '48px';
			// Gap - MD.
			$values['content_spacing_gap_md']['top']    = '60px';
			$values['content_spacing_gap_md']['bottom'] = '60px';
			// Gap - LG.
			$values['content_spacing_gap_lg']['top']    = '72px';
			$values['content_spacing_gap_lg']['bottom'] = '72px';
			// Gap - XL.
			$values['content_spacing_gap_xl']['top']    = '80px';
			$values['content_spacing_gap_xl']['bottom'] = '80px';
			// Gap - 2XL.
			$values['content_spacing_gap_2xl']['top']    = '96px';
			$values['content_spacing_gap_2xl']['bottom'] = '96px';

			/*
			 * Content > Headings.
			 */
			// H1 to H6.
			foreach ( [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ] as $tag ) {
				$values[ "content_headings_{$tag}" ]['font-size']      = '18px';
				$values[ "content_headings_{$tag}" ]['line-height']    = '1.2';
				$values[ "content_headings_{$tag}" ]['letter-spacing'] = 'inherit';
			}
			// H1.
			$values['content_headings_h1']['font-size'] = '27px';
			// H2.
			$values['content_headings_h2']['font-size'] = '24px';
			// H3.
			$values['content_headings_h3']['font-size'] = '21px';

			/*
			 * Content > Image caption.
			 */
			// Colors.
			$values['content_image_caption_color']            = '#fff';
			$values['content_image_caption_background_color'] = '#000';
			// Typography.
			$values['content_image_caption_typography']['font-family']    = '';
			$values['content_image_caption_typography']['variant']        = 'regular';
			$values['content_image_caption_typography']['font-size']      = '16px';
			$values['content_image_caption_typography']['line-height']    = 'inherit';
			$values['content_image_caption_typography']['letter-spacing'] = 'inherit';
			// Padding.
			$values['content_image_caption_padding']['top']    = '4px';
			$values['content_image_caption_padding']['right']  = '12px';
			$values['content_image_caption_padding']['bottom'] = '4px';
			$values['content_image_caption_padding']['left']   = '12px';

			/*
			 * Content > Links.
			 */
			// Colors.
			$values['content_links_underline'] = true;

			/*
			 * Content > Blockquote.
			 */
			// Colors.
			$values['content_blockquote_color']            = $colors['title_text'];
			$values['content_blockquote_background_color'] = 'rgba(255,255,255,0)';
			$values['content_blockquote_border_color']     = '#0274be';
			// Typography.
			$values['content_blockquote_typography']['font-family'] = '';
			$values['content_blockquote_typography']['variant']     = 'regular';
			$values['content_blockquote_typography']['font-size']   = '18px';
			$values['content_blockquote_typography']['line-height'] = 'inherit';
			// Force italic.
			$values['content_blockquote_force_italic'] = true;
			// Padding.
			$values['content_blockquote_padding']['top']    = '15px';
			$values['content_blockquote_padding']['right']  = '0';
			$values['content_blockquote_padding']['bottom'] = '15px';
			$values['content_blockquote_padding']['left']   = '20px';
			// Border width.
			$values['content_blockquote_border_width']['top']    = '0px';
			$values['content_blockquote_border_width']['right']  = '0px';
			$values['content_blockquote_border_width']['bottom'] = '0px';
			$values['content_blockquote_border_width']['left']   = '2px';
			// Border radius.
			$values['content_blockquote_border_radius']['top-left']     = '0px';
			$values['content_blockquote_border_radius']['top-right']    = '0px';
			$values['content_blockquote_border_radius']['bottom-right'] = '0px';
			$values['content_blockquote_border_radius']['bottom-left']  = '0px';

			/*
			 * Content > Nothing found.
			 */
			// Minimum height.
			$values['nothing_found_min_height'] = '30vh';
			// Title typography.
			$values['nothing_found_title_typography']['font-family']    = '';
			$values['nothing_found_title_typography']['variant']        = 'regular';
			$values['nothing_found_title_typography']['font-size']      = '36px';
			$values['nothing_found_title_typography']['line-height']    = '1.2';
			$values['nothing_found_title_typography']['letter-spacing'] = 'inherit';
			// Description typography.
			$values['nothing_found_description_typography']['font-family']    = '';
			$values['nothing_found_description_typography']['variant']        = 'regular';
			$values['nothing_found_description_typography']['font-size']      = '18px';
			$values['nothing_found_description_typography']['line-height']    = 'inherit';
			$values['nothing_found_description_typography']['letter-spacing'] = 'inherit';

			/*
			 * Sticky header.
			 */
			$values['sticky_header_enabled']          = false;
			$values['sticky_header_resent_selector']  = '.aura-site > .elementor-location-header';
			$values['sticky_header_resent_threshold'] = 0;

			/*
			 * Sticky Footer.
			 */
			$values['sticky_footer_enabled']          = false;
			$values['sticky_footer_resent_selector']  = '.aura-resented-by-sticky-footer';
			$values['sticky_footer_resent_threshold'] = 0;

			/*
			 * Advanced.
			 */
			$values['advanced_acf_menu_item_enabled'] = false;

			$values = apply_filters( 'aura_theme_default_mods', $values );
		}

		return $values;
	}

	/**
	 * Add button defaults.
	 *
	 * @param string $prefix  Prefix.
	 * @param array  $values  Default values.
	 * @return array $values
	 */
	public static function add_button_defaults( $prefix, $values ) {
		// Colors.
		$values[ "{$prefix}_text_color" ]             = '#fff';
		$values[ "{$prefix}_background_color" ]       = '#0274be';
		$values[ "{$prefix}_border_color" ]           = '#0274be';
		$values[ "{$prefix}_hover_color" ]            = '#fff';
		$values[ "{$prefix}_hover_background_color" ] = '#333';
		$values[ "{$prefix}_hover_border_color" ]     = '#333';
		// Typography.
		$values[ "{$prefix}_typography" ]['font-family']    = '';
		$values[ "{$prefix}_typography" ]['variant']        = 'regular';
		$values[ "{$prefix}_typography" ]['font-size']      = '18px';
		$values[ "{$prefix}_typography" ]['line-height']    = '1.2';
		$values[ "{$prefix}_typography" ]['letter-spacing'] = 'inherit';
		// Padding.
		$values[ "{$prefix}_padding" ]['top']    = '19px';
		$values[ "{$prefix}_padding" ]['right']  = '30px';
		$values[ "{$prefix}_padding" ]['bottom'] = '19px';
		$values[ "{$prefix}_padding" ]['left']   = '30px';
		// Border width.
		$values[ "{$prefix}_border_width" ]['top']    = '0px';
		$values[ "{$prefix}_border_width" ]['right']  = '0px';
		$values[ "{$prefix}_border_width" ]['bottom'] = '0px';
		$values[ "{$prefix}_border_width" ]['left']   = '0px';
		// Border radius.
		$values[ "{$prefix}_border_radius" ]['top-left']     = '3px';
		$values[ "{$prefix}_border_radius" ]['top-right']    = '3px';
		$values[ "{$prefix}_border_radius" ]['bottom-right'] = '3px';
		$values[ "{$prefix}_border_radius" ]['bottom-left']  = '3px';
		// Icon.
		$values[ "{$prefix}_icon_location" ] = 'none';
		// Icon image.
		$values[ "{$prefix}_icon_image" ] = '';
		// Icon colors.
		$values[ "{$prefix}_icon_color" ]       = '#fff';
		$values[ "{$prefix}_icon_hover_color" ] = '#fff';
		// Icon size.
		$values[ "{$prefix}_icon_size" ]['width']  = '15px';
		$values[ "{$prefix}_icon_size" ]['height'] = '13px';
		// Icon position.
		$values[ "{$prefix}_icon_position" ]['gap']    = '7px';
		$values[ "{$prefix}_icon_position" ]['offset'] = '0px';

		return $values;
	}
}
