(function () {
	document.querySelectorAll( 'input[name^="ccgal_text_override["], textarea[name^="ccgal_text_override["]' ).forEach( function ( el ) {
		var def  = el.getAttribute( 'data-ccgal-default' ) || '';
		var hint = el.parentNode.querySelector( '.ccgal-override-default-hint' );
		var sync = function () {
			var matchesDefault = ( def !== '' && el.value === def );
			el.style.color     = matchesDefault ? '#7a756c' : '';
			el.style.fontStyle = matchesDefault ? 'italic'  : '';
			if ( hint ) {
				hint.style.display = matchesDefault ? 'block' : 'none';
			}
		};
		el.addEventListener( 'input', sync );
		sync();
	} );
})();
