<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>Domain Intercepted by 301Domains</title>
  <meta name="description" content="This domain has been intercepted by 301Domains." />
  <link rel="icon" type="image/webp" href="30favi.webp" />
  <link rel="preconnect" href="https://fonts.googleapis.com" />
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
  <link rel="stylesheet" href="styles.css?v=5" />

  <!-- Yandex.Metrika counter -->
  <script type="text/javascript">
      (function(m,e,t,r,i,k,a){
          m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
          m[i].l=1*new Date();
          for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
          k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)
      })(window, document,'script','https://mc.yandex.ru/metrika/tag.js?id=106900229', 'ym');

      ym(106900229, 'init', {ssr:true, webvisor:true, clickmap:true, ecommerce:"dataLayer", referrer: document.referrer, url: location.href, accurateTrackBounce:true, trackLinks:true});
  </script>
  <noscript><div><img src="https://mc.yandex.ru/watch/106900229" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
  <!-- /Yandex.Metrika counter -->
</head>
<body>
  <main class="page">
    <section class="card" aria-label="Domain status">
      <img src="logo.svg" alt="301 Domains" class="logo" />

      <p class="eyebrow">301Domains</p>
      <h1>
        <span id="domainName">This domain</span>
        <span class="subtitle">intercepted by 301Domains</span>
      </h1>
      <p class="lead">
        This domain has been intercepted by 301Domains through our infrastructure.
      </p>

      <a class="cta" href="https://301domains.com/" target="_blank" rel="noopener noreferrer">
        Buy domains at 301domains.com
      </a>

      <div class="divider"></div>

      <h2 class="form-heading">Interested in this domain?</h2>
      <p class="form-desc">
        Leave your contact details and offer — we'll get back to you.
      </p>

      <form id="contactForm" class="offer-form" method="POST" action="submit.php">
        <input type="hidden" name="domain" id="formDomain" value="" />
        <input type="hidden" name="lang" id="formLang" value="" />

        <div class="form-grid">
          <div class="form-group">
            <label for="name">Your name</label>
            <input type="text" id="name" name="name" placeholder="John Smith" required />
          </div>

          <div class="form-group">
            <label for="contact">Email or Telegram</label>
            <input type="text" id="contact" name="contact" placeholder="email@example.com or @username" required />
          </div>
        </div>

        <div class="form-group form-group--full">
          <label for="price">Your offer (USD)</label>
          <input type="number" id="price" name="price" inputmode="numeric" placeholder="e.g. 500 (min $ 100 )" required min="100" />
        </div>

        <!-- Honeypot: hidden from humans, bots fill it -->
        <div style="position:absolute;left:-9999px;top:-9999px;" aria-hidden="true">
          <input type="text" name="website" id="website" tabindex="-1" autocomplete="off" />
        </div>
        <input type="hidden" name="_ts" id="formTs" value="" />

        <!-- Anti-bot checkbox with math challenge -->
        <div class="captcha-box" id="captchaBox">
          <div class="captcha-main">
            <label class="captcha-label">
              <input type="checkbox" id="notRobot" />
              <span class="captcha-checkmark">
                <svg class="captcha-tick" viewBox="0 0 24 24" fill="none"><path d="M5 13l4 4L19 7" stroke="#fff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></svg>
              </span>
              <span class="captcha-text">I'm not a robot</span>
            </label>
            <div class="captcha-brand">
              <svg class="captcha-shield" viewBox="0 0 24 24" fill="none" width="28" height="28"><path d="M12 2L3 7v5c0 5.25 3.83 10.17 9 11.38C17.17 22.17 21 17.25 21 12V7l-9-5z" fill="rgba(40,167,69,0.12)" stroke="rgb(40,167,69)" stroke-width="1.5"/><path d="M9 12l2 2 4-4" stroke="rgb(40,167,69)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
              <span class="captcha-brand-text">Anti-spam</span>
            </div>
          </div>
          <div id="captchaChallenge" class="captcha-challenge" style="display:none;">
            <div class="captcha-challenge-inner">
              <span class="captcha-hint">Quick check — solve this:</span>
              <div class="captcha-math">
                <span id="captchaQuestion" class="captcha-question"></span>
                <input type="text" id="captchaAnswer" name="captcha_answer" inputmode="numeric" placeholder="?" autocomplete="off" maxlength="3" />
              </div>
            </div>
            <input type="hidden" name="captcha_expected" id="captchaExpected" value="" />
          </div>
        </div>

        <button type="submit" class="cta cta--submit">Send offer</button>
        <div id="formStatus" class="form-status"></div>
      </form>

      <p class="note">
        Interested in premium domains and expiring auctions? Visit our platform.
      </p>
    </section>
  </main>

  <script>
    (function () {
      const host = window.location.hostname;
      const domainEl = document.getElementById('domainName');
      const formDomainEl = document.getElementById('formDomain');
      document.getElementById('formLang').value = navigator.language;

      if (!domainEl) return;

      if (!host || host === 'localhost' || host === '127.0.0.1') {
        domainEl.textContent = 'This domain';
      } else {
        domainEl.textContent = host;
        if (formDomainEl) formDomainEl.value = host;
      }

      function fitText() {
        const card = domainEl.parentElement && domainEl.parentElement.closest ? domainEl.parentElement.closest('.card') : document.querySelector('.card');
        if (!card) return;
        const style = window.getComputedStyle(card);
        const padL = parseFloat(style.paddingLeft) || 0;
        const padR = parseFloat(style.paddingRight) || 0;
        const maxW = card.clientWidth - padL - padR;
        if (maxW <= 0) return;

        const size = 42;
        const minSize = 14;
        domainEl.style.fontSize = size + 'px';

        while (domainEl.scrollWidth > maxW && size > minSize) {
          size--;
          domainEl.style.fontSize = size + 'px';
        }
      }

      // Run after full layout
      if (document.readyState === 'complete') {
        fitText();
      } else {
        window.addEventListener('load', fitText);
      }
      window.addEventListener('resize', fitText);

      // Set form timestamp for anti-bot
      const tsField = document.getElementById('formTs');
      if (tsField) tsField.value = Date.now();

      // Price field: allow only digits
      const priceField = document.getElementById('price');
      if (priceField) {
        priceField.addEventListener('input', function() {
          this.value = this.value.replace(/[^0-9]/g, '');
        });
      }

      // Contact field validation: email or @telegram
      function isValidContact(val) {
        val = val.trim();
        // Telegram: @username (5-32 chars, alphanumeric + underscore)
        if (/^@[a-zA-Z][a-zA-Z0-9_]{4,31}$/.test(val)) return true;
        // Email
        if (/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(val)) return true;
        return false;
      }

      // Anti-bot math captcha
      const notRobotCb = document.getElementById('notRobot');
      const challengeDiv = document.getElementById('captchaChallenge');
      const questionEl = document.getElementById('captchaQuestion');
      const answerEl = document.getElementById('captchaAnswer');
      const expectedEl = document.getElementById('captchaExpected');
      var captchaSolved = false;

      if (notRobotCb) {
        notRobotCb.addEventListener('change', function() {
          if (this.checked && !captchaSolved) {
            const a = Math.floor(Math.random() * 10) + 1;
            const b = Math.floor(Math.random() * 10) + 1;
            questionEl.textContent = a + ' + ' + b + ' =';
            expectedEl.value = String(a + b);
            challengeDiv.style.display = 'flex';
            answerEl.value = '';
            answerEl.focus();
          } else if (!this.checked) {
            challengeDiv.style.display = 'none';
            captchaSolved = false;
          }
        });
      }

      if (answerEl) {
        answerEl.addEventListener('input', function() {
          if (answerEl.value.trim() === expectedEl.value) {
            captchaSolved = true;
            challengeDiv.style.display = 'none';
            notRobotCb.checked = true;
            const box = document.getElementById('captchaBox');
            if (box) box.classList.add('captcha-solved');
          }
        });
      }

      // Form AJAX submit
      const form = document.getElementById('contactForm');
      const statusEl = document.getElementById('formStatus');
      if (form) {
        form.addEventListener('submit', function(e) {
          e.preventDefault();
          const btn = form.querySelector('button[type="submit"]');
          statusEl.className = 'form-status';
          statusEl.textContent = '';

          // Validate contact
          const contactVal = document.getElementById('contact').value;
          if (!isValidContact(contactVal)) {
            statusEl.className = 'form-status form-status--err';
            statusEl.textContent = 'Please enter a valid email (user@example.com) or Telegram (@username).';
            return;
          }

          // Validate price: digits only, > 0
          const priceVal = document.getElementById('price').value.trim();
          if (!/^[0-9]+$/.test(priceVal) || parseInt(priceVal, 10) <= 0) {
            statusEl.className = 'form-status form-status--err';
            statusEl.textContent = 'Please enter a valid offer amount (digits only).';
            return;
          }

          // Check captcha
          if (!captchaSolved) {
            statusEl.className = 'form-status form-status--err';
            statusEl.textContent = 'Please confirm that you are not a robot.';
            return;
          }

          btn.disabled = true;
          btn.textContent = 'Sending...';

          const data = new FormData(form);
          const xhr = new XMLHttpRequest();
          xhr.open('POST', 'submit.php', true);
          xhr.setRequestHeader('Accept', 'application/json');
          xhr.onload = function() {
            try {
              var res = JSON.parse(xhr.responseText);
              if (xhr.status === 200 && res.success) {
                statusEl.className = 'form-status form-status--ok';
                statusEl.textContent = res.message || 'Thank you! We will contact you soon.';
                form.reset();
                if (formDomainEl) formDomainEl.value = host;
              } else {
                statusEl.className = 'form-status form-status--err';
                statusEl.textContent = res.message || 'Something went wrong. Please try again.';
              }
            } catch(_) {
              statusEl.className = 'form-status form-status--err';
              statusEl.textContent = 'Server error. Please try again later.';
            }
            btn.disabled = false;
            btn.textContent = 'Send offer';
          };
          xhr.onerror = function() {
            statusEl.className = 'form-status form-status--err';
            statusEl.textContent = 'Network error. Please try again.';
            btn.disabled = false;
            btn.textContent = 'Send offer';
          };
          xhr.send(data);
        });
      }
    })();
  </script>
</body>
</html>