<?php

function car_rental_service_enqueue_fonts() {
    $car_rental_service_default_font_content = 'inter';
    $car_rental_service_default_font_heading = 'almarai';

    $car_rental_service_font_content = esc_attr(get_theme_mod('car_rental_service_content_typography_font', $car_rental_service_default_font_content));
    $car_rental_service_font_heading = esc_attr(get_theme_mod('car_rental_service_heading_typography_font', $car_rental_service_default_font_heading));

    $car_rental_service_css = '';

    // Always enqueue main font
    $car_rental_service_css .= '
    :root {
        --font-main: ' . $car_rental_service_font_content . ', ' . (in_array($car_rental_service_font_content, ['bitter', 'charis-sil']) ? 'serif' : 'sans-serif') . '!important;
    }';
    wp_enqueue_style('car-rental-service-style-font-general', get_template_directory_uri() . '/fonts/' . $car_rental_service_font_content . '/font.css');

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

    // Add inline style
    wp_add_inline_style('car-rental-service-style-font-general', $car_rental_service_css);
}
add_action('wp_enqueue_scripts', 'car_rental_service_enqueue_fonts', 50);