<?php

function omega_food_delivery_enqueue_fonts() {
    $omega_food_delivery_default_font_content = 'lato';
    $omega_food_delivery_default_font_heading = 'lato';

    $omega_food_delivery_font_content = esc_attr(get_theme_mod('omega_food_delivery_content_typography_font', $omega_food_delivery_default_font_content));
    $omega_food_delivery_font_heading = esc_attr(get_theme_mod('omega_food_delivery_heading_typography_font', $omega_food_delivery_default_font_heading));

    $omega_food_delivery_css = '';

    // Always enqueue main font
    $omega_food_delivery_css .= '
    :root {
        --font-main: ' . $omega_food_delivery_font_content . ', ' . (in_array($omega_food_delivery_font_content, ['bitter', ' ']) ? 'serif' : 'sans-serif') . '!important;
    }';
    wp_enqueue_style('omega-food-delivery-style-font-general', get_template_directory_uri() . '/fonts/' . $omega_food_delivery_font_content . '/font.css');

    // Always enqueue header font
    $omega_food_delivery_css .= '
    :root {
        --font-head: ' . $omega_food_delivery_font_heading . ', ' . (in_array($omega_food_delivery_font_heading, ['bitter', 'WorkSans']) ? 'serif' : 'sans-serif') . '!important;
    }';
    wp_enqueue_style('omega-food-delivery-style-font-h', get_template_directory_uri() . '/fonts/' . $omega_food_delivery_font_heading . '/font.css');

    // Add inline style
    wp_add_inline_style('omega-food-delivery-style-font-general', $omega_food_delivery_css);
}
add_action('wp_enqueue_scripts', 'omega_food_delivery_enqueue_fonts', 50);