<?php

function online_learning_lms_enqueue_fonts() {
    $online_learning_lms_default_font_content = 'Poppins';
    $online_learning_lms_default_font_heading = 'playfair-display';

    $online_learning_lms_font_content = esc_attr(get_theme_mod('online_learning_lms_content_typography_font', $online_learning_lms_default_font_content));
    $online_learning_lms_font_heading = esc_attr(get_theme_mod('online_learning_lms_heading_typography_font', $online_learning_lms_default_font_heading));

    $online_learning_lms_css = '';

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

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

    // Add inline style
    wp_add_inline_style('boat-rental-style-font-general', $online_learning_lms_css);
}
add_action('wp_enqueue_scripts', 'online_learning_lms_enqueue_fonts', 50);