// software-mockups.jsx — Software/App variant (fintech/productivity app)

// PHASE 01 — DISCOVER: spec doc + persona cards
function SwDiscoverMockup({ progress = 1 }) {
  return (
    <div style={{ width: '100%', height: '100%', background: '#fafaf6', position: 'relative', padding: 28, boxSizing: 'border-box', fontFamily: DH.body }}>
      <div style={{ fontFamily: DH.mono, fontSize: 11, letterSpacing: '0.14em', color: DH.moss600, textTransform: 'uppercase', marginBottom: 16 }}>
        PRODUCT · DISCOVERY · v0.3
      </div>
      <div style={{ display: 'grid', gridTemplateColumns: '1.1fr 1fr', gap: 22, height: 'calc(100% - 50px)' }}>
        {/* Spec doc */}
        <div style={{ background: '#fff', borderRadius: 8, padding: 22, border: `1px solid ${DH.rule}`,
          opacity: clamp(progress * 3, 0, 1), transform: `translateX(${(1 - clamp(progress*3,0,1)) * -14}px)` }}>
          <div style={{ fontFamily: DH.mono, fontSize: 9, color: DH.moss600, letterSpacing: '0.14em' }}>SPEC · v0.3</div>
          <div style={{ fontFamily: DH.display, fontWeight: 700, fontSize: 22, color: DH.ink, marginTop: 6, letterSpacing: '-0.01em' }}>
            Tally · weekly budget review
          </div>
          <div style={{ height: 1, background: DH.rule, margin: '14px 0' }}/>
          <div style={{ fontFamily: DH.mono, fontSize: 9, color: DH.moss600, letterSpacing: '0.1em', marginBottom: 6 }}>PROBLEM</div>
          <div style={{ fontSize: 12, color: DH.ink, opacity: 0.82, lineHeight: 1.55, marginBottom: 14 }}>
            Users check balances daily but abandon weekly reviews. Need a calmer ritual.
          </div>
          <div style={{ fontFamily: DH.mono, fontSize: 9, color: DH.moss600, letterSpacing: '0.1em', marginBottom: 6 }}>TARGET · WEEK 1</div>
          {['Sunday-evening review push', 'Category summary card', 'One-tap roll-forward'].map((t, i) => {
            const p = clamp(progress * 4 - 1 - i * 0.3, 0, 1);
            return (
              <div key={i} style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '7px 0', fontSize: 12, opacity: p }}>
                <div style={{ width: 14, height: 14, borderRadius: 3, border: `1.5px solid ${DH.moss600}`,
                  background: i < 2 ? DH.moss600 : 'transparent',
                  display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff', fontSize: 9 }}>
                  {i < 2 && '✓'}
                </div>
                <span style={{ color: DH.ink }}>{t}</span>
              </div>
            );
          })}
          <div style={{ height: 1, background: DH.rule, margin: '14px 0' }}/>
          <div style={{ fontFamily: DH.mono, fontSize: 9, color: DH.moss600, letterSpacing: '0.1em', marginBottom: 6 }}>KPI</div>
          <div style={{ fontSize: 12, color: DH.ink, opacity: 0.82 }}>D7 retention ≥ 35% · NPS ≥ 42</div>
        </div>

        {/* Persona cards */}
        <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
          {[
            { name: 'Priya · 29', role: 'Freelance designer', goal: 'See money fortnightly', friction: 'Dreads spreadsheets', tone: DH.moss600 },
            { name: 'Jonas · 36', role: 'Engineer · two kids',  goal: 'Stay on track quietly', friction: 'Noisy notifications', tone: DH.amber },
          ].map((p, i) => {
            const pr = clamp(progress * 3 - i * 0.5 - 0.2, 0, 1);
            return (
              <div key={i} style={{ background: '#fff', border: `1px solid ${DH.rule}`, borderRadius: 8, padding: 18,
                opacity: pr, transform: `translateY(${(1 - pr) * 14}px)`, flex: 1 }}>
                <div style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 12 }}>
                  <div style={{ width: 44, height: 44, borderRadius: 22, background: `linear-gradient(135deg, ${p.tone}, ${DH.moss700})` }}/>
                  <div>
                    <div style={{ fontFamily: DH.display, fontWeight: 600, fontSize: 15, color: DH.ink }}>{p.name}</div>
                    <div style={{ fontSize: 11, color: DH.ink, opacity: 0.6 }}>{p.role}</div>
                  </div>
                  <div style={{ marginLeft: 'auto', fontFamily: DH.mono, fontSize: 9, color: DH.moss600, letterSpacing: '0.12em' }}>§ 0{i + 1}</div>
                </div>
                <div style={{ fontSize: 11, marginBottom: 5 }}>
                  <span style={{ color: DH.moss600, fontWeight: 600, fontFamily: DH.mono, fontSize: 9, letterSpacing: '0.1em' }}>GOAL · </span>
                  <span style={{ color: DH.ink, opacity: 0.82 }}>{p.goal}</span>
                </div>
                <div style={{ fontSize: 11 }}>
                  <span style={{ color: DH.amber, fontWeight: 600, fontFamily: DH.mono, fontSize: 9, letterSpacing: '0.1em' }}>FRICTION · </span>
                  <span style={{ color: DH.ink, opacity: 0.82 }}>{p.friction}</span>
                </div>
              </div>
            );
          })}
        </div>
      </div>
    </div>
  );
}

