keyhaven-sign-in.html
The finished file. Open it in a browser. Put your auth calls in onSubmit and onProvider at the top of the script.
Part of Soft tray sign-in card by Admin
<!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="#f4f1ec" /> <title>Sign in · Keyhaven</title> <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=Instrument+Serif:ital@0;1&family=Inter+Tight:wght@400;500;600&display=swap" rel="stylesheet" /> <style> :root{ --page:#f4f1ec;--tray:#ebe6de;--card:#fffdfa;--ink:#1d1a17;--muted:#8a8278;--well:#f3efe9;--line:#e6e0d7; --clay:#c65f3b;--clay2:#e08a5f;--ok:#2f8f5b; } *{box-sizing:border-box} html,body{margin:0;min-height:100%;background:var(--page);color:var(--ink);font-family:"Inter Tight",system-ui,-apple-system,"Segoe UI",sans-serif;-webkit-font-smoothing:antialiased} .kh-page{min-height:100vh;min-height:100svh;display:grid;place-items:center;padding:28px 16px; background:radial-gradient(60% 50% at 50% 40%,#fbf8f3,transparent 70%),var(--page)}
.kh-tray{width:min(400px,100%);padding:6px 6px 0;border-radius:30px;background:var(--tray); box-shadow:inset 0 1px 0 rgba(255,255,255,.7),inset 0 0 0 1px rgba(0,0,0,.035),0 30px 60px -30px rgba(80,60,40,.35);opacity:0} .kh-card{position:relative;padding:28px 26px 24px;border-radius:24px;background:var(--card); box-shadow:0 1px 0 rgba(255,255,255,.9) inset,0 0 0 1px rgba(60,40,20,.06),0 10px 24px -14px rgba(80,60,40,.35)} .kh-foot{padding:15px 12px 16px;text-align:center;font-size:13.5px;color:var(--muted)} .kh-foot a{color:var(--ink);font-weight:500;text-decoration:none} .kh-foot a:hover{text-decoration:underline}
/ mark + halo / .kh-mark{position:relative;width:132px;height:112px;margin:-6px auto 6px;display:grid;place-items:center} .kh-mark canvas{position:absolute;inset:0;width:100%;height:100%} .kh-tile{position:relative;width:52px;height:52px;border-radius:16px;display:grid;place-items:center; background:linear-gradient(160deg,var(--clay2),var(--clay)); box-shadow:inset 0 1px 0 rgba(255,255,255,.4),inset 0 -2px 0 rgba(0,0,0,.12),0 8px 18px -6px rgba(198,95,59,.6);transform:scale(0)} .kh-tile svg{width:26px;height:26px} .kh-tile path{stroke-dasharray:var(--len);stroke-dashoffset:var(--len)}
.kh-title{margin:0;text-align:center;font-family:"Instrument Serif",Georgia,serif;font-weight:400;font-size:34px;line-height:1.05;letter-spacing:-.01em} .kh-title em{color:var(--clay)} .kh-sub{margin:8px 0 22px;text-align:center;font-size:14px;line-height:1.5;color:var(--muted)}
.kh-form{display:flex;flex-direction:column;gap:10px} .kh-well{position:relative;display:flex;align-items:center;gap:10px;height:46px;padding:0 6px 0 14px;border-radius:13px;background:var(--well); box-shadow:inset 0 1px 2px rgba(60,40,20,.08),inset 0 0 0 1px rgba(60,40,20,.04);transition:box-shadow .2s,background .2s} .kh-well:focus-within{background:#fff;box-shadow:inset 0 0 0 1.5px var(--clay),0 0 0 4px rgba(198,95,59,.12)} .kh-well>svg{width:16px;height:16px;flex:none;color:#a59c91} .kh-well:focus-within>svg{color:var(--clay)} .kh-well input{flex:1;min-width:0;height:100%;border:0;outline:0;background:none;font:inherit;font-size:15px;color:var(--ink)} .kh-well input::placeholder{color:#a79e94} .kh-eye{display:grid;place-items:center;width:34px;height:34px;border:0;border-radius:9px;background:none;color:#a59c91;cursor:pointer} .kh-eye:hover{background:rgba(0,0,0,.05);color:var(--ink)} .kh-eye svg{width:17px;height:17px} .kh-eye .off{display:none}.kh-eye[aria-pressed="true"] .on{display:none}.kh-eye[aria-pressed="true"] .off{display:block}
.kh-row{display:flex;align-items:center;justify-content:space-between;margin:2px 2px 4px;font-size:13.5px} .kh-check{display:inline-flex;align-items:center;gap:8px;color:#5d564e;cursor:pointer;user-select:none} .kh-check input{position:absolute;opacity:0;width:1px;height:1px} .kh-box{width:18px;height:18px;border-radius:6px;background:var(--well);box-shadow:inset 0 0 0 1px #d8d0c5;display:grid;place-items:center;transition:background .15s,box-shadow .15s} .kh-box svg{width:11px;height:11px;opacity:0;transform:scale(.6);transition:opacity .15s,transform .15s} .kh-check input:checked+.kh-box{background:var(--ink);box-shadow:none} .kh-check input:checked+.kh-box svg{opacity:1;transform:none} .kh-check input:focus-visible+.kh-box{outline:2px solid var(--clay);outline-offset:2px} .kh-link{color:var(--clay);text-decoration:none;font-weight:500} .kh-link:hover{text-decoration:underline}
.kh-btn{position:relative;height:48px;border:0;border-radius:14px;cursor:pointer;color:#fff;font:inherit;font-weight:500;font-size:15px;overflow:hidden; background:linear-gradient(180deg,#2b2622,var(--ink));box-shadow:inset 0 1px 0 rgba(255,255,255,.14),0 8px 18px -8px rgba(29,26,23,.7);transition:transform .15s,background .3s} .kh-btn:hover{transform:translateY(-1px)} .kh-btn:active{transform:scale(.985)} .kh-btn[data-state="done"]{background:linear-gradient(180deg,#3aa56c,var(--ok))} .kh-roll{position:absolute;inset:0} .kh-roll span{position:absolute;left:0;right:0;height:48px;display:flex;align-items:center;justify-content:center;gap:8px} .kh-roll svg{width:16px;height:16px} .kh-spin{animation:none}
.kh-or{display:flex;align-items:center;gap:10px;margin:18px 0 12px;font-size:12.5px;color:#a79e94} .kh-or::before,.kh-or::after{content:"";flex:1;border-top:1px dashed #ddd5ca} .kh-social{display:grid;grid-template-columns:repeat(3,1fr);gap:8px} .kh-social button{height:44px;border-radius:13px;border:0;background:#fff;cursor:pointer;display:grid;place-items:center; box-shadow:0 0 0 1px var(--line),0 1px 2px rgba(60,40,20,.06);transition:box-shadow .2s,transform .15s} .kh-social button:hover{box-shadow:0 0 0 1px #d6cdc1,0 6px 14px -8px rgba(60,40,20,.35);transform:translateY(-1px)} .kh-social svg{width:19px;height:19px} :is(.kh-btn,.kh-social button,.kh-eye,.kh-link,.kh-foot a):focus-visible{outline:2px solid var(--clay);outline-offset:2px} .kh-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
@media (max-width:400px){.kh-card{padding:24px 18px 20px}.kh-title{font-size:30px}} @media (max-height:640px){.kh-mark{height:84px;margin-bottom:2px}.kh-sub{margin-bottom:16px}.kh-or{margin:14px 0 10px}} </style> </head> <body> <main class="kh-page"> <section class="kh-tray" aria-labelledby="kh-title"> <div class="kh-card"> <div class="kh-mark" aria-hidden="true"> <canvas></canvas> <div class="kh-tile"> <svg viewBox="0 0 26 26" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M4.5 11.5 13 4.5l8.5 7V21a1 1 0 0 1-1 1h-15a1 1 0 0 1-1-1z"/> <path d="M13 13.4a2 2 0 1 1 0 .01M13 15.4V18.5"/> </svg> </div> </div> <h1 class="kh-title" id="kh-title" data-row>Welcome <em>home</em></h1> <p class="kh-sub" data-row>Sign in to see your saved homes, viewings and offers.</p>
<form class="kh-form"> <label class="kh-well" data-row> <span class="kh-sr">Email</span> <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><rect x="1.8" y="3.2" width="12.4" height="9.6" rx="2"/><path d="m2.5 4.5 5.5 4 5.5-4"/></svg> <input type="email" name="email" placeholder="Email address" autocomplete="email" required /> </label> <div class="kh-well" data-row> <label class="kh-sr" for="kh-pass">Password</label> <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><rect x="2.5" y="7" width="11" height="7.2" rx="2"/><path d="M5 7V5a3 3 0 0 1 6 0v2"/></svg> <input id="kh-pass" type="password" name="password" placeholder="Password" autocomplete="current-password" minlength="6" required /> <button class="kh-eye" type="button" aria-pressed="false" aria-label="Show password"> <svg class="on" viewBox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="M1.5 9S4.2 3.8 9 3.8 16.5 9 16.5 9 13.8 14.2 9 14.2 1.5 9 1.5 9Z"/><circle cx="9" cy="9" r="2.3"/></svg> <svg class="off" viewBox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="M2.5 2.5l13 13M7.2 4C7.8 3.9 8.4 3.8 9 3.8 13.8 3.8 16.5 9 16.5 9a13 13 0 0 1-2 2.6M5 5.3C2.8 6.8 1.5 9 1.5 9S4.2 14.2 9 14.2c1.4 0 2.6-.4 3.6-1"/><path d="M7.4 7.5a2.3 2.3 0 0 0 3.1 3.1"/></svg> </button> </div> <div class="kh-row" data-row> <label class="kh-check"><input type="checkbox" name="remember" checked /><span class="kh-box"><svg viewBox="0 0 12 12" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m2.5 6.2 2.3 2.3 4.7-5"/></svg></span>Keep me signed in</label> <a class="kh-link" href="#">Forgot password?</a> </div> <button class="kh-btn" type="submit" data-row data-state="idle"> <span class="kh-roll" aria-hidden="true"> <span>Sign in</span> <span><svg class="kh-spin" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M14 8a6 6 0 1 1-4.2-5.7"/></svg>Signing in…</span> <span><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="m3.5 8.3 3 3 6-6.6"/></svg>Welcome back</span> </span> <span class="kh-sr" aria-live="polite" data-label>Sign in</span> </button> </form>
<div class="kh-or" data-row><span>or continue with</span></div> <div class="kh-social" data-row> <button type="button" aria-label="Continue with Google" data-provider="google"> <svg viewBox="0 0 24 24" aria-hidden="true"><path fill="#4285F4" d="M22.6 12.3c0-.8-.1-1.5-.2-2.3H12v4.3h6a5.1 5.1 0 0 1-2.2 3.4v2.8h3.6c2.1-2 3.2-4.8 3.2-8.2z"/><path fill="#34A853" d="M12 23c3 0 5.5-1 7.4-2.7l-3.6-2.8c-1 .7-2.3 1.1-3.8 1.1-2.9 0-5.4-2-6.3-4.6H2v2.9A11 11 0 0 0 12 23z"/><path fill="#FBBC05" d="M5.7 14c-.2-.7-.4-1.3-.4-2s.1-1.4.4-2V7.1H2A11 11 0 0 0 2 16.9z"/><path fill="#EA4335" d="M12 5.4c1.6 0 3.1.6 4.2 1.7l3.2-3.2A11 11 0 0 0 2 7.1L5.7 10c.9-2.6 3.4-4.6 6.3-4.6z"/></svg> </button> <button type="button" aria-label="Continue with Facebook" data-provider="facebook"> <svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="11" fill="#1877F2"/><path fill="#fff" d="M13.4 23v-8.1h2.7l.4-3.2h-3.1V9.7c0-.9.3-1.5 1.6-1.5h1.6V5.3c-.3 0-1.3-.1-2.4-.1-2.4 0-4 1.4-4 4.1v2.4H7.5v3.2h2.7V23z"/></svg> </button> <button type="button" aria-label="Continue with Apple" data-provider="apple"> <svg viewBox="0 0 24 24" aria-hidden="true"><path fill="#111" d="M16.4 12.6c0-2.6 2.1-3.8 2.2-3.9-1.2-1.8-3.1-2-3.7-2-1.6-.2-3.1.9-3.9.9-.8 0-2-.9-3.4-.9-1.7 0-3.3 1-4.2 2.6-1.8 3.1-.5 7.7 1.3 10.2.9 1.2 1.9 2.6 3.2 2.6 1.3-.1 1.8-.8 3.3-.8 1.6 0 2 .8 3.4.8s2.2-1.3 3.1-2.5c1-1.4 1.4-2.8 1.4-2.9 0 0-2.7-1-2.7-4.1zM13.9 5c.7-.9 1.2-2 1-3.2-1 0-2.2.7-3 1.5-.6.7-1.2 1.9-1 3.1 1.1.1 2.3-.6 3-1.4z"/></svg> </button> </div> </div> <p class="kh-foot" data-row>New to Keyhaven? <a href="#">Create an account</a></p> </section> <span class="kh-sr" role="status" aria-live="polite"></span> </main>
<script> (() => { / hook these up to your auth / async function onSubmit({ email, password }) { await new Promise(r => setTimeout(r, 1300)); } function onProvider(provider) { status.textContent = Opening ${provider} sign-in; }
const root = document.documentElement; const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches; const clamp = (v, a, b) => Math.min(b, Math.max(a, v)); const easeOut = x => 1 - Math.pow(1 - x, 3); const spring = x => x >= 1 ? 1 : 1 - Math.exp(-6.5 x) Math.cos(9.5 * x); // damped spring 0 → 1 with overshoot
const tray = document.querySelector('.kh-tray'); const tile = document.querySelector('.kh-tile'); const paths = [...tile.querySelectorAll('path')]; paths.forEach(p => { const l = p.getTotalLength(); p.style.setProperty('--len', l); p.dataset.len = l; }); const rows = [...document.querySelectorAll('[data-row]')]; rows.forEach(r => { r.style.opacity = 0; }); const status = document.querySelector('.kh-sr[role="status"]');
/ ---------- dot halo ---------- / const cv = document.querySelector('.kh-mark canvas'); const ctx = cv.getContext('2d'); const RINGS = []; for (let r = 34, i = 0; r <= 64; r += 6, i++) RINGS.push({ r, n: Math.round(r 0.62), dir: i % 2 ? -1 : 1, a: 0.55 - i 0.08 }); function sizeCanvas() { const b = cv.getBoundingClientRect(), d = Math.min(devicePixelRatio || 1, 2); cv.width = b.width d; cv.height = b.height d; ctx.setTransform(d, 0, 0, d, 0, 0); } sizeCanvas(); addEventListener('resize', sizeCanvas); function drawHalo(t) { const b = cv.getBoundingClientRect(); const cx = b.width / 2, cy = b.height / 2; ctx.clearRect(0, 0, b.width, b.height); const u = reduce ? 1 : easeOut(clamp((t - 0.15) / 1.3, 0, 1)); const scale = b.height < 100 ? 0.75 : 1; for (const ring of RINGS) { const R = ring.r scale (0.35 + 0.65 u); const spin = ring.dir (t 0.12 + (1 - u) 2.2) (reduce ? 0 : 1); ctx.fillStyle = rgba(120,100,80,${(ring.a u).toFixed(3)}); for (let k = 0; k < ring.n; k++) { const a = spin + k / ring.n Math.PI 2; ctx.beginPath(); ctx.arc(cx + Math.cos(a) R, cy + Math.sin(a) R, 1.05, 0, Math.PI * 2); ctx.fill(); } } }
/ ---------- show / hide password ---------- / const eye = document.querySelector('.kh-eye'); const pass = document.getElementById('kh-pass'); eye.addEventListener('click', () => { const show = eye.getAttribute('aria-pressed') !== 'true'; eye.setAttribute('aria-pressed', String(show)); eye.setAttribute('aria-label', show ? 'Hide password' : 'Show password'); pass.type = show ? 'text' : 'password'; });
/ ---------- submit with a rolling label ---------- / const form = document.querySelector('.kh-form'); const btn = form.querySelector('.kh-btn'); const roll = [...btn.querySelectorAll('.kh-roll > span')]; const live = btn.querySelector('[data-label]'); const spinEl = btn.querySelector('.kh-spin'); const LABELS = { idle: 'Sign in', busy: 'Signing in…', done: 'Welcome back' }; let rollTarget = 0, rollPos = 0; function setState(s) { btn.dataset.state = s; rollTarget = { idle: 0, busy: 1, done: 2 }[s]; live.textContent = LABELS[s]; btn.disabled = s === 'busy'; } form.addEventListener('submit', async e => { e.preventDefault(); if (btn.dataset.state !== 'idle') return; if (!form.checkValidity()) { form.reportValidity(); return; } setState('busy'); try { await onSubmit({ email: form.email.value, password: pass.value }); setState('done'); status.textContent = 'Signed in. Welcome back.'; } catch (err) { setState('idle'); status.textContent = 'Sign in failed. Try again.'; } }); document.querySelectorAll('[data-provider]').forEach(b => b.addEventListener('click', () => onProvider(b.dataset.provider)));
/ ---------- one loop for every motion ---------- / let t0 = null, last = 0; document.fonts.ready.then(() => { t0 = performance.now(); last = t0; root.dataset.ready = '1'; }); function frame(now) { requestAnimationFrame(frame); if (t0 === null) return; const dt = Math.min(0.05, (now - last) / 1000); last = now; const t = (now - t0) / 1000;
// tray rises in const tp = reduce ? 1 : easeOut(clamp(t / 0.8, 0, 1)); tray.style.opacity = reduce ? clamp(t / 0.4, 0, 1) : tp; tray.style.transform = tp < 1 ? translateY(${(1 - tp) 26}px) scale(${0.98 + tp 0.02}) : '';
drawHalo(t);
// mark springs in, then draws its door const sp = reduce ? 1 : spring(clamp((t - 0.35) / 1.1, 0, 1)); tile.style.transform = scale(${sp.toFixed(3)}) rotate(${((1 - sp) -14).toFixed(2)}deg); paths.forEach((p, i) => { const d = reduce ? 1 : easeOut(clamp((t - 0.7 - i 0.35) / 0.7, 0, 1)); p.style.strokeDashoffset = (+p.dataset.len * (1 - d)).toFixed(2); });
// rows rise and un-blur on a stagger rows.forEach((r, i) => { if (r.dataset.done) return; const p = clamp((t - 0.45 - i 0.065) / 0.6, 0, 1), e = easeOut(p); r.style.opacity = e; r.style.transform = reduce || p >= 1 ? '' : translateY(${(1 - e) 10}px); r.style.filter = reduce || p >= 1 ? '' : blur(${(1 - e) * 5}px); if (p >= 1) r.dataset.done = '1'; });
// rolling label rollPos += (rollTarget - rollPos) (reduce ? 1 : Math.min(1, dt 12)); roll.forEach((s, i) => { const off = i - rollPos; s.style.transform = translateY(${(off 100).toFixed(1)}%); s.style.opacity = Math.max(0, 1 - Math.abs(off) 1.4).toFixed(3); }); spinEl.style.transform = rotate(${(t 360 1.2) % 360}deg); } requestAnimationFrame(frame); })(); </script> </body> </html>
Source, 280 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="#f4f1ec" />
<title>Sign in · Keyhaven</title>
<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=Instrument+Serif:ital@0;1&family=Inter+Tight:wght@400;500;600&display=swap" rel="stylesheet" />
<style>
:root{
--page:#f4f1ec;--tray:#ebe6de;--card:#fffdfa;--ink:#1d1a17;--muted:#8a8278;--well:#f3efe9;--line:#e6e0d7;
--clay:#c65f3b;--clay2:#e08a5f;--ok:#2f8f5b;
}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;background:var(--page);color:var(--ink);font-family:"Inter Tight",system-ui,-apple-system,"Segoe UI",sans-serif;-webkit-font-smoothing:antialiased}
.kh-page{min-height:100vh;min-height:100svh;display:grid;place-items:center;padding:28px 16px;
background:radial-gradient(60% 50% at 50% 40%,#fbf8f3,transparent 70%),var(--page)}
.kh-tray{width:min(400px,100%);padding:6px 6px 0;border-radius:30px;background:var(--tray);
box-shadow:inset 0 1px 0 rgba(255,255,255,.7),inset 0 0 0 1px rgba(0,0,0,.035),0 30px 60px -30px rgba(80,60,40,.35);opacity:0}
.kh-card{position:relative;padding:28px 26px 24px;border-radius:24px;background:var(--card);
box-shadow:0 1px 0 rgba(255,255,255,.9) inset,0 0 0 1px rgba(60,40,20,.06),0 10px 24px -14px rgba(80,60,40,.35)}
.kh-foot{padding:15px 12px 16px;text-align:center;font-size:13.5px;color:var(--muted)}
.kh-foot a{color:var(--ink);font-weight:500;text-decoration:none}
.kh-foot a:hover{text-decoration:underline}
/* mark + halo */
.kh-mark{position:relative;width:132px;height:112px;margin:-6px auto 6px;display:grid;place-items:center}
.kh-mark canvas{position:absolute;inset:0;width:100%;height:100%}
.kh-tile{position:relative;width:52px;height:52px;border-radius:16px;display:grid;place-items:center;
background:linear-gradient(160deg,var(--clay2),var(--clay));
box-shadow:inset 0 1px 0 rgba(255,255,255,.4),inset 0 -2px 0 rgba(0,0,0,.12),0 8px 18px -6px rgba(198,95,59,.6);transform:scale(0)}
.kh-tile svg{width:26px;height:26px}
.kh-tile path{stroke-dasharray:var(--len);stroke-dashoffset:var(--len)}
.kh-title{margin:0;text-align:center;font-family:"Instrument Serif",Georgia,serif;font-weight:400;font-size:34px;line-height:1.05;letter-spacing:-.01em}
.kh-title em{color:var(--clay)}
.kh-sub{margin:8px 0 22px;text-align:center;font-size:14px;line-height:1.5;color:var(--muted)}
.kh-form{display:flex;flex-direction:column;gap:10px}
.kh-well{position:relative;display:flex;align-items:center;gap:10px;height:46px;padding:0 6px 0 14px;border-radius:13px;background:var(--well);
box-shadow:inset 0 1px 2px rgba(60,40,20,.08),inset 0 0 0 1px rgba(60,40,20,.04);transition:box-shadow .2s,background .2s}
.kh-well:focus-within{background:#fff;box-shadow:inset 0 0 0 1.5px var(--clay),0 0 0 4px rgba(198,95,59,.12)}
.kh-well>svg{width:16px;height:16px;flex:none;color:#a59c91}
.kh-well:focus-within>svg{color:var(--clay)}
.kh-well input{flex:1;min-width:0;height:100%;border:0;outline:0;background:none;font:inherit;font-size:15px;color:var(--ink)}
.kh-well input::placeholder{color:#a79e94}
.kh-eye{display:grid;place-items:center;width:34px;height:34px;border:0;border-radius:9px;background:none;color:#a59c91;cursor:pointer}
.kh-eye:hover{background:rgba(0,0,0,.05);color:var(--ink)}
.kh-eye svg{width:17px;height:17px}
.kh-eye .off{display:none}.kh-eye[aria-pressed="true"] .on{display:none}.kh-eye[aria-pressed="true"] .off{display:block}
.kh-row{display:flex;align-items:center;justify-content:space-between;margin:2px 2px 4px;font-size:13.5px}
.kh-check{display:inline-flex;align-items:center;gap:8px;color:#5d564e;cursor:pointer;user-select:none}
.kh-check input{position:absolute;opacity:0;width:1px;height:1px}
.kh-box{width:18px;height:18px;border-radius:6px;background:var(--well);box-shadow:inset 0 0 0 1px #d8d0c5;display:grid;place-items:center;transition:background .15s,box-shadow .15s}
.kh-box svg{width:11px;height:11px;opacity:0;transform:scale(.6);transition:opacity .15s,transform .15s}
.kh-check input:checked+.kh-box{background:var(--ink);box-shadow:none}
.kh-check input:checked+.kh-box svg{opacity:1;transform:none}
.kh-check input:focus-visible+.kh-box{outline:2px solid var(--clay);outline-offset:2px}
.kh-link{color:var(--clay);text-decoration:none;font-weight:500}
.kh-link:hover{text-decoration:underline}
.kh-btn{position:relative;height:48px;border:0;border-radius:14px;cursor:pointer;color:#fff;font:inherit;font-weight:500;font-size:15px;overflow:hidden;
background:linear-gradient(180deg,#2b2622,var(--ink));box-shadow:inset 0 1px 0 rgba(255,255,255,.14),0 8px 18px -8px rgba(29,26,23,.7);transition:transform .15s,background .3s}
.kh-btn:hover{transform:translateY(-1px)}
.kh-btn:active{transform:scale(.985)}
.kh-btn[data-state="done"]{background:linear-gradient(180deg,#3aa56c,var(--ok))}
.kh-roll{position:absolute;inset:0}
.kh-roll span{position:absolute;left:0;right:0;height:48px;display:flex;align-items:center;justify-content:center;gap:8px}
.kh-roll svg{width:16px;height:16px}
.kh-spin{animation:none}
.kh-or{display:flex;align-items:center;gap:10px;margin:18px 0 12px;font-size:12.5px;color:#a79e94}
.kh-or::before,.kh-or::after{content:"";flex:1;border-top:1px dashed #ddd5ca}
.kh-social{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.kh-social button{height:44px;border-radius:13px;border:0;background:#fff;cursor:pointer;display:grid;place-items:center;
box-shadow:0 0 0 1px var(--line),0 1px 2px rgba(60,40,20,.06);transition:box-shadow .2s,transform .15s}
.kh-social button:hover{box-shadow:0 0 0 1px #d6cdc1,0 6px 14px -8px rgba(60,40,20,.35);transform:translateY(-1px)}
.kh-social svg{width:19px;height:19px}
:is(.kh-btn,.kh-social button,.kh-eye,.kh-link,.kh-foot a):focus-visible{outline:2px solid var(--clay);outline-offset:2px}
.kh-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
@media (max-width:400px){.kh-card{padding:24px 18px 20px}.kh-title{font-size:30px}}
@media (max-height:640px){.kh-mark{height:84px;margin-bottom:2px}.kh-sub{margin-bottom:16px}.kh-or{margin:14px 0 10px}}
</style>
</head>
<body>
<main class="kh-page">
<section class="kh-tray" aria-labelledby="kh-title">
<div class="kh-card">
<div class="kh-mark" aria-hidden="true">
<canvas></canvas>
<div class="kh-tile">
<svg viewBox="0 0 26 26" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M4.5 11.5 13 4.5l8.5 7V21a1 1 0 0 1-1 1h-15a1 1 0 0 1-1-1z"/>
<path d="M13 13.4a2 2 0 1 1 0 .01M13 15.4V18.5"/>
</svg>
</div>
</div>
<h1 class="kh-title" id="kh-title" data-row>Welcome <em>home</em></h1>
<p class="kh-sub" data-row>Sign in to see your saved homes, viewings and offers.</p>
<form class="kh-form">
<label class="kh-well" data-row>
<span class="kh-sr">Email</span>
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><rect x="1.8" y="3.2" width="12.4" height="9.6" rx="2"/><path d="m2.5 4.5 5.5 4 5.5-4"/></svg>
<input type="email" name="email" placeholder="Email address" autocomplete="email" required />
</label>
<div class="kh-well" data-row>
<label class="kh-sr" for="kh-pass">Password</label>
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><rect x="2.5" y="7" width="11" height="7.2" rx="2"/><path d="M5 7V5a3 3 0 0 1 6 0v2"/></svg>
<input id="kh-pass" type="password" name="password" placeholder="Password" autocomplete="current-password" minlength="6" required />
<button class="kh-eye" type="button" aria-pressed="false" aria-label="Show password">
<svg class="on" viewBox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="M1.5 9S4.2 3.8 9 3.8 16.5 9 16.5 9 13.8 14.2 9 14.2 1.5 9 1.5 9Z"/><circle cx="9" cy="9" r="2.3"/></svg>
<svg class="off" viewBox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="M2.5 2.5l13 13M7.2 4C7.8 3.9 8.4 3.8 9 3.8 13.8 3.8 16.5 9 16.5 9a13 13 0 0 1-2 2.6M5 5.3C2.8 6.8 1.5 9 1.5 9S4.2 14.2 9 14.2c1.4 0 2.6-.4 3.6-1"/><path d="M7.4 7.5a2.3 2.3 0 0 0 3.1 3.1"/></svg>
</button>
</div>
<div class="kh-row" data-row>
<label class="kh-check"><input type="checkbox" name="remember" checked /><span class="kh-box"><svg viewBox="0 0 12 12" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m2.5 6.2 2.3 2.3 4.7-5"/></svg></span>Keep me signed in</label>
<a class="kh-link" href="#">Forgot password?</a>
</div>
<button class="kh-btn" type="submit" data-row data-state="idle">
<span class="kh-roll" aria-hidden="true">
<span>Sign in</span>
<span><svg class="kh-spin" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M14 8a6 6 0 1 1-4.2-5.7"/></svg>Signing in…</span>
<span><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="m3.5 8.3 3 3 6-6.6"/></svg>Welcome back</span>
</span>
<span class="kh-sr" aria-live="polite" data-label>Sign in</span>
</button>
</form>
<div class="kh-or" data-row><span>or continue with</span></div>
<div class="kh-social" data-row>
<button type="button" aria-label="Continue with Google" data-provider="google">
<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="#4285F4" d="M22.6 12.3c0-.8-.1-1.5-.2-2.3H12v4.3h6a5.1 5.1 0 0 1-2.2 3.4v2.8h3.6c2.1-2 3.2-4.8 3.2-8.2z"/><path fill="#34A853" d="M12 23c3 0 5.5-1 7.4-2.7l-3.6-2.8c-1 .7-2.3 1.1-3.8 1.1-2.9 0-5.4-2-6.3-4.6H2v2.9A11 11 0 0 0 12 23z"/><path fill="#FBBC05" d="M5.7 14c-.2-.7-.4-1.3-.4-2s.1-1.4.4-2V7.1H2A11 11 0 0 0 2 16.9z"/><path fill="#EA4335" d="M12 5.4c1.6 0 3.1.6 4.2 1.7l3.2-3.2A11 11 0 0 0 2 7.1L5.7 10c.9-2.6 3.4-4.6 6.3-4.6z"/></svg>
</button>
<button type="button" aria-label="Continue with Facebook" data-provider="facebook">
<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="11" fill="#1877F2"/><path fill="#fff" d="M13.4 23v-8.1h2.7l.4-3.2h-3.1V9.7c0-.9.3-1.5 1.6-1.5h1.6V5.3c-.3 0-1.3-.1-2.4-.1-2.4 0-4 1.4-4 4.1v2.4H7.5v3.2h2.7V23z"/></svg>
</button>
<button type="button" aria-label="Continue with Apple" data-provider="apple">
<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="#111" d="M16.4 12.6c0-2.6 2.1-3.8 2.2-3.9-1.2-1.8-3.1-2-3.7-2-1.6-.2-3.1.9-3.9.9-.8 0-2-.9-3.4-.9-1.7 0-3.3 1-4.2 2.6-1.8 3.1-.5 7.7 1.3 10.2.9 1.2 1.9 2.6 3.2 2.6 1.3-.1 1.8-.8 3.3-.8 1.6 0 2 .8 3.4.8s2.2-1.3 3.1-2.5c1-1.4 1.4-2.8 1.4-2.9 0 0-2.7-1-2.7-4.1zM13.9 5c.7-.9 1.2-2 1-3.2-1 0-2.2.7-3 1.5-.6.7-1.2 1.9-1 3.1 1.1.1 2.3-.6 3-1.4z"/></svg>
</button>
</div>
</div>
<p class="kh-foot" data-row>New to Keyhaven? <a href="#">Create an account</a></p>
</section>
<span class="kh-sr" role="status" aria-live="polite"></span>
</main>
<script>
(() => {
/* hook these up to your auth */
async function onSubmit({ email, password }) { await new Promise(r => setTimeout(r, 1300)); }
function onProvider(provider) { status.textContent = `Opening ${provider} sign-in`; }
const root = document.documentElement;
const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
const clamp = (v, a, b) => Math.min(b, Math.max(a, v));
const easeOut = x => 1 - Math.pow(1 - x, 3);
const spring = x => x >= 1 ? 1 : 1 - Math.exp(-6.5 * x) * Math.cos(9.5 * x); // damped spring 0 → 1 with overshoot
const tray = document.querySelector('.kh-tray');
const tile = document.querySelector('.kh-tile');
const paths = [...tile.querySelectorAll('path')];
paths.forEach(p => { const l = p.getTotalLength(); p.style.setProperty('--len', l); p.dataset.len = l; });
const rows = [...document.querySelectorAll('[data-row]')];
rows.forEach(r => { r.style.opacity = 0; });
const status = document.querySelector('.kh-sr[role="status"]');
/* ---------- dot halo ---------- */
const cv = document.querySelector('.kh-mark canvas');
const ctx = cv.getContext('2d');
const RINGS = [];
for (let r = 34, i = 0; r <= 64; r += 6, i++) RINGS.push({ r, n: Math.round(r * 0.62), dir: i % 2 ? -1 : 1, a: 0.55 - i * 0.08 });
function sizeCanvas() {
const b = cv.getBoundingClientRect(), d = Math.min(devicePixelRatio || 1, 2);
cv.width = b.width * d; cv.height = b.height * d; ctx.setTransform(d, 0, 0, d, 0, 0);
}
sizeCanvas(); addEventListener('resize', sizeCanvas);
function drawHalo(t) {
const b = cv.getBoundingClientRect(); const cx = b.width / 2, cy = b.height / 2;
ctx.clearRect(0, 0, b.width, b.height);
const u = reduce ? 1 : easeOut(clamp((t - 0.15) / 1.3, 0, 1));
const scale = b.height < 100 ? 0.75 : 1;
for (const ring of RINGS) {
const R = ring.r * scale * (0.35 + 0.65 * u);
const spin = ring.dir * (t * 0.12 + (1 - u) * 2.2) * (reduce ? 0 : 1);
ctx.fillStyle = `rgba(120,100,80,${(ring.a * u).toFixed(3)})`;
for (let k = 0; k < ring.n; k++) {
const a = spin + k / ring.n * Math.PI * 2;
ctx.beginPath(); ctx.arc(cx + Math.cos(a) * R, cy + Math.sin(a) * R, 1.05, 0, Math.PI * 2); ctx.fill();
}
}
}
/* ---------- show / hide password ---------- */
const eye = document.querySelector('.kh-eye');
const pass = document.getElementById('kh-pass');
eye.addEventListener('click', () => {
const show = eye.getAttribute('aria-pressed') !== 'true';
eye.setAttribute('aria-pressed', String(show));
eye.setAttribute('aria-label', show ? 'Hide password' : 'Show password');
pass.type = show ? 'text' : 'password';
});
/* ---------- submit with a rolling label ---------- */
const form = document.querySelector('.kh-form');
const btn = form.querySelector('.kh-btn');
const roll = [...btn.querySelectorAll('.kh-roll > span')];
const live = btn.querySelector('[data-label]');
const spinEl = btn.querySelector('.kh-spin');
const LABELS = { idle: 'Sign in', busy: 'Signing in…', done: 'Welcome back' };
let rollTarget = 0, rollPos = 0;
function setState(s) {
btn.dataset.state = s; rollTarget = { idle: 0, busy: 1, done: 2 }[s];
live.textContent = LABELS[s]; btn.disabled = s === 'busy';
}
form.addEventListener('submit', async e => {
e.preventDefault();
if (btn.dataset.state !== 'idle') return;
if (!form.checkValidity()) { form.reportValidity(); return; }
setState('busy');
try {
await onSubmit({ email: form.email.value, password: pass.value });
setState('done'); status.textContent = 'Signed in. Welcome back.';
} catch (err) { setState('idle'); status.textContent = 'Sign in failed. Try again.'; }
});
document.querySelectorAll('[data-provider]').forEach(b => b.addEventListener('click', () => onProvider(b.dataset.provider)));
/* ---------- one loop for every motion ---------- */
let t0 = null, last = 0;
document.fonts.ready.then(() => { t0 = performance.now(); last = t0; root.dataset.ready = '1'; });
function frame(now) {
requestAnimationFrame(frame);
if (t0 === null) return;
const dt = Math.min(0.05, (now - last) / 1000); last = now;
const t = (now - t0) / 1000;
// tray rises in
const tp = reduce ? 1 : easeOut(clamp(t / 0.8, 0, 1));
tray.style.opacity = reduce ? clamp(t / 0.4, 0, 1) : tp;
tray.style.transform = tp < 1 ? `translateY(${(1 - tp) * 26}px) scale(${0.98 + tp * 0.02})` : '';
drawHalo(t);
// mark springs in, then draws its door
const sp = reduce ? 1 : spring(clamp((t - 0.35) / 1.1, 0, 1));
tile.style.transform = `scale(${sp.toFixed(3)}) rotate(${((1 - sp) * -14).toFixed(2)}deg)`;
paths.forEach((p, i) => {
const d = reduce ? 1 : easeOut(clamp((t - 0.7 - i * 0.35) / 0.7, 0, 1));
p.style.strokeDashoffset = (+p.dataset.len * (1 - d)).toFixed(2);
});
// rows rise and un-blur on a stagger
rows.forEach((r, i) => {
if (r.dataset.done) return;
const p = clamp((t - 0.45 - i * 0.065) / 0.6, 0, 1), e = easeOut(p);
r.style.opacity = e;
r.style.transform = reduce || p >= 1 ? '' : `translateY(${(1 - e) * 10}px)`;
r.style.filter = reduce || p >= 1 ? '' : `blur(${(1 - e) * 5}px)`;
if (p >= 1) r.dataset.done = '1';
});
// rolling label
rollPos += (rollTarget - rollPos) * (reduce ? 1 : Math.min(1, dt * 12));
roll.forEach((s, i) => {
const off = i - rollPos;
s.style.transform = `translateY(${(off * 100).toFixed(1)}%)`;
s.style.opacity = Math.max(0, 1 - Math.abs(off) * 1.4).toFixed(3);
});
spinEl.style.transform = `rotate(${(t * 360 * 1.2) % 360}deg)`;
}
requestAnimationFrame(frame);
})();
</script>
</body>
</html>