<?php

function aviation_industry_enqueue_fonts() {
    $aviation_industry_default_font_content = 'Poppins';
    $aviation_industry_default_font_heading = 'playfair-display';

    $aviation_industry_font_content = esc_attr(get_theme_mod('aviation_industry_content_typography_font', $aviation_industry_default_font_content));
    $aviation_industry_font_heading = esc_attr(get_theme_mod('aviation_industry_heading_typography_font', $aviation_industry_default_font_heading));

    $aviation_industry_css = '';

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

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

    // Add inline style
    wp_add_inline_style('aviation-industry-style-font-general', $aviation_industry_css);
}
add_action('wp_enqueue_scripts', 'aviation_industry_enqueue_fonts', 50);