<?php

function education_reform_enqueue_fonts() {
    $education_reform_default_font_content = 'roboto';
    $education_reform_default_font_heading = 'RobotoSlab';

    $education_reform_font_content = esc_attr(get_theme_mod('education_reform_content_typography_font', $education_reform_default_font_content));
    $education_reform_font_heading = esc_attr(get_theme_mod('education_reform_heading_typography_font', $education_reform_default_font_heading));

    $education_reform_css = '';

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

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

    // Add inline style
    wp_add_inline_style('education-reform-style-font-general', $education_reform_css);
}
add_action('wp_enqueue_scripts', 'education_reform_enqueue_fonts', 50);