← back to Ventura Corridor

public/upgrade.html

220 lines

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<meta name="theme-color" content="#0e0e0e">
<title>Upgrade your listing — Ventura Corridor</title>
<meta name="description" content="Three tiers per category — Basic free, Featured, Spotlight. Stand out on the boulevard.">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=Inter:wght@400;500;600;700&display=swap">
<style>
:root{--bg:#0e0e0e;--panel:#181613;--fg:#f1ece2;--muted:#9a8f7e;--rule:rgba(255,255,255,0.10);--gold:#c9a96e;--green:#7ee69b}
*{box-sizing:border-box}
html,body{margin:0;padding:0;background:var(--bg);color:var(--fg);font-family:'Inter',sans-serif;line-height:1.55}
header{padding:14px 22px;border-bottom:1px solid var(--rule);display:flex;align-items:center;gap:14px;position:sticky;top:0;background:rgba(14,14,14,0.96);backdrop-filter:blur(10px);z-index:5}
header .logo{display:flex;align-items:center;gap:10px;text-decoration:none;color:var(--gold);font-family:'Playfair Display',serif;font-weight:700;font-size:1.2em}
header .logo svg{width:30px;height:30px}
.hamburger{margin-left:auto;width:36px;height:36px;border:1px solid var(--rule);border-radius:50%;display:flex;align-items:center;justify-content:center;color:var(--fg);font-size:1.05em;cursor:pointer;background:transparent}
main{max-width:1100px;margin:0 auto;padding:36px 24px 80px}
.biz{margin-bottom:32px}
.biz .eyebrow{color:var(--gold);font-size:0.72em;letter-spacing:2px;text-transform:uppercase;font-weight:600;margin-bottom:8px}
.biz h1{margin:0 0 6px;font-family:'Playfair Display',serif;font-weight:700;font-size:2.1em;letter-spacing:-0.01em}
.biz .meta{color:var(--muted);font-size:0.95em}
.biz .meta span{display:inline-block;padding:3px 10px;background:rgba(255,255,255,0.04);border:1px solid var(--rule);border-radius:999px;font-size:0.78em;margin-right:6px}
.tiers{display:grid;grid-template-columns:repeat(3,1fr);gap:18px;margin-top:28px}
.tier{background:var(--panel);border:1px solid var(--rule);border-radius:14px;padding:24px;display:flex;flex-direction:column;gap:14px;transition:transform 0.18s,border-color 0.18s,box-shadow 0.18s;position:relative;min-height:480px}
.tier:hover{transform:translateY(-4px);border-color:rgba(201,169,110,0.4);box-shadow:0 12px 28px rgba(0,0,0,0.4)}
.tier.featured{border-color:var(--gold);box-shadow:0 0 0 1px rgba(201,169,110,0.3) inset}
.tier.featured::before{content:'MOST POPULAR';position:absolute;top:-11px;left:50%;transform:translateX(-50%);background:var(--gold);color:#0a0a0a;font-size:0.65em;letter-spacing:2px;padding:4px 10px;border-radius:999px;font-weight:700}
.tier .name{font-family:'Playfair Display',serif;font-size:1.4em;font-weight:700;margin:0}
.tier .name em{color:var(--gold);font-style:italic}
.tier .price{font-family:'Playfair Display',serif;font-size:2.4em;font-weight:700;color:var(--gold);margin:0;line-height:1}
.tier .price small{display:block;color:var(--muted);font-family:'Inter',sans-serif;font-size:0.32em;font-weight:500;letter-spacing:1.5px;margin-top:4px;text-transform:uppercase}
.tier .desc{margin:0;color:var(--muted);font-size:0.92em;line-height:1.5}
.tier ul{margin:0;padding-left:20px;flex:1}
.tier li{margin-bottom:8px;color:var(--fg);font-size:0.88em}
.tier li::marker{color:var(--gold)}
.tier .cta{margin-top:auto;background:transparent;color:var(--fg);border:1px solid var(--rule);border-radius:10px;padding:13px 18px;font-family:inherit;font-weight:600;font-size:0.95em;cursor:pointer;transition:all 0.18s}
.tier.featured .cta,.tier.spotlight .cta{background:var(--gold);color:#0a0a0a;border-color:var(--gold)}
.tier .cta:hover{filter:brightness(1.15)}
.tier .cta:disabled{opacity:0.5;cursor:not-allowed}
.current{background:rgba(126,230,155,0.1);border:1px solid rgba(126,230,155,0.4);color:var(--green);text-align:center;padding:8px;border-radius:8px;font-size:0.82em;font-weight:600;letter-spacing:1px;text-transform:uppercase}
.intent-form{display:none;background:var(--panel);border:1px solid var(--gold);border-radius:14px;padding:24px;margin-top:24px}
.intent-form.show{display:block;animation:slidein 0.3s ease}
@keyframes slidein{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
.intent-form h3{margin:0 0 6px;font-family:'Playfair Display',serif;font-size:1.3em}
.intent-form p{margin:0 0 18px;color:var(--muted);font-size:0.92em}
.intent-form .row{display:grid;gap:12px}
.intent-form input,.intent-form textarea{width:100%;background:rgba(255,255,255,0.05);border:1px solid var(--rule);border-radius:8px;padding:11px 14px;color:var(--fg);font-family:inherit;font-size:0.95em;outline:none}
.intent-form input:focus,.intent-form textarea:focus{border-color:var(--gold)}
.intent-form .actions{display:flex;gap:10px;margin-top:14px}
.intent-form button{padding:12px 22px;border-radius:10px;font-family:inherit;font-weight:700;cursor:pointer;border:1px solid var(--rule);background:transparent;color:var(--fg)}
.intent-form button[type=submit]{background:var(--gold);color:#0a0a0a;border-color:var(--gold)}
.intent-form .label{color:var(--muted);font-size:0.75em;letter-spacing:1.5px;text-transform:uppercase;font-weight:600;margin-bottom:4px;display:block}
.toast{margin-top:14px;padding:12px 16px;border-radius:8px;font-size:0.9em}
.toast.ok{background:rgba(126,230,155,0.1);border:1px solid rgba(126,230,155,0.4);color:var(--green)}
.toast.err{background:rgba(255,138,138,0.1);border:1px solid rgba(255,138,138,0.4);color:#ff8a8a}
.empty{padding:60px 24px;text-align:center;color:var(--muted)}
.empty h2{font-family:'Playfair Display',serif;color:var(--fg);font-size:1.6em;margin:0 0 8px}
@media (max-width:780px){
  main{padding:24px 16px 60px}
  .biz h1{font-size:1.6em}
  .tiers{grid-template-columns:1fr;gap:14px}
  .tier{min-height:auto}
  .tier.featured::before{font-size:0.6em}
}
</style>
</head>
<body>

<header>
  <a class="logo" href="/" aria-label="Ventura Corridor home">
    <svg viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
      <circle cx="20" cy="20" r="18" fill="none" stroke="#c9a96e" stroke-width="1.5"/>
      <path d="M6 22 L34 18" stroke="#c9a96e" stroke-width="1.5" fill="none"/>
      <circle cx="13" cy="21" r="1.5" fill="#c9a96e"/>
      <circle cx="20" cy="20.5" r="1.5" fill="#c9a96e"/>
      <circle cx="27" cy="19.5" r="1.5" fill="#c9a96e"/>
    </svg>
    <span>Ventura Corridor</span>
  </a>
  <button class="hamburger" aria-label="Menu">≡</button>
</header>

<main id="root">
  <div class="empty"><h2>Loading…</h2></div>
</main>

<script>
const TIER_COPY = {
  // Default marketing copy when tier_pricing.marketing_copy JSONB is null —
  // generic-but-honest fallback per (tier) name.
  basic: { tagline: "Always free. The default listing from public-records data.", bullets: ["Name, address, phone","Auto-updated from OpenStreetMap","Standard sort + browse"] },
  featured: { tagline: "Stand out · logo, photos, boosted placement.", bullets: ["Logo + up to 5 photos","Boosted in browse + search","Featured ribbon on the card","Category tags + amenities"] },
  spotlight: { tagline: "Premium · video, reservations, priority everywhere.", bullets: ["Everything in Featured","Video embed or chef bio","Reservation / booking link","Priority placement in search","Weekly nearby-user email digest","Promo offer slot"] },
  verified: { tagline: "Verified · State Bar # + practice areas + intake form.", bullets: ["State Bar number on card","Up to 5 practice areas with descriptions","Consultation request form","Verified badge"] },
};

function $(id) { return document.getElementById(id); }
function esc(s) { return String(s||'').replace(/[&<>"]/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'}[c])); }
function dollars(cents) { return cents === 0 ? 'Free' : '$' + (cents/100).toFixed(0); }

const bizId = parseInt(location.pathname.split('/').pop(), 10);

async function load() {
  const r = await fetch('/api/upgrade/' + bizId);
  if (!r.ok) {
    $('root').innerHTML = '<div class="empty"><h2>Business not found</h2><p>The listing for ID ' + bizId + ' doesn\\'t exist in the directory. <a href="/" style="color:var(--gold)">← back</a></p></div>';
    return;
  }
  const j = await r.json();
  if (!j.ok) { $('root').innerHTML = '<div class="empty"><h2>Error</h2><p>' + esc(j.error || '') + '</p></div>'; return; }
  render(j.business, j.tiers);
}

function render(biz, tiers) {
  if (!tiers.length) {
    $('root').innerHTML = `<div class="empty"><h2>${esc(biz.name)}</h2><p>This category (<code>${esc(biz.category||'')}</code>) doesn't have a tier ladder yet. Email <a href="mailto:steve@designerwallcoverings.com" style="color:var(--gold)">steve@designerwallcoverings.com</a> if you want one.</p></div>`;
    return;
  }
  const currentTier = biz.tier || 'basic';
  $('root').innerHTML = `
    <div class="biz">
      <div class="eyebrow">Listing upgrade</div>
      <h1>${esc(biz.name)}</h1>
      <div class="meta">
        <span>${esc(biz.category||'')}</span>
        ${biz.address ? `<span>📍 ${esc(biz.address)}</span>` : ''}
        ${biz.website ? `<span><a href="${esc(biz.website)}" target="_blank" rel="noopener" style="color:var(--gold);text-decoration:none">${esc(biz.website.replace(/^https?:\\/\\//,''))} ↗</a></span>` : ''}
      </div>
    </div>
    <div class="tiers">
      ${tiers.map(t => {
        const isCurrent = t.tier === currentTier;
        const copy = (t.marketing_copy && typeof t.marketing_copy === 'object') ? t.marketing_copy : TIER_COPY[t.tier] || {};
        const bullets = copy.bullets || TIER_COPY[t.tier]?.bullets || [];
        const featured = t.tier === 'featured' || t.tier === 'verified';
        const spotlight = t.tier === 'spotlight';
        return `
          <article class="tier ${featured?'featured':''} ${spotlight?'spotlight':''}">
            <h3 class="name">${t.tier === 'basic' ? 'Basic' : t.tier === 'spotlight' ? '<em>'+esc(t.display_name||'Spotlight')+'</em>' : esc(t.display_name||t.tier)}</h3>
            <p class="price">${dollars(t.price_cents)}<small>${t.price_cents > 0 ? '/ month' : 'forever'}</small></p>
            <p class="desc">${esc(copy.tagline || copy.subtitle || TIER_COPY[t.tier]?.tagline || '')}</p>
            <ul>${bullets.map(b => '<li>' + esc(b) + '</li>').join('')}</ul>
            ${isCurrent
              ? '<div class="current">✓ Your current tier</div>'
              : t.tier === 'basic'
                ? '<button class="cta" disabled>Already on Basic</button>'
                : `<button class="cta" data-tier="${esc(t.tier)}" data-price="${t.price_cents}">${spotlight ? 'Get on the list' : 'Notify me when this opens'}</button>`}
          </article>
        `;
      }).join('')}
    </div>
    <form class="intent-form" id="intent-form">
      <h3>Get notified when <span id="intent-tier-label">this tier</span> opens for ${esc(biz.name)}</h3>
      <p>We're finishing payment integration. Drop your email and we'll reach out the day you can sign up. No spam, no upsells you didn't ask for.</p>
      <div class="row">
        <div>
          <label class="label">Your email</label>
          <input type="email" name="email" required placeholder="you@${esc((biz.website||'thebusiness.com').replace(/^https?:\\/\\/(www\\.)?/,'').split('/')[0])}">
        </div>
        <div>
          <label class="label">Your name (optional)</label>
          <input type="text" name="name" placeholder="Steve Owner">
        </div>
        <div>
          <label class="label">Anything to add? (optional)</label>
          <textarea name="notes" rows="2" placeholder="e.g. We want to highlight our patio dining + sunset hours."></textarea>
        </div>
      </div>
      <div class="actions">
        <button type="button" id="intent-cancel">Cancel</button>
        <button type="submit">Notify me →</button>
      </div>
      <div id="intent-result"></div>
    </form>
  `;

  // Wire CTAs
  document.querySelectorAll('.cta[data-tier]').forEach(btn => {
    btn.addEventListener('click', () => {
      const tier = btn.dataset.tier;
      $('intent-tier-label').textContent = tier.charAt(0).toUpperCase() + tier.slice(1);
      $('intent-form').classList.add('show');
      $('intent-form').dataset.tier = tier;
      $('intent-form').scrollIntoView({ behavior: 'smooth', block: 'center' });
    });
  });
  $('intent-cancel').addEventListener('click', () => $('intent-form').classList.remove('show'));
  $('intent-form').addEventListener('submit', async e => {
    e.preventDefault();
    const form = e.target;
    const tier = form.dataset.tier;
    const fd = new FormData(form);
    const body = { tier, email: fd.get('email'), name: fd.get('name'), notes: fd.get('notes') };
    form.querySelector('button[type=submit]').disabled = true;
    try {
      const r = await fetch('/api/upgrade/' + bizId + '/intent', {
        method:'POST', headers:{'Content-Type':'application/json'},
        body: JSON.stringify(body),
      });
      const j = await r.json();
      $('intent-result').innerHTML = j.ok
        ? '<div class="toast ok">✓ Got it. We\\'ll email <b>'+esc(body.email)+'</b> the moment <b>'+esc(tier)+'</b> opens for '+esc(biz.name)+'.</div>'
        : '<div class="toast err">✕ '+esc(j.error || 'failed')+'</div>';
      if (j.ok) form.reset();
    } catch (err) {
      $('intent-result').innerHTML = '<div class="toast err">✕ '+esc(err.message)+'</div>';
    } finally {
      form.querySelector('button[type=submit]').disabled = false;
    }
  });
}

load();
</script>
</body>
</html>