// PHASE 02 — DESIGN: Figma screen flows (3-4 screens with arrows)
function SwDesignMockup({ progress = 1 }) {
  const screens = [
    { label: 'Onboarding', x: 60, y: 80 },
    { label: 'Weekly recap', x: 320, y: 60 },
    { label: 'Category detail', x: 580, y: 80 },
    { label: 'Celebrate', x: 840, y: 60 },
  ];
  return (
    <div style={{ width: '100%', height: '100%', background: '#fafaf8', position: 'relative', overflow: 'hidden', fontFamily: DH.body }}>
      {/* Fake figma chrome */}
      <div style={{ height: 34, background: '#1d1d1d', color: '#bbb', fontFamily: DH.mono, fontSize: 10,
        display: 'flex', alignItems: 'center', padding: '0 14px', gap: 12 }}>
        <div style={{ display: 'flex', gap: 6 }}>
          {['#ff5f57','#febc2e','#28c840'].map((c, i) => <div key={i} style={{ width: 9, height: 9, borderRadius: 5, background: c }}/>)}
        </div>
        <div style={{ opacity: 0.65 }}>tally — userflow_v4.fig</div>
        <div style={{ marginLeft: 'auto', opacity: 0.6 }}>Play flow ▸</div>
      </div>

      <div style={{ position: 'relative', width: '100%', height: 'calc(100% - 34px)', padding: 16, boxSizing: 'border-box' }}>
        {/* Arrows */}
        <svg style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }} viewBox="0 0 1100 420">
          <defs>
            <marker id="arr-sw" markerWidth="10" markerHeight="10" refX="7" refY="5" orient="auto">
              <path d="M0,0 L7,5 L0,10" fill="none" stroke={DH.moss600} strokeWidth="2"/>
            </marker>
          </defs>
          {[[200, 200, 310, 180], [470, 180, 580, 200], [720, 200, 830, 180]].map(([x1,y1,x2,y2], i) => {
            const p = clamp((progress - 0.3 - i * 0.15) * 4, 0, 1);
            return (
              <path key={i} d={`M${x1},${y1} Q${(x1+x2)/2},${(y1+y2)/2 - 30} ${x2},${y2}`}
                stroke={DH.moss600} strokeWidth="2" fill="none" markerEnd="url(#arr-sw)"
                strokeDasharray="180" strokeDashoffset={(1 - p) * 180} opacity={p}/>
            );
          })}
        </svg>

        {screens.map((s, i) => {
          const p = clamp(progress * 3 - i * 0.35, 0, 1);
          return (
            <div key={i} style={{
              position: 'absolute', left: s.x, top: s.y,
              width: 140, height: 260,
              background: '#fff', borderRadius: 22, padding: 6,
              boxShadow: '0 14px 28px rgba(36,69,58,0.12)',
              border: `1px solid ${DH.rule}`,
              opacity: p, transform: `translateY(${(1-p)*14}px) scale(${0.9 + 0.1*p})`,
            }}>
              <div style={{ width: '100%', height: '100%', background: DH.bg, borderRadius: 18, position: 'relative', overflow: 'hidden', padding: 10, boxSizing: 'border-box' }}>
                {/* Notch */}
                <div style={{ position: 'absolute', left: '50%', top: 4, transform: 'translateX(-50%)', width: 36, height: 4, background: '#0f1713', borderRadius: 2, opacity: 0.55 }}/>
                {/* Content sketch */}
                {i === 0 && <>
                  <div style={{ marginTop: 24, fontFamily: DH.serif, fontStyle: 'italic', fontSize: 14, color: DH.ink }}>Welcome</div>
                  <div style={{ width: '70%', height: 6, background: DH.rule, marginTop: 10 }}/>
                  <div style={{ width: '50%', height: 6, background: DH.rule, marginTop: 6 }}/>
                  <div style={{ position: 'absolute', left: 10, right: 10, bottom: 12, height: 24, background: DH.moss600, borderRadius: 12 }}/>
                </>}
                {i === 1 && <>
                  <div style={{ marginTop: 20, fontFamily: DH.mono, fontSize: 7, color: DH.moss600, letterSpacing: '0.12em' }}>WEEK 14</div>
                  <div style={{ fontFamily: DH.display, fontWeight: 700, fontSize: 16, color: DH.ink, marginTop: 2 }}>−€124</div>
                  <div style={{ height: 1, background: DH.rule, margin: '6px 0' }}/>
                  {[60, 42, 30, 20].map((w, j) => <div key={j} style={{ width: `${w}%`, height: 5, background: j === 0 ? DH.moss600 : DH.moss500, opacity: j === 0 ? 1 : 0.5, marginTop: 4, borderRadius: 2 }}/>)}
                </>}
                {i === 2 && <>
                  <div style={{ marginTop: 24, fontFamily: DH.mono, fontSize: 7, color: DH.moss600, letterSpacing: '0.12em' }}>GROCERIES</div>
                  <div style={{ fontFamily: DH.display, fontWeight: 700, fontSize: 15, color: DH.ink, marginTop: 2 }}>€312</div>
                  <svg viewBox="0 0 100 40" style={{ width: '100%', marginTop: 8 }}>
                    <path d="M0,25 Q25,15 50,20 T100,12" stroke={DH.moss600} strokeWidth="1.5" fill="none"/>
                  </svg>
                </>}
                {i === 3 && <>
                  <div style={{ height: '100%', display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' }}>
                    <div style={{ width: 44, height: 44, borderRadius: 22, background: `radial-gradient(circle, ${DH.amber}, ${DH.moss600})` }}/>
                    <div style={{ fontFamily: DH.serif, fontStyle: 'italic', fontSize: 14, color: DH.ink, marginTop: 8 }}>Nicely done.</div>
                  </div>
                </>}
              </div>
              <div style={{ position: 'absolute', left: 0, right: 0, bottom: -22, textAlign: 'center',
                fontFamily: DH.mono, fontSize: 9, color: DH.ink, opacity: 0.55, letterSpacing: '0.08em' }}>
                {String(i+1).padStart(2,'0')} · {s.label}
              </div>
            </div>
          );
        })}
      </div>
    </div>
  );
}

