<?php

function electrician_company_enqueue_fonts() {
    $electrician_company_default_font_content = 'roboto';
    $electrician_company_default_font_heading = 'roboto';

    $electrician_company_font_content = esc_attr(get_theme_mod('electrician_company_content_typography_font', $electrician_company_default_font_content));
    $electrician_company_font_heading = esc_attr(get_theme_mod('electrician_company_heading_typography_font', $electrician_company_default_font_heading));

    $electrician_company_css = '';

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

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

    // Add inline style
    wp_add_inline_style('electrician-company-style-font-general', $electrician_company_css);
}
add_action('wp_enqueue_scripts', 'electrician_company_enqueue_fonts', 50);