<?php

function wind_energy_enqueue_fonts() {
    $wind_energy_default_font_content = 'Inter';
    $wind_energy_default_font_heading = 'Inter';

    $wind_energy_font_content = esc_attr(get_theme_mod('wind_energy_content_typography_font', $wind_energy_default_font_content));
    $wind_energy_font_heading = esc_attr(get_theme_mod('wind_energy_heading_typography_font', $wind_energy_default_font_heading));

    $wind_energy_css = '';

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

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

    // Add inline style
    wp_add_inline_style('wind-energy-style-font-general', $wind_energy_css);
}
add_action('wp_enqueue_scripts', 'wind_energy_enqueue_fonts', 50);