// PHASE 03 — BUILD: IDE with live preview
function SwBuildMockup({ progress = 1 }) {
  const codeLines = [
    { i: 'import', c: 'import { View, Text } from "react-native";', color: '#6fa37a' },
    { i: '', c: '' },
    { i: 'export', c: 'export function WeeklyRecap({ week }) {', color: '#3f6b54' },
    { i: 'const', c: '  const total = useTotal(week);', color: '#cd8a4b' },
    { i: 'return', c: '  return (', color: '#3f6b54' },
    { i: 'jsx', c: '    <View style={styles.card}>', color: '#555' },
    { i: 'jsx', c: '      <Text style={styles.eyebrow}>WEEK {week}</Text>', color: '#555' },
    { i: 'jsx', c: '      <Text style={styles.amount}>−€{total}</Text>', color: '#555' },
    { i: 'jsx', c: '      <Sparkline data={data} />', color: '#555' },
    { i: 'jsx', c: '    </View>', color: '#555' },
    { i: '', c: '  );' },
    { i: '', c: '}' },
  ];
  return (
    <div style={{ width: '100%', height: '100%', background: '#1c1f1d', fontFamily: DH.mono, fontSize: 12, color: '#e6e1d6', display: 'flex', flexDirection: 'column' }}>
      {/* Title bar */}
      <div style={{ height: 30, background: '#15181a', display: 'flex', alignItems: 'center', padding: '0 14px', gap: 12, fontSize: 10, color: '#8c948f' }}>
        <div style={{ display: 'flex', gap: 6 }}>
          {['#ff5f57','#febc2e','#28c840'].map((c, i) => <div key={i} style={{ width: 9, height: 9, borderRadius: 5, background: c }}/>)}
        </div>
        <div>tally — WeeklyRecap.tsx</div>
        <div style={{ marginLeft: 'auto', display: 'flex', gap: 12 }}>
          <span>▶ Run</span><span style={{ color: DH.moss500 }}>● Build · passed</span>
        </div>
      </div>
      <div style={{ flex: 1, display: 'flex' }}>
        {/* Explorer */}
        <div style={{ width: 180, background: '#191c1a', padding: '12px 10px', fontSize: 10, color: '#8c948f', borderRight: '1px solid #2a2d2b' }}>
          <div style={{ opacity: 0.5, marginBottom: 8, letterSpacing: '0.1em' }}>TALLY / SRC</div>
          {['App.tsx', 'screens/', '  Home.tsx', '  WeeklyRecap.tsx', '  Category.tsx', 'components/', '  Sparkline.tsx', '  Card.tsx'].map((f, i) => (
            <div key={i} style={{ padding: '3px 6px', color: f.includes('WeeklyRecap') ? '#fff' : '#c7c3b8',
              background: f.includes('WeeklyRecap') ? '#2a2d2b' : 'transparent',
              borderRadius: 3, fontSize: 10 }}>
              {f}
            </div>
          ))}
        </div>
        {/* Editor */}
        <div style={{ flex: 1, padding: '14px 18px', background: '#1c1f1d', fontFamily: DH.mono, fontSize: 12, lineHeight: 1.6 }}>
          {codeLines.map((l, i) => {
            const p = clamp(progress * 4 - i * 0.15, 0, 1);
            return (
              <div key={i} style={{ display: 'flex', opacity: p }}>
                <div style={{ width: 24, textAlign: 'right', color: '#55605a', marginRight: 14 }}>{i+1}</div>
                <div style={{ color: l.color || '#c7c3b8' }}>{l.c}</div>
              </div>
            );
          })}
          <div style={{ marginTop: 14, height: 2, background: DH.moss500, width: `${progress * 100}%` }}/>
          <div style={{ marginTop: 8, color: '#8c948f', fontSize: 10 }}>Metro bundler · Ready in 412ms</div>
        </div>
        {/* iPhone preview */}
        <div style={{ width: 260, background: '#15181a', padding: 20, display: 'flex', alignItems: 'center', justifyContent: 'center', borderLeft: '1px solid #2a2d2b' }}>
          <div style={{ width: 200, height: 400, background: '#0f1713', borderRadius: 32, padding: 6, boxShadow: '0 0 0 2px #2a2d2b, 0 20px 40px rgba(0,0,0,0.4)' }}>
            <div style={{ width: '100%', height: '100%', background: DH.bg, borderRadius: 26, position: 'relative', overflow: 'hidden', padding: 16, boxSizing: 'border-box' }}>
              <div style={{ position: 'absolute', left: '50%', top: 6, transform: 'translateX(-50%)', width: 60, height: 6, background: '#0f1713', borderRadius: 3 }}/>
              <div style={{ marginTop: 24, fontFamily: DH.mono, fontSize: 8, color: DH.moss600, letterSpacing: '0.18em' }}>WEEK 14</div>
              <div style={{ fontFamily: DH.display, fontWeight: 700, fontSize: 34, color: DH.ink, marginTop: 4, letterSpacing: '-0.02em' }}>
                −€124
              </div>
              <div style={{ fontFamily: DH.serif, fontStyle: 'italic', fontSize: 13, color: DH.moss600, marginTop: 2 }}>
                Under budget.
              </div>
              <svg viewBox="0 0 180 60" style={{ width: '100%', marginTop: 16 }}>
                <path d="M0,40 Q30,25 60,30 T120,18 T180,12" stroke={DH.moss600} strokeWidth="2" fill="none"/>
                <path d="M0,40 Q30,25 60,30 T120,18 T180,12 L180,60 L0,60 Z" fill={DH.moss500} fillOpacity="0.15"/>
              </svg>
              <div style={{ marginTop: 14, height: 1, background: DH.rule }}/>
              {['Groceries', 'Transport', 'Leisure'].map((c, i) => (
                <div key={i} style={{ display: 'flex', justifyContent: 'space-between', fontSize: 10, padding: '6px 0', color: DH.ink, opacity: 0.85 }}>
                  <span>{c}</span>
                  <span style={{ fontFamily: DH.mono, color: DH.moss600 }}>€{[42, 28, 54][i]}</span>
                </div>
              ))}
              <div style={{ position: 'absolute', left: 16, right: 16, bottom: 18, height: 34, borderRadius: 17, background: DH.moss600,
                display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff', fontFamily: DH.body, fontSize: 10, fontWeight: 500 }}>
                Roll forward →
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  );
}

// PHASE 04 — LAUNCH: iPhone mockup of shipped app home screen
function SwLaunchMockup({ progress = 1 }) {
  const time = useTime();
  return (
    <div style={{ width: '100%', height: '100%', background: DH.bg, position: 'relative', fontFamily: DH.body, overflow: 'hidden' }}>
      {/* Shipped badge top */}
      <div style={{ position: 'absolute', top: 24, right: 32,
        display: 'flex', alignItems: 'center', gap: 8,
        fontFamily: DH.mono, fontSize: 11, color: DH.moss600, letterSpacing: '0.14em',
        opacity: clamp(progress * 3, 0, 1), zIndex: 3 }}>
        <span style={{ width: 9, height: 9, borderRadius: 5, background: DH.moss500, boxShadow: `0 0 ${8 + Math.sin(time * 6) * 4}px ${DH.moss500}` }}/>
        LIVE ON APP STORE · v1.0
      </div>

      {/* App name + tagline */}
      <div style={{ position: 'absolute', left: 64, top: 80, maxWidth: 480, zIndex: 2 }}>
        <div style={{ fontFamily: DH.mono, fontSize: 11, color: DH.moss600, letterSpacing: '0.14em', textTransform: 'uppercase', marginBottom: 12 }}>
          § LAUNCHED · day 42
        </div>
        <div style={{ fontFamily: DH.display, fontWeight: 700, fontSize: 60, color: DH.ink, letterSpacing: '-0.03em', lineHeight: 0.95 }}>
          Tally
        </div>
        <div style={{ fontFamily: DH.serif, fontStyle: 'italic', fontSize: 36, color: DH.moss600, marginTop: 2, lineHeight: 1.05 }}>
          a quieter budget.
        </div>
        <div style={{ fontSize: 14, color: DH.ink, opacity: 0.72, marginTop: 22, lineHeight: 1.55, maxWidth: 360 }}>
          <span style={{ fontFamily: DH.serif, fontStyle: 'italic', fontSize: 18 }}>S</span>pend well, check in weekly. No charts that shout.
        </div>

        <div style={{ marginTop: 26, display: 'flex', gap: 10 }}>
          <div style={{ background: '#0f1713', color: '#fff', padding: '10px 16px', borderRadius: 10,
            fontSize: 12, display: 'flex', alignItems: 'center', gap: 8 }}>
            <span style={{ fontFamily: DH.display, fontSize: 18 }}></span>
            <div>
              <div style={{ fontSize: 8, opacity: 0.7 }}>Download on the</div>
              <div style={{ fontWeight: 600 }}>App Store</div>
            </div>
          </div>
          <div style={{ background: '#0f1713', color: '#fff', padding: '10px 16px', borderRadius: 10,
            fontSize: 12, display: 'flex', alignItems: 'center', gap: 8 }}>
            <span style={{ fontFamily: DH.display, fontSize: 16 }}>▶</span>
            <div>
              <div style={{ fontSize: 8, opacity: 0.7 }}>Get it on</div>
              <div style={{ fontWeight: 600 }}>Google Play</div>
            </div>
          </div>
        </div>
      </div>

      {/* iPhone mockup */}
      <div style={{ position: 'absolute', right: 120, top: 40, width: 300, height: 610,
        background: '#0f1713', borderRadius: 44, padding: 8,
        boxShadow: '0 40px 80px -20px rgba(36, 69, 58, 0.4), 0 0 0 2px #2a2d2b' }}>
        <div style={{ width: '100%', height: '100%', background: DH.bg, borderRadius: 36, position: 'relative', overflow: 'hidden', padding: 24, boxSizing: 'border-box' }}>
          {/* Notch */}
          <div style={{ position: 'absolute', left: '50%', top: 10, transform: 'translateX(-50%)', width: 90, height: 26, background: '#0f1713', borderRadius: 13 }}/>
          <div style={{ marginTop: 30, display: 'flex', justifyContent: 'space-between', fontFamily: DH.mono, fontSize: 10, color: DH.ink, opacity: 0.7 }}>
            <span>9:41</span>
            <span>● ● ●</span>
          </div>
          <div style={{ marginTop: 24, fontFamily: DH.mono, fontSize: 10, color: DH.moss600, letterSpacing: '0.18em' }}>WEEK 14 · SUNDAY</div>
          <div style={{ fontFamily: DH.display, fontWeight: 700, fontSize: 44, color: DH.ink, marginTop: 4, letterSpacing: '-0.025em' }}>
            −€124
          </div>
          <div style={{ fontFamily: DH.serif, fontStyle: 'italic', fontSize: 18, color: DH.moss600, marginTop: 2 }}>
            under budget.
          </div>
          <svg viewBox="0 0 200 60" style={{ width: '100%', marginTop: 18 }}>
            <path d="M0,42 Q30,28 60,32 T120,20 T200,12"
              stroke={DH.moss600} strokeWidth="2" fill="none"
              strokeDasharray="400" strokeDashoffset={(1 - clamp(progress * 2, 0, 1)) * 400}/>
            <path d="M0,42 Q30,28 60,32 T120,20 T200,12 L200,60 L0,60 Z" fill={DH.moss500} fillOpacity={0.2 * clamp(progress * 2, 0, 1)}/>
          </svg>
          <div style={{ marginTop: 18, height: 1, background: DH.rule }}/>
          {[
            ['Groceries', '€312', '−8%'],
            ['Transport', '€88', '−22%'],
            ['Leisure', '€134', '+4%'],
          ].map(([c, v, d], i) => {
            const p = clamp(progress * 3 - i * 0.25 - 0.2, 0, 1);
            return (
              <div key={i} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '10px 0',
                borderBottom: i === 2 ? 'none' : `1px solid ${DH.rule}`,
                opacity: p, fontSize: 13, color: DH.ink }}>
                <span>{c}</span>
                <div style={{ display: 'flex', gap: 10, alignItems: 'baseline' }}>
                  <span style={{ fontFamily: DH.mono, fontSize: 11 }}>{v}</span>
                  <span style={{ fontFamily: DH.mono, fontSize: 10, color: d.includes('+') ? DH.amber : DH.moss600 }}>{d}</span>
                </div>
              </div>
            );
          })}
          <div style={{ position: 'absolute', left: 20, right: 20, bottom: 38, height: 48, borderRadius: 24, background: DH.moss600,
            display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff', fontFamily: DH.body, fontSize: 14, fontWeight: 500,
            boxShadow: `0 12px 24px -8px ${DH.moss600}` }}>
            Roll forward to Week 15 →
          </div>
          {/* Home indicator */}
          <div style={{ position: 'absolute', left: '50%', bottom: 8, transform: 'translateX(-50%)', width: 100, height: 4, background: '#0f1713', borderRadius: 2, opacity: 0.4 }}/>
        </div>
      </div>

      {/* Background glow behind phone */}
      <div style={{ position: 'absolute', right: 80, top: 100, width: 380, height: 380,
        background: `radial-gradient(circle, ${DH.moss500}, transparent 65%)`, filter: 'blur(50px)', opacity: 0.45, zIndex: 0 }}/>
    </div>
  );
}

