/* journify.ai — Pictures: every picture the site draws in HTML, in one place (journify/brand/README.md section 1,
   the window picture). Pic({ p }) draws p.kind:
   post, inbox, call, review   the journey cards' pictures (content/homepage.json s1.journey.cards[].picture)
   verdict, booking, map, scorecard, trend   the S3 pictures (s3.rows[].picture)
   calendar, stamps   the Two Sprints pictures (s7.cards[].picture); their slots and rows appear one after the other
                      once a parent has the class is-in (GlareCard adds it), and hold
   image   a screenshot in the window: { chrome, src, alt, ratio } (/tools, the case study)
   A window is .j-shot with a .j-shot-bar (styles/tokens.css). No words in this file: they come from the caller's JSON.
   The styles below are put in the page's <head> once, when this file loads, so every page that loads it can draw
   any picture. Moved here from JourneyCards.jsx, S3.jsx and S7.jsx on 2026-11-10, unchanged. */

const PIC_CSS = `
.j-shot-in { padding: 12px 14px; }
.jc-post-head { display: flex; align-items: center; gap: 10px; }
.jc-ava { width: 32px; height: 32px; border-radius: 50%; background: var(--block); border: 1px solid var(--hairline); flex: none; display: inline-flex; align-items: center; justify-content: center; }
.jc-ava img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.jc-post-head b { display: block; font-weight: var(--w-semibold); font-size: 13px; line-height: 1.2; }
.jc-post-head span { display: block; font-size: 12px; color: var(--ink-2); }
.jc-post-lines { margin: 10px 0 0; }
.jc-post-lines p { margin: 0 0 6px; }
.jc-post-foot { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--hairline); font-size: 12px; color: var(--ink-2); }
.jc-inbox-row { display: grid; grid-template-columns: 74px 1fr; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--hairline); }
.jc-inbox-row > div { min-width: 0; }  /* so a long preview shortens with the ellipsis instead of widening the row past the frame */
.jc-inbox-row:last-child { border-bottom: 0; }
.jc-inbox-row.is-sel { background: var(--row-selected); }
.jc-name { display: inline-block; width: 64px; height: 10px; border-radius: 3px; background: var(--ink-2); opacity: .35; filter: blur(3px); }
.jc-prev { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); margin-top: 3px; }
.jc-stage { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: var(--w-medium); white-space: nowrap; }
.jc-stage.ox { background: var(--ink); color: var(--card); border-radius: var(--r-chip); padding: 1px 7px; }
.jc-stage i { width: 7px; height: 7px; border-radius: 50%; }
.jc-call { padding: 12px 14px; }
.jc-call-line { display: grid; grid-template-columns: 50px 1fr; gap: 8px; align-items: baseline; margin-top: 6px; }
.jc-call-line small { font-size: 12px; color: var(--ink-2); }
.jc-call-line b { font-weight: var(--w-semibold); font-size: 12px; }
.jc-call-line em { font-style: normal; font-size: 12px; color: var(--ink-2); }
.jc-chip { display: inline-block; margin-top: 10px; border-radius: var(--r-chip); padding: 2px 8px; font-size: 12px; background: var(--status-ok-bg); color: var(--status-ok); }
.jc-bars { margin-top: 10px; height: 26px; display: flex; align-items: center; gap: 2px; overflow: hidden; }
.jc-bars i { flex: none; width: 3px; border-radius: 1px; display: block; }
.jc-review { padding: 12px 14px; }
.jc-review-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.jc-review-head img { width: 34px; height: 34px; flex: none; }
.jc-review-head b { font-weight: var(--w-semibold); }
.jc-review table { width: 100%; border-collapse: collapse; font-size: 12px; }
.jc-review th { text-align: left; font-weight: var(--w-medium); color: var(--ink-2); padding: 4px 6px 4px 0; border-bottom: 1px solid var(--hairline); }
.jc-review td { padding: 5px 6px 5px 0; border-bottom: 1px solid var(--hairline); vertical-align: top; }
.jc-review tr:last-child td { border-bottom: 0; }
.j-s3-ver { padding: 14px 16px; }
.j-s3-ver-head { display: flex; align-items: center; gap: 12px; }
.j-s3-ver-head .jc-ava { width: 40px; height: 40px; }
.j-s3-ver-name { display: block; width: 110px; height: 11px; border-radius: 3px; background: var(--ink-2); opacity: .35; filter: blur(3px); margin-bottom: 6px; }
.j-s3-ver-head span { color: var(--ink-2); }
.j-s3-ver-verdict { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border: 1px solid var(--hairline); border-radius: var(--r-card); background: var(--cell); }
.j-s3-ver-verdict b { font-weight: var(--w-semibold); }
.j-s3-ver-verdict i { font-style: normal; color: var(--ink-2); }
.j-s3-ver-reply { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--hairline); }
.j-s3-ver-reply small { display: block; color: var(--ink-2); font-size: 12px; margin-bottom: 4px; }
.j-s3-book { display: grid; grid-template-columns: minmax(0, 1fr) 150px; }
.j-s3-book .j-s3-ver { border-right: 1px solid var(--hairline); }
.j-s3-cal { padding: 10px 12px 12px; font-size: 12px; }
.j-s3-cal-day { font-weight: var(--w-semibold); margin-bottom: 6px; }
.j-s3-cal-grid { position: relative; height: 126px; }
.j-s3-cal-hour { position: absolute; left: 0; right: 0; height: 42px; border-top: 1px solid var(--hairline); color: var(--ink-2); font-size: 11px; padding-top: 2px; }
.j-s3-cal-event { position: absolute; left: 34px; right: 0; top: 44px; height: 32px; border-radius: 4px; background: var(--action); color: var(--on-action); font-size: 11px; line-height: 1.2; padding: 2px 6px; overflow: hidden; white-space: nowrap; }
.j-s3-cal-event small { display: block; font-size: 10px; opacity: .85; }
.j-s3-map { padding: 16px 16px 14px; }
.j-s3-wave { position: absolute; left: 76px; right: 8px; top: 20px; height: 24px; display: flex; align-items: center; gap: 2px; opacity: .3; pointer-events: none; }
.j-s3-wave i { flex: 1 1 0; display: block; border-radius: 1px; }
.j-s3-track { position: relative; height: 64px; }
.j-s3-track + .j-s3-track { margin-top: 10px; }
.j-s3-track-label { position: absolute; left: 0; top: 24px; font-size: 12px; color: var(--ink-2); }
.j-s3-line { position: absolute; left: 76px; right: 8px; top: 31px; height: 2px; background: var(--hairline); }
.j-s3-track.is-right .j-s3-line { background: linear-gradient(90deg, var(--action), var(--ember)); }
.j-s3-mark { position: absolute; top: 27px; width: 10px; height: 10px; border-radius: 50%; background: var(--action); transform: translateX(-50%); }
.j-s3-track.is-wrong .j-s3-mark { background: var(--ink-2); }
.j-s3-track.is-right .j-s3-mark:last-of-type { background: var(--ember); }
.j-s3-mark span { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 11px; line-height: 1.3; color: var(--ink-2); text-align: center; }
.j-s3-track.is-wrong .j-s3-mark span { bottom: 14px; }
.j-s3-track.is-right .j-s3-mark span { top: 14px; }
.j-s3-mark span b { display: block; font-weight: var(--w-medium); color: var(--ink); }
.j-s3-track.is-right .j-s3-mark.is-end span { top: auto; bottom: 14px; transform: translateX(-100%); left: 5px; }  /* the last mark's words go above, right-aligned, clear of the mark before */
.j-s3-card { padding: 14px 16px; }
.j-s3-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.j-s3-card-head img { width: 34px; height: 34px; flex: none; }
.j-s3-card-head b { font-weight: var(--w-semibold); }
.j-s3-card-row { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-top: 1px solid var(--hairline); font-size: 12.5px; line-height: 1.45; }
.j-s3-card-row small { font-size: 12px; color: var(--ink-2); }
.j-s3-trend { padding: 14px 16px 12px; }
.j-s3-trend b { display: block; font-weight: var(--w-semibold); }
.j-s3-bars { margin-top: 14px; height: 110px; display: flex; align-items: flex-end; gap: 10px; }
.j-s3-bars i { flex: 1 1 0; display: block; border-radius: 3px 3px 0 0; background: var(--action); position: relative; }
.j-s3-bars i:last-child { background: var(--ember); }
.j-s3-bars i span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--ink-2); }
.j-s3-trend small { display: block; margin-top: 10px; color: var(--ink-2); font-size: 12px; }
.j-s7-cal { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); min-height: 124px; }
.j-s7-day { padding: 8px 6px; border-right: 1px solid var(--hairline); }
.j-s7-day:last-child { border-right: 0; }
.j-s7-day b { display: block; font-weight: 600; font-size: 12px; color: var(--ink-2); margin-bottom: 8px; }
.j-s7-slot { display: block; background: var(--row-selected); border-left: 3px solid var(--action); border-radius: 4px; padding: 4px 6px; font-size: 12px; line-height: 1.3; font-weight: 600; color: var(--ink); opacity: 0; transform: translateY(6px); transition: opacity var(--t-reveal), transform var(--t-reveal); }
.j-s7-slot span { display: block; font-weight: 400; color: var(--ink-2); }
.j-s7-stamps { min-height: 124px; }
.j-s7-stamp { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--hairline); font-size: 13px; color: var(--ink); opacity: 0; transform: translateY(6px); transition: opacity var(--t-reveal), transform var(--t-reveal); }
.j-s7-stamp:last-child { border-bottom: 0; }
.j-s7-stamp i { font-style: normal; color: var(--ink-2); font-size: 12px; }
.j-s7-stamp b { font-weight: 600; }
.j-s7-stamp em { font-style: normal; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--action); }   /* the booked dot, ember on the row that is the next call */
.j-s7-stamp.is-next em { background: var(--ember); }
.is-in .j-s7-slot, .is-in .j-s7-stamp { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .j-s7-slot, .j-s7-stamp { transition: none !important; opacity: 1; transform: none; } }
@media (max-width: 899px) {
  .j-s3-mark span { font-size: 10px; }
  .j-s7-day { padding: 6px 4px; }
  .j-s7-slot { font-size: 11px; padding: 3px 4px; }
}
`;
(function () {
  if (document.getElementById('j-pic-css')) return;
  const s = document.createElement('style'); s.id = 'j-pic-css'; s.textContent = PIC_CSS; document.head.appendChild(s);
})();

