<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title id="page-title"></title>
  <meta name="robots" content="noindex">
  <meta name="theme-color" content="#fbf9f8">
  <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&family=Fraunces:opsz,wght@9..144,400&display=swap" rel="stylesheet">
  <style>
    * { margin: 0; padding: 0; box-sizing: border-box; }
    html, body {
      min-height: 100%;
      background: #fbf9f8;
      color: #1a1a1a;
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
      -webkit-font-smoothing: antialiased;
    }
    body { min-height: 100vh; display: flex; flex-direction: column; }
    [hidden] { display: none !important; }

    /* Coming-soon layout */
    .cs-root {
      flex: 1;
      display: flex; align-items: center; justify-content: center;
      padding: 48px 24px;
    }
    .cs-box { text-align: center; max-width: 560px; }
    .cs-domain {
      font-family: 'Fraunces', 'EB Garamond', Georgia, 'Times New Roman', serif;
      font-size: clamp(40px, 9vw, 68px);
      font-weight: 400; letter-spacing: -0.02em; line-height: 1.05;
      margin: 0 0 24px; color: #1a1a1a; word-break: break-word;
      font-variation-settings: "opsz" 144;
    }
    .cs-rule {
      width: 32px; height: 1px; background: #d8d5d0;
      margin: 0 auto 24px;
    }
    .cs-tag {
      font-size: 11px; font-weight: 500;
      letter-spacing: 0.26em; text-transform: uppercase;
      color: #a8a8a8;
      margin: 0;
    }

    /* Inquiry layout */
    .inq-root {
      flex: 1;
      display: flex; align-items: center; justify-content: center;
      padding: 48px 24px 80px;
    }
    .inq-card { width: 100%; max-width: 420px; }
    .inq-title {
      font-family: 'Fraunces', 'EB Garamond', Georgia, 'Times New Roman', serif;
      font-size: clamp(38px, 8vw, 56px);
      font-weight: 400; letter-spacing: -0.02em; line-height: 1.05;
      margin: 0 0 14px; text-align: center; color: #1a1a1a;
      word-break: break-word;
      font-variation-settings: "opsz" 144;
    }
    .inq-subtitle {
      font-size: 11px; font-weight: 500;
      letter-spacing: 0.22em; text-transform: uppercase;
      color: #a8a8a8;
      margin: 0 0 56px; text-align: center;
    }
    .inq-form { display: flex; flex-direction: column; gap: 28px; }
    .field { display: flex; flex-direction: column; gap: 8px; }
    .field > span {
      font-size: 10px; font-weight: 500;
      letter-spacing: 0.16em; text-transform: uppercase;
      color: #9a9a9a;
    }
    .field input, .field textarea {
      width: 100%; box-sizing: border-box;
      padding: 12px 14px;
      font-size: 15px; font-family: inherit; color: #1a1a1a;
      background: #ffffff;
      border: 1px solid #e0ddd7;
      border-radius: 8px;
      outline: none;
      transition: border-color 0.2s ease, box-shadow 0.2s ease;
      resize: none;
    }
    .field input::placeholder, .field textarea::placeholder { color: #c8c4be; }
    .field input:hover, .field textarea:hover { border-color: #c8c4be; }
    .field input:focus, .field textarea:focus {
      border-color: #1a1a1a;
      box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.06);
    }
    .field textarea { min-height: 120px; line-height: 1.5; }
    .field input:-webkit-autofill, .field textarea:-webkit-autofill {
      -webkit-box-shadow: 0 0 0 1000px #ffffff inset;
      -webkit-text-fill-color: #1a1a1a;
    }
    .inq-submit {
      margin-top: 16px;
      padding: 14px 20px;
      font-size: 12px; font-weight: 600; font-family: inherit;
      letter-spacing: 0.18em; text-transform: uppercase;
      color: #fbf9f8; background: #1a1a1a;
      border: none; border-radius: 2px;
      cursor: pointer;
      transition: transform 0.2s ease, background 0.2s ease;
    }
    .inq-submit:hover:not(:disabled) { background: #000; transform: translateY(-1px); }
    .inq-submit:disabled { background: #d8d5d0; cursor: not-allowed; }
    .inq-error {
      font-size: 12px; color: #8a3a2f;
      padding: 10px 14px; background: #f5ebe6;
      border-left: 2px solid #8a3a2f;
      letter-spacing: 0.01em;
    }
    .inq-thanks {
      display: flex; flex-direction: column; align-items: center; gap: 24px;
      padding: 40px 0 8px;
    }
    .inq-thanks-icon {
      color: #1a1a1a;
      width: 56px; height: 56px; border-radius: 50%;
      border: 1px solid #1a1a1a;
      display: flex; align-items: center; justify-content: center;
    }
    .inq-thanks-icon svg { width: 24px; height: 24px; }
    .inq-thanks-text {
      margin: 0;
      font-family: 'Fraunces', 'EB Garamond', Georgia, serif;
      font-weight: 400; font-size: 20px; letter-spacing: -0.01em;
      color: #1a1a1a;
    }
    .inq-link {
      background: none; border: none;
      font-size: 11px; font-weight: 500;
      letter-spacing: 0.14em; text-transform: uppercase;
      color: #9a9a9a; text-decoration: none;
      cursor: pointer; padding: 8px 4px; font-family: inherit;
      border-bottom: 1px solid transparent;
      transition: color 0.15s, border-color 0.15s;
    }
    .inq-link:hover { color: #1a1a1a; border-bottom-color: #1a1a1a; }
  </style>
</head>
<body>
  <div id="coming-soon" class="cs-root" hidden>
    <div class="cs-box">
      <h1 class="cs-domain" id="cs-domain"></h1>
      <div class="cs-rule"></div>
      <p class="cs-tag">Coming soon</p>
    </div>
  </div>

  <div id="inquiry" class="inq-root">
    <div class="inq-card">
      <h1 class="inq-title" id="inq-domain"></h1>
      <p class="inq-subtitle">Contact</p>

      <form id="inq-form" class="inq-form">
        <label class="field">
          <span>Name</span>
          <input type="text" name="name" autocomplete="name">
        </label>
        <label class="field">
          <span>Email</span>
          <input type="email" name="email" autocomplete="email">
        </label>
        <label class="field">
          <span>Message</span>
          <textarea name="message" rows="4" required></textarea>
        </label>
        <div class="inq-error" id="inq-error" hidden></div>
        <button type="submit" class="inq-submit" id="inq-submit">Submit</button>
      </form>

      <div class="inq-thanks" id="inq-thanks" hidden>
        <div class="inq-thanks-icon">
          <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>
        </div>
        <p class="inq-thanks-text">Thanks, we'll get back to you.</p>
        <button class="inq-link" id="inq-another">Send another message</button>
      </div>
    </div>
  </div>

  <script>
    (function () {
      var API = 'https://inquiry-api.07007com.workers.dev';
      var BLOCKED = ['bidu.com', 'yzy.com'];
      var host = location.hostname.replace(/^www\./, '');
      document.getElementById('page-title').textContent = host;

      if (BLOCKED.indexOf(host) !== -1) {
        document.getElementById('coming-soon').hidden = false;
        document.getElementById('inquiry').hidden = true;
        document.getElementById('cs-domain').textContent = host;
        return;
      }

      document.getElementById('inq-domain').textContent = host;

      var fp = localStorage.getItem('_as_fp');
      if (!fp) {
        fp = (crypto && crypto.randomUUID ? crypto.randomUUID() : String(Date.now()) + Math.random())
          .replace(/-/g, '');
        try { localStorage.setItem('_as_fp', fp); } catch (_) {}
      }
      fetch(API + '/api/t', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ d: host, f: fp })
      }).catch(function () {});

      var form = document.getElementById('inq-form');
      var errorEl = document.getElementById('inq-error');
      var thanks = document.getElementById('inq-thanks');
      var submitBtn = document.getElementById('inq-submit');
      var another = document.getElementById('inq-another');

      form.addEventListener('submit', async function (e) {
        e.preventDefault();
        submitBtn.disabled = true;
        submitBtn.textContent = 'Sending…';
        errorEl.hidden = true;
        var fd = new FormData(form);
        var body = {
          domain: host,
          name: String(fd.get('name') || '').trim(),
          email: String(fd.get('email') || '').trim(),
          message: String(fd.get('message') || '').trim(),
          fp: fp
        };
        try {
          var res = await fetch(API + '/api/inquiry', {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify(body)
          });
          if (!res.ok) throw new Error('bad status ' + res.status);
          form.hidden = true;
          thanks.hidden = false;
        } catch (_) {
          errorEl.textContent = 'Submit failed. Please try again.';
          errorEl.hidden = false;
          submitBtn.disabled = false;
          submitBtn.textContent = 'Submit';
        }
      });

      another.addEventListener('click', function () {
        form.reset();
        form.hidden = false;
        thanks.hidden = true;
        submitBtn.disabled = false;
        submitBtn.textContent = 'Submit';
      });
    })();
  </script>
</body>
</html>
