<?php
/**
 * v2.1.0
 */
/**
 * Enqueue ProQyz font styles once per page
 * 
 * This function ensures that the required font CSS is only loaded once per page,
 * even if called by multiple shortcodes. It uses WordPress's wp_add_inline_style
 * for better performance and proper style handling.
 * 
 * @param string $handle Optional. Style handle to attach inline styles to. Default 'proqyz-fonts'
 * @return bool True if styles were enqueued, false if already enqueued
 */
function st_proqyz_enqueue_fonts($handle = 'proqyz-fonts') {
    static $fonts_enqueued = false;
    
    // If fonts already enqueued, return early
    if ($fonts_enqueued) {
        return false;
    }
    
    // Mark as enqueued to prevent duplicate loading
    $fonts_enqueued = true;
    
    // Get site URL for font paths
    $site_url = site_url();
    $fonts_base_url = $site_url . '/wp-content/plugins/spacetree/libs/proqyz/includes/public/dist/fonts/';
    
    // Generate the CSS
    $css = st_proqyz_generate_fonts_css($fonts_base_url);
    
    // Try to add inline style to existing handle, or create a new one
    if (!wp_style_is($handle, 'registered')) {
        // Register a dummy style handle if it doesn't exist
        wp_register_style($handle, false);
        wp_enqueue_style($handle);
    }
    
    // Add inline style
    wp_add_inline_style($handle, $css);
    
    return true;
}

/**
 * Generate font CSS for ProQyz
 * 
 * @param string $fonts_base_url Base URL for font files
 * @return string Generated CSS
 */
