/* Cartesian Corp — shared page runtime (all pages) */ (function () { const $ = (s, el = document) => el.querySelector(s); const $$ = (s, el = document) => [...el.querySelectorAll(s)]; const reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches; const hasGSAP = typeof gsap !== 'undefined' && typeof ScrollTrigger !== 'undefined'; const base = document.body.dataset.base || ''; const root = document.documentElement; if (reduced || !hasGSAP) root.classList.add('no-anim'); $$('.year').forEach((el) => { el.textContent = new Date().getFullYear(); }); /* ================= PAGE READY ================= */ // Page transitions are handled natively by CSS view transitions, so links navigate instantly. window.__ccReady = true; requestAnimationFrame(() => root.classList.add('page-ready')); // Warm up the next page: prefetch internal pages when a link is hovered or touched. const prefetched = new Set(); const prefetch = (e) => { const a = e.target.closest && e.target.closest('a[href$=".html"]'); if (!a || a.target === '_blank') return; const url = new URL(a.href, location.href); if (url.origin !== location.origin || prefetched.has(url.pathname) || url.pathname === location.pathname) return; prefetched.add(url.pathname); const l = document.createElement('link'); l.rel = 'prefetch'; l.href = url.href; document.head.appendChild(l); }; document.addEventListener('mouseover', prefetch, { passive: true }); document.addEventListener('touchstart', prefetch, { passive: true }); /* ================= NAV ================= */ const nav = $('#nav'), navToggle = $('#navToggle'), navLinks = $('#navLinks'); let lastY = 0; const onScroll = () => { const y = window.scrollY; nav.classList.toggle('scrolled', y > 20); nav.classList.toggle('hidden', y > lastY && y > 300 && !navLinks.classList.contains('open')); lastY = y; }; window.addEventListener('scroll', onScroll, { passive: true }); onScroll(); navToggle.addEventListener('click', () => { const open = navLinks.classList.toggle('open'); navToggle.setAttribute('aria-expanded', open); navToggle.setAttribute('aria-label', open ? 'Close menu' : 'Open menu'); }); // same-page anchors use smooth scroll function scrollToEl(el) { if (!el) return; if (window.__lenis) window.__lenis.scrollTo(el, { offset: -90, duration: 1.2 }); else el.scrollIntoView({ behavior: reduced ? 'auto' : 'smooth' }); } $$('a[href^="#"]').forEach((a) => a.addEventListener('click', (e) => { const id = a.getAttribute('href'); if (id.length < 2) return; const el = $(id); if (!el) return; e.preventDefault(); scrollToEl(el); history.replaceState(null, '', id); })); /* ================= GENERATIVE VISUALS ================= */ const PAL = ['#5b7cff', '#ff6a45', '#a9b8ff']; function makeViz(canvas, type, seed = 1) { const ctx = canvas.getContext('2d'); let w, h, raf = null, running = false; const t0 = performance.now() - seed * 997; let rnd = seed * 9301; const rand = () => ((rnd = (rnd * 9301 + 49297) % 233280) / 233280); const pts = Array.from({ length: 34 }, () => ({ x: rand(), y: rand(), vx: rand() - .5, vy: rand() - .5, c: PAL[(rand() * 3) | 0] })); const bars = Array.from({ length: 28 }, () => rand()); const rr = (x, y, ww, hh, r) => { ctx.beginPath(); ctx.roundRect ? ctx.roundRect(x, y, ww, hh, r) : ctx.rect(x, y, ww, hh); }; // Architecture diagram: labeled components connected in order, with data flowing through. let labels = []; try { labels = JSON.parse(canvas.dataset.arch || '[]'); } catch (e) { labels = []; } function wrap(text, maxW) { const words = text.split(' '); const lines = []; let cur = ''; for (const wd of words) { const test = cur ? cur + ' ' + wd : wd; if (ctx.measureText(test).width > maxW && cur) { lines.push(cur); cur = wd; } else cur = test; } lines.push(cur); return lines.slice(0, 2); } function drawArch(t) { const n = labels.length; if (!n) return; const cols = (w / h > 2.2 && w > 900) ? n : (w < 460 ? 2 : 3); const rows = Math.ceil(n / cols); const padX = Math.max(24, w * .05), top = 58, bottom = 28; const cellW = (w - padX * 2) / cols, cellH = (h - top - bottom) / rows; const bw = Math.min(cellW - 28, 210), bh = Math.min(cellH - 30, w > 900 ? 74 : 62); const fs = w > 900 ? 14 : 12.5; const pos = labels.map((_, i) => { const r = Math.floor(i / cols); let c = i % cols; if (r % 2 === 1) c = cols - 1 - c; // serpentine flow return { x: padX + cellW * c + cellW / 2, y: top + cellH * r + cellH / 2 }; }); const flow = (t * .55) % (n - 1 + .6); const seg = Math.min(n - 2, Math.floor(flow)), u = Math.min(1, flow - seg); // connectors ctx.setLineDash([4, 5]); ctx.lineWidth = 1.5; for (let i = 0; i < n - 1; i++) { ctx.strokeStyle = i < seg || (i === seg && u >= 1) ? 'rgba(125,151,255,.75)' : 'rgba(255,255,255,.18)'; ctx.beginPath(); ctx.moveTo(pos[i].x, pos[i].y); ctx.lineTo(pos[i + 1].x, pos[i + 1].y); ctx.stroke(); } ctx.setLineDash([]); // travelling packet const a = pos[seg], b = pos[seg + 1]; const px = a.x + (b.x - a.x) * u, py = a.y + (b.y - a.y) * u; ctx.fillStyle = 'rgba(255,90,54,.25)'; ctx.beginPath(); ctx.arc(px, py, 9, 0, 7); ctx.fill(); ctx.fillStyle = '#ff5a36'; ctx.beginPath(); ctx.arc(px, py, 4.5, 0, 7); ctx.fill(); // nodes labels.forEach((label, i) => { const { x, y } = pos[i]; const active = i === seg + (u > .98 ? 1 : 0), done = i <= seg; ctx.fillStyle = active ? 'rgba(43,76,255,.35)' : 'rgba(18,40,61,.96)'; ctx.strokeStyle = active ? '#7d97ff' : (done ? 'rgba(125,151,255,.55)' : 'rgba(255,255,255,.16)'); ctx.lineWidth = active ? 2 : 1; rr(x - bw / 2, y - bh / 2, bw, bh, 10); ctx.fill(); ctx.stroke(); ctx.font = `500 ${fs - 3}px "JetBrains Mono", monospace`; ctx.fillStyle = '#ff8a6b'; ctx.textAlign = 'left'; ctx.textBaseline = 'top'; ctx.fillText(String(i + 1).padStart(2, '0'), x - bw / 2 + 12, y - bh / 2 + 9); ctx.font = `600 ${fs}px Inter, system-ui, sans-serif`; ctx.fillStyle = '#ffffff'; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; const lines = wrap(label, bw - 24), lh = fs * 1.3, y0 = y + 6 - ((lines.length - 1) * lh) / 2; lines.forEach((ln, k) => ctx.fillText(ln, x, y0 + k * lh)); }); ctx.textAlign = 'left'; ctx.textBaseline = 'alphabetic'; } function size() { const dpr = Math.min(window.devicePixelRatio || 1, 2); w = canvas.clientWidth; h = canvas.clientHeight; canvas.width = w * dpr; canvas.height = h * dpr; ctx.setTransform(dpr, 0, 0, dpr, 0, 0); } function bg() { const g = ctx.createLinearGradient(0, 0, w, h); g.addColorStop(0, '#0b1d2e'); g.addColorStop(1, '#14304a'); ctx.fillStyle = g; ctx.fillRect(0, 0, w, h); ctx.strokeStyle = 'rgba(255,255,255,.05)'; ctx.lineWidth = 1; ctx.beginPath(); for (let x = 0; x < w; x += 32) { ctx.moveTo(x + .5, 0); ctx.lineTo(x + .5, h); } for (let y = 0; y < h; y += 32) { ctx.moveTo(0, y + .5); ctx.lineTo(w, y + .5); } ctx.stroke(); } function draw(now) { const t = (now - t0) / 1000; bg(); if (type === 'network') { for (const p of pts) { p.x += p.vx * .0008; p.y += p.vy * .0008; if (p.x < 0 || p.x > 1) p.vx *= -1; if (p.y < 0 || p.y > 1) p.vy *= -1; } for (let i = 0; i < pts.length; i++) for (let j = i + 1; j < pts.length; j++) { const a = pts[i], b = pts[j], d = Math.hypot((a.x - b.x) * w, (a.y - b.y) * h); if (d < 150) { ctx.strokeStyle = `rgba(125,151,255,${(1 - d / 150) * .45})`; ctx.beginPath(); ctx.moveTo(a.x * w, a.y * h); ctx.lineTo(b.x * w, b.y * h); ctx.stroke(); } } pts.forEach((p, i) => { ctx.fillStyle = i === 0 ? '#ff6a45' : p.c; ctx.beginPath(); ctx.arc(p.x * w, p.y * h, i === 0 ? 8 + Math.sin(t * 3) * 1.5 : 3.2, 0, 7); ctx.fill(); if (i === 0) { ctx.strokeStyle = 'rgba(255,106,69,.35)'; ctx.beginPath(); ctx.arc(p.x * w, p.y * h, 16 + (t * 12 % 14), 0, 7); ctx.stroke(); } }); } else if (type === 'bars') { const n = bars.length, bw = w / n; bars.forEach((b, i) => { const v = .15 + .7 * (0.5 + 0.5 * Math.sin(t * 1.3 + i * .45 + b * 6)) * (.4 + b * .6); ctx.fillStyle = i % 7 === 3 ? '#ff6a45' : (i % 2 ? '#5b7cff' : '#7d97ff'); rr(i * bw + 4, h - v * h * .8 - 16, bw - 8, v * h * .8, 3); ctx.fill(); }); } else if (type === 'grid') { const cols = 11, rows = 6, cw = w / cols, ch = h / rows; for (let i = 0; i < cols; i++) for (let j = 0; j < rows; j++) { const on = (Math.sin(t * 1.1 + i * .7 + j * 1.3) + 1) / 2; ctx.fillStyle = on > .85 ? 'rgba(255,106,69,.85)' : `rgba(91,124,255,${.1 + on * .5})`; rr(i * cw + 6, j * ch + 6, cw - 12, ch - 12, 6); ctx.fill(); } } else if (type === 'orbit') { const cx = w / 2, cy = h / 2, R = Math.min(w, h) * .11; for (let r = 1; r <= 4; r++) { ctx.strokeStyle = 'rgba(255,255,255,.1)'; ctx.beginPath(); ctx.ellipse(cx, cy, r * R * 1.6, r * R, 0, 0, 7); ctx.stroke(); for (let k = 0; k < r + 1; k++) { const a = t * (0.6 / r) + k * (6.28 / (r + 1)); ctx.fillStyle = PAL[(r + k) % 3]; ctx.beginPath(); ctx.arc(cx + Math.cos(a) * r * R * 1.6, cy + Math.sin(a) * r * R, 4.5, 0, 7); ctx.fill(); } } ctx.fillStyle = '#ff6a45'; ctx.beginPath(); ctx.arc(cx, cy, 13, 0, 7); ctx.fill(); } else if (type === 'wave') { for (let k = 0; k < 6; k++) { ctx.strokeStyle = k === 2 ? '#ff6a45' : PAL[k % 3 === 1 ? 0 : k % 3]; ctx.globalAlpha = .35 + k * .1; ctx.lineWidth = 2; ctx.beginPath(); for (let x = 0; x <= w; x += 6) { const y = h / 2 + Math.sin(x * .012 + t * (1 + k * .2) + k) * (h * .12 + k * 6) * Math.sin(x / w * Math.PI); x ? ctx.lineTo(x, y) : ctx.moveTo(x, y); } ctx.stroke(); } ctx.globalAlpha = 1; ctx.lineWidth = 1; } else if (type === 'flow') { const stages = 5, sw = w / stages; for (let s = 0; s < stages; s++) { const x = s * sw + sw / 2, y = h / 2, bw2 = Math.min(46, sw * .38); ctx.fillStyle = 'rgba(255,255,255,.06)'; ctx.strokeStyle = 'rgba(255,255,255,.18)'; rr(x - bw2, y - 30, bw2 * 2, 60, 10); ctx.fill(); ctx.stroke(); ctx.fillStyle = s === 2 ? '#ff6a45' : '#7d97ff'; ctx.fillRect(x - bw2 + 14, y - 8, (bw2 * 2 - 28) * (0.4 + 0.6 * ((Math.sin(t + s) + 1) / 2)), 4); ctx.fillStyle = 'rgba(255,255,255,.25)'; ctx.fillRect(x - bw2 + 14, y + 4, bw2, 3); if (s < stages - 1) { ctx.strokeStyle = 'rgba(125,151,255,.4)'; ctx.beginPath(); ctx.moveTo(x + bw2, y); ctx.lineTo(x + sw - bw2, y); ctx.stroke(); const p = (t * .6 + s * .2) % 1; ctx.fillStyle = '#fff'; ctx.beginPath(); ctx.arc(x + bw2 + p * (sw - bw2 * 2), y, 3.5, 0, 7); ctx.fill(); } } } else if (type === 'arch') { drawArch(t); } else if (type === 'avatar') { ctx.lineWidth = 1.6; for (let m = 0; m < 3; m++) { ctx.strokeStyle = m === 1 ? '#ff6a45' : PAL[m === 0 ? 0 : 2]; ctx.globalAlpha = .7 - m * .15; ctx.beginPath(); for (let a = 0; a <= 6.3; a += .03) { const r = Math.min(w, h) * (.28 + m * .06) * (1 + .18 * Math.sin((seed + 2) * a + t * .8 + m)); const x = w / 2 + Math.cos(a) * r, y = h / 2 + Math.sin(a) * r; a ? ctx.lineTo(x, y) : ctx.moveTo(x, y); } ctx.closePath(); ctx.stroke(); } ctx.globalAlpha = 1; ctx.strokeStyle = 'rgba(255,255,255,.2)'; ctx.beginPath(); ctx.moveTo(w / 2, 10); ctx.lineTo(w / 2, h - 10); ctx.moveTo(10, h / 2); ctx.lineTo(w - 10, h / 2); ctx.stroke(); } if (running) raf = requestAnimationFrame(draw); } size(); draw(performance.now()); window.addEventListener('resize', () => { size(); if (!running) draw(performance.now()); }); if (!reduced) new IntersectionObserver(([e]) => { if (e.isIntersecting && !running) { running = true; raf = requestAnimationFrame(draw); } else if (!e.isIntersecting) { running = false; cancelAnimationFrame(raf); } }).observe(canvas); } $$('canvas[data-viz]').forEach((c) => makeViz(c, c.dataset.viz, +c.dataset.seed || 1)); /* ================= PRODUCT VIDEOS ================= */ // Work cards: play the demo on hover (desktop) or when scrolled into view (touch devices). const canHover = window.matchMedia('(hover:hover)').matches; $$('.project').forEach((card) => { const v = $('.pv-video', card); if (!v) return; const play = () => { if (reduced) return; if (!v.src) v.src = v.dataset.src; v.play().then(() => card.classList.add('playing')).catch(() => {}); }; const stop = () => { v.pause(); card.classList.remove('playing'); }; if (canHover) { card.addEventListener('mouseenter', play); card.addEventListener('mouseleave', stop); } else new IntersectionObserver(([e]) => (e.isIntersecting ? play() : stop()), { threshold: .6 }).observe(card); }); // Case-study video player $$('[data-vp]').forEach((vp) => { const v = $('video', vp), fill = $('.vp-fill', vp), time = $('.vp-time', vp), track = $('.vp-track', vp); const fmt = (s) => `${Math.floor(s / 60)}:${String(Math.floor(s % 60)).padStart(2, '0')}`; const sync = () => vp.classList.toggle('is-playing', !v.paused); const toggle = () => (v.paused ? v.play().catch(() => {}) : v.pause()); v.addEventListener('play', sync); v.addEventListener('pause', sync); v.addEventListener('timeupdate', () => { if (v.duration) fill.style.width = (v.currentTime / v.duration * 100) + '%'; time.textContent = fmt(v.currentTime); }); $('.vp-big', vp).addEventListener('click', toggle); $('.vp-toggle', vp).addEventListener('click', toggle); v.addEventListener('click', toggle); track.addEventListener('click', (e) => { const r = track.getBoundingClientRect(); if (v.duration) v.currentTime = ((e.clientX - r.left) / r.width) * v.duration; }); $('.vp-fs', vp).addEventListener('click', () => { if (document.fullscreenElement) document.exitFullscreen(); else if (vp.requestFullscreen) vp.requestFullscreen(); else if (v.webkitEnterFullscreen) v.webkitEnterFullscreen(); // iOS Safari }); // Autoplay muted when visible, pause when scrolled away (respects reduced motion). let userPaused = false; $('.vp-toggle', vp).addEventListener('click', () => { userPaused = v.paused; }); if (!reduced) new IntersectionObserver(([e]) => { if (e.isIntersecting && !userPaused) v.play().catch(() => {}); else if (!e.isIntersecting) v.pause(); }, { threshold: .5 }).observe(vp); }); /* ================= 3D STACK <-> LIST SYNC ================= */ const stackEl = $('[data-three="stack"]'), stackList = $('#stackList'); if (stackEl && stackList) { const items = $$('li', stackList); stackEl.addEventListener('stack:active', (e) => items.forEach((li) => li.classList.toggle('on', +li.dataset.layer === e.detail))); items.forEach((li) => { li.addEventListener('mouseenter', () => stackEl.dispatchEvent(new CustomEvent('stack:hover', { detail: +li.dataset.layer }))); li.addEventListener('mouseleave', () => stackEl.dispatchEvent(new CustomEvent('stack:hover', { detail: -1 }))); }); } /* ================= MARQUEE ================= */ const mq = $('.marquee-track'); if (mq) mq.innerHTML += mq.innerHTML; /* ================= WORK FILTER ================= */ $$('.filter').forEach((btn) => btn.addEventListener('click', () => { $$('.filter').forEach((b) => b.classList.toggle('active', b === btn)); const f = btn.dataset.filter; const cards = $$('#workGrid .project'); const apply = () => cards.forEach((c) => c.classList.toggle('hide', f !== 'all' && c.dataset.cat !== f)); if (hasGSAP && !reduced) { gsap.to(cards, { opacity: 0, y: 16, duration: .18, onComplete: () => { apply(); gsap.fromTo(cards.filter((c) => !c.classList.contains('hide')), { opacity: 0, y: 26 }, { opacity: 1, y: 0, duration: .5, stagger: .06, ease: 'power3.out', onComplete: () => ScrollTrigger.refresh() }); } }); } else apply(); })); /* ================= SHOWREEL ================= */ const player = $('#player'); if (player) (function () { const video = $('#reelVideo'), sim = $('#reelSim'), log = $('#simLog'), steps = $$('#simSteps li'); const barsEl = $('#simBars'), toggle = $('#reelToggle'), fill = $('#reelProgress'), timeEl = $('#reelTime'); const line = $('#chartLine'), area = $('#chartArea'); let useVideo = false; video.addEventListener('loadeddata', () => { video.hidden = false; sim.style.display = 'none'; useVideo = true; }); // Only fetch the showreel when the player is about to scroll into view. new IntersectionObserver(([e], o) => { if (e.isIntersecting) { o.disconnect(); video.preload = 'auto'; video.load(); } }, { rootMargin: '400px' }).observe(player); for (let i = 0; i < 16; i++) barsEl.appendChild(document.createElement('span')); const barEls = $$('span', barsEl); const SCRIPT = [ [0, '09:41:02 ▸ request "Summarize Q3 churn for enterprise accounts and draft outreach"'], [1, '09:41:03 ▸ plan 1) query warehouse 2) enrich from CRM 3) draft 4) evaluate'], [2, '09:41:04 tool sql.query("SELECT account, mrr, churn_risk FROM accounts WHERE tier=\'ent\'")'], [2, '09:41:05 ✓ 1,284 rows · 212ms'], [3, '09:41:06 tool crm.get_contacts(accounts=top_risk[:25])'], [3, '09:41:07 ✓ 25 accounts enriched · owners assigned'], [4, '09:41:08 ▸ draft executive summary + 25 personalized emails…'], [4, '09:41:10 ✓ report.md · 25 drafts queued for review'], [5, '09:41:11 ▸ eval factuality 0.97 · tone ✓ · PII scan ✓ · policy ✓'], [6, '09:41:12 ✓ delivered to #customer-success in 9.8s · awaiting human approval'] ]; const DURATION = 16000; let playing = true, elapsed = 0, last = performance.now(), shown = 0; const chartPts = Array.from({ length: 40 }, (_, i) => 70 + Math.sin(i / 3) * 20); const renderChart = () => { const d = chartPts.map((v, i) => `${i ? 'L' : 'M'}${(i / 39) * 400},${v}`).join(' '); line.setAttribute('d', d); area.setAttribute('d', d + ' L400,140 L0,140 Z'); }; const reset = () => { log.innerHTML = ''; shown = 0; steps.forEach((s) => s.classList.remove('done', 'active')); }; function tick(now) { const dt = now - last; last = now; if (playing && !useVideo) { elapsed += dt; if (elapsed > DURATION) { elapsed = 0; reset(); } const p = elapsed / DURATION; fill.style.width = (p * 100) + '%'; timeEl.textContent = `00:${String(Math.floor(elapsed / 1000)).padStart(2, '0')}`; const target = Math.min(SCRIPT.length, Math.floor(p * (SCRIPT.length + 2))); while (shown < target) { const [step, html] = SCRIPT[shown]; const cur = log.querySelector('.cursor'); if (cur) cur.remove(); const ln = document.createElement('div'); ln.className = 'ln'; ln.innerHTML = html + ' '; log.appendChild(ln); while (log.children.length > 9) log.firstChild.remove(); steps.forEach((el, k) => { el.classList.toggle('done', k < step); el.classList.toggle('active', k === step); }); if (shown === SCRIPT.length - 1) steps.forEach((el) => { el.classList.add('done'); el.classList.remove('active'); }); shown++; } if (Math.random() < .25) { chartPts.shift(); chartPts.push(Math.max(10, Math.min(130, chartPts[chartPts.length - 1] + (Math.random() - .55) * 18))); renderChart(); barEls.forEach((b) => { b.style.height = (15 + Math.random() * 85) + '%'; }); } } else if (useVideo && video.duration) { fill.style.width = (video.currentTime / video.duration * 100) + '%'; timeEl.textContent = `00:${String(Math.floor(video.currentTime)).padStart(2, '0')}`; } requestAnimationFrame(tick); } renderChart(); requestAnimationFrame(tick); toggle.addEventListener('click', () => { playing = !playing; toggle.textContent = playing ? '❚❚' : '▶'; toggle.setAttribute('aria-label', playing ? 'Pause' : 'Play'); if (useVideo) playing ? video.play() : video.pause(); }); new IntersectionObserver(([e]) => { if (useVideo) (e.isIntersecting && playing) ? video.play().catch(() => {}) : video.pause(); }, { threshold: .3 }).observe(player); })(); /* ================= CONTACT FORM ================= */ const form = $('#contactForm'); if (form) { const qs = new URLSearchParams(location.search); if (qs.get('need')) form.elements.need.value = qs.get('need'); try { const pre = JSON.parse(sessionStorage.getItem('cc_prefill') || 'null'); if (pre) { if (pre.need) form.elements.need.value = pre.need; if (pre.msg) form.elements.msg.value = pre.msg; sessionStorage.removeItem('cc_prefill'); } } catch (e) { /* storage unavailable */ } form.addEventListener('submit', async (e) => { e.preventDefault(); const d = Object.fromEntries(new FormData(form)); if (d._honey) return; // spam bot const needLabel = form.elements.need.selectedOptions[0].text; const subject = 'Project inquiry: ' + (d.company || d.name); const email = (window.CC_DATA && window.CC_DATA.email) || 'hello@cartesiancorp.com'; const endpoint = window.CC_DATA && window.CC_DATA.formEndpoint; const note = $('#formNote'), btn = $('button[type="submit"]', form); const mailto = () => { const body = `Name: ${d.name}\nEmail: ${d.email}\nCompany: ${d.company || '-'}\nNeed: ${needLabel}\nBudget: ${d.budget}\nTimeline: ${d.timeline}\n\n${d.msg}`; location.href = `mailto:${email}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`; note.textContent = 'Opening your email app to send the message.'; }; if (!endpoint) return mailto(); btn.disabled = true; note.textContent = 'Sending…'; try { const r = await fetch(endpoint, { method: 'POST', headers: { 'Content-Type': 'application/json', Accept: 'application/json' }, body: JSON.stringify({ _subject: subject, _template: 'table', _replyto: d.email, name: d.name, email: d.email, company: d.company || '-', need: needLabel, budget: d.budget, timeline: d.timeline, message: d.msg }) }); const j = await r.json().catch(() => ({})); if (!r.ok || j.success === false || j.success === 'false') throw new Error(j.message || 'send failed'); form.innerHTML = `
A senior architect will reply to ${d.email.replace(/[<>&"]/g, '')} within one business day. If it's urgent, email ${email}.