<?php
/**
 * Customizer Typography
 *
 * @package Arendelle
 * @since 1.0.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit( 'Direct script access denied.' );
}

/**
 * Add custom choice
 */
if ( ! function_exists( 'arendelle_add_custom_choice' ) ) {
	function arendelle_add_custom_choice() {
		return array(
			'fonts' => apply_filters( 'arendelle_kirki_font_choices', array() ),
			'variant' => array( 'regular', 'italic', '500', '600', '700' )
		);
	}
}


// Base font
Kirki::add_field( 'arendelle_settings_config', array(
	'type'        => 'typography',
	'settings'    => 'arendelle_settings_base_font',
	'label'       => '<h2 class="customizer-control-title__heading">' . esc_html__( 'Base font', 'arendelle' ) . '</h2>',
	'section'     => 'arendelle_settings_typography',
	'default'     => array(
		'font-family'    => $body_font,
		'font-size'      => '16px',
		'line-height'    => '1.5',
		'letter-spacing' => 'normal',
		'variant' 			 => 'regular',
	),
	'choices'  => arendelle_add_custom_choice(),
	'output' => array(
		array(
			'element' => $selectors['base_font'],
		)
	),
	'transport' => 'auto',
));


// Secondary font
Kirki::add_field( 'arendelle_settings_config', array(
	'type'        => 'typography',
	'settings'    => 'arendelle_settings_secondary_font',
	'label'       => '<hr class="customizer-separator"><h2 class="customizer-control-title__heading">' . esc_html__( 'Secondary font', 'arendelle' ) . '</h2>',
	'section'     => 'arendelle_settings_typography',
	'default'     => array(
		'font-family'   => $heading_font,
		'variant' 	 		=> '500',
	),
	'choices'  => arendelle_add_custom_choice(),
	'output' => array(
		array(
			'element' => $selectors['secondary_font'],
		),
		array(
			'element'  => isset( $selectors['shop_secondary_font'] ) ? $selectors['shop_secondary_font'] : null,
		),
	),
	'transport' => 'auto',
));


/*-------------------------------------------------------*/
/* Headings font
/*-------------------------------------------------------*/

// Headings
Kirki::add_field( 'arendelle_settings_config', array(
	'type'        => 'typography',
	'settings'    => 'arendelle_settings_headings_font',
	'label'       => '<h2 class="customizer-control-title__heading">' . esc_html__( 'Headings font', 'arendelle' ) . '</h2>',
	'section'     => 'arendelle_settings_typography',
	'default'     => array(
		'font-family'    => $heading_font,
		'variant' 	 		=> '500',
		'line-height' 	 => '1.3',
		'letter-spacing' => 'normal',
		'text-transform' => 'none'
	),
	'choices'  => arendelle_add_custom_choice(),
	'output' => array(
		array(
			'element' => $selectors['headings'],
		)
	),
	'transport' => 'auto',
));


// H1
Kirki::add_field( 'arendelle_settings_config', array(
	'type'        => 'typography',
	'settings'    => 'arendelle_settings_headings_h1',
	'label'       => '<hr class="customizer-separator"><h2 class="customizer-control-title__heading">' . esc_html__( 'H1 Headings', 'arendelle' ) . '</h2>',
	'section'     => 'arendelle_settings_typography',
	'default'     => array(
		'font-size'   	 => '42px',
		'text-transform' => 'none'
	),
	'choices'  => arendelle_add_custom_choice(),
	'output' => array(
		array(
			'element' => $selectors['h1'],
		)
	),
	'transport' => 'auto',
));

// H2
Kirki::add_field( 'arendelle_settings_config', array(
	'type'        => 'typography',
	'settings'    => 'arendelle_settings_headings_h2',
	'label'       => '<hr class="customizer-separator"><h2 class="customizer-control-title__heading">' . esc_html__( 'H2 Headings', 'arendelle' ) . '</h2>',
	'section'     => 'arendelle_settings_typography',
	'default'     => array(
		'font-size'   	 => '34px',
		'text-transform' => 'none'
	),
	'choices'  => arendelle_add_custom_choice(),
	'output' => array(
		array(
			'element' => $selectors['h2'],
		)
	),
	'transport' => 'auto',
));

// H3
Kirki::add_field( 'arendelle_settings_config', array(
	'type'        => 'typography',
	'settings'    => 'arendelle_settings_headings_h3',
	'label'       => '<hr class="customizer-separator"><h2 class="customizer-control-title__heading">' . esc_html__( 'H3 Headings', 'arendelle' ) . '</h2>',
	'section'     => 'arendelle_settings_typography',
	'default'     => array(
		'font-size'   	 => '28px',
		'text-transform' => 'none'
	),
	'choices'  => arendelle_add_custom_choice(),
	'output' => array(
		array(
			'element' => $selectors['h3'],
		)
	),
	'transport' => 'auto',
));