// PHASE 05 — OPTIMIZE: retention cohorts + DAU chart
function SwOptimizeMockup({ progress = 1 }) {
  const dau = [140, 155, 170, 165, 188, 210, 225, 240, 260, 255, 280, 300];
  // Cohort grid
  const cohorts = [
    [100, 78, 62, 52, 46, 42],
    [100, 72, 58, 48, 40, 38],
    [100, 82, 68, 58, 50, 46],
    [100, 88, 72, 64, 58, 52],
    [100, 90, 78, 70, 62, 56],
  ];
  return (
    <div style={{ width: '100%', height: '100%', background: '#fff', padding: 24, boxSizing: 'border-box', fontFamily: DH.body }}>
      <div style={{ display: 'flex', alignItems: 'center', marginBottom: 16 }}>
        <div>
          <div style={{ fontFamily: DH.mono, fontSize: 10, color: DH.moss600, letterSpacing: '0.12em', textTransform: 'uppercase' }}>
            TALLY · RETENTION · COHORTS
          </div>
          <div style={{ fontFamily: DH.display, fontWeight: 600, fontSize: 20, color: DH.ink, marginTop: 4 }}>
            Health · last 5 weeks
          </div>
        </div>
        <div style={{ marginLeft: 'auto', display: 'flex', gap: 16 }}>
          <div>
            <div style={{ fontSize: 9, fontFamily: DH.mono, color: DH.ink, opacity: 0.55, letterSpacing: '0.1em' }}>DAU</div>
            <div style={{ fontFamily: DH.display, fontWeight: 700, fontSize: 22, color: DH.ink, fontVariantNumeric: 'tabular-nums' }}>
              18,420 <span style={{ fontSize: 11, color: DH.moss600, fontWeight: 500 }}>↑ 32%</span>
            </div>
          </div>
          <div>
            <div style={{ fontSize: 9, fontFamily: DH.mono, color: DH.ink, opacity: 0.55, letterSpacing: '0.1em' }}>D7</div>
            <div style={{ fontFamily: DH.display, fontWeight: 700, fontSize: 22, color: DH.ink, fontVariantNumeric: 'tabular-nums' }}>
              38% <span style={{ fontSize: 11, color: DH.amber, fontWeight: 500 }}>↑ 16pp</span>
            </div>
          </div>
        </div>
      </div>

      <div style={{ display: 'grid', gridTemplateColumns: '1fr 1.2fr', gap: 16, height: 'calc(100% - 70px)' }}>
        {/* Cohort grid */}
        <div style={{ background: '#fafaf6', border: `1px solid ${DH.rule}`, borderRadius: 6, padding: 14 }}>
          <div style={{ fontFamily: DH.mono, fontSize: 9, color: DH.moss600, letterSpacing: '0.1em', marginBottom: 10 }}>COHORT · RETENTION %</div>
          <div style={{ display: 'grid', gridTemplateColumns: '60px repeat(6, 1fr)', gap: 3, fontFamily: DH.mono, fontSize: 9 }}>
            <div></div>
            {['W0','W1','W2','W3','W4','W5'].map(w => <div key={w} style={{ textAlign: 'center', color: DH.ink, opacity: 0.6 }}>{w}</div>)}
            {cohorts.map((row, i) => (
              <React.Fragment key={i}>
                <div style={{ color: DH.ink, opacity: 0.7, fontSize: 9, display: 'flex', alignItems: 'center' }}>Cohort {i+1}</div>
                {row.map((v, j) => {
                  const p = clamp(progress * 3 - (i * 0.1 + j * 0.06), 0, 1);
                  const intensity = v / 100;
                  return (
                    <div key={j} style={{
                      height: 26, borderRadius: 2,
                      background: `rgba(63, 107, 84, ${0.12 + intensity * 0.75})`,
                      color: intensity > 0.55 ? '#fff' : DH.ink,
                      fontSize: 10, display: 'flex', alignItems: 'center', justifyContent: 'center',
                      opacity: p, transform: `scale(${0.9 + 0.1*p})`,
                      fontFamily: DH.mono,
                    }}>
                      {v}
                    </div>
                  );
                })}
              </React.Fragment>
            ))}
          </div>
        </div>

        {/* DAU chart */}
        <div style={{ background: '#fafaf6', border: `1px solid ${DH.rule}`, borderRadius: 6, padding: 14 }}>
          <div style={{ fontFamily: DH.mono, fontSize: 9, color: DH.moss600, letterSpacing: '0.1em' }}>DAU · LAST 12 WEEKS</div>
          <div style={{ fontFamily: DH.display, fontWeight: 700, fontSize: 22, color: DH.ink, marginTop: 2, fontVariantNumeric: 'tabular-nums' }}>
            18,420 <span style={{ fontSize: 11, color: DH.moss600, fontWeight: 500 }}>↑ 32%</span>
          </div>
          <svg viewBox="0 0 300 140" style={{ width: '100%', marginTop: 10 }}>
            {[0, 100, 200, 300].map(g => <line key={g} x1="0" x2="300" y1={140 - g * 0.4} y2={140 - g * 0.4} stroke={DH.rule}/>)}
            <path d={dau.map((v, i) => {
              const x = (i / (dau.length - 1)) * 290 + 5;
              const y = 135 - (v / 320) * 115;
              return `${i === 0 ? 'M' : 'L'}${x},${y}`;
            }).join(' ')}
              stroke={DH.moss600} strokeWidth="2" fill="none"
              strokeDasharray="500" strokeDashoffset={(1 - clamp(progress * 1.5, 0, 1)) * 500}/>
            <path d={dau.map((v, i) => {
              const x = (i / (dau.length - 1)) * 290 + 5;
              const y = 135 - (v / 320) * 115;
              return `${i === 0 ? 'M' : 'L'}${x},${y}`;
            }).join(' ') + ' L295,140 L5,140 Z'}
              fill={DH.moss500} fillOpacity={0.15 * clamp(progress * 2, 0, 1)}/>
            {progress > 0.85 && (
              <circle cx={295} cy={135 - (dau[dau.length - 1] / 320) * 115} r="4" fill={DH.amber}/>
            )}
          </svg>
        </div>
      </div>
    </div>
  );
}