const PIC_DOT = { hot: 'var(--hot)', warm: 'var(--warm)', cold: 'var(--cold)' };
const PicBar = ({ chrome }) => <div className="j-shot-bar"><i /><i /><i />{chrome}</div>;

function Pic({ p }) {
  if (!p) return null;
  if (p.kind === 'image') return (
    <div className="j-shot">
      {p.chrome && <PicBar chrome={p.chrome} />}
      <img src={p.src} alt={p.alt || ''} loading="lazy" style={p.ratio ? { aspectRatio: p.ratio, objectFit: 'cover', objectPosition: 'top' } : undefined} />
    </div>
  );
  if (p.kind === 'post') return (
    <div className="j-shot">
      <div className="j-shot-in">
        <div className="jc-post-head"><span className="jc-ava">{p.avatar && <img src={p.avatar.src} alt={p.avatar.alt} />}</span><div><b>{p.name}</b><span>{p.meta}</span></div></div>
        <div className="jc-post-lines">{p.lines.map((l, i) => <p key={i}>{l}</p>)}</div>
        <div className="jc-post-foot">{p.reactions}</div>
      </div>
    </div>
  );
  if (p.kind === 'inbox') return (
    <div className="j-shot">
      <PicBar chrome={p.chrome} />
      {p.rows.map((r, i) => (
        <div key={i} className={'jc-inbox-row' + (i === 0 ? ' is-sel' : '')}>
          <span className={'jc-stage ' + r.tone}>{r.tone !== 'ox' && <i style={{ background: PIC_DOT[r.tone] }} />}{r.stage}</span>
          <div><span className="jc-name" /><div className="jc-prev">{r.preview}</div></div>
        </div>
      ))}
    </div>
  );
  if (p.kind === 'call') {
    const bars = Array.from({ length: 90 }, (_, i) => Math.round(6 + 14 * (0.5 + 0.5 * Math.sin(i / 2.6))));  /* the calm wave: a good call */
    return (
      <div className="j-shot jc-call">
        <div className="jc-bars" aria-hidden="true">{bars.map((h, i) => <i key={i} style={{ height: h, background: recHeat(h, 20) }} />)}</div>
        <div className="jc-call-line"><small>{p.at}</small><div><b>You</b><br />{p.q}</div></div>
        <div className="jc-call-line"><small /><div><em>Buyer</em><br />{p.a}</div></div>
        <span className="jc-chip">{p.note}</span>
      </div>
    );
  }
  if (p.kind === 'review') return (
    <div className="j-shot">
      <PicBar chrome={p.chrome} />
      <div className="jc-review">
        <div className="jc-review-head">{p.sally && <img src={p.sally} alt="" />}<b>{p.score}</b></div>
        <table>
          <thead><tr><th>Stage</th><th>Score</th><th>Next time</th><th>Watch</th></tr></thead>
          <tbody>{p.rows.map((r, i) => <tr key={i}><td>{r.stage}</td><td>{r.score}</td><td>{r.next}</td><td>{r.watch}</td></tr>)}</tbody>
        </table>
      </div>
    </div>
  );
  if (p.kind === 'verdict') return (
    <div className="j-shot">
      <PicBar chrome={p.chrome} />
      <div className="j-s3-ver">
        <div className="j-s3-ver-head"><span className="jc-ava" /><div><span className="j-s3-ver-name" /><span>{p.headline}</span></div></div>
        <div className="j-s3-ver-verdict"><b>{p.verdict}</b><i>{p.score}</i></div>
        <div className="j-s3-ver-reply"><small>{p.replyLabel}</small>{p.reply}</div>
      </div>
    </div>
  );
  if (p.kind === 'booking') return (
    <div className="j-shot">
      <PicBar chrome={p.chrome} />
      <div className="j-s3-book">
        <div className="j-s3-ver">
          <div className="j-s3-ver-head"><span className="jc-ava" /><div><span className="j-s3-ver-name" /><span className="j-s3-ver-name" style={{ width: 150, opacity: .22 }} />{p.headline && <span>{p.headline}</span>}</div></div>
          <div className="j-s3-ver-verdict"><b>{p.verdict}</b>{p.score && <i>{p.score}</i>}</div>
        </div>
        <div className="j-s3-cal">
          <div className="j-s3-cal-day">{p.day}</div>
          <div className="j-s3-cal-grid">
            {p.hours.map((h, i) => <div key={i} className="j-s3-cal-hour" style={{ top: i * 42 }}>{h}</div>)}
            <div className="j-s3-cal-event">{p.event}<small>{p.time}</small></div>
          </div>
        </div>
      </div>
    </div>
  );
  if (p.kind === 'map') return (
    <div className="j-shot">
      <PicBar chrome={p.chrome} />
      <div className="j-s3-map">
        {p.tracks.map((t, i) => (
          <div key={i} className={'j-s3-track is-' + t.tone}>
            <span className="j-s3-track-label">{t.label}</span>
            <div className="j-s3-wave" aria-hidden="true">
              {recVoice(t.tone === 'wrong' ? 11 : 5, 60).map((h, k) => {
                const hh = Math.round((t.tone === 'wrong' ? h : 8 + 14 * (0.5 + 0.5 * Math.sin(k / 3.2))) * 0.7);
                return <i key={k} style={{ height: hh, background: t.tone === 'wrong' ? recCold(hh, 30) : recHeat(hh, 22) }} />;
              })}
            </div>
            <div className="j-s3-line" />
            {t.marks.map((m, k) => (
              <span key={k} className={'j-s3-mark' + (m.pos >= 1 ? ' is-end' : '')} style={{ left: 'calc(76px + (100% - 84px) * ' + m.pos + ')' }}>
                <span><b>{m.at}</b>{m.t}</span>
              </span>
            ))}
          </div>
        ))}
      </div>
    </div>
  );
  if (p.kind === 'scorecard') return (
    <div className="j-shot">
      <PicBar chrome={p.chrome} />
      <div className="j-s3-card">
        <div className="j-s3-card-head">{p.sally && <img src={p.sally} alt="" />}<b>{p.score}</b></div>
        <div className="j-s3-card-row"><small>Minute {p.minute}</small><span>{p.what}</span></div>
        <div className="j-s3-card-row"><small>Next time</small><span>{p.next}</span></div>
        <div className="j-s3-card-row"><small>Next post</small><span>{p.post}</span></div>
      </div>
    </div>
  );
  if (p.kind === 'trend') return (
    <div className="j-shot">
      <PicBar chrome={p.chrome} />
      <div className="j-s3-trend">
        <b>{p.title}</b>
        <div className="j-s3-bars">{p.scores.map((v, i) => <i key={i} style={{ height: (v / p.max * 100) + '%' }}><span>{v}</span></i>)}</div>
        <small>{p.note}</small>
      </div>
    </div>
  );
  if (p.kind === 'calendar') return (
    <div className="j-shot">
      <PicBar chrome={p.chrome} />
      <div className="j-s7-cal">
        {p.days.map((d, i) => (
          <div key={d} className="j-s7-day"><b>{d}</b>
            {p.slots.filter(s => s.day === i).map((s, j) => {
              const n = p.slots.indexOf(s);
              return <span key={j} className="j-s7-slot" style={{ transitionDelay: (200 + n * 220) + 'ms' }}>{s.time}<span>{s.who}</span></span>;
            })}
          </div>
        ))}
      </div>
    </div>
  );
  if (p.kind === 'stamps') return (
    <div className="j-shot">
      <PicBar chrome={p.chrome} />
      <div className="j-s7-stamps">
        {p.stamps.map((s, i) => <div key={i} className={'j-s7-stamp' + (i === p.stamps.length - 1 ? ' is-next' : '')} style={{ transitionDelay: (200 + i * 300) + 'ms' }}><i>{s.day}</i><b>{s.text}</b><em /></div>)}
      </div>
    </div>
  );
  return null;
}

Object.assign(window, { Pic });
