<?php
/**
 * Service Section
 *
 * @package technology_software_firm
 */

 $wp_customize->add_section(
	'technology_software_firm_services_section',
	array(
		'panel'    => 'technology_software_firm_front_page_options',
		'title'    => esc_html__( 'Services Section', 'technology-software-firm' ),
		'priority' => 10,
	)
);

//Service Section - Enable Section.
$wp_customize->add_setting(
	'technology_software_firm_enable_services_section',
	array(
		'default'           => false,
		'sanitize_callback' => 'technology_software_firm_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Technology_Software_Firm_Toggle_Switch_Custom_Control(
		$wp_customize,
		'technology_software_firm_enable_services_section',
		array(
			'label'    => esc_html__( 'Enable Services Section', 'technology-software-firm' ),
			'section'  => 'technology_software_firm_services_section',
			'settings' => 'technology_software_firm_enable_services_section'
		)
	)
);

// Partial Refresh
if ( isset( $wp_customize->selective_refresh ) ) {
	$wp_customize->selective_refresh->add_partial(
		'technology_software_firm_enable_services_section',
		array(
			'selector' => '#technology_software_firm_services_section .section-link',
			'settings' => 'technology_software_firm_enable_services_section',
		)
	);
}

// ── New custom-cards settings ─────────────────────────────────────────────────


// Background decorative heading text.
$wp_customize->add_setting(
	'technology_software_firm_services_bg_heading',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);
$wp_customize->add_control(
	'technology_software_firm_services_bg_heading',
	array(
		'label'           => esc_html__( 'Section Sub-Title', 'technology-software-firm' ),
		'section'         => 'technology_software_firm_services_section',
		'type'            => 'text',
		'active_callback' => 'technology_software_firm_is_services_section_enabled',
	)
);

// Section title (new standalone setting; falls back to trending_post_content if empty).
$wp_customize->add_setting(
	'technology_software_firm_services_section_title',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);
$wp_customize->add_control(
	'technology_software_firm_services_section_title',
	array(
		'label'           => esc_html__( 'Section Title (Heading)', 'technology-software-firm' ),
		'section'         => 'technology_software_firm_services_section',
		'type'            => 'text',
		'active_callback' => 'technology_software_firm_is_services_section_enabled',
	)
);

// Number of service posts to show.
$wp_customize->add_setting(
	'technology_software_firm_services_posts_count',
	array(
		'default'           => 3,
		'sanitize_callback' => 'technology_software_firm_sanitize_range_value',
	)
);

$wp_customize->add_control(
	'technology_software_firm_services_posts_count',
	array(
		'label'           => esc_html__( 'Services Post Count', 'technology-software-firm' ),
		'section'         => 'technology_software_firm_services_section',
		'type'            => 'number',
		'input_attrs'     => array(
			'min'  => 1,
			'max'  => 9,
			'step' => 1,
		),
		'active_callback' => 'technology_software_firm_is_services_section_enabled',
	)
);

// Select category for services posts.
$wp_customize->add_setting(
	'technology_software_firm_services_category',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	new Technology_Software_Firm_Customize_Category_Dropdown_Control(
		$wp_customize,
		'technology_software_firm_services_category',
		array(
			'label'           => esc_html__( 'Select Category', 'technology-software-firm' ),
			'section'         => 'technology_software_firm_services_section',
			'settings'        => 'technology_software_firm_services_category',
			'active_callback' => 'technology_software_firm_is_services_section_enabled',
		)
	)
);