<?php

function cargo_and_shipping_company_enqueue_fonts() {
    $cargo_and_shipping_company_default_font_content = 'inter';
    $cargo_and_shipping_company_default_font_heading = 'almarai';

    $cargo_and_shipping_company_font_content = esc_attr(get_theme_mod('cargo_and_shipping_company_content_typography_font', $cargo_and_shipping_company_default_font_content));
    $cargo_and_shipping_company_font_heading = esc_attr(get_theme_mod('cargo_and_shipping_company_heading_typography_font', $cargo_and_shipping_company_default_font_heading));

    $cargo_and_shipping_company_css = '';

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

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

    // Add inline style
    wp_add_inline_style('cargo-and-shipping-company-style-font-general', $cargo_and_shipping_company_css);
}
add_action('wp_enqueue_scripts', 'cargo_and_shipping_company_enqueue_fonts', 50);