<?php
Kirki::add_section( 'page_settings_section', array(
    'title'          => esc_html__( 'Page Settings', 'book-review-blog' ),
    'panel'          => 'book_review_blog_global_panel',
    'capability'     => 'edit_theme_options',
    'priority'      => 20,
) );

Kirki::add_field( 'book_review_blog_config', [
    'type'     => 'toggle',
    'settings' => 'show_page_featured_image',
    'label'    => esc_html__( 'Show Page Featured Image', 'book-review-blog' ),
    'section'  => 'page_settings_section',
    'default'   => '1',
    'choices' => [
        'on'  => esc_html__( 'Show', 'book-review-blog' ),
        'off' => esc_html__( 'Hide', 'book-review-blog' )
    ]
] );

Kirki::add_field( 'book_review_blog_config', array(
    'type'        => 'custom',
    'settings'    => 'separator_before_page_banner_settings',
    'label'       => '',
    'section'     => 'page_settings_section',
    'default'     => '<div class="settings-separator">'.esc_html__('Page Banner Settings', 'book-review-blog').'</div>',
) );

Kirki::add_field( 'book_review_blog_config', [
    'type'     => 'toggle',
    'settings' => 'show_page_banner_on_archive_pages',
    'label'    => esc_html__( 'Show On Archive Pages', 'book-review-blog' ),
    'section'  => 'page_settings_section',
    'default'   => '1',
    'choices' => [
        'on'  => esc_html__( 'Show', 'book-review-blog' ),
        'off' => esc_html__( 'Hide', 'book-review-blog' )
    ]
] );

Kirki::add_field( 'book_review_blog_config', [
    'type'     => 'toggle',
    'settings' => 'show_page_banner_on_pages',
    'label'    => esc_html__( 'Show On Pages', 'book-review-blog' ),
    'section'  => 'page_settings_section',
    'default'   => '1',
    'choices' => [
        'on'  => esc_html__( 'Show', 'book-review-blog' ),
        'off' => esc_html__( 'Hide', 'book-review-blog' )
    ]
] );

Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'number',
    'settings'    => 'page_banner_custom_height',
    'label'       => esc_html__( 'Page Banner Height', 'book-review-blog' ),
    'section'     => 'page_settings_section',
    'default'     => '100',
    'transport' => 'postMessage',
    'active_callback'   => function(){
        $showPageHeader = get_theme_mod('show_page_header', true);
        if (true == $showPageHeader) {
            return true;
        }
        return false;
    }
] );

Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'background',
    'settings'    => 'page_banner_background',
    'label'       => esc_html__( 'Page Banner Background', 'book-review-blog' ),
    'section'     => 'page_settings_section',
    'default'     => [
        'background-color'      => '#ffffff',
        'background-image'      => '',
        'background-repeat'     => 'repeat',
        'background-position'   => 'center center',
        'background-size'       => 'cover',
        'background-attachment' => 'scroll',
    ],
    'transport'   => 'auto',
    'output'      => [
        [
            'element' => 'section.page-header-area, .books-category-archive-header',
        ],
    ],
    'active_callback' => [
        [
            'setting'  => 'show_page_header',
            'operator' => '==',
            'value'    => true,
        ]
    ],
] );

Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'color',
    'settings'    => 'page_banner_overlay_color',
    'label'       => __( 'Banner Overly Color', 'book-review-blog' ),
    'section'     => 'page_settings_section',
    'transport'   => 'auto',
    'default'       => 'rgba(33, 33, 33, 0.3)',
    'choices'     => [
            'alpha' => true,
        ],
    'output' => array(
        array(
            'element'  => '.page_banner_overlay',
            'property' => 'background',
        ),
    ),
    'active_callback' => [
        [
            'setting'  => 'show_page_header',
            'operator' => '==',
            'value'    => true,
        ]
    ],
] );

Kirki::add_field( 'book_review_blog_config', [
    'type'        => 'typography',
    'settings'    => 'page_banner_title_typography',
    'label'       => esc_html__( 'Page Title Typography', 'book-review-blog' ),
    'section'     => 'page_settings_section',
    'default'     => [
        'font-family'    => 'Roboto',
        'variant'        => '700',
        'font-size'      => '2.5rem',
        'line-height'    => '1.6',
        'letter-spacing' => '0px',
        'color'          => '#222222',
        'text-transform' => 'none',
        'text-align'     => 'left',
    ],
    'active_callback' => [
        [
            'setting'  => 'show_page_header',
            'operator' => '==',
            'value'    => true,
        ]
    ],
    'transport'   => 'auto',
    'output'      => [
        [
            'element' => 'section.page-header-area h1',
        ],
    ],
] );