<?php

function omega_design_agency_enqueue_fonts() {
    $omega_design_agency_default_font_content = 'Poppins';
    $omega_design_agency_default_font_heading = 'Poppins';

    $omega_design_agency_font_content = esc_attr(get_theme_mod('omega_design_agency_content_typography_font', $omega_design_agency_default_font_content));
    $omega_design_agency_font_heading = esc_attr(get_theme_mod('omega_design_agency_heading_typography_font', $omega_design_agency_default_font_heading));

    $omega_design_agency_css = '';

    // Always enqueue main font
    $omega_design_agency_css .= '
    :root {
        --font-main: ' . $omega_design_agency_font_content . ', ' . (in_array($omega_design_agency_font_content, ['bitter', 'charis-sil']) ? 'serif' : 'sans-serif') . '!important;
    }';
    wp_enqueue_style('omega-design-agency-style-font-general', get_template_directory_uri() . '/fonts/' . $omega_design_agency_font_content . '/font.css');

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

    // Add inline style
    wp_add_inline_style('omega-design-agency-style-font-general', $omega_design_agency_css);
}
add_action('wp_enqueue_scripts', 'omega_design_agency_enqueue_fonts', 50);