<?php
/**
 * WE88 Express — Theme functions
 *
 * @package WE88_Express
 */

defined( 'ABSPATH' ) || exit;

if ( ! defined( 'WE88_EXPRESS_VERSION' ) ) {
	define( 'WE88_EXPRESS_VERSION', '1.0.2' );
}

if ( file_exists( __DIR__ . '/inc/provisioner.php' ) ) {
	require_once __DIR__ . '/inc/provisioner.php';
}

/**
 * Theme setup: declare feature support and add image sizes.
 */
function we88_express_setup(): void {
	load_theme_textdomain( 'we88-express', get_template_directory() . '/languages' );

	add_theme_support( 'wp-block-styles' );
	add_theme_support( 'editor-styles' );
	add_theme_support( 'responsive-embeds' );
	add_theme_support( 'align-wide' );
	add_theme_support( 'custom-logo', [
		'height'      => 80,
		'width'       => 240,
		'flex-height' => true,
		'flex-width'  => true,
	] );
	add_theme_support( 'post-thumbnails' );
	add_theme_support( 'title-tag' );
	add_theme_support( 'html5', [ 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'style', 'script' ] );

	add_editor_style( 'assets/css/style.css' );

	register_nav_menus( [
		'primary' => __( 'Primary Menu', 'we88-express' ),
		'footer'  => __( 'Footer Menu', 'we88-express' ),
	] );
}
add_action( 'after_setup_theme', 'we88_express_setup' );

/**
 * Enqueue front-end styles. Fonts are bundled woff2 files loaded via
 * theme.json fontFace entries (file:./assets/fonts/…) — no external hosts.
 */
function we88_express_enqueue(): void {
	wp_enqueue_style(
		'we88-express-main',
		get_theme_file_uri( 'assets/css/style.css' ),
		[],
		WE88_EXPRESS_VERSION
	);
}
add_action( 'wp_enqueue_scripts', 'we88_express_enqueue' );

/**
 * Register block patterns category for WE88 Portal.
 */
function we88_express_register_pattern_category(): void {
	if ( function_exists( 'register_block_pattern_category' ) ) {
		register_block_pattern_category(
			'we88-portal',
			[
				'label'       => __( 'WE88 Portal', 'we88-express' ),
				'description' => __( 'Patterns built around the WE88 Portal plugin blocks.', 'we88-express' ),
			]
		);
	}
}
add_action( 'init', 'we88_express_register_pattern_category' );
