<?php

function board_games_enqueue_fonts() {
    $board_games_default_font_content = 'PlusJakartaSans';
    $board_games_default_font_heading = 'play';

    $board_games_font_content = esc_attr(get_theme_mod('board_games_content_typography_font', $board_games_default_font_content));
    $board_games_font_heading = esc_attr(get_theme_mod('board_games_heading_typography_font', $board_games_default_font_heading));

    $board_games_css = '';

    // Always enqueue main font
    $board_games_css .= '
    :root {
        --font-main: ' . $board_games_font_content . ', ' . (in_array($board_games_font_content, ['bitter', 'charis-sil']) ? 'serif' : 'sans-serif') . '!important;
    }';
    wp_enqueue_style('board-games-style-font-general', get_template_directory_uri() . '/fonts/' . $board_games_font_content . '/font.css');

    // Always enqueue header font
    $board_games_css .= '
    :root {
        --font-head: ' . $board_games_font_heading . ', ' . (in_array($board_games_font_heading, ['bitter', 'charis-sil']) ? 'serif' : 'sans-serif') . '!important;
    }';
    wp_enqueue_style('board-games-style-font-h', get_template_directory_uri() . '/fonts/' . $board_games_font_heading . '/font.css');

    // Add inline style
    wp_add_inline_style('board-games-style-font-general', $board_games_css);
}
add_action('wp_enqueue_scripts', 'board_games_enqueue_fonts', 50);