/**
 * WTE Business Card — Email Protection JS (ROT13 decode)
 */
'use strict';
document.addEventListener('DOMContentLoaded', function() {
	function rot13(str) {
		return str.replace(/[a-zA-Z]/g, function(c) {
			return String.fromCharCode((c <= 'Z' ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26);
		});
	}
	// Reveal email text.
	document.querySelectorAll('.wte-email-protect').forEach(function(el) {
		const user = rot13(el.dataset.user || '');
		const domain = rot13(el.dataset.domain || '');
		if (user && domain) { el.textContent = user + '@' + domain; }
	});
	// Reveal mailto link.
	document.querySelectorAll('.wte-contact__email-btn').forEach(function(btn) {
		btn.addEventListener('click', function(e) {
			e.preventDefault();
			const user = rot13(btn.dataset.user || '');
			const domain = rot13(btn.dataset.domain || '');
			if (user && domain) { window.location.href = 'mailto:' + user + '@' + domain; }
		});
	});
});
