<?php
/**
 * Ticker News Section Settings
 *
 * @package Blog_Over
 */

Kirki::add_section('blog_over_ticker_section', array(
    'title' => esc_html__('Ticker News', 'blog-over'),
    'panel' => 'blog_over_frontpage_panel',
    'priority' => 10,
));

// ─────────────────────────────────────────────
// A) Enable / Visibility
// ─────────────────────────────────────────────

// Enable Ticker
Kirki::add_field('Blog_Over_config', array(
    'type' => 'toggle',
    'settings' => 'blog_over_enable_ticker',
    'label' => esc_html__('Enable Ticker News', 'blog-over'),
    'section' => 'blog_over_ticker_section',
    'default' => false,
    'priority' => 10,
    'partial_refresh' => array(
        'blog_over_enable_ticker_refresh' => array(
            'selector' => '#ticker.blog-over-ticker-slider',
            'render_callback' => 'blog_over_render_ticker_partial',
            'container_inclusive' => true,
        ),
    ),
));

// Show On Pages (Page visibility)
Kirki::add_field('Blog_Over_config', array(
    'type' => 'multicheck',
    'settings' => 'blog_over_ticker_enable_on',
    'label' => esc_html__('Show On Pages', 'blog-over'),
    'description' => esc_html__('Choose on which pages you want to enable Ticker News.', 'blog-over'),
    'section' => 'blog_over_ticker_section',
    'default' => array('home', 'posts_page'),
    'priority' => 11,
    'choices' => array(
        'home' => esc_html__('Home Page', 'blog-over'),
        'posts_page' => esc_html__('Blog / Posts Page', 'blog-over'),
        'archive' => esc_html__('Archive Page', 'blog-over'),
        'search' => esc_html__('Search Page', 'blog-over'),
        'post' => esc_html__('Single Post', 'blog-over'),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_enable_ticker', 'operator' => '==', 'value' => true),
    ),
));

// Container Width
Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_ticker_container',
    'label' => esc_html__('Container Width', 'blog-over'),
    'section' => 'blog_over_ticker_section',
    'default' => 'container',
    'priority' => 12,
    'choices' => array(
        'container' => esc_html__('Container', 'blog-over'),
        'full-width' => esc_html__('Full Width', 'blog-over'),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_enable_ticker', 'operator' => '==', 'value' => true),
    ),
));

// Ticker Layout Style
Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_ticker_layout',
    'label' => esc_html__('Layout Style', 'blog-over'),
    'section' => 'blog_over_ticker_section',
    'default' => 'classic',
    'priority' => 13,
    'choices' => blog_over_get_ticker_layout_choices(),
    'sanitize_callback' => 'blog_over_sanitize_select',
    'active_callback' => array(
        array('setting' => 'blog_over_enable_ticker', 'operator' => '==', 'value' => true),
    ),
    'partial_refresh' => array(
        'blog_over_ticker_layout_refresh' => array(
            'selector' => '#ticker.blog-over-ticker-slider',
            'render_callback' => 'blog_over_render_ticker_partial',
            'container_inclusive' => true,
        ),
    ),
));


// ─────────────────────────────────────────────
// B) Content Settings
// ─────────────────────────────────────────────

// Ticker Label Text - Edit shortcut on this setting
Kirki::add_field('Blog_Over_config', array(
    'type' => 'text',
    'settings' => 'blog_over_ticker_title',
    'label' => esc_html__('Label Text', 'blog-over'),
    'section' => 'blog_over_ticker_section',
    'default' => esc_html__('Top Stories', 'blog-over'),
    'priority' => 15,
    'active_callback' => array(
        array('setting' => 'blog_over_enable_ticker', 'operator' => '==', 'value' => true),
    ),
    'partial_refresh' => array(
        'blog_over_ticker_title_refresh' => array(
            'selector' => '#ticker.blog-over-ticker-slider',
            'render_callback' => 'blog_over_render_ticker_partial',
            'container_inclusive' => true,
        ),
    ),
));

// Number of Posts - Max 20
Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_ticker_posts_count',
    'label' => esc_html__('Number of Posts', 'blog-over'),
    'section' => 'blog_over_ticker_section',
    'default' => 6,
    'priority' => 21,
    'choices' => array(
        'min' => 1,
        'max' => 20,
        'step' => 1,
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_enable_ticker', 'operator' => '==', 'value' => true),
    ),
));

