<?php

/**
 * Dynamic CSS
 */
function resort_motel_dynamic_css() {
	$resort_motel_primary_color = get_theme_mod( 'resort_motel_primary_color', '#2eb0d0' );

	$resort_motel_site_title_font       = get_theme_mod( 'resort_motel_site_title_font', 'Raleway' );
	$resort_motel_site_description_font = get_theme_mod( 'resort_motel_site_description_font', 'Raleway' );
	$resort_motel_header_font           = get_theme_mod( 'resort_motel_header_font', 'Playfair Display' );
	$resort_motel_content_font             = get_theme_mod( 'resort_motel_content_font', 'Poppins' );

	// Enqueue Google Fonts
	$resort_motel_fonts_url = resort_motel_get_fonts_url();
	if ( ! empty( $resort_motel_fonts_url ) ) {
		wp_enqueue_style( 'resort-motel-google-fonts', esc_url( $resort_motel_fonts_url ), array(), null );
	}

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

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

    body,
	button, input, select, optgroup, textarea, p {
        font-family: "' . esc_attr( $resort_motel_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( $resort_motel_site_title_font ) . '", serif;
	}
    
	p.site-description {
        font-family: "' . esc_attr( $resort_motel_site_description_font ) . '", serif !important;
	}
    ';

	wp_add_inline_style( 'resort-motel-style', $resort_motel_custom_css );
}
add_action( 'wp_enqueue_scripts', 'resort_motel_dynamic_css', 99 );