<?php
/**
 * Feature Story (Parallax) Section Settings
 *
 * @package Blog_Over
 */

// ─────────────────────────────────────────────
// Section: Feature Story
// ─────────────────────────────────────────────
Kirki::add_section('blog_over_feature_story_section', array(
    'title' => esc_html__('Big Feature Story', 'blog-over'),
    'panel' => 'blog_over_frontpage_panel',
    'priority' => 35, // Below Featured Links (30) but Before Footer/Missed Section (40)
));

// ═══════════════════════════════════════════
// A) Enable Toggle
// ═══════════════════════════════════════════
Kirki::add_field('Blog_Over_config', array(
    'type' => 'toggle',
    'settings' => 'blog_over_feature_story_enable',
    'label' => esc_html__('Enable Feature Story Section', 'blog-over'),
    'description' => esc_html__('Displays a full-width immersive parallax block for a single prominent post.', 'blog-over'),
    'section' => 'blog_over_feature_story_section',
    'default' => false,
    'priority' => 5,
    'partial_refresh' => array(
        'blog_over_feature_story_enable' => array(
            'selector' => '#blog-over-feature-story-ajax-wrap',
            'render_callback' => 'blog_over_render_feature_story_partial',
        ),
    ),
));

// ═══════════════════════════════════════════
// B) Show On Pages
// ═══════════════════════════════════════════
Kirki::add_field('Blog_Over_config', array(
    'type' => 'multicheck',
    'settings' => 'blog_over_feature_story_show_on',
    'label' => esc_html__('Show On Pages', 'blog-over'),
    'section' => 'blog_over_feature_story_section',
    'default' => array('home', 'blog'),
    'priority' => 10,
    'choices' => array(
        'home' => esc_html__('Home Page', 'blog-over'),
        'blog' => esc_html__('Blog / Posts Page', 'blog-over'),
        'single' => esc_html__('Single Post', 'blog-over'),
        'archive' => esc_html__('Archive Pages', 'blog-over'),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_feature_story_enable', 'operator' => '==', 'value' => true),
    ),
));

