<?php
Kirki::add_section( 'book_review_blog_theme_header_section', array(
    'title'          => esc_html__( 'Header Settings', 'book-review-blog' ),
    'panel'          => 'book_review_blog_global_panel',
    'priority'      => 10,
) );


Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'number',
    'settings'    => 'header_height',
    'label'       => __( 'Header Height', 'book-review-blog' ),
    'section'     => 'book_review_blog_theme_header_section',
    'default'     => 200,
    'transport'   => 'auto',
    'priority'    => 2,
    'output'      => [
        [
            'element'  => '.site-header.header-one .logo-section',
            'property' => 'height',
            'units'    => 'px', // Ensure valid CSS unit
        ],
    ],
] );


Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'select',
    'settings'    => 'header_align_items',
    'label'       => __( 'Header Content Alignment', 'book-review-blog' ),
    'section'     => 'book_review_blog_theme_header_section',
    'default'     => 'center',
    'transport'   => 'auto',
    'priority'    => 3, // Place after header_height
    'choices'     => [
        'flex-start' => __( 'Top', 'book-review-blog' ),
        'center'     => __( 'Center', 'book-review-blog' ),
        'flex-end'   => __( 'Bottom', 'book-review-blog' ),
    ],
    'output'      => [
        [
            'element'  => '.site-header.header-one .logo-section',
            'property' => 'align-items',
        ],
    ],
] );


Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'color',
    'settings'    => 'header_bg_color',
    'label'       => __( 'Background Color', 'book-review-blog' ),
    'section'     => 'book_review_blog_theme_header_section',
    'default'     => '#ffffff',
    'transport'   => 'auto',
    'priority'  => 3,
    'output' => array(
        array(
            'element'  => 'header.site-header.header-one',
            'property' => 'background-color',
        ),
    ),
] );


Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'typography',
    'settings'    => 'header_title_typography',
    'label'       => esc_html__( 'Site Title Typography', 'book-review-blog' ),
    'section'     => 'title_tagline',
    'priority'     => 80,
    'default'     => [
        'font-family'    => 'Roboto',
        'variant'        => 'bold',
        'font-size'      => '3.125',
        'line-height'    => '1.6',
        'letter-spacing' => '0px',
        'text-transform' => 'none',
    ],
    'transport'   => 'auto',
    'output'      => [
        [
            'element' => '.site-header .site-branding .site-title',
        ],
    ],
] );


Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'color',
    'settings'    => 'header_title_color',
    'label'       => __( 'Font Color', 'book-review-blog' ),
    'section'     => 'title_tagline',
    'transport'   => 'auto',
    'default'     => '#222222',
    'priority'     => 81,
    'output' => array(
        array(
            'element'  => '.site-header .site-branding.header-logo .site-title a',
            'property' => 'color',
        ),
    ),
] );


Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'typography',
    'settings'    => 'header_desc_typography',
    'label'       => esc_html__( 'Site Description Typography', 'book-review-blog' ),
    'section'     => 'title_tagline',
    'priority'     => 85,
    'default'     => [
        'font-family'    => 'Roboto',
        'variant'        => 'regular',
        'font-size'      => '1rem',
        'line-height'    => '1.4',
        'letter-spacing' => '0px',
        'color'          => '#222222',
        'text-transform' => 'none',
    ],
    'transport'   => 'auto',
    'output'      => [
        [
            'element' => '.site-branding p.site-description',
        ],
    ],
] );

Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'typography',
    'settings'    => 'header_menu_typography',
    'label'       => esc_html__( 'Menu Typography', 'book-review-blog' ),
    'section'     => 'book_review_blog_theme_header_section',
    'default'     => [
        'font-family'    => 'Roboto',
        'variant'        => 'regular',
        'font-size'      => '1rem',
        'line-height'    => '1.6',
        'letter-spacing' => '0px',
        'color'          => '#222222',
        'text-transform' => 'none',
    ],
    'transport'   => 'auto',
    'priority'  => 8,
    'output'      => [
        [
            'element' => '#cssmenu>ul>li>a',
        ],
    ],
] );

Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'color',
    'settings'    => 'header_icon_color',
    'label'       => esc_html__( 'Icon Color', 'book-review-blog' ),
    'section'     => 'book_review_blog_theme_header_section',
    'default'     => '#222222',
    'transport'   => 'auto',
    'priority'      => 12,
    'output'      => [
        [
            'element' => '.social-links-wrapper.header-social-links a',
        ],
    ],
] );