// A/B mockups for software — two app screens
function SwABMockupA() {
  return (
    <div style={{ width: '100%', height: '100%', background: DH.bg, display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 40 }}>
      <div style={{ width: 260, height: 520, background: '#0f1713', borderRadius: 40, padding: 6, boxShadow: '0 0 0 2px #2a2d2b' }}>
        <div style={{ width: '100%', height: '100%', background: '#fff', borderRadius: 34, padding: 18, boxSizing: 'border-box', position: 'relative', overflow: 'hidden' }}>
          <div style={{ position: 'absolute', left: '50%', top: 8, transform: 'translateX(-50%)', width: 74, height: 22, background: '#0f1713', borderRadius: 11 }}/>
          <div style={{ marginTop: 30, fontFamily: DH.body, fontSize: 11, color: DH.ink, opacity: 0.65 }}>Good evening, user</div>
          <div style={{ fontFamily: DH.display, fontWeight: 700, fontSize: 32, color: DH.ink, marginTop: 6 }}>€2,140</div>
          <div style={{ fontSize: 11, color: DH.ink, opacity: 0.55, marginTop: 4 }}>Balance · all accounts</div>
          <div style={{ marginTop: 20 }}>
            {[0,1,2,3,4].map(i => (
              <div key={i} style={{ display: 'flex', justifyContent: 'space-between', padding: '10px 0', borderBottom: '1px solid #eee', fontSize: 11, color: DH.ink }}>
                <span>Transaction {i+1}</span>
                <span style={{ fontFamily: DH.mono }}>−€{[12, 48, 22, 86, 34][i]}</span>
              </div>
            ))}
          </div>
        </div>
      </div>
    </div>
  );
}

