// mocks.jsx — Mocked secondary screens (favorites, report, filter panel)
// We have one real screenshot (the map). These fill the other device frames.

// ──────────────────────────────────────────────────────────
// Small inline icons (24px viewBox)
// ──────────────────────────────────────────────────────────
const Ico = {
  heart: (c = 'currentColor') => (
    <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke={c} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 1 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>
  ),
  bolt: (c = 'currentColor') => (
    <svg viewBox="0 0 24 24" width="14" height="14" fill={c}><path d="M13 2 4 14h7l-1 8 9-12h-7z"/></svg>
  ),
  drop: (c = 'currentColor') => (
    <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke={c} strokeWidth="2"><path d="M12 2.5c-3 4-7 8-7 12a7 7 0 0 0 14 0c0-4-4-8-7-12z"/></svg>
  ),
  alert: (c = 'currentColor') => (
    <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke={c} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M12 2 2 21h20z"/><path d="M12 9v5"/><circle cx="12" cy="17.5" r="1" fill={c}/></svg>
  ),
  flame: (c = 'currentColor') => (
    <svg viewBox="0 0 24 24" width="14" height="14" fill={c}><path d="M12 2c2 4 6 6 6 11a6 6 0 0 1-12 0c0-3 2-5 2-7 2 1 3 3 4 0z"/></svg>
  ),
  wind: (c = 'currentColor') => (
    <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke={c} strokeWidth="2" strokeLinecap="round"><path d="M4 9h13a3 3 0 1 0-3-3"/><path d="M4 15h17a3 3 0 1 1-3 3"/></svg>
  ),
  search: (c = 'currentColor') => (
    <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke={c} strokeWidth="2" strokeLinecap="round"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>
  ),
  download: (c = 'currentColor') => (
    <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke={c} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M12 4v12"/><path d="m7 11 5 5 5-5"/><path d="M5 20h14"/></svg>
  ),
  mail: (c = 'currentColor') => (
    <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke={c} strokeWidth="2"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="m3 7 9 6 9-6"/></svg>
  ),
  check: (c = 'currentColor') => (
    <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke={c} strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><path d="m5 12 5 5L20 7"/></svg>
  ),
  chev: (c = 'currentColor') => (
    <svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke={c} strokeWidth="2" strokeLinecap="round"><path d="m9 6 6 6-6 6"/></svg>
  ),
  pin: (c = 'currentColor') => (
    <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke={c} strokeWidth="2"><path d="M12 22s7-6 7-12a7 7 0 1 0-14 0c0 6 7 12 7 12z"/><circle cx="12" cy="10" r="2.5"/></svg>
  ),
  rail: (c = 'currentColor') => (
    <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke={c} strokeWidth="2"><path d="M5 4h14M5 8h14M5 12h14M5 16h14M5 20h14M9 4v16M15 4v16"/></svg>
  ),
  star: (c = 'currentColor') => (
    <svg viewBox="0 0 24 24" width="14" height="14" fill={c}><path d="m12 2 3 7 7 .5-5.5 4.5L18 21l-6-3.5L6 21l1.5-7L2 9.5 9 9z"/></svg>
  ),
  leaf: (c = 'currentColor') => (
    <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke={c} strokeWidth="2" strokeLinecap="round"><path d="M3 21c0-9 7-16 18-16-1 11-8 18-18 16z"/><path d="M3 21 14 10"/></svg>
  ),
};

