← back to Dw Photo Capture
public/themes/v21-beat-the-clock.html
211 lines
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>v21 — Beat the Clock</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=Inter:wght@400;600;700&display=swap" rel="stylesheet">
<style>
:root{
--bg:#141414;
--cam:#1c1c1e;
--track:#3a3a3a;
--orange:#ff6a00; /* decorative fills (bar, shutter) */
--orange-deep:#f06000; /* surfaces carrying white text (3:1 at >=24px) */
--amber:#ffc23f;
--green:#2e9e5b;
--muted:#9a9a9a;
--btn-dark:#333333;
--focus:#ffc23f;
}
*{box-sizing:border-box;}
html,body{margin:0;padding:0;background:#0a0a0a;font-family:'Inter',system-ui,sans-serif;}
.stage{
width:390px;height:780px;margin:24px auto;position:relative;
background:var(--bg);border-radius:36px;overflow:hidden;
box-shadow:0 20px 60px rgba(0,0,0,.5);border:8px solid #000;color:#fff;
display:flex;flex-direction:column;
}
@media (max-width:405.98px){
.stage{width:100%;height:100dvh;min-height:640px;margin:0;border:0;border-radius:0;}
}
.screen{display:none;flex:1;min-height:0;flex-direction:column;gap:16px;padding:18px 24px 28px;overflow-y:auto;overflow-x:hidden;}
.screen.is-active{display:flex;}
.screen[data-screen="4"]{background:var(--orange-deep);}
.topbar{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:44px;flex-shrink:0;}
.topbar .right{display:flex;gap:8px;}
.step{margin:0;font-size:13px;font-weight:600;color:var(--muted);}
.screen[data-screen="4"] .step{color:var(--bg);}
h1{margin:0;font-weight:700;text-align:center;line-height:1.2;color:#fff;}
h1:focus{outline:none;}
.h-34{font-size:34px;} .h-26{font-size:26px;}
.sub{margin:0;text-align:center;font-size:17px;color:var(--muted);line-height:1.4;}
button{font:inherit;cursor:pointer;border:0;-webkit-tap-highlight-color:transparent;}
button:focus-visible{outline:3px solid var(--focus);outline-offset:3px;}
.screen[data-screen="4"] button:focus-visible{outline-color:#fff;}
.chip{
min-width:44px;min-height:44px;padding:0 12px;border-radius:14px;
background:var(--btn-dark);color:#fff;font-size:14px;font-weight:700;
}
.screen[data-screen="4"] .chip{background:var(--bg);}
.spacer{flex:1 1 0;min-height:0;}
.go{
width:100%;height:190px;border-radius:999px;background:var(--orange-deep);color:#fff;
font-size:28px;font-weight:700;letter-spacing:.5px;flex-shrink:0;
box-shadow:0 10px 0 #a84300;transition:transform .08s ease,box-shadow .08s ease;
}
.go:active{transform:translateY(6px);box-shadow:0 4px 0 #a84300;}
.bar{height:16px;border-radius:8px;background:var(--track);overflow:hidden;flex-shrink:0;position:relative;}
.bar > span{position:absolute;left:0;top:0;bottom:0;width:100%;border-radius:8px;background:var(--orange);transition:width 1s linear;}
.bar.amber > span{background:var(--amber);}
.timer{font-variant-numeric:tabular-nums;}
.camera{
background:var(--cam);border-radius:24px;display:flex;align-items:center;justify-content:center;
flex:1 1 auto;min-height:200px;max-height:470px;position:relative;
}
.target{width:14px;height:14px;border:2px solid #fff;border-radius:2px;}
.shutter-row{display:flex;justify-content:center;flex-shrink:0;}
.shutter{width:96px;height:96px;border-radius:50%;background:var(--orange);box-shadow:inset 0 0 0 6px #fff;}
.shutter:active{transform:scale(.96);}
.item{
background:#fff;border-radius:20px;padding:14px;display:flex;gap:14px;align-items:center;color:#1a1a1a;flex-shrink:0;
}
.item .sw{width:84px;height:84px;border-radius:14px;background:#d9ccb4;flex-shrink:0;}
.item .t{margin:0;font-size:20px;font-weight:700;}
.item .s{margin:4px 0 0;font-size:15px;color:#6b6b6b;}
.yes{min-height:104px;border-radius:20px;background:var(--green);color:#fff;font-size:24px;font-weight:700;letter-spacing:.8px;width:100%;flex-shrink:0;}
.nope{min-height:72px;border-radius:20px;background:var(--btn-dark);color:#fff;font-size:20px;font-weight:700;letter-spacing:.8px;width:100%;flex-shrink:0;}
.big{font-size:120px;line-height:1;font-variant-numeric:tabular-nums;}
.best{margin:0;text-align:center;font-size:34px;font-weight:700;color:#fff;}
.next{min-height:84px;border-radius:20px;background:var(--bg);color:#fff;font-size:20px;font-weight:600;letter-spacing:.8px;width:100%;flex-shrink:0;}
.timeup{margin:0;text-align:center;font-size:15px;font-weight:600;color:var(--amber);min-height:18px;}
@media (prefers-reduced-motion:reduce){
*,*::before,*::after{animation:none !important;transition:none !important;}
}
.confirm{margin:10px auto 0;text-align:center;font-size:18px;font-weight:700;color:#fff;background:#6b2600;padding:8px 16px;border-radius:999px;width:max-content;max-width:100%;}
</style>
</head>
<body>
<main class="stage" id="app">
<!-- 1 / 4 · Go -->
<section class="screen is-active" data-screen="1" aria-labelledby="s1-h">
<div class="topbar"><p class="step">1 / 4 · Go</p></div>
<h1 id="s1-h" class="h-34" tabindex="-1"><span aria-hidden="true">⏱️</span> 30 seconds.</h1>
<p class="sub">Check in a sample before time runs out.</p>
<div class="spacer"></div>
<button class="go" id="go-btn" aria-label="Go! Start the 30 second clock">GO!</button>
<div class="spacer"></div>
</section>
<!-- 2 / 4 · Scan -->
<section class="screen" data-screen="2" aria-labelledby="s2-h">
<div class="topbar">
<p class="step">2 / 4 · Scan</p>
<div class="right">
<button class="chip pause" aria-pressed="false">❚❚ Pause</button>
<button class="chip" data-home aria-label="Home">⌂ Home</button>
</div>
</div>
<div class="bar" aria-hidden="true"><span></span></div>
<h1 id="s2-h" class="h-26" tabindex="-1"><span class="timer" role="timer" aria-live="off">0:30</span> · scan the box</h1>
<p class="timeup" aria-live="polite"></p>
<div class="camera" role="img" aria-label="Camera viewfinder (pretend)"><div class="target"></div></div>
<div class="shutter-row"><button class="shutter" data-go="3" aria-label="Scan the box"></button></div>
</section>
<!-- 3 / 4 · Confirm -->
<section class="screen" data-screen="3" aria-labelledby="s3-h">
<div class="topbar">
<p class="step">3 / 4 · Confirm</p>
<div class="right">
<button class="chip pause" aria-pressed="false">❚❚ Pause</button>
<button class="chip" data-home aria-label="Home">⌂ Home</button>
</div>
</div>
<div class="bar amber" aria-hidden="true"><span></span></div>
<h1 id="s3-h" class="h-26" tabindex="-1"><span class="timer" role="timer" aria-live="off">0:30</span> · is this it?</h1>
<p class="timeup" aria-live="polite"></p>
<div class="item">
<div class="sw" aria-hidden="true"></div>
<div><p class="t">Linen — Oat</p><p class="s">Kravet · K-4410</p></div>
</div>
<div class="spacer"></div>
<button class="yes" id="yes-btn">YES ✓</button>
<button class="nope" data-go="2">NOPE</button>
</section>
<!-- 4 / 4 · Result -->
<section class="screen" data-screen="4" aria-labelledby="s4-h">
<div class="topbar"><p class="step">4 / 4 · Result</p><button class="chip" data-home aria-label="Home">⌂ Home</button></div>
<div class="spacer"></div>
<h1 id="s4-h" class="big" tabindex="-1"><span id="elapsed">19</span>s</h1>
<p class="best" id="best-line">New best! 🔥</p>
<p class="confirm">✓ Sample marked received</p>
<div class="spacer"></div>
<button class="next" data-home>NEXT BOX</button>
</section>
</main>
<script>
(function(){
const TOTAL = 30;
let remaining = TOTAL, tick = null, paused = false, best = Infinity;
const screens = Array.from(document.querySelectorAll('.screen'));
function fmt(s){ return '0:' + String(Math.max(0, s)).padStart(2, '0'); }
function render(){
document.querySelectorAll('.timer').forEach(t => t.textContent = fmt(remaining));
document.querySelectorAll('.bar > span').forEach(b => b.style.width = (remaining / TOTAL * 100) + '%');
const msg = remaining <= 0 ? "Time's up — finish when you're ready." : '';
document.querySelectorAll('.timeup').forEach(p => { if (p.textContent !== msg) p.textContent = msg; });
document.querySelectorAll('.pause').forEach(b => {
b.setAttribute('aria-pressed', paused ? 'true' : 'false');
b.textContent = paused ? '▶ Resume' : '❚❚ Pause';
b.disabled = remaining <= 0;
});
}
function stop(){ if (tick){ clearInterval(tick); tick = null; } }
function start(){
stop(); remaining = TOTAL; paused = false; render();
tick = setInterval(() => {
if (paused) return;
remaining -= 1;
if (remaining <= 0){ remaining = 0; stop(); }
render();
}, 1000);
}
// NOTE: the clock never navigates on its own; only the user's buttons move between screens.
function go(n){
screens.forEach(s => s.classList.toggle('is-active', s.dataset.screen === String(n)));
const h = document.querySelector('.screen.is-active h1');
if (h) h.focus({preventScroll:true});
}
function home(){ stop(); remaining = TOTAL; paused = false; render(); go(1); }
document.addEventListener('click', e => {
if (e.target.closest('[data-home]')) { home(); return; }
const b = e.target.closest('[data-go]');
if (b) go(b.dataset.go);
const p = e.target.closest('.pause');
if (p){ paused = !paused; render(); }
});
document.getElementById('go-btn').addEventListener('click', () => { start(); go(2); });
document.getElementById('yes-btn').addEventListener('click', () => {
stop();
const used = TOTAL - remaining;
document.getElementById('elapsed').textContent = used;
document.getElementById('best-line').textContent = used <= best ? 'New best! 🔥' : 'Nice run! 👏';
best = Math.min(best, used);
go(4);
});
render();
})();
</script>
<script>window.__theme = {id:'v21', name:'Beat the Clock', screens:4};</script>
</body>
</html>