<?php

/**
 * Dynamic CSS
 */
function bridal_jewelry_store_dynamic_css() {
	$bridal_jewelry_store_primary_color = get_theme_mod( 'bridal_jewelry_store_primary_color', '#BC913E' );

	$bridal_jewelry_store_site_title_font       = get_theme_mod( 'bridal_jewelry_store_site_title_font', 'Raleway' );
	$bridal_jewelry_store_site_description_font = get_theme_mod( 'bridal_jewelry_store_site_description_font', 'Raleway' );
	$bridal_jewelry_store_header_font           = get_theme_mod( 'bridal_jewelry_store_header_font', 'Cinzel' );
	$bridal_jewelry_store_content_font             = get_theme_mod( 'bridal_jewelry_store_content_font', 'Tenor Sans' );

	// Enqueue Google Fonts
	$bridal_jewelry_store_fonts_url = bridal_jewelry_store_get_fonts_url();
	if ( ! empty( $bridal_jewelry_store_fonts_url ) ) {
		wp_enqueue_style( 'bridal-jewelry-store-google-fonts', esc_url( $bridal_jewelry_store_fonts_url ), array(), null );
	}

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

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

    body,
	button, input, select, optgroup, textarea, p, a, .mag-post-excerpt, .tab-product .product-image .box-content.intro-button a.button.product_type_simple.add_to_cart_button.ajax_add_to_cart, .tab-product .product-image .box-content.intro-button a.added_to_cart.wc-forward{
        font-family: "' . esc_attr( $bridal_jewelry_store_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 {
        font-family: "' . esc_attr( $bridal_jewelry_store_site_title_font ) . '", serif;
	}
    
	p.site-description {
        font-family: "' . esc_attr( $bridal_jewelry_store_site_description_font ) . '", serif !important;
	}
    ';

	wp_add_inline_style( 'bridal-jewelry-store-style', $bridal_jewelry_store_custom_css );
}
add_action( 'wp_enqueue_scripts', 'bridal_jewelry_store_dynamic_css', 99 );