/*------------------------------------------------------------------------------
# Colors
------------------------------------------------------------------------------*/

/*
 * Default contrast (text) and/or highlight (link, button) color based on 
 * background color.
 * 
 * Set these in theme.json:
 *		--wp--custom--color--contrast--{color-group}
 *		--wp--custom--color--highlight--{color-group}
 * 
 * {color-group}: primary, secondary, tertiary, neutral, dark, foreground-alt
 */

/*-----------------------------------------------------------------------------
# Default Contrast color
-----------------------------------------------------------------------------*/

/* Accent colored backgrounds use foreground-alt color unless over-ridden */
.has-primary-background-color, 
.has-primary-alt-background-color {
     color: var(--wp--custom--color--contrast--primary, var(--wp--preset--color--foreground-alt));
}

.has-secondary-background-color, 
.has-secondary-alt-background-color {
     color: var(--wp--custom--color--contrast--secondary, var(--wp--preset--color--foreground-alt));
}

.has-tertiary-background-color, 
.has-tertiary-alt-background-color {
     color: var(--wp--custom--color--contrast--tertiary, var(--wp--preset--color--foreground-alt));
}

/* Neutral colored backgrounds use black color unless over-ridden */
.has-neutral-background-color.has-background, 
.has-neutral-alt-background-color.has-background {
     color: var(--wp--custom--color--contrast--neutral, var(--wp--preset--color--almost-black));
}

/* Dark colored backgrounds use white color unless over-ridden */
.has-dark-background-color, 
.has-dark-alt-background-color {
     color: var(--wp--custom--color--contrast--dark, var(--wp--preset--color--off-white));
}

/* Light-colored backgrounds use black color */
.has-white-background-color.has-background, 
.has-off-white-background-color.has-background, 
.has-light-yellow-background-color.has-background, 
.has-yellow-background-color.has-background, 
.has-very-light-gray-background-color.has-background, 
.has-light-gray-background-color.has-background, 
.has-gray-background-color.has-background {
     color: var(--wp--preset--color--almost-black);
}

/* Foreground Alt is normally light, but allow override if it is dark */
.has-foreground-alt-background-color.has-background {
	color: var(--wp--custom--color--contrast--foreground-alt, var(--wp--preset--color--contrast));
}

/* Invert contrast and base colors */
.has-base-background-color.has-background {
     color: var(--wp--preset--color--contrast);
}

.has-contrast-background-color.has-background {
     color: var(--wp--preset--color--base);
}

/*-----------------------------------------------------------------------------
# Default link color
-----------------------------------------------------------------------------*/

/* Inherit link color on backgrounds except very light or very dark */
.has-background:not(.has-base-background-color, .has-white-background-color, .has-off-white-background-color, .has-very-light-gray-background-color, .has-light-gray-background-color, .has-gray-background-color, .has-neutral-background-color, .has-neutral-alt-background-color, .has-dark-background-color, .has-dark-alt-background-color, .has-almost-black-background-color, .has-not-quite-black-background-color, .has-black-background-color) {
	& a:not(.wp-element-button) {
     	color: inherit;
    }	
}

/*-----------------------------------------------------------------------------
# Default Contrast Color on Gradients
-----------------------------------------------------------------------------*/
/* Set the text color on gradient backgrounds */
:root :where([class*="-gradient-background"]:not(.has-gray-gradient-background):not(.has-yellow-gradient-background)) {
	color: var(--wp--preset--color--foreground-alt); 
}

:root :where(.has-primary-gradient-background, .has-primary-to-secondary-gradient-background, .has-secondary-to-primary-gradient-background, .has-primary-to-tertiary-gradient-background, .has-tertiary-to-primary-gradient-background) {
	color: var(--wp--custom--color--contrast--primary, var(--wp--preset--color--foreground-alt));
}

:root :where(.has-secondary-gradient-background, .has-secondary-to-tertiary-gradient-background, .has-tertiary-to-secondary-gradient-background) {
	color: var(--wp--custom--color--contrast--secondary, var(--wp--preset--color--foreground-alt));
}

:root :where(.has-tertiary-gradient-background) {
	color: var(--wp--custom--color--contrast--tertiary, var(--wp--preset--color--foreground-alt));
}

/*-----------------------------------------------------------------------------
# Default Link Color on Gradients
-----------------------------------------------------------------------------*/

/* Inherit the link and outline button color on gradient backgrounds */
:root :where([class*=-gradient-background]) {
	& a:where(:not(.wp-element-button)),
	& .is-style-outline > .wp-element-button, 
	& [class*="is-style-button-outline-"] > .wp-element-button {	
		color: inherit;
	}
}
