<?php

function packers_movers_company_enqueue_fonts() {
    $packers_movers_company_default_font_content = 'roboto';
    $packers_movers_company_default_font_heading = 'roboto';

    $packers_movers_company_font_content = esc_attr(get_theme_mod('packers_movers_company_content_typography_font', $packers_movers_company_default_font_content));
    $packers_movers_company_font_heading = esc_attr(get_theme_mod('packers_movers_company_heading_typography_font', $packers_movers_company_default_font_heading));

    $packers_movers_company_css = '';

    // Always enqueue main font
    $packers_movers_company_css .= '
    :root {
        --font-main: ' . $packers_movers_company_font_content . ', ' . (in_array($packers_movers_company_font_content, ['bitter', 'charis-sil']) ? 'serif' : 'sans-serif') . '!important;
    }';
    wp_enqueue_style('packers-movers-company-style-font-general', get_template_directory_uri() . '/fonts/' . $packers_movers_company_font_content . '/font.css');

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

    // Add inline style
    wp_add_inline_style('packers-movers-company-style-font-general', $packers_movers_company_css);
}
add_action('wp_enqueue_scripts', 'packers_movers_company_enqueue_fonts', 50);