import React, { useEffect, useRef, useState } from 'react' import { useSearchParams } from 'react-router-dom' import { AnimatePresence, animate, motion } from 'framer-motion' import './demo.css' import { type FlowId, type DemoPlayerState, ALL_FLOWS, useDemoPlayer, } from './context/DemoContext' import { ScoreRing } from './components/ScoreRing' import { IconHome, IconUsers, IconApps, IconSliders, IconCheck, IconShieldCheck as IconShieldCheckSvg, IconChevron as IconChevronSvg, IconShield, IconAlert, IconLock, IconPin, IconRouter, IconConsole, IconTv, IconCamera, IconSpeaker, IconPhone, IconLaptop, IconBell, IconDownload, IconGlobe, } from './components/Icons' import { SECURITY_ALERTS, WEEKLY_REPORT, SECURITY_SCORE, EMMA_INCIDENT_TIMELINE, } from './data/mock' // ── Design tokens ───────────────────────────────────────────────────────────── const T = { bg: '#013B49', bgGrad: 'radial-gradient(140% 90% at 50% 0%, #075466 0%, #013B49 55%, #01303b 100%)', surface: 'rgba(255,255,255,0.04)', surface2: 'rgba(255,255,255,0.07)', surface3: 'rgba(255,255,255,0.10)', surfaceStr:'#0a4856', border: 'rgba(255,255,255,0.09)', borderStr: 'rgba(255,255,255,0.16)', text: '#e8f4f3', text2: '#b9cdd1', muted: '#8aa5ab', dim: '#5a7a82', accent: '#3BB586', accentSoft:'rgba(59,181,134,0.16)', accentGlow:'rgba(59,181,134,0.30)', danger: '#ff6b6b', dangerSoft:'rgba(255,107,107,0.14)', warn: '#ffb56b', warnSoft: 'rgba(255,181,107,0.14)', success: '#4ec99a', successSoft:'rgba(78,201,154,0.14)', info: '#6fa9f7', av: { S: '#2563EB', E: '#ea580c', M: '#9333EA', J: '#16A34A' } as Record, chrome: '#013B49', chrome2: '#012e3a', chromeBdr: 'rgba(59,181,134,0.18)', toastBg: '#0a3d4a', } // ── Easing ──────────────────────────────────────────────────────────────────── const EASE_OUT = [0.23, 1, 0.32, 1] as const // strong ease-out for entries const EASE_SPRING = { type: 'spring', stiffness: 340, damping: 28 } as const // ── Atoms ───────────────────────────────────────────────────────────────────── const cardStyle: React.CSSProperties = { background: T.surface2, border: `1px solid ${T.border}`, borderRadius: 16, padding: '12px 14px', } function Av({ k, size = 32 }: { k: string; size?: number }) { const col = T.av[k] ?? T.accent const init: Record = { S:'S', E:'E', M:'M', J:'J' } return (
{init[k] ?? k}
) } function Pill({ label, variant }: { label: string; variant: 'ok'|'warn'|'off'|'danger'|'info' }) { const map = { ok: { bg: T.successSoft, color: T.success }, warn: { bg: T.warnSoft, color: T.warn }, off: { bg: T.surface3, color: T.muted }, danger: { bg: T.dangerSoft, color: T.danger }, info: { bg: T.accentSoft, color: T.accent }, } const s = map[variant] return {label} } function Iconbox({ children, color = T.text2, bg = T.surface3, size = 32 }: { children: React.ReactNode; color?: string; bg?: string; size?: number }) { return (
{children}
) } function Chevron() { return } function ShieldCheck({ size = 20, color = T.success }: { size?: number; color?: string }) { return } function PrimaryBtn({ children, color = T.accent, onClick }: { children: React.ReactNode; color?: string; onClick?: () => void }) { return ( {children} ) } function LiveDot({ color = T.success }: { color?: string }) { return ( ) } function AnimNum({ to, from = 0, delay = 0 }: { to: number; from?: number; delay?: number }) { const ref = useRef(null) useEffect(() => { const timer = setTimeout(() => { animate(from, to, { duration: 1.4, ease: [0.22, 1, 0.36, 1], onUpdate: v => { if (ref.current) ref.current.textContent = Math.round(v).toString() }, }) }, delay) return () => clearTimeout(timer) }, [to, from, delay]) return {from} } function RowDivider({ first }: { first: boolean }) { return first ? null :
} function StatusChip({ label, ok }: { label: string; ok: boolean }) { return (
{label}
) } // ── Global pulse keyframes ──────────────────────────────────────────────────── const PULSE_CSS = ` @keyframes bdPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,107,107,.45) } 50% { box-shadow: 0 0 0 10px rgba(255,107,107,0) } } @keyframes bdGlow { 0%,100% { opacity: .7 } 50% { opacity: 1 } } ` // ── Flow A ──────────────────────────────────────────────────────────────────── export function SceneHome() { const [count, setCount] = useState(47) useEffect(() => { const t = setTimeout(() => setCount(48), 2800); return () => clearTimeout(t) }, []) return (
{/* Greeting + live badge */}
Good morning, Sarah
LIVE
{/* KPI strip */}
{[ { label: 'Blocked today', value: count, color: T.success }, { label: 'Devices safe', value: 12, color: T.accent }, { label: 'Family score', value: 92, color: T.success }, ].map((k, i) => (
{k.label === 'Blocked today' ? count : k.value}
{k.label}
))}
{/* Protection banner */}
Your family is protected
3 children · 12 devices · VPN active
{/* Approval nudge */}
2 requests need your attention
App install · Website access
{/* Quick actions */} {([{ Icon: IconLock, label: 'Pause internet' }, { Icon: IconPin, label: 'Where are kids' }] as const).map(q => (
{q.label}
))}
{/* Family */}
Family
{[ { k:'E', name:'Emma', sub:'At school · 2h 47m left', pill:'ok' as const }, { k:'M', name:'Mia', sub:'At home · 45m today', pill:'ok' as const }, { k:'J', name:'Jack', sub:'Home · screen limit hit', pill:'warn' as const }, ].map((c, i) => (
{c.name}
{c.sub}
))}
) } function SceneAlertToast() { const [show, setShow] = useState(false) useEffect(() => { const t = setTimeout(() => setShow(true), 600); return () => clearTimeout(t) }, []) return (
{show && (
Critical
Just now
Malware detected · PlayStation 5
Trojan.GenericKD.71234 · Outbound C&C traffic
Tap →
)}
) } function SceneAlertDetail() { const a = SECURITY_ALERTS[0] return ( {/* Threat header */}
{a.timeAgo}
Malware detected
PlayStation 5 · Jack · Age 8
{/* Threat name */}
THREAT IDENTIFIER
Trojan.GenericKD.71234
{/* Kill chain */}
{['Delivery', 'Install', 'C&C ←', 'Exfil...'].map((s, i) => ( {s} {i < 3 && ›} ))}
{/* Intelligence rows */} {[ { label: 'C&C Server', value: '185.220.101.47', sub: 'Amsterdam 🇳🇱 · Tor exit node', color: T.danger }, { label: 'Upload rate', value: '3.2 MB/s', sub: 'Sustained 4 min · Rising', color: T.warn }, { label: 'Device', value: a.deviceName ?? 'PlayStation 5', sub: 'FW 23.02 · Jack', color: T.text2 }, { label: 'Detected', value: a.timeAgo, sub: 'Pattern match + heuristic', color: T.muted }, ].map((r, i) => (
{r.label}
{r.sub &&
{r.sub}
}
{r.value}
))}
Isolate PlayStation 5 →
) } function SceneDevicePS5() { const [mb, setMb] = useState(3.2) useEffect(() => { const t = setInterval(() => setMb(v => Math.round((v + 0.1) * 10) / 10), 1800) return () => clearInterval(t) }, []) const bars = [18, 22, 19, 25, 20, 71, 88, 92, mb > 3.5 ? 94 : 90] return ( {/* Device card */}
PlayStation 5
Sony · FW 23.02 · 192.168.1.9
{/* Live traffic */}
LIVE OUTBOUND
{mb.toFixed(1)} MB/s
{bars.map((h, i) => ( 50 ? T.danger : T.accentSoft }} /> ))}
→ 185.220.101.47 · Amsterdam · Tor exit
{/* Info table */}
{[ { l: 'Status', v: 'Active C&C link', c: T.danger }, { l: 'Owner', v: 'Jack · Age 8', c: T.text2 }, { l: 'Network', v: 'Hughes-Home-5G', c: T.text2 }, { l: 'Last clean',v: '14 days ago', c: T.muted }, ].map((r, i) => (
{r.l} {r.v}
))}
) } function SceneIsolateModal() { const [tapped, setTapped] = useState(false) return ( // Negative margin exactly cancels the screen padding (6px top / 13px sides / 8px bottom) // so the panel fills the phone screen edge-to-edge with no scroll/overflow.
{/* Dimmed background scene */}
{/* Full overlay — fills the phone screen, sheet anchored to bottom */} {/* Bottom sheet slides up */} {/* Drag handle */}
{/* Header */}
Isolate PlayStation 5?
All internet access cut immediately.
Restore any time from your dashboard.
{/* Checklist */}
{[ 'C&C connection severed instantly', 'Outbound uploads stopped', 'All 11 other devices unaffected', 'Full incident report auto-saved', ].map((text, i) => (
{text}
))}
{/* Actions */}
setTapped(true)}> {tapped ? 'Isolating…' : 'Isolate Now'} Cancel – stay connected
) } function SceneIsolateProgress() { const [done, setDone] = useState(-1) useEffect(() => { const timers = [600, 1800, 3200, 4800].map((d, i) => setTimeout(() => setDone(i), d)) return () => timers.forEach(clearTimeout) }, []) const steps = [ { label: 'Blocking network access', sub: 'Firewall rule applied' }, { label: 'Severing C&C connection', sub: '185.220.101.47 blacklisted' }, { label: 'Logging incident report', sub: 'CVE reference + pcap saved' }, { label: 'Notifying Sarah', sub: 'Push + email sent' }, ] const pct = done < 0 ? 0 : done >= 3 ? 100 : Math.round(((done + 1) / 4) * 100) return ( {/* Progress ring */}
= 3 ? T.success : T.danger} strokeWidth="6" strokeLinecap="round" strokeDasharray={188.5} animate={{ strokeDashoffset: 188.5 - (188.5 * pct / 100) }} transition={{ duration: .6, ease: EASE_OUT }} />
{done >= 3 ? : {pct}%}
= 3 ? T.success : T.text }}> {done >= 3 ? 'Device isolated' : 'Isolating PlayStation 5…'}
{steps.map((s, i) => { const state = i < done ? 'done' : i === done ? 'active' : 'pending' return ( {state === 'done' ? :
}
{s.label}
{state !== 'pending' &&
{s.sub}
}
) })}
) } function SceneResolved() { return ( {/* Success banner */}
Threat neutralised
PlayStation 5 isolated · family safe
{/* Score before → after */}
/100
Family Security Score
88
→
94 · ▲ +6
{/* Action log */} {[ { label: 'Malware blocked', done: true }, { label: 'PS5 network isolated', done: true }, { label: 'C&C connection severed', done: true }, { label: 'All 11 other devices safe', done: true }, ].map((r, i) => ( {r.label} ))} View full incident report →
) } // ── Flow B ──────────────────────────────────────────────────────────────────── function SceneNotifPanel() { return (
Notifications
2 critical
{/* Critical group */}
Critical
{([ { Icon: IconAlert, title: "Suspicious login – Emma's account", body: 'Instagram · Moscow 🇷🇺 · 02:31 AM', t: '8m ago', variant: 'danger' as const }, { Icon: IconShield, title: 'Malware blocked · PS5', body: 'Trojan.GenericKD.71234 · Stopped', t: '6m ago', variant: 'danger' as const }, ] as const).map((n, i) => { const c = T.danger return (
{n.title}
{n.body}
{n.t}
) })} {/* Info group */}
Earlier
{([ { Icon: IconPin, title: 'Emma arrived at School', body: '8:42 AM · geofence enter', t: '2h ago', variant: 'ok' as const }, { Icon: IconLock, title: 'Unsafe WiFi – VPN on', body: "Starbucks_Free · Sarah's iPhone", t: '4h ago', variant: 'warn' as const }, ] as const).map((n, i) => { const vc = { ok: T.success, warn: T.warn } const c = vc[n.variant] return (
{n.title}
{n.body}
{n.t}
) })} ) } function SceneEmmaProfile() { return ( {/* Alert banner */}
Account alert · Investigate →
Suspicious login on Instagram · 02:31
{/* Profile */}
Emma Hughes
Age 14 · Teen filter · iPhone 14
School · since 8:42 AM
{/* Screen time */}
Screen time today 2h 47m / 4h
{[{ app: 'TikTok', t: '1h 12m', c: T.danger }, { app: 'YouTube', t: '48m', c: T.warn }, { app: 'Snapchat', t: '31m', c: T.accent }].map(a => (
{a.app} {a.t}
))}
{/* Devices */} {[ { icon: , label: "iPhone 14", sub: 'Online · iOS 17.4', ok: true }, { icon: , label: "MacBook Air", sub: 'At home · Off', ok: false }, ].map((d, i) => (
{d.icon}
{d.label}
{d.sub}
))}
) } function SceneTimeline() { const kindColor: Record = { normal: T.success, info: T.muted, anomaly: T.danger, blocked: T.warn } return (
Event Timeline · Emma
Jun 28–29
{EMMA_INCIDENT_TIMELINE.map((e, i) => { const isAnomaly = e.kind === 'anomaly' return (
{e.time}
{e.label}
{e.detail}
) })}
) } function SceneIPDetail() { const riskPct = 94 const circ = 2 * Math.PI * 28 return ( {/* IP card */}
IP Intelligence
77.88.55.244
Yandex LLC · Moscow 🇷🇺 · AS208312
{/* Risk gauge */}
9.4
risk
{/* Tags */}
{['Credential stuffing', 'Botnet C&C', 'Tor exit', 'Brute force'].map(tag => ( {tag} ))}
{/* Stats grid */}
{[ { label: 'Abuse reports', value: '94', color: T.danger }, { label: 'Countries hit', value: '37', color: T.warn }, { label: 'Victims linked', value: '3,400+', color: T.warn }, { label: 'Active since', value: 'Nov 2024', color: T.text2 }, ].map((s, i) => (
{s.label}
{s.value}
))}
Linked to: Instagram credential stuffing campaign – 3,400+ victims globally, ongoing since Nov 2024. Block this IP across all devices →
) } function SceneScope() { return ( {/* Impact numbers */}
{[ { n: 1, label: 'Account affected', color: T.danger, sub: "Emma's Instagram" }, { n: 0, label: 'Devices affected', color: T.success, sub: '12/12 safe' }, ].map((s, i) => ( 0 ? T.danger + '44' : T.border, background: s.n > 0 ? T.dangerSoft : T.surface2 }}>
{s.label}
0 ? T.danger : T.success, marginTop: 2 }}>{s.sub}
))}
{/* Actions required */}
Actions required
{[ { label: 'Force Instagram password reset', urgency: 'Now', color: T.danger }, { label: 'Enable two-factor authentication', urgency: '5 min', color: T.warn }, { label: 'Review connected third-party apps', urgency: '10 min', color: T.accent }, ].map((r, i) => (
{r.label}
{r.urgency} ))}
Take action now →
) } // ── Flow C ──────────────────────────────────────────────────────────────────── function SceneDevicesList() { return (
Home devices
1 needs attention
{([ { Icon: IconPhone, name: "Sarah's iPhone 15 Pro", sub: 'iOS 17.4 · Online', variant: 'ok' as const, score: 100 }, { Icon: IconLaptop, name: "Mark's MacBook Pro", sub: 'macOS 14.4 · Online', variant: 'ok' as const, score: 98 }, { Icon: IconConsole, name: 'PlayStation 5', sub: 'FW 23.02 · Isolated', variant: 'warn' as const, score: 72 }, { Icon: IconTv, name: 'Samsung 65" Smart TV', sub: 'Tizen 7.0 · Online', variant: 'ok' as const, score: 95 }, { Icon: IconRouter, name: 'HP LaserJet Pro', sub: 'FW 22.5 · CVE-2024-8471', variant: 'warn' as const, score: 61 }, { Icon: IconCamera, name: 'Nest Cam (Front Door)', sub: 'FW 3.5.2 · Online', variant: 'ok' as const, score: 97 }, ] as const).map((d, i) => (
{d.name}
{d.sub}
= 90 ? T.success : d.score >= 75 ? T.accent : T.warn }}>{d.score}
score
))}
) } function SceneVulnDetail() { return (
HP LaserJet Pro
Firmware 22.5 · Port 9100
{/* CVE */}
VULNERABILITY
CVE-2024-8471
Remote code execution via print port 9100
{/* CVSS bar */}
CVSS v3 7.8 / 10
{/* Attack vector */}
Attack vector
{[['🌐', 'Network'], ['→', ''], ['🖨️', 'Port 9100'], ['→', ''], ['💀', 'RCE']].map((p, i) => ( p[0] === '→' ? → : {p[0]} {p[1]} ))}
{/* Fix */} {[ { l: 'Affected FW', v: '< 22.6', c: T.danger, first: true }, { l: 'Your version', v: '22.5 · Vulnerable', c: T.danger, first: false }, { l: 'Fix available', v: 'v22.6.1 · Ready', c: T.success, first: false }, { l: 'Downtime', v: 'None required', c: T.accent, first: false }, ].map(r => (
{r.l} {r.v}
))}
Update firmware now →
) } function SceneScanRunning() { const items: { Icon: React.ComponentType<{ size?: number; style?: React.CSSProperties }>; name: string; ok: boolean; warn?: boolean }[] = [ { Icon: IconPhone, name: "Sarah's iPhone", ok: true }, { Icon: IconLaptop, name: "Mark's MacBook", ok: true }, { Icon: IconPhone, name: "Emma's iPhone", ok: true }, { Icon: IconLaptop, name: "Mia's iPad", ok: true }, { Icon: IconConsole, name: 'PS5', ok: true }, { Icon: IconTv, name: 'Smart TV', ok: true }, { Icon: IconCamera, name: 'Nest Cam', ok: true }, { Icon: IconSpeaker, name: 'HomePod', ok: true }, { Icon: IconConsole, name: 'Switch', ok: true }, { Icon: IconRouter, name: 'Hue Bridge', ok: true }, { Icon: IconRouter, name: 'HP Printer', ok: false, warn: true }, { Icon: IconLaptop, name: 'Guest Laptop', ok: false }, ] const [visible, setVisible] = useState(0) useEffect(() => { const t = setInterval(() => setVisible(v => Math.min(v + 1, items.length)), 280) return () => clearInterval(t) }, [items.length]) return ( {/* Progress */}
Scanning network…
{Math.min(visible, 11)} / 12
= 11 ? T.warn : T.muted, marginTop: 5 }}> {visible >= 11 ? '⚠ 1 issue found · HP Printer · CVE-2024-8471' : 'Checking firmware versions and CVE database…'}
{/* Device grid */}
{items.map((d, i) => { const shown = i < visible const iconColor = d.warn ? T.warn : d.ok ? T.accent : T.dim return ( {shown && ( {d.name} {d.warn ? : d.ok ? : null} )} ) })}
) } function SceneRemediation() { const [phase, setPhase] = useState(0) useEffect(() => { const ts = [900, 2200, 3800].map((d, i) => setTimeout(() => setPhase(i + 1), d)) return () => ts.forEach(clearTimeout) }, []) const stages = ['Downloading v22.6.1', 'Verifying checksum', 'Applying patch'] return ( {/* Device header */}
= 3 ? T.successSoft : T.surface3} size={40}> = 3 ? T.success : T.text2 }} />
HP LaserJet Pro
{phase < 3 ? `FW 22.5 → 22.6.1 · ${stages[Math.min(phase, 2)]}` : 'FW 22.6.1 · Patch applied'}
= 3 ? 'Updated' : 'Updating…'} variant={phase >= 3 ? 'ok' : 'warn'} />
{/* Stage progress */}
{stages.map((s, i) => { const done = phase > i const active = phase === i return (
{done ? :
}
{done ? '✓' : active ? '…' : ''}
) })}
{phase >= 3 && ( ✓ Firmware updated successfully )}
{[ { l: 'Patch version', v: '22.5 → 22.6.1', c: T.text2, first: true }, { l: 'CVE closed', v: 'CVE-2024-8471', c: T.success, first: false }, { l: 'Downtime', v: 'None required', c: T.accent, first: false }, { l: 'Verified by', v: 'BlackDice cloud', c: T.muted, first: false }, ].map(r => (
{r.l} {r.v}
))}
) } function SceneVerified() { return (
All clear
HP Printer patched · CVE-2024-8471 resolved
/100
Family Security Score
92
95 · ▲ +3
{[ { t: 'HP Printer · FW 22.6.1 installed', done: true }, { t: 'CVE-2024-8471 patch verified', done: true }, { t: '12 devices · all secure', done: true }, { t: 'Next scan in 24 hours', done: false }, ].map((r, i) => ( {r.done ? :
} {r.t} ))}
) } // ── Flow D ──────────────────────────────────────────────────────────────────── function SceneScoreRingFull() { const categories = [ { label: 'Network', score: 97, color: T.success }, { label: 'Devices', score: 88, color: T.accent }, { label: 'Accounts', score: 94, color: T.success }, { label: 'Kids', score: 92, color: T.accent }, ] return (
{SECURITY_SCORE.label}
Family Security Score
{SECURITY_SCORE.previous} +{SECURITY_SCORE.change} this week
{/* Category breakdown */}
{categories.map((c, i) => (
{c.label}
{c.score}
))}
{/* Stats row */}
{[ { label: 'Threats blocked', value: WEEKLY_REPORT.threatsBlocked, color: T.success }, { label: 'Devices', value: WEEKLY_REPORT.devicesProtected, color: T.accent }, { label: 'Open issues', value: WEEKLY_REPORT.openIssues, color: T.warn }, ].map((s, i) => (
{s.label}
))}
) } function SceneTrendsChart() { const days = ['M','T','W','T','F','S','S'] const max = Math.max(...WEEKLY_REPORT.daily) const total = WEEKLY_REPORT.daily.reduce((a, b) => a + b, 0) return ( {/* Bar chart */}
blocked
↓ {Math.abs(WEEKLY_REPORT.threatsVsLastWeek)}% vs last week
{WEEKLY_REPORT.daily.map((v, i) => (
{days[i]}
))}
{/* Top threat types */}
By threat type
{WEEKLY_REPORT.topThreats.map((t, i) => (
{t.label}
{t.pct}%
))}
) } function SceneDeviceGrid() { const gridIcons = [ { I: IconPhone, n: "Sarah" }, { I: IconLaptop, n: "Mark" }, { I: IconPhone, n: "Emma" }, { I: IconLaptop, n: "Mia" }, { I: IconConsole, n: "PS5" }, { I: IconConsole, n: "Switch" }, { I: IconTv, n: "TV" }, { I: IconSpeaker, n: "HomePod" }, { I: IconCamera, n: "Cam" }, { I: IconRouter, n: "Bridge" }, { I: IconRouter, n: "Printer" }, { I: IconLaptop, n: "Guest" }, ] return (
12 Devices Protected
Last scan: Just now · 0 vulnerabilities
{gridIcons.map((d, i) => (
{d.n}
))}
) } function SceneExport() { const [open, setOpen] = useState(false) useEffect(() => { const t = setTimeout(() => setOpen(true), 650); return () => clearTimeout(t) }, []) return (
{open && ( {/* Report preview */}
Weekly Security Report
Hughes Family · {WEEKLY_REPORT.period}
{/* Score summary row */}
{SECURITY_SCORE.score}
Security score
↓{Math.abs(WEEKLY_REPORT.threatsVsLastWeek)}%
vs last week
A+
Rating
{/* Action buttons */}
{(['Share', 'Download PDF', 'Print'] as const).map(l => ( {l === 'Download PDF' && } {l} ))}
)}
) } // ── Scene registry ───────────────────────────────────────────────────────────── const SCENES: Record JSX.Element> = { 'home': SceneHome, 'alert-toast': SceneAlertToast, 'alert-detail': SceneAlertDetail, 'device-ps5': SceneDevicePS5, 'isolate-modal': SceneIsolateModal, 'isolate-progress': SceneIsolateProgress, 'resolved': SceneResolved, 'notif-panel': SceneNotifPanel, 'emma-profile': SceneEmmaProfile, 'timeline': SceneTimeline, 'ip-detail': SceneIPDetail, 'scope': SceneScope, 'devices-list': SceneDevicesList, 'vuln-detail': SceneVulnDetail, 'scan-running': SceneScanRunning, 'remediation': SceneRemediation, 'verified': SceneVerified, 'score-ring': SceneScoreRingFull, 'trends-chart': SceneTrendsChart, 'device-grid': SceneDeviceGrid, 'export': SceneExport, } // ── Video mode (Apple-style, phone-first) ───────────────────────────────────── type Tilt = { rotateY: number; rotateX: number; scale: number } type VideoItem = { id: string; scene: string | null; ms: number; caption: string; vo: string; tilt: Tilt } // Sequence: title + 7 Flow-A scenes + end card ≈ 52s const VIDEO_SEQUENCE: VideoItem[] = [ { id: 'title', scene: null, ms: 4000, caption: 'Welcome', vo: 'Your family’s digital life. One screen.', tilt: { rotateY: -4, rotateX: 2, scale: 0.97 } }, { id: 'home', scene: 'home', ms: 5400, caption: 'Home Dashboard', vo: 'Everything you need to protect your family – in one place.', tilt: { rotateY: -2, rotateX: 2, scale: 1.00 } }, { id: 'toast', scene: 'alert-toast', ms: 6000, caption: 'Real-time Alert', vo: 'Real-time threats, delivered exactly when they happen.', tilt: { rotateY: 3, rotateX: 1, scale: 1.01 } }, { id: 'detail', scene: 'alert-detail', ms: 6400, caption: 'Threat Intelligence', vo: 'We don’t just say something’s wrong. We show you what it is.', tilt: { rotateY: 0, rotateX: 0, scale: 1.00 } }, { id: 'ps5', scene: 'device-ps5', ms: 6000, caption: 'Live Traffic', vo: 'Watch threats in real time. See what’s leaving your home.', tilt: { rotateY: -3, rotateX: 2, scale: 1.01 } }, { id: 'modal', scene: 'isolate-modal', ms: 7400, caption: 'One Tap', vo: 'One tap. That’s all it takes to stop it.', tilt: { rotateY: 0, rotateX: 4, scale: 1.02 } }, { id: 'progress', scene: 'isolate-progress', ms: 6500, caption: 'Automatic Response', vo: 'Isolated. Severed. Logged. Notified.', tilt: { rotateY: -1, rotateX: 1, scale: 1.00 } }, { id: 'resolved', scene: 'resolved', ms: 5600, caption: 'Resolved', vo: 'Threat neutralised. Family safe. Score improved.', tilt: { rotateY: 0, rotateX: 0, scale: 1.00 } }, { id: 'end', scene: null, ms: 5200, caption: 'BlackDice Angel', vo: 'BlackDice Angel. Safety you can see.', tilt: { rotateY: -4, rotateX: 2, scale: 0.97 } }, ] const VIDEO_TOTAL_MS = VIDEO_SEQUENCE.reduce((s, v) => s + v.ms, 0) function VideoLogo({ size = 36 }: { size?: number }) { return ( ) } function SceneVideoTitle() { return (
{/* Glow ring behind logo */}
BlackDice Angel
Your family’s digital life.
One screen.
) } function SceneVideoEnd() { return (
BlackDice Angel
Safety you can see.
Get started free blackdice.ai/angel
) } // Apple-style bezel-less phone with Dynamic Island + ambient glass reflection function PhoneShell({ children }: { children: React.ReactNode }) { return (
{/* Inner screen */}
{/* Status bar */}
9:41 5G  ▲ 100%
{/* Dynamic Island */}
{/* Content */}
{children}
{/* Tab bar */}
{([ { Icon: IconHome, label: 'Home' }, { Icon: IconUsers, label: 'Family' }, { Icon: IconApps, label: 'Devices' }, { Icon: IconSliders, label: 'Controls'}, { Icon: IconBell, label: 'Alerts' }, ] as const).map((tab, i) => (
{tab.label}
))}
{/* Ambient glass reflection (top-left sheen) */}
) } export function VideoPlayer({ embedded = false }: { embedded?: boolean }) { const [idx, setIdx] = useState(0) const [started, setStarted] = useState(false) const [muted, setMuted] = useState(false) const [elapsed, setElapsed] = useState(0) // ms since start const rafRef = useRef(0) const t0Ref = useRef(0) const cancelSpeech = () => { try { window.speechSynthesis && window.speechSynthesis.cancel() } catch { /* noop */ } } const item = VIDEO_SEQUENCE[idx] const isFirst = idx === 0 const isLast = idx === VIDEO_SEQUENCE.length - 1 // Cumulative start offset of current scene const sceneOffset = VIDEO_SEQUENCE.slice(0, idx).reduce((s, v) => s + v.ms, 0) const sceneElapsed = elapsed - sceneOffset const scenePct = Math.min(sceneElapsed / item.ms, 1) const totalPct = Math.min(elapsed / VIDEO_TOTAL_MS, 1) function start() { setStarted(true) t0Ref.current = performance.now() - elapsed function tick() { const now = performance.now() - t0Ref.current setElapsed(now) // Advance scene setIdx(i => { let cum = 0 for (let j = 0; j < VIDEO_SEQUENCE.length; j++) { cum += VIDEO_SEQUENCE[j].ms if (now < cum) return j } return VIDEO_SEQUENCE.length - 1 }) if (now < VIDEO_TOTAL_MS) rafRef.current = requestAnimationFrame(tick) else { setStarted(false) } } rafRef.current = requestAnimationFrame(tick) } function pause() { setStarted(false) cancelAnimationFrame(rafRef.current) cancelSpeech() } function reset() { cancelAnimationFrame(rafRef.current) cancelSpeech() setStarted(false) setElapsed(0) setIdx(0) } function jumpTo(i: number) { const target = Math.max(0, Math.min(i, VIDEO_SEQUENCE.length - 1)) cancelAnimationFrame(rafRef.current) cancelSpeech() setStarted(false) const off = VIDEO_SEQUENCE.slice(0, target).reduce((s, x) => s + x.ms, 0) setElapsed(off) setIdx(target) } useEffect(() => () => { cancelAnimationFrame(rafRef.current); cancelSpeech() }, []) // Spoken voiceover for each scene via the Web Speech API (triggered by the // user's Play click, so autoplay-audio policies allow it). useEffect(() => { if (!started || muted) return const synth = window.speechSynthesis if (!synth) return synth.cancel() const u = new SpeechSynthesisUtterance(item.vo) u.lang = 'en-GB' u.rate = 0.96 u.pitch = 1.02 u.volume = 1 const pickVoice = () => { const vs = synth.getVoices() return ( vs.find((v) => /en-GB/i.test(v.lang) && /female|libby|sonia|google uk english female|samantha/i.test(v.name)) || vs.find((v) => /en-GB/i.test(v.lang)) || vs.find((v) => /en-US/i.test(v.lang)) || vs.find((v) => /^en/i.test(v.lang)) ) } const v = pickVoice() if (v) u.voice = v synth.speak(u) return () => synth.cancel() }, [idx, started, muted, item.vo]) const SceneComp = item.scene ? SCENES[item.scene] : null const secs = Math.floor(elapsed / 1000) const mins = Math.floor(secs / 60) const ss = String(secs % 60).padStart(2, '0') const tilt = item.tilt return (
{/* Vignette */}
{/* Scene chip — top left, subtle */} {String(idx + 1).padStart(2, '0')} {item.caption} {/* ── Stage: full-size phone + vertical control dock beside it ── */}
{/* Phone column: device + voiceover subtitle below. Fixed width so the phone & dock never shift between scenes. */}
{/* Phone — per-scene tilt wrapper */} {/* Breathing float */} {/* Accent glow behind phone */}
{SceneComp ? : isFirst ? : } {/* Cinematic voiceover subtitle — fixed-size box so changing text never alters the column's footprint. */}
{item.vo}
{/* ── Vertical control dock (right side of the phone) ── */}
{/* Play / Pause */} {started ? '⏸' : '▶'} {/* Mute / unmute voiceover */} setMuted((m) => !m)} title={muted ? 'Unmute voiceover' : 'Mute voiceover'} style={{ width: 34, height: 34, borderRadius: '50%', background: muted ? 'rgba(255,255,255,.06)' : T.accentSoft, border: `1px solid ${muted ? 'rgba(255,255,255,.1)' : T.accentGlow}`, color: muted ? T.muted : T.accent, fontSize: 14, cursor: 'pointer', fontFamily: 'inherit', display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0 }}> {muted ? '🔇' : '🔊'} {/* Restart */} ↩ {/* Prev scene */} jumpTo(idx - 1)} disabled={idx === 0} style={{ width: 34, height: 34, borderRadius: '50%', background: 'rgba(255,255,255,.06)', border: '1px solid rgba(255,255,255,.1)', color: T.muted, fontSize: 11, cursor: 'pointer', fontFamily: 'inherit', display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0, opacity: idx === 0 ? .3 : 1 }}>▲ {/* Vertical progress track */}
{/* Next scene */} jumpTo(idx + 1)} disabled={idx >= VIDEO_SEQUENCE.length - 1} style={{ width: 34, height: 34, borderRadius: '50%', background: 'rgba(255,255,255,.06)', border: '1px solid rgba(255,255,255,.1)', color: T.muted, fontSize: 11, cursor: 'pointer', fontFamily: 'inherit', display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0, opacity: idx >= VIDEO_SEQUENCE.length - 1 ? .3 : 1 }}>▼ {/* Scene dots */}
{VIDEO_SEQUENCE.map((v, i) => ( jumpTo(i)} title={v.caption} style={{ width: 6, height: 6, borderRadius: '50%', border: 'none', cursor: 'pointer', padding: 0, background: i === idx ? T.accent : i < idx ? T.accent + '66' : 'rgba(255,255,255,.18)' }} /> ))}
{/* Timecode */} {mins}:{ss}
) } // ── Control bar — vertical strip ────────────────────────────────────────────── function ControlBar({ player }: { player: DemoPlayerState }) { const { isPlaying, play, pause, reset, prev, next, flow, stepIndex } = player const btn: React.CSSProperties = { width: 34, height: 34, borderRadius: 9, background: 'rgba(255,255,255,0.06)', border: `1px solid ${T.chromeBdr}`, color: T.muted, fontSize: 13, cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'center', fontFamily: 'inherit', flexShrink: 0, } return (
{/* Reset */} {/* Play / Pause */} {isPlaying ? '⏸' : '▶'} {/* Prev */} {/* Vertical progress track */}
{/* Next */} {/* Step counter */} {stepIndex + 1}
/{flow.steps.length}
) } // ── Main DemoScreen ─────────────────────────────────────────────────────────── export default function DemoScreen() { const [searchParams, setSearchParams] = useSearchParams() // Video recording mode — ?mode=video if (searchParams.get('mode') === 'video') return const rawFlow = searchParams.get('flow')?.toUpperCase() as FlowId | null const [flowId, setFlowId] = useState( rawFlow && ['A','B','C','D'].includes(rawFlow ?? '') ? rawFlow! : 'A' ) const player = useDemoPlayer(flowId) const { flow, step, stepIndex, isPlaying, progress } = player useEffect(() => { setSearchParams({ flow: flowId }, { replace: true }) }, [flowId, setSearchParams]) useEffect(() => { if (rawFlow) player.play() }, []) // eslint-disable-line const handleFlowChange = (id: FlowId) => { setFlowId(id); player.reset() } const SceneComponent = SCENES[step.screen] return (
{/* Top bar */}
BlackDice Angel
Demo Player
{ALL_FLOWS.map(f => ( handleFlowChange(f.id)} whileTap={{ scale: .95 }} style={{ padding: '3px 11px', borderRadius: 7, fontSize: 11, fontWeight: 500, cursor: 'pointer', fontFamily: 'inherit', transition: 'all .15s', border: `1px solid ${flowId === f.id ? f.color : T.chromeBdr}`, background: flowId === f.id ? f.color + '20' : 'rgba(255,255,255,0.04)', color: flowId === f.id ? f.color : T.dim }}> {f.id} · {f.durationSec}s ))}
{/* Body — fills remaining 100vh */}
{/* Left — steps (scrolls internally) */}
{flow.title}
{flow.subtitle}
{flow.steps.map((s, i) => { const isActive = i === stepIndex const isDone = i < stepIndex return ( ) })}
{step.camera && (
CAMERA
{step.camera}
)}
{/* Centre — phone natural size + vertical controls to its right */}
{/* Phone — fixed natural size, full height of available space up to 700px */}
{/* Status bar */}
9:41 DEMO ▲ 100%
{/* Content */}
{SceneComponent ? :
—
}
{/* Tab bar */}
{([ { Icon: IconHome, label: 'Home', active: ['home','alert-toast','resolved'].includes(step.screen) }, { Icon: IconUsers, label: 'Family', active: ['emma-profile','notif-panel'].includes(step.screen) }, { Icon: IconApps, label: 'Devices', active: ['device-ps5','devices-list','scan-running'].includes(step.screen) }, { Icon: IconSliders, label: 'Controls', active: ['timeline','ip-detail','scope'].includes(step.screen) }, { Icon: IconBell, label: 'Alerts', active: false }, ] as const).map(tab => (
{tab.label}
))}
{/* Vertical control strip */}
{/* Right — info (scrolls internally) */}
Scene
{step.label}
{step.caption}
Timing
{step.durationMs / 1000}s this scene
{flow.durationSec}s total · Flow {flow.id}
Recording tip
Press ▶ to auto-advance. Record at 60fps 1080p. Direct URL: ?flow={flowId}
Flow {flow.id} · {flow.durationSec}s
{flow.subtitle}
) }