/**
 * Pro Settings
 */
Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'select',
    'settings'    => 'header_container_size',
    'label'       => esc_html__( 'Header Area Container Size', 'book-review-blog' ),
    'section'     => 'book_review_blog_theme_header_section',
    'default'     => 'container',
    'priority'  => 1,
    'choices'   => [
        'container' => __('Container', 'book-review-blog'),
        'container-fluid' => __('Container Full Width', 'book-review-blog'),
        'container-custom-size' => __('Container Custom Size', 'book-review-blog'),
    ]
] );

Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'number',
    'settings'    => 'header_container_custom_size',
    'label'       => esc_html__( 'Header Container Custom Size px', 'book-review-blog' ),
    'section'     => 'book_review_blog_theme_header_section',
    'default'     => '1170',
    'priority'  => 1,
    'transport' => 'postMessage',
    'active_callback'   => function(){
        $containerSize = get_theme_mod('header_container_size', 'container');
        if ('container-custom-size' == $containerSize) {
            return true;
        }
        return false;
    }
] );

Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'toggle',
    'settings'    => 'show_social_icon',
    'label'       => esc_html__( 'Show Social Icons', 'book-review-blog' ),
    'section'     => 'book_review_blog_theme_header_section',
    'default'     => '1',
    'priority'  => 2
] );

Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'color',
    'settings'    => 'header_bg_overlay_color',
    'label'       => __( 'Header Overly Color', 'book-review-blog' ),
    'section'     => 'book_review_blog_theme_header_section',
    'transport'   => 'auto',
    'priority'    => 4,
    'choices'     => [
            'alpha' => true,
        ],
    'output' => array(
        array(
            'element'  => '.header_overlay_color',
            'property' => 'background',
        ),
    ),
    'active_callback' => function(){
        $headerImg = get_header_image();
        if (!empty($headerImg)) {
            return true;
        }
        return false;
    }
] );

Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'multicolor',
    'settings'    => 'header_border_color',
    'label'       => __( 'Header Border Color', 'book-review-blog' ),
    'section'     => 'book_review_blog_theme_header_section',
    'transport'   => 'auto',
    'priority'    => 4,
    'choices'     => [
        'top'    => esc_html__( 'Top Border', 'book-review-blog' ),
        'bottom' => esc_html__( 'Bottom Border', 'book-review-blog' ),
    ],
    'default'     => [
        'top'    => '#f1f1f1',
        'bottom' => '#f1f1f1',
    ],
    'output'      => [
        [
            'choice'   => 'top',
            'element'  => '.menu-section',
            'property' => 'border-top-color',
        ],
        [
            'choice'   => 'bottom',
            'element'  => '.menu-section',
            'property' => 'border-bottom-color',
        ],
    ],
] );

Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'color',
    'settings'    => 'header_menu_hover_color',
    'label'       => __( 'Menu Hover Color', 'book-review-blog' ),
    'section'     => 'book_review_blog_theme_header_section',
    'default'     => '#34568B',
    'transport'   => 'auto',
    'priority'      => 9,
    'output' => array(
        array(
            'element'  => '#cssmenu>ul>li:hover>a',
            'property' => 'color',
        ),
    ),

] );

Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'color',
    'settings'    => 'header_sub_menu_hover_color',
    'label'       => __( 'Sub Menu Hover Color', 'book-review-blog' ),
    'section'     => 'book_review_blog_theme_header_section',
    'default'     => '#34568B',
    'transport'   => 'auto',
    'priority'    => 10,
    'output' => array(
        array(
            'element'  => '#cssmenu ul ul li:hover>a, #cssmenu ul ul li a:hover',
            'property' => 'color',
        ),
    ),
] );

Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'typography',
    'settings'    => 'header_social_icons_style',
    'label'       => esc_html__( 'Social Icons Styles', 'book-review-blog' ),
    'section'     => 'book_review_blog_theme_header_section',
    'default'     =>  '1',
    'transport'   => 'auto',
    'priority'    => 11,
    'default'     => [
        'font-size'      => '1rem',
    ],
    'output'      => [
        [
            'element' => '.social-links-wrapper.header-social-links a',
        ],
    ],
] );

Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'color',
    'settings'    => 'header_icon_hover_color',
    'label'       => __( 'Header Icon Hover Color', 'book-review-blog' ),
    'section'     => 'book_review_blog_theme_header_section',
    'default'     => '#34568B',
    'transport'   => 'auto',
    'priority'    => 13,
    'output' => array(
        array(
            'element'  => '.social-links-wrapper.header-social-links a:hover',
            'property' => 'color',
        ),
    ),
] );

Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'typography',
    'settings'    => 'mobile_menu_icon_typography',
    'label'       => esc_html__( 'Mobile Menu Icon', 'book-review-blog' ),
    'section'     => 'book_review_blog_theme_header_section',
    'priority'    => 14,
    'default'     => [
        'font-size'      => '1.2rem',
        'color'          => '#222222',
    ],
    'transport'   => 'auto',
    'output'      => [
        [
            'element' => '#cssmenu.small-screen #menu-button',
        ],
    ],
] );

Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'color',
    'settings'    => 'mobile_menu_icon_hover_color',
    'label'       => __( 'Mobile Menu Icon Hover', 'book-review-blog' ),
    'section'     => 'book_review_blog_theme_header_section',
    'default'     => '#34568B',
    'priority'    => 15,
    'transport'   => 'auto',
    'output' => array(
        array(
            'element'  => '#cssmenu.small-screen #menu-button:hover',
            'property' => 'color',
        ),
    ),
] );

Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'color',
    'settings'    => 'mobile_menu_item_hover_color',
    'label'       => __( 'Mobile Menu Items Border Color', 'book-review-blog' ),
    'section'     => 'book_review_blog_theme_header_section',
    'default'     => '#34568B',
    'priority'    => 15,
    'transport'   => 'auto',
    'output' => array(
        array(
            'element'  => '#cssmenu.small-screen ul li, #cssmenu.small-screen ul.menu, #cssmenu.small-screen ul ul li:first-child, #cssmenu.small-screen ul ul li',
            'property' => 'border-color',
        ),
        array(
            'element'  => '#cssmenu.small-screen #menu-button:focus',
            'property' => 'outline-color',
        ),
    ),
] );