/**
 * Build the styles used inside Adyen's secured-field iframes.
 *
 * CSS inheritance cannot cross an iframe boundary, so copy the host theme's
 * computed typography and text colour into Adyen's supported styles object.
 *
 * @param {HTMLElement} container Card component mount point.
 * @return {Object} Adyen secured-field styles.
 */
export function getAdyenCardStyles( container ) {
	if ( ! container || ! window.getComputedStyle ) {
		return {};
	}

	const computedStyle = window.getComputedStyle( container );
	const base = {
		background: 'transparent',
		color: computedStyle.color,
		fontFamily: computedStyle.fontFamily,
		fontSize: computedStyle.fontSize,
		fontStyle: computedStyle.fontStyle,
		fontWeight: computedStyle.fontWeight,
		letterSpacing: computedStyle.letterSpacing,
		lineHeight: computedStyle.lineHeight,
		webkitFontSmoothing: 'antialiased',
	};

	return {
		base,
		validated: {
			color: computedStyle.color,
		},
	};
}