function SwABMockupB() {
  const time = useTime();
  return (
    <div style={{ width: '100%', height: '100%', background: DH.bg, display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 40, position: 'relative' }}>
      <div style={{ position: 'absolute', inset: 0, background: `radial-gradient(circle at 50% 50%, ${DH.moss500}, transparent 65%)`, opacity: 0.3, filter: 'blur(60px)' }}/>
      <div style={{ position: 'relative', width: 260, height: 520, background: '#0f1713', borderRadius: 40, padding: 6, boxShadow: `0 30px 60px -10px ${DH.moss600}, 0 0 0 2px #2a2d2b` }}>
        <div style={{ width: '100%', height: '100%', background: DH.bg, borderRadius: 34, padding: 20, boxSizing: 'border-box', position: 'relative', overflow: 'hidden' }}>
          <div style={{ position: 'absolute', left: '50%', top: 8, transform: 'translateX(-50%)', width: 74, height: 22, background: '#0f1713', borderRadius: 11 }}/>
          <div style={{ marginTop: 30, fontFamily: DH.mono, fontSize: 9, color: DH.moss600, letterSpacing: '0.18em' }}>WEEK 14 · SUNDAY</div>
          <div style={{ fontFamily: DH.display, fontWeight: 700, fontSize: 42, color: DH.ink, marginTop: 4, letterSpacing: '-0.025em' }}>
            −€124
          </div>
          <div style={{ fontFamily: DH.serif, fontStyle: 'italic', fontSize: 18, color: DH.moss600, marginTop: 2 }}>
            under budget.
          </div>
          <svg viewBox="0 0 200 50" style={{ width: '100%', marginTop: 14 }}>
            <path d="M0,35 Q30,22 60,26 T120,14 T200,8" stroke={DH.moss600} strokeWidth="2" fill="none"/>
            <path d="M0,35 Q30,22 60,26 T120,14 T200,8 L200,50 L0,50 Z" fill={DH.moss500} fillOpacity="0.2"/>
          </svg>
          <div style={{ marginTop: 16, height: 1, background: DH.rule }}/>
          {[
            ['Groceries', '€312', '−8%'],
            ['Transport', '€88', '−22%'],
            ['Leisure', '€134', '+4%'],
          ].map(([c, v, d], i) => (
            <div key={i} style={{ display: 'flex', justifyContent: 'space-between', padding: '9px 0',
              borderBottom: i === 2 ? 'none' : `1px solid ${DH.rule}`, fontSize: 12, color: DH.ink }}>
              <span>{c}</span>
              <div style={{ display: 'flex', gap: 10, alignItems: 'baseline' }}>
                <span style={{ fontFamily: DH.mono, fontSize: 10 }}>{v}</span>
                <span style={{ fontFamily: DH.mono, fontSize: 9, color: d.includes('+') ? DH.amber : DH.moss600 }}>{d}</span>
              </div>
            </div>
          ))}
          <div style={{ position: 'absolute', left: 16, right: 16, bottom: 24, height: 42, borderRadius: 21, background: DH.moss600,
            display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff', fontFamily: DH.body, fontSize: 12, fontWeight: 500 }}>
            Roll forward →
          </div>
          <div style={{ position: 'absolute', right: 16, top: 72,
            display: 'flex', alignItems: 'center', gap: 4,
            fontFamily: DH.mono, fontSize: 8, color: DH.moss600, letterSpacing: '0.1em' }}>
            <span style={{ width: 5, height: 5, borderRadius: 3, background: DH.moss500, boxShadow: `0 0 ${4 + Math.sin(time * 6) * 2}px ${DH.moss500}` }}/>
            ON TRACK
          </div>
        </div>
      </div>
    </div>
  );
}

Object.assign(window, { SwDiscoverMockup, SwDesignMockup, SwBuildMockup, SwLaunchMockup, SwOptimizeMockup, SwABMockupA, SwABMockupB });