// ═══════════════════════════════════════════
// C) Section Content Settings
// ═══════════════════════════════════════════
Kirki::add_field('Blog_Over_config', array(
    'type' => 'custom',
    'settings' => 'blog_over_fs_content_heading',
    'section' => 'blog_over_feature_story_section',
    'default' => '<div style="background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%); padding: 10px 14px; border-radius: 6px; margin-top: 20px; border-left: 3px solid #3b82f6;"><span style="font-size: 13px; font-weight: 600; color: #1e40af; text-transform: uppercase; letter-spacing: 0.5px;">' . esc_html__('Content Source', 'blog-over') . '</span></div>',
    'priority' => 15,
    'active_callback' => array(
        array('setting' => 'blog_over_feature_story_enable', 'operator' => '==', 'value' => true),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'text',
    'settings' => 'blog_over_feature_story_section_title',
    'label' => esc_html__('Section Title', 'blog-over'),
    'description' => esc_html__('Optional title displayed above the feature story.', 'blog-over'),
    'section' => 'blog_over_feature_story_section',
    'default' => '',
    'priority' => 16,
    'active_callback' => array(
        array('setting' => 'blog_over_feature_story_enable', 'operator' => '==', 'value' => true),
    ),
    'partial_refresh' => array(
        'blog_over_feature_story_section_title' => array(
            'selector' => '#blog-over-feature-story-ajax-wrap',
            'render_callback' => 'blog_over_render_feature_story_partial',
        ),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'select',
    'settings' => 'blog_over_feature_story_category',
    'label' => esc_html__('Pull from Category', 'blog-over'),
    'description' => esc_html__('Select a category to feature the latest post from.', 'blog-over'),
    'section' => 'blog_over_feature_story_section',
    'default' => '',
    'priority' => 20,
    'choices' => blog_over_get_categories_choices(),
    'active_callback' => array(
        array('setting' => 'blog_over_feature_story_enable', 'operator' => '==', 'value' => true),
    ),
));

// PRO TEASER FOR CUSTOM POST ID
if (!function_exists('blog_over_is_pro_active') || !blog_over_is_pro_active()) {
    Kirki::add_field('Blog_Over_config', array(
        'type' => 'custom',
        'settings' => 'blog_over_feature_story_pro_teaser',
        'section' => 'blog_over_feature_story_section',
        'default' => '<div style="margin-top: 10px; padding: 12px; background: rgba(59, 130, 246, 0.05); border: 1px solid rgba(59, 130, 246, 0.2); border-radius: 4px; font-size: 12px; line-height: 1.5; color: #475569;"><strong>⭐ Pro Feature:</strong> Use a <strong>Custom Image</strong>, embed a <strong>YouTube / Vimeo</strong> video, or use a self-hosted <strong>Video Background</strong>. You can also feature a specific post by its ID. <br><a href="#" target="_blank" style="color: #3b82f6; text-decoration: none; font-weight: 600; display: inline-block; margin-top: 4px;">Upgrade to Blog Over Pro &rarr;</a></div>',
        'priority' => 100,
        'active_callback' => array(
            array('setting' => 'blog_over_feature_story_enable', 'operator' => '==', 'value' => true),
        ),
    ));
}

// ═══════════════════════════════════════════
// D) Section Design Settings
// ═══════════════════════════════════════════
Kirki::add_field('Blog_Over_config', array(
    'type' => 'custom',
    'settings' => 'blog_over_fs_design_heading',
    'section' => 'blog_over_feature_story_section',
    'default' => '<div style="background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%); padding: 10px 14px; border-radius: 6px; margin-top: 20px; border-left: 3px solid #3b82f6;"><span style="font-size: 13px; font-weight: 600; color: #1e40af; text-transform: uppercase; letter-spacing: 0.5px;">' . esc_html__('Design Options', 'blog-over') . '</span></div>',
    'priority' => 25,
    'active_callback' => array(
        array('setting' => 'blog_over_feature_story_enable', 'operator' => '==', 'value' => true),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'radio-buttonset',
    'settings' => 'blog_over_feature_story_layout',
    'label' => esc_html__('Story Layout', 'blog-over'),
    'section' => 'blog_over_feature_story_section',
    'default' => 'overlay',
    'priority' => 28,
    'choices' => array(
        'overlay' => esc_html__('Overlay', 'blog-over'),
        'split' => esc_html__('Split', 'blog-over'),
        'overlap' => esc_html__('Overlap', 'blog-over'),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_feature_story_enable', 'operator' => '==', 'value' => true),
    ),
    'partial_refresh' => array(
        'blog_over_feature_story_layout' => array(
            'selector' => '#blog-over-feature-story-ajax-wrap',
            'render_callback' => 'blog_over_render_feature_story_partial',
        ),
    ),
));

// PRO ONLY: Box Alignment
if (function_exists('blog_over_is_pro_active') && blog_over_is_pro_active()) {
    Kirki::add_field('Blog_Over_config', array(
        'type' => 'radio-buttonset',
        'settings' => 'blog_over_feature_story_box_align',
        'label' => esc_html__('Content Box Alignment', 'blog-over'),
        'description' => esc_html__('Position the content box to the left or right of the image.', 'blog-over'),
        'section' => 'blog_over_feature_story_section',
        'default' => 'right',
        'priority' => 29,
        'choices' => array(
            'left' => esc_html__('Left', 'blog-over'),
            'right' => esc_html__('Right', 'blog-over'),
        ),
        'active_callback' => array(
            array('setting' => 'blog_over_feature_story_enable', 'operator' => '==', 'value' => true),
            // Works for all layouts but is most useful for Overlap and Split and Overlay
        ),
        'partial_refresh' => array(
            'blog_over_feature_story_box_align' => array(
                'selector' => '#blog-over-feature-story-ajax-wrap',
                'render_callback' => 'blog_over_render_feature_story_partial',
            ),
        ),
    ));
}

Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_feature_story_height',
    'label' => esc_html__('Section Height (px)', 'blog-over'),
    'section' => 'blog_over_feature_story_section',
    'default' => 600,
    'priority' => 30,
    'choices' => array('min' => 450, 'max' => 900, 'step' => 10),
    'transport' => 'auto',
    'output' => array(
        array(
            'element' => '.layout-overlay .blog-over-overlay-inner, .layout-overlap .blog-over-feature-media, .layout-split .blog-over-feature-media',
            'property' => 'min-height',
            'units' => 'px',
        ),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_feature_story_enable', 'operator' => '==', 'value' => true),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'slider',
    'settings' => 'blog_over_feature_story_overlay',
    'label' => esc_html__('Overlay Opacity (%)', 'blog-over'),
    'description' => esc_html__('Darken the background image so white text is readable.', 'blog-over'),
    'section' => 'blog_over_feature_story_section',
    'default' => 60,
    'priority' => 35,
    'choices' => array('min' => 0, 'max' => 95, 'step' => 1),
    'transport' => 'postMessage',
    'output' => array(
        array(
            'element' => ':root',
            'property' => '--blog-over-fs-opacity',
            'value_pattern' => 'calc($ / 100)',
        ),
    ),
    'active_callback' => array(
        array('setting' => 'blog_over_feature_story_enable', 'operator' => '==', 'value' => true),
    ),
));

// ═══════════════════════════════════════════
// E) Feature Story Post Elements (sortable)
// ═══════════════════════════════════════════
Kirki::add_field('Blog_Over_config', array(
    'type' => 'sortable',
    'settings' => 'blog_over_feature_story_elements',
    'label' => esc_html__('Block Elements', 'blog-over'),
    'description' => esc_html__('Drag to reorder. Uncheck to hide.', 'blog-over'),
    'section' => 'blog_over_feature_story_section',
    'default' => array('category', 'title', 'meta', 'excerpt', 'button'),
    'choices' => array(
        'category' => esc_html__('Category Badge', 'blog-over'),
        'title' => esc_html__('Post Title', 'blog-over'),
        'meta' => esc_html__('Post Meta', 'blog-over'),
        'excerpt' => esc_html__('Excerpt', 'blog-over'),
        'button' => esc_html__('Read More Button', 'blog-over'),
    ),
    'priority' => 45,
    'partial_refresh' => array(
        'blog_over_feature_story_elements' => array(
            'selector' => '#blog-over-feature-story-ajax-wrap',
            'render_callback' => 'blog_over_render_feature_story_partial',
        ),
    ),
));

Kirki::add_field('Blog_Over_config', array(
    'type' => 'text',
    'settings' => 'blog_over_feature_story_btn_text',
    'label' => esc_html__('Button Text', 'blog-over'),
    'section' => 'blog_over_feature_story_section',
    'default' => esc_html__('Read Story', 'blog-over'),
    'priority' => 46,
    'active_callback' => array(
        array('setting' => 'blog_over_feature_story_enable', 'operator' => '==', 'value' => true),
    ),
    'partial_refresh' => array(
        'blog_over_feature_story_btn_text' => array(
            'selector' => '#blog-over-feature-story-ajax-wrap',
            'render_callback' => 'blog_over_render_feature_story_partial',
        ),
    ),
));
