<?php

function event_decorations_enqueue_fonts() {
    $event_decorations_default_font_content = 'be-vietnam-pro';
    $event_decorations_default_font_heading = 'be-vietnam-pro';

    $event_decorations_font_content = esc_attr(get_theme_mod('event_decorations_content_typography_font', $event_decorations_default_font_content));
    $event_decorations_font_heading = esc_attr(get_theme_mod('event_decorations_heading_typography_font', $event_decorations_default_font_heading));

    $event_decorations_css = '';

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

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

    // Add inline style
    wp_add_inline_style('event-decorations-style-font-general', $event_decorations_css);
}
add_action('wp_enqueue_scripts', 'event_decorations_enqueue_fonts', 50);