function st_proqyz_generate_fonts_css($fonts_base_url) {
    $css = '
        @font-face {
            font-family: "Glyphicons Halflings";
            src: url(' . $fonts_base_url . 'glyphicons-halflings-regular.eot);
            src: url(' . $fonts_base_url . 'glyphicons-halflings-regular.eot#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'glyphicons-halflings-regular.woff2) format("woff2"),
                 url(' . $fonts_base_url . 'glyphicons-halflings-regular.woff) format("woff"),
                 url(' . $fonts_base_url . 'glyphicons-halflings-regular.ttf) format("truetype"),
                 url(' . $fonts_base_url . 'glyphicons-halflings-regular.svg#glyphicons_halflingsregular) format("svg");
        }

        @font-face {
            font-family: "FontAwesome";
            src: url(' . $fonts_base_url . 'fontawesome-webfont.eot?v=4.7.0);
            src: url(' . $fonts_base_url . 'fontawesome-webfont.eot#iefix&v=4.7.0) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'fontawesome-webfont.woff2?v=4.7.0) format("woff2"),
                 url(' . $fonts_base_url . 'fontawesome-webfont.woff?v=4.7.0) format("woff"),
                 url(' . $fonts_base_url . 'fontawesome-webfont.ttf?v=4.7.0) format("truetype"),
                 url(' . $fonts_base_url . 'fontawesome-webfont.svg?v=4.7.0#fontawesomeregular) format("svg");
            font-weight: normal;
            font-style: normal;
        }

        @font-face {
            font-family: "Ionicons";
            src: url(' . $fonts_base_url . 'ionicons.eot?v=2.0.1);
            src: url(' . $fonts_base_url . 'ionicons.eot?v=2.0.1#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'ionicons.ttf?v=2.0.1) format("truetype"),
                 url(' . $fonts_base_url . 'ionicons.woff?v=2.0.1) format("woff"),
                 url(' . $fonts_base_url . 'ionicons.svg?v=2.0.1#Ionicons) format("svg");
            font-weight: normal;
            font-style: normal;
        }

        @font-face {
            font-family: "FontAwesome";
            src: url(' . $fonts_base_url . 'fontawesome-webfont.eot);
            src: local("FontAwesome"),
                 url(' . $fonts_base_url . 'fontawesome-webfont.eot#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'fontawesome-webfont.woff2) format("woff2"),
                 url(' . $fonts_base_url . 'fontawesome-webfont.woff) format("woff"),
                 url(' . $fonts_base_url . 'fontawesome-webfont.ttf) format("truetype"),
                 url(' . $fonts_base_url . 'fontawesome-webfont.svg#fontawesomeregular) format("svg");
            font-weight: normal;
            font-style: normal;
            font-display: swap;
        }

        @font-face {
            font-family: "Nunito";
            font-style: normal;
            font-weight: 300;
            src: url(' . $fonts_base_url . 'nunito-v14-latin-300.eot);
            src: local("Nunito Light"), local("Nunito-Light"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-300.eot#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-300.woff2) format("woff2"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-300.woff) format("woff"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-300.ttf) format("truetype"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-300.svg#Nunito) format("svg");
            font-display: swap;
        }

        @font-face {
            font-family: "Nunito";
            font-style: normal;
            font-weight: 400;
            src: url(' . $fonts_base_url . 'nunito-v14-latin-regular.eot);
            src: local("Nunito Regular"), local("Nunito-Regular"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-regular.eot#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-regular.woff2) format("woff2"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-regular.woff) format("woff"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-regular.ttf) format("truetype"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-regular.svg#Nunito) format("svg");
            font-display: swap;
        }

        @font-face {
            font-family: "Nunito";
            font-style: italic;
            font-weight: 400;
            src: url(' . $fonts_base_url . 'nunito-v14-latin-italic.eot);
            src: local("Nunito Italic"), local("Nunito-Italic"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-italic.eot#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-italic.woff2) format("woff2"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-italic.woff) format("woff"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-italic.ttf) format("truetype"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-italic.svg#Nunito) format("svg");
            font-display: swap;
        }

        @font-face {
            font-family: "Nunito";
            font-style: normal;
            font-weight: 600;
            src: url(' . $fonts_base_url . 'nunito-v14-latin-600.eot);
            src: local("Nunito SemiBold"), local("Nunito-SemiBold"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-600.eot#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-600.woff2) format("woff2"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-600.woff) format("woff"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-600.ttf) format("truetype"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-600.svg#Nunito) format("svg");
            font-display: swap;
        }

        @font-face {
            font-family: "Nunito";
            font-style: normal;
            font-weight: 700;
            src: url(' . $fonts_base_url . 'nunito-v14-latin-700.eot);
            src: local("Nunito Bold"), local("Nunito-Bold"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-700.eot#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-700.woff2) format("woff2"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-700.woff) format("woff"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-700.ttf) format("truetype"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-700.svg#Nunito) format("svg");
            font-display: swap;
        }

        @font-face {
            font-family: "Nunito";
            font-style: normal;
            font-weight: 800;
            src: url(' . $fonts_base_url . 'nunito-v14-latin-800.eot);
            src: local("Nunito ExtraBold"), local("Nunito-ExtraBold"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-800.eot#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-800.woff2) format("woff2"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-800.woff) format("woff"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-800.ttf) format("truetype"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-800.svg#Nunito) format("svg");
            font-display: swap;
        }

        @font-face {
            font-family: "Nunito";
            font-style: normal;
            font-weight: 900;
            src: url(' . $fonts_base_url . 'nunito-v14-latin-900.eot);
            src: local("Nunito Black"), local("Nunito-Black"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-900.eot#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-900.woff2) format("woff2"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-900.woff) format("woff"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-900.ttf) format("truetype"),
                 url(' . $fonts_base_url . 'nunito-v14-latin-900.svg#Nunito) format("svg");
            font-display: swap;
        }

        @font-face {
            font-family: "Montserrat";
            font-style: normal;
            font-weight: 300;
            src: url(' . $fonts_base_url . 'montserrat-v15-latin-300.eot);
            src: local("Montserrat Light"), local("Montserrat-Light"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-300.eot#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-300.woff2) format("woff2"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-300.woff) format("woff"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-300.ttf) format("truetype"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-300.svg#Montserrat) format("svg");
            font-display: swap;
        }

        @font-face {
            font-family: "Montserrat";
            font-style: normal;
            font-weight: 400;
            src: url(' . $fonts_base_url . 'montserrat-v15-latin-regular.eot);
            src: local("Montserrat Regular"), local("Montserrat-Regular"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-regular.eot#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-regular.woff2) format("woff2"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-regular.woff) format("woff"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-regular.ttf) format("truetype"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-regular.svg#Montserrat) format("svg");
            font-display: swap;
        }

        @font-face {
            font-family: "Montserrat";
            font-style: normal;
            font-weight: 500;
            src: url(' . $fonts_base_url . 'montserrat-v15-latin-500.eot);
            src: local("Montserrat Medium"), local("Montserrat-Medium"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-500.eot#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-500.woff2) format("woff2"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-500.woff) format("woff"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-500.ttf) format("truetype"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-500.svg#Montserrat) format("svg");
            font-display: swap;
        }

        @font-face {
            font-family: "Montserrat";
            font-style: italic;
            font-weight: 400;
            src: url(' . $fonts_base_url . 'montserrat-v15-latin-italic.eot);
            src: local("Montserrat Italic"), local("Montserrat-Italic"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-italic.eot#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-italic.woff2) format("woff2"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-italic.woff) format("woff"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-italic.ttf) format("truetype"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-italic.svg#Montserrat) format("svg");
            font-display: swap;
        }

        @font-face {
            font-family: "Montserrat";
            font-style: normal;
            font-weight: 600;
            src: url(' . $fonts_base_url . 'montserrat-v15-latin-600.eot);
            src: local("Montserrat SemiBold"), local("Montserrat-SemiBold"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-600.eot#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-600.woff2) format("woff2"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-600.woff) format("woff"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-600.ttf) format("truetype"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-600.svg#Montserrat) format("svg");
            font-display: swap;
        }

        @font-face {
            font-family: "Montserrat";
            font-style: normal;
            font-weight: 700;
            src: url(' . $fonts_base_url . 'montserrat-v15-latin-700.eot);
            src: local("Montserrat Bold"), local("Montserrat-Bold"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-700.eot#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-700.woff2) format("woff2"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-700.woff) format("woff"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-700.ttf) format("truetype"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-700.svg#Montserrat) format("svg");
            font-display: swap;
        }

        @font-face {
            font-family: "Montserrat";
            font-style: normal;
            font-weight: 800;
            src: url(' . $fonts_base_url . 'montserrat-v15-latin-800.eot);
            src: local("Montserrat ExtraBold"), local("Montserrat-ExtraBold"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-800.eot#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-800.woff2) format("woff2"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-800.woff) format("woff"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-800.ttf) format("truetype"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-800.svg#Montserrat) format("svg");
            font-display: swap;
        }

        @font-face {
            font-family: "Montserrat";
            font-style: normal;
            font-weight: 900;
            src: url(' . $fonts_base_url . 'montserrat-v15-latin-900.eot);
            src: local("Montserrat Black"), local("Montserrat-Black"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-900.eot#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-900.woff2) format("woff2"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-900.woff) format("woff"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-900.ttf) format("truetype"),
                 url(' . $fonts_base_url . 'montserrat-v15-latin-900.svg#Montserrat) format("svg");
            font-display: swap;
        }

        @font-face {
            font-family: "iot-fonts";
            src: url(' . $fonts_base_url . 'iot-fonts.eot?sex6nu=);
            src: url(' . $fonts_base_url . 'iot-fonts.eot?sex6nu=#iefix) format("embedded-opentype"),
                 url(' . $fonts_base_url . 'iot-fonts.ttf?sex6nu=) format("truetype"),
                 url(' . $fonts_base_url . 'iot-fonts.woff?sex6nu=) format("woff"),
                 url(' . $fonts_base_url . 'iot-fonts.svg?sex6nu=#iot-fonts) format("svg");
            font-weight: normal;
            font-style: normal;
            font-display: block;
        }';
    
    return $css;
}