// ──────────────────────────────────────────────────────────
// Phone screen: Favorites list
// ──────────────────────────────────────────────────────────
function PhoneFavorites({ dark = false }) {
  const bg = dark ? '#0b0d12' : '#ffffff';
  const card = dark ? '#161922' : '#f6f5f1';
  const text = dark ? '#e8e9ec' : '#1a1a1d';
  const dim = dark ? 'rgba(232,233,236,.55)' : 'rgba(26,26,29,.55)';
  const div = dark ? 'rgba(255,255,255,.06)' : 'rgba(0,0,0,.06)';
  const accent = dark ? '#a78bff' : '#5b46d4';

  const items = [
    { name: '142 Elm Street', city: 'Asheville, NC',     issues: 3, top: 'EMF',           color: accent,   ico: Ico.bolt },
    { name: '88 Maple Ave',   city: 'Raleigh, NC',       issues: 1, top: 'Water Quality', color: '#3aa3ff', ico: Ico.drop },
    { name: 'Lake Lure Cabin', city: 'Lake Lure, NC',    issues: 0, top: 'All clear',     color: '#34c79a', ico: Ico.check },
    { name: '21 Birch Lane',  city: 'Greenville, SC',    issues: 2, top: 'Contam. land',  color: '#d97f3b', ico: Ico.alert },
    { name: '305 Oak Run',    city: 'Charlotte, NC',     issues: 4, top: 'Noise',         color: '#e68a3a', ico: Ico.wind  },
  ];

  return (
    <div style={{ background: bg, color: text, height: '100%', fontFamily: 'inherit', display: 'flex', flexDirection: 'column' }}>
      <div style={{ padding: '8px 20px 16px' }}>
        <div style={{ fontSize: 11, letterSpacing: '.12em', textTransform: 'uppercase', color: dim, fontWeight: 600 }}>My Homes</div>
        <div style={{ fontSize: 28, fontWeight: 600, letterSpacing: '-0.02em', marginTop: 4, fontFamily: 'var(--font-display, inherit)' }}>Favorites</div>
        <div style={{ marginTop: 14, padding: '10px 12px', background: card, borderRadius: 12, display: 'flex', alignItems: 'center', gap: 8, color: dim, fontSize: 13 }}>
          {Ico.search(dim)} <span>Search saved properties…</span>
        </div>
      </div>
      <div style={{ flex: 1, overflow: 'hidden', padding: '0 12px', display: 'flex', flexDirection: 'column', gap: 8 }}>
        {items.map((it, i) => (
          <div key={i} style={{ background: card, borderRadius: 14, padding: '12px 14px', display: 'flex', alignItems: 'center', gap: 12 }}>
            <div style={{ width: 38, height: 38, borderRadius: 10, background: `color-mix(in oklch, ${it.color} 22%, transparent)`, color: it.color, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
              <span style={{ transform: 'scale(1.4)' }}>{it.ico(it.color)}</span>
            </div>
            <div style={{ flex: 1, minWidth: 0 }}>
              <div style={{ fontSize: 14, fontWeight: 600, letterSpacing: '-0.01em' }}>{it.name}</div>
              <div style={{ fontSize: 12, color: dim, marginTop: 2 }}>{it.city} · {it.top}</div>
            </div>
            <div style={{ fontSize: 11, fontWeight: 600, color: it.issues === 0 ? '#34c79a' : dim, padding: '3px 8px', borderRadius: 999, background: it.issues === 0 ? 'rgba(52,199,154,.15)' : div }}>
              {it.issues === 0 ? 'Clear' : `${it.issues} flags`}
            </div>
          </div>
        ))}
      </div>
      <div style={{ borderTop: `1px solid ${div}`, padding: '14px 0 8px', display: 'flex', justifyContent: 'space-around', color: dim, fontSize: 10, fontWeight: 600, letterSpacing: '.05em' }}>
        {['Map','Favorites','Reports','Account'].map((l, i) => (
          <div key={l} style={{ color: i === 1 ? accent : dim, display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 4 }}>
            <div style={{ width: 18, height: 18, borderRadius: 5, background: i === 1 ? `color-mix(in oklch, ${accent} 22%, transparent)` : 'transparent' }} />
            {l.toUpperCase()}
          </div>
        ))}
      </div>
    </div>
  );
}

// ──────────────────────────────────────────────────────────
// Phone screen: Report (renders the actual PDF report image)
// ──────────────────────────────────────────────────────────
function PhoneReport({ dark = false, bare = false }) {
  const bg = dark ? '#0b0d12' : '#ffffff';
  const card = dark ? '#161922' : '#f6f5f1';
  const text = dark ? '#e8e9ec' : '#1a1a1d';
  const dim = dark ? 'rgba(232,233,236,.55)' : 'rgba(26,26,29,.55)';
  const div = dark ? 'rgba(255,255,255,.06)' : 'rgba(0,0,0,.06)';
  const accent = dark ? '#a78bff' : '#5b46d4';

  if (bare) {
    return (
      <div style={{ background: '#fff', height: '100%', overflow: 'hidden' }}>
        <img src="assets/report-top.jpg" alt="report" style={{ width: '100%', display: 'block' }}/>
      </div>
    );
  }

  return (
    <div style={{ background: bg, color: text, height: '100%', display: 'flex', flexDirection: 'column' }}>
      {/* Compact top bar */}
      <div style={{ padding: '6px 16px 10px', display: 'flex', alignItems: 'center', justifyContent: 'space-between', borderBottom: `1px solid ${div}` }}>
        <div style={{ fontSize: 11, color: dim, fontWeight: 600, letterSpacing: '.08em' }}>REPORT</div>
        <div style={{ display: 'flex', gap: 6 }}>
          <div style={{ width: 26, height: 26, borderRadius: 7, background: card, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>{Ico.mail(text)}</div>
          <div style={{ width: 26, height: 26, borderRadius: 7, background: card, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>{Ico.download(text)}</div>
        </div>
      </div>
      {/* Scrolling report content — shows the actual PDF */}
      <div style={{ flex: 1, overflow: 'hidden', background: '#fff' }}>
        <img src="assets/report-top.jpg" alt="report" style={{ width: '100%', display: 'block' }}/>
      </div>
      {/* Footer CTA */}
      <div style={{ padding: '10px 14px', borderTop: `1px solid ${div}`, display: 'flex', gap: 8 }}>
        <button style={{ flex: 1, height: 38, borderRadius: 10, border: 'none', background: accent, color: '#fff', fontWeight: 600, fontSize: 12, display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 6 }}>
          {Ico.download('#fff')} Export PDF
        </button>
      </div>
    </div>
  );
}

// ──────────────────────────────────────────────────────────
// Phone screen: Mini map preview (for the dark variant hero)
// ──────────────────────────────────────────────────────────
function PhoneMapPreview({ dark = true }) {
  // Stylized abstract map (radial streets + chips)
  const bg = dark ? '#0b0d12' : '#ffffff';
  const card = dark ? 'rgba(22,25,34,.92)' : 'rgba(255,255,255,.92)';
  const text = dark ? '#e8e9ec' : '#1a1a1d';
  const dim = dark ? 'rgba(232,233,236,.55)' : 'rgba(26,26,29,.55)';
  const accent = dark ? '#a78bff' : '#5b46d4';

  return (
    <div style={{ background: bg, color: text, height: '100%', position: 'relative', overflow: 'hidden' }}>
      {/* fake map */}
      <svg viewBox="0 0 400 800" preserveAspectRatio="xMidYMid slice" width="100%" height="100%" style={{ position: 'absolute', inset: 0 }}>
        <defs>
          <radialGradient id="rg" cx="50%" cy="46%" r="50%">
            <stop offset="0%" stopColor={dark ? '#1c2030' : '#eef0f6'} stopOpacity="1"/>
            <stop offset="100%" stopColor={bg} stopOpacity="0"/>
          </radialGradient>
        </defs>
        <rect width="400" height="800" fill={dark ? '#0b0d12' : '#ffffff'}/>
        <circle cx="200" cy="370" r="280" fill="url(#rg)"/>
        {/* street lines */}
        {Array.from({ length: 16 }).map((_, i) => {
          const a = (i / 16) * Math.PI * 2;
          const x2 = 200 + Math.cos(a) * 500;
          const y2 = 370 + Math.sin(a) * 500;
          return <line key={i} x1="200" y1="370" x2={x2} y2={y2} stroke="#e07a3a" strokeOpacity={0.55} strokeWidth={1.2}/>;
        })}
        {/* rings */}
        <circle cx="200" cy="370" r="120" stroke={accent} strokeOpacity="0.5" strokeWidth="1" fill="none" strokeDasharray="3 4"/>
        <circle cx="200" cy="370" r="200" stroke={accent} strokeOpacity="0.3" strokeWidth="1" fill="none" strokeDasharray="3 4"/>
        {/* dots */}
        {[[150,300,accent],[260,330,'#d97f3b'],[180,420,'#3aa3ff'],[240,440,accent],[200,360,'#fff'],[120,400,'#e68a3a'],[280,380,'#34c79a']].map(([x,y,c], i) => (
          <g key={i}>
            <circle cx={x} cy={y} r="11" fill={c} fillOpacity="0.2"/>
            <circle cx={x} cy={y} r="6" fill={c}/>
          </g>
        ))}
      </svg>

      {/* top search */}
      <div style={{ position: 'relative', padding: '12px 16px 0' }}>
        <div style={{ background: card, backdropFilter: 'blur(20px)', WebkitBackdropFilter: 'blur(20px)', borderRadius: 12, padding: '10px 12px', display: 'flex', alignItems: 'center', gap: 8, fontSize: 13, boxShadow: '0 4px 16px rgba(0,0,0,.25)' }}>
          {Ico.search(dim)}
          <span style={{ color: text }}>142 Elm Street, Asheville</span>
        </div>
      </div>

      {/* bottom sheet */}
      <div style={{ position: 'absolute', left: 0, right: 0, bottom: 0, background: card, backdropFilter: 'blur(24px)', WebkitBackdropFilter: 'blur(24px)', borderTopLeftRadius: 24, borderTopRightRadius: 24, padding: '14px 18px 26px' }}>
        <div style={{ width: 36, height: 4, background: dim, borderRadius: 2, margin: '0 auto 12px', opacity: .35 }}/>
        <div style={{ fontSize: 11, color: dim, letterSpacing: '.1em', textTransform: 'uppercase', fontWeight: 600 }}>Around this home</div>
        <div style={{ fontSize: 18, fontWeight: 600, marginTop: 2, letterSpacing: '-0.02em', fontFamily: 'var(--font-display, inherit)' }}>5 things to know</div>
        <div style={{ marginTop: 12, display: 'flex', flexDirection: 'column', gap: 8 }}>
          {[
            { c: accent,    l: 'EMF — 12 sources within 1 mi', i: Ico.bolt },
            { c: '#d97f3b', l: 'Contaminated land — 3 nearby', i: Ico.alert },
            { c: '#34c79a', l: 'Air quality — Good (AQI 42)',  i: Ico.wind  },
          ].map((r, i) => (
            <div key={i} style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
              <div style={{ width: 26, height: 26, borderRadius: 8, background: `color-mix(in oklch, ${r.c} 22%, transparent)`, color: r.c, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>{r.i(r.c)}</div>
              <div style={{ fontSize: 12.5, fontWeight: 500 }}>{r.l}</div>
            </div>
          ))}
        </div>
      </div>
    </div>
  );
}

// Expose
Object.assign(window, { Ico, PhoneFavorites, PhoneReport, PhoneMapPreview });
