<?php
/**
 * Dynamic CSS
 */
function jeweler_shop_dynamic_css() {
	$jeweler_shop_primary_color = get_theme_mod( 'jeweler_shop_primary_color', '#314B4C' );
	$jeweler_shop_secondary_color = get_theme_mod( 'jeweler_shop_secondary_color', '#F1C1BD' );
	$jeweler_shop_tertiary_color = get_theme_mod( 'jeweler_shop_tertiary_color', '#182C2B' );

	$jeweler_shop_site_title_font       = get_theme_mod( 'jeweler_shop_site_title_font', 'Jost' );
	$jeweler_shop_site_description_font = get_theme_mod( 'jeweler_shop_site_description_font', 'Playfair Display' );
	$jeweler_shop_header_font           = get_theme_mod( 'jeweler_shop_header_font', 'Jost' );
	$jeweler_shop_content_font          = get_theme_mod( 'jeweler_shop_content_font', 'Playfair Display' );

	// Enqueue Google Fonts
	$jeweler_shop_fonts_url = jeweler_shop_get_fonts_url();
	if ( ! empty( $jeweler_shop_fonts_url ) ) {
		wp_enqueue_style( 'jeweler-shop-google-fonts', esc_url( $jeweler_shop_fonts_url ), array(), null );
	}

	$jeweler_shop_custom_css  = '';
	$jeweler_shop_custom_css .= '
    /* Color */
    :root {
        --primary-color: ' . esc_attr( $jeweler_shop_primary_color ) . ';
        --header-text-color: ' . esc_attr( '#' . get_header_textcolor() ) . ';

		--secondary-color: ' . esc_attr( $jeweler_shop_secondary_color ) . ';

		--tertiary-color: ' . esc_attr( $jeweler_shop_tertiary_color ) . ';
    }
    ';

	$jeweler_shop_custom_css .= '
    /* Typography */
    :root {
        --font-heading: "' . esc_attr( $jeweler_shop_content_font ) . '", serif;
        --font-main: -apple-system, BlinkMacSystemFont, "' . esc_attr( $jeweler_shop_header_font) . '", "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    }

    body,
	button, input, select, optgroup, textarea, p {
        font-family: "' . esc_attr( $jeweler_shop_content_font ) . '", serif;
	}

	.site-identity p.site-title, h1.site-title a, h1.site-title, p.site-title a, .site-branding h1.site-title a, header.site-header .header-main-wrapper:not(.transparent-header) .bottom-header-outer-wrapper .bottom-header-part .bottom-header-part-wrapper .site-branding .site-identity .site-title .banner-text {
        font-family: "' . esc_attr( $jeweler_shop_site_title_font ) . '", serif;
	}
    
	p.site-description {
        font-family: "' . esc_attr( $jeweler_shop_site_description_font ) . '", serif !important;
	}
    ';

	wp_add_inline_style( 'jeweler-shop-style', $jeweler_shop_custom_css );
}
add_action( 'wp_enqueue_scripts', 'jeweler_shop_dynamic_css', 99 );