// Content Source
Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_ticker_source',
    'label' => esc_html__('Content Source', 'blog-over'),
    'section' => 'blog_over_ticker_section',
    'default' => 'latest',
    'priority' => 22,
    'choices' => blog_over_get_ticker_source_choices(),
    'sanitize_callback' => 'blog_over_sanitize_select',
    'active_callback' => array(
        array('setting' => 'blog_over_enable_ticker', 'operator' => '==', 'value' => true),
    ),
));

// Category Select
Kirki::add_field('Blog_Over_config', array(
    'type' => 'select',
    'settings' => 'blog_over_ticker_category',
    'label' => esc_html__('Select Category', 'blog-over'),
    'section' => 'blog_over_ticker_section',
    'default' => '',
    'priority' => 23,
    'choices' => blog_over_get_categories_choices(),
    'active_callback' => array(
        array('setting' => 'blog_over_enable_ticker', 'operator' => '==', 'value' => true),
        array('setting' => 'blog_over_ticker_source', 'operator' => '==', 'value' => 'category'),
    ),
));

// ─────────────────────────────────────────────
// C) Display Controls (Inside Design Dropdown - priority 51+)
// ─────────────────────────────────────────────

// Show Post Image
Kirki::add_field('Blog_Over_config', array(
    'type' => 'toggle',
    'settings' => 'blog_over_ticker_show_image',
    'label' => esc_html__('Show Post Image', 'blog-over'),
    'section' => 'blog_over_ticker_section',
    'default' => true,
    'priority' => 51,
    'active_callback' => array(
        array('setting' => 'blog_over_enable_ticker', 'operator' => '==', 'value' => true),
    ),
));

// Show Post Date
Kirki::add_field('Blog_Over_config', array(
    'type' => 'toggle',
    'settings' => 'blog_over_ticker_show_date',
    'label' => esc_html__('Show Post Date', 'blog-over'),
    'section' => 'blog_over_ticker_section',
    'default' => true,
    'priority' => 52,
    'active_callback' => array(
        array('setting' => 'blog_over_enable_ticker', 'operator' => '==', 'value' => true),
    ),
));

// Show Pause/Play Button
Kirki::add_field('Blog_Over_config', array(
    'type' => 'toggle',
    'settings' => 'blog_over_ticker_show_pause',
    'label' => esc_html__('Show Pause/Play Button', 'blog-over'),
    'section' => 'blog_over_ticker_section',
    'default' => true,
    'priority' => 53,
    'active_callback' => array(
        array('setting' => 'blog_over_enable_ticker', 'operator' => '==', 'value' => true),
    ),
));

// ─────────────────────────────────────────────
// D) Motion & Interaction (Inside Design Dropdown - priority 54+)
// ─────────────────────────────────────────────

// Scroll Direction
Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_ticker_direction',
    'label' => esc_html__('Scroll Direction', 'blog-over'),
    'section' => 'blog_over_ticker_section',
    'default' => 'left',
    'priority' => 54,
    'choices' => blog_over_get_ticker_direction_choices(),
    'sanitize_callback' => 'blog_over_sanitize_select',
    'active_callback' => array(
        array('setting' => 'blog_over_enable_ticker', 'operator' => '==', 'value' => true),
    ),
));

// Scroll Speed
Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_ticker_speed',
    'label' => esc_html__('Scroll Speed', 'blog-over'),
    'description' => esc_html__('Speed in pixels per second', 'blog-over'),
    'section' => 'blog_over_ticker_section',
    'default' => 50,
    'priority' => 55,
    'choices' => array(
        'min' => 20,
        'max' => 100,
        'step' => 5,
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_enable_ticker', 'operator' => '==', 'value' => true),
    ),
));

// Pause on Hover
Kirki::add_field('Blog_Over_config', array(
    'type' => 'toggle',
    'settings' => 'blog_over_ticker_pause_hover',
    'label' => esc_html__('Pause on Hover', 'blog-over'),
    'section' => 'blog_over_ticker_section',
    'default' => true,
    'priority' => 56,
    'active_callback' => array(
        array('setting' => 'blog_over_enable_ticker', 'operator' => '==', 'value' => true),
    ),
));
