<?php
/**
 * The template for displaying the footer
 *
 * Contains the closing of the #content div and all content after
 *
 * @package WordPress
 * @subpackage Twenty_Sixteen
 * @since Twenty Sixteen 1.0
 */
?>

		</div><!-- .site-content -->
	
	</div><!-- .site-inner -->
    
    <footer id="colophon" class="site-footer" role="contentinfo">
			<div class="site-inner">
            	<div class="copright"><?php if ( function_exists ( dynamic_sidebar('sidebar-2') ) ) : ?> <?php endif; ?></div>
            </div>
		</footer><!-- .site-footer -->
    
</div><!-- .site -->

<?php wp_footer(); ?>
<script>
document.addEventListener('DOMContentLoaded', () => {
  const btn = document.getElementById('holdButton');
  const input = document.getElementById('holdCaptchaVerified');
  const captchaDiv = document.getElementById('holdCaptcha');
  const loaderBox = document.getElementById('loaderBox');
  const tickMark = document.getElementById('tickMark');
  const successText = document.getElementById('successText');

  let timer;

  btn.addEventListener('mousedown', start);
  btn.addEventListener('touchstart', start, { passive: false });

  btn.addEventListener('mouseup', stop);
  btn.addEventListener('mouseleave', stop);
  btn.addEventListener('touchend', stop);
  btn.addEventListener('touchcancel', stop);

  function start(e) {
    e.preventDefault();
    if (btn.disabled) return;

    // Reset animation
    loaderBox.classList.remove('animating');
    void loaderBox.offsetWidth; // Force reflow
    loaderBox.classList.add('animating');

    // Hide success UI initially
    tickMark.style.display = 'none';
    successText.style.display = 'none';

    // Start 3-second timer
    timer = setTimeout(() => {
      // Success logic
      input.value = 'true';
      btn.textContent = 'Press and Hold';
      btn.disabled = true;

      loaderBox.classList.remove('animating');
      tickMark.style.display = 'block';
      successText.textContent = 'Verified! You passed the CAPTCHA.';
      successText.style.display = 'block';
      // Remove error message if present
      const errorTip = captchaDiv.querySelector('.wpcf7-not-valid-press-captcha');
      if (errorTip) errorTip.remove();
    }, 3000);
  }
  function stop() {
    clearTimeout(timer);
    if (input.value !== 'true') {
      loaderBox.classList.remove('animating');
    }
  }
});



document.addEventListener('wpcf7invalid', function (event) {
  const captchaDiv = event.target.querySelector('#holdCaptcha');
  const input = event.target.querySelector('#holdCaptchaVerified');

  if (captchaDiv && input && input.value !== 'true') {
    if (!captchaDiv.querySelector('.wpcf7-not-valid-press-captcha')) {
      const tip = document.createElement('span');
      tip.className = 'wpcf7-not-valid-press-captcha';
      tip.setAttribute('aria-hidden', 'true');
      tip.textContent = 'Please complete the CAPTCHA';
      captchaDiv.appendChild(tip);
    }
  }
}, false);


</script>
</body>
</html>
