document.addEventListener('DOMContentLoaded', function () {
var form = document.getElementById('event-rsvp-form');
if (!form) return;
var submit = document.getElementById('rsvp-submit');
var thankYou = document.getElementById('thank-you-msg');
var upsell = document.getElementById('upsell-products');
form.addEventListener('submit', function (e) {
e.preventDefault();
if (submit) submit.disabled = true;
// hide form card
var card = form.closest('.rsvp-form-container');
if (card) card.style.display = 'none';
// show thank-you + upsell (toggle with style.display in case "hidden" is ignored)
if (thankYou) {
thankYou.style.display = '';
if (typeof thankYou.focus === 'function') thankYou.focus();
}
if (upsell) upsell.style.display = '';
var target = upsell || thankYou;
if (target && typeof target.scrollIntoView === 'function') {
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
});
});