// H4
Kirki::add_field( 'arendelle_settings_config', array(
	'type'        => 'typography',
	'settings'    => 'arendelle_settings_headings_h4',
	'label'       => '<hr class="customizer-separator"><h2 class="customizer-control-title__heading">' . esc_html__( 'H4 Headings', 'arendelle' ) . '</h2>',
	'section'     => 'arendelle_settings_typography',
	'default'     => array(
		'font-size'   	 => '24px',
		'text-transform' => 'none'
	),
	'choices'  => arendelle_add_custom_choice(),
	'output' => array(
		array(
			'element' => $selectors['h4'],
		)
	),
	'transport' => 'auto',
));

// H5
Kirki::add_field( 'arendelle_settings_config', array(
	'type'        => 'typography',
	'settings'    => 'arendelle_settings_headings_h5',
	'label'       => '<hr class="customizer-separator"><h2 class="customizer-control-title__heading">' . esc_html__( 'H5 Headings', 'arendelle' ) . '</h2>',
	'section'     => 'arendelle_settings_typography',
	'default'     => array(
		'font-size'   	 => '20px',
		'text-transform' => 'none'
	),
	'choices'  => arendelle_add_custom_choice(),
	'output' => array(
		array(
			'element' => $selectors['h5'],
		)
	),
	'transport' => 'auto',
));

// H6
Kirki::add_field( 'arendelle_settings_config', array(
	'type'        => 'typography',
	'settings'    => 'arendelle_settings_headings_h6',
	'label'       => '<hr class="customizer-separator"><h2 class="customizer-control-title__heading">' . esc_html__( 'H6 Headings', 'arendelle' ) . '</h2>',
	'section'     => 'arendelle_settings_typography',
	'default'     => array(
		'font-size'   	 => '16px',
		'text-transform' => 'none'
	),
	'choices'  => arendelle_add_custom_choice(),
	'output' => array(
		array(
			'element' => 'h6',
		)
	),
	'transport' => 'auto',
));


// Post typography
Kirki::add_field( 'arendelle_settings_config', array(
	'type'        => 'typography',
	'settings'    => 'arendelle_settings_post_typography',
	'label'       => '<hr class="customizer-separator"><h2 class="customizer-control-title__heading">' . esc_html__( 'Post article text', 'arendelle' ) . '</h2>',
	'section'     => 'arendelle_settings_typography',
	'default'     => array(
		'font-size'      => '18px',
		'line-height'    => '1.8',
		'letter-spacing' => 'normal',
	),
	'choices'  => arendelle_add_custom_choice(),
	'output' => array(
		array(
			'element' => '.entry__article, .wp-block-post-content',
		)
	),
	'transport' => 'auto',
));


/*-------------------------------------------------------*/
/* Forms
/*-------------------------------------------------------*/

// Buttons typography
Kirki::add_field( 'arendelle_settings_config', array(
	'type'        => 'typography',
	'settings'    => 'arendelle_settings_buttons_typography',
	'label'       => '<h2 class="customizer-control-title__heading">' . esc_html__( 'Buttons', 'arendelle' ) . '</h2>',
	'section'     => 'arendelle_settings_typography',
	'default'     => array(
		'font-family'    => $heading_font,
		'variant'		 		 => '600',
		'letter-spacing' => 'normal',
		'text-transform' => 'uppercase'
	),
	'choices'  => arendelle_add_custom_choice(),
	'output' => array(
		array(
			'element' => $selectors['buttons'],
		)
	),
	'transport' => 'auto',
));


/*-------------------------------------------------------*/
/* Header
/*-------------------------------------------------------*/

// Menu Links typography
Kirki::add_field( 'arendelle_settings_config', array(
	'type'        => 'typography',
	'settings'    => 'arendelle_settings_menu_links_typography',
	'label'       => '<h2 class="customizer-control-title__heading">' . esc_html__( 'Menu links', 'arendelle' ) . '</h2>',
	'section'     => 'arendelle_settings_typography',
	'default'     => array(
		'font-family'    => $heading_font,
		'variant' 	 		 => '500',
		'font-size'			 => '12px',
		'letter-spacing' => 'normal',
		'text-transform' => 'uppercase'
	),
	'choices'  => arendelle_add_custom_choice(),
	'output' => array(
		array(
			'element' => '.nav__menu > li > a',
		),
	),
	'transport' => 'auto',
));

// Dropdown menu Links typography
Kirki::add_field( 'arendelle_settings_config', array(
	'type'        => 'typography',
	'settings'    => 'arendelle_settings_dropdown_menu_links_typography',
	'label'       => '<hr class="customizer-separator"><h2 class="customizer-control-title__heading">' . esc_html__( 'Dropdown menu links', 'arendelle' ) . '</h2>',
	'section'     => 'arendelle_settings_typography',
	'default'     => array(
		'font-family'    => $heading_font,
		'variant' 			 => '400',
		'font-size'			 => '15px',
		'letter-spacing' => 'normal',
		'text-transform' => 'none'
	),
	'choices'  => arendelle_add_custom_choice(),
	'output' => array(
		array(
			'element' => '.nav__dropdown-menu li a',
		),
	),
	'transport' => 'auto',
));