// pastel-cards.jsx — kartlar dokunulduğunda 3D ile çevrilir, bağlı film bilgisi gelir
const { useState: pUseState, useEffect: pUseEffect, useRef: pUseRef } = React;

const PC = {
  PAPER:  '#FBF3DC',
  INK:    '#1F1812',          // daha derin mürekkep
  INK2:   '#5C4A3D',
  INK3:   'rgba(31,24,18,0.42)',
  LINE:   'rgba(31,24,18,0.14)',
  HAIR:   'rgba(31,24,18,0.32)',  // ince çerçeve hattı
  ACCENT: '#B85A4A',          // daha derin, daha az parlak mercan
  GOLD:   '#B89765',          // pirinç/altın — editöryel aksan
  GOLD2:  '#8E6F42',          // daha derin pirinç (vurgu için)
  BACK:   '#15100C',
  BACK2:  '#0E0A07',
  T_PAPER: '#FBF3DC',
  T_SKY:   '#DCE7EE',
  T_PLUM:  '#ECDDEA',
  T_SAGE:  '#DCE5D2',
  T_SUN:   '#F4E5C0',
  T_CORAL: '#F2D5CC',
  T_CREAM: '#EFE3C2',
  T_ROSE:  '#F0D8CF',
};

const mmFmt = (m) => {
  const h = Math.floor(m/60), r = m%60;
  return `${h}s ${String(r).padStart(2,'0')}d`;
};

// Dokunmatik / dar ekran tespiti — perf ve uzun-bas davranışı için
const IS_TOUCH = !!(window.matchMedia &&
  window.matchMedia('(max-width: 768px), (pointer: coarse)').matches);
window.IS_TOUCH = IS_TOUCH;

// Uzun bas: karta basılı tutunca tam ekran detay aç. Kaydırma/sürükleme iptal eder.
function useLongPress(getPayload, ms = 380) {
  const tRef = pUseRef(null);
  const firedRef = pUseRef(false);
  const onStart = (e) => {
    firedRef.current = false;
    const sx = e.clientX, sy = e.clientY;
    const cancel = () => {
      if (tRef.current) { clearTimeout(tRef.current); tRef.current = null; }
      window.removeEventListener('pointermove', mv, true);
      window.removeEventListener('pointerup', up, true);
      window.removeEventListener('pointercancel', up, true);
    };
    const mv = (ev) => {
      if (Math.hypot(ev.clientX - sx, ev.clientY - sy) > 9) cancel();
    };
    const up = () => cancel();
    window.addEventListener('pointermove', mv, true);
    window.addEventListener('pointerup', up, true);
    window.addEventListener('pointercancel', up, true);
    tRef.current = setTimeout(() => {
      firedRef.current = true;
      try { navigator.vibrate && navigator.vibrate(14); } catch (_) {}
      const p = getPayload();
      if (p && window.__sorraDetail) window.__sorraDetail(p);
      cancel();
    }, ms);
  };
  return { fired: firedRef, onStart };
}

// Mobilde ağır gölgeleri hafiflet (Android repaint maliyeti)
const sh = (mobileVal, deskVal) => (IS_TOUCH ? mobileVal : deskVal);

// Toggleable tap state
function useFlip() {
  const [flipped, setFlipped] = pUseState(false);
  const toggle = pUseRef(null);
  if (!toggle.current) {
    toggle.current = (e) => {
      e && e.stopPropagation && e.stopPropagation();
      setFlipped(f => !f);
    };
  }
  return [flipped, toggle.current];
}

// ─── FLIP SURFACE ─────────────────────────────────────────────────────────
// 3D çevirme. Front auto-yüksekliği belirler; back absolute, aynı boyutu kapsar.
function FlipSurface({ flipped, onTap, tint, frontPad='14px 12px', children, backChildren, backTint=PC.BACK, edition='BEN İZLEDİM ED. 014' }) {
  const lp = useLongPress(() => ({ tint, front: children, back: backChildren, edition }));
  const handleTap = (e) => {
    if (lp.fired.current) { lp.fired.current = false; e && e.stopPropagation && e.stopPropagation(); return; }
    onTap(e);
  };
  // ön yüzde ince çerçeve + iç gölge, arka yüzde derin pirinç çerçeve
  return (
    <div onClick={handleTap} onPointerDown={lp.onStart} style={{
      perspective: 1200, cursor: 'pointer', position: 'relative',
      userSelect: 'none', WebkitUserSelect: 'none', WebkitTouchCallout: 'none',
    }}>
      <div style={{
        position: 'relative',
        transformStyle: 'preserve-3d',
        transition: 'transform 760ms cubic-bezier(.22,.85,.28,1)',
        transform: flipped ? 'rotateY(180deg)' : 'rotateY(0deg)',
        boxShadow: flipped
          ? sh('0 1.5px 0 rgba(31,24,18,0.20)', `0 22px 44px -14px rgba(31,24,18,0.42), 0 6px 14px -6px rgba(31,24,18,0.28)`)
          : sh('none', `0 1px 0 rgba(31,24,18,0.04), 0 4px 14px -8px rgba(31,24,18,0.16)`),
        borderRadius: 2,
      }}>
        {/* ÖN YÜZ */}
        <div style={{
          background: tint, color: PC.INK, padding: frontPad,
          backfaceVisibility: 'hidden', WebkitBackfaceVisibility: 'hidden',
          borderRadius: 2, boxSizing: 'border-box',
          position: 'relative', zIndex: 2,
          boxShadow: `inset 0 0 0 0.5px ${PC.HAIR}, inset 0 0 0 2.5px ${tint}, inset 0 0 0 3px rgba(31,24,18,0.06)`,
        }}>
          {children}
          <div style={{
            position:'absolute', top:5, left:8, color: PC.GOLD2, opacity:0.7,
            fontFamily:'JetBrains Mono, monospace', fontSize:6, letterSpacing:2.2, fontWeight:500,
          }}>{edition}</div>
          <div style={{
            position:'absolute', top:5, right:8, color: PC.INK, opacity:0.38,
            fontFamily:'JetBrains Mono, monospace', fontSize:6.5, letterSpacing:1.6,
          }}>⤺ ÇEVİR</div>
        </div>
        {/* ARKA YÜZ */}
        {backChildren && (
          <div style={{
            position: 'absolute', top: 0, left: 0, right: 0, bottom: 0,
            background: `linear-gradient(155deg, ${PC.BACK} 0%, ${PC.BACK2} 100%)`,
            color: PC.PAPER, padding: frontPad,
            backfaceVisibility: 'hidden', WebkitBackfaceVisibility: 'hidden',
            transform: 'rotateY(180deg)',
            borderRadius: 2, boxSizing: 'border-box',
            zIndex: 1,
            boxShadow: `inset 0 0 0 0.5px rgba(184,151,101,0.22)`,
          }}>
            {backChildren}
            <div style={{
              position:'absolute', top:5, left:8, color: PC.GOLD, opacity:0.85,
              fontFamily:'JetBrains Mono, monospace', fontSize:6, letterSpacing:2.2, fontWeight:500,
            }}>{edition} · VERSO</div>
            <div style={{
              position:'absolute', top:5, right:8, color: PC.GOLD, opacity:0.6,
              fontFamily:'JetBrains Mono, monospace', fontSize:6.5, letterSpacing:1.6,
            }}>← GERİ</div>
          </div>
        )}
      </div>
    </div>
  );
}

// ─── FILM BACK ─────────────────────────────────────────────────────────────
// Her kartın arka yüzünde gösterilecek küçük film özeti.
function FilmBack({ film, w }) {
  if (!film) return null;
  const posterW = Math.min(68, w * 0.44);
  const posterH = Math.round(posterW * 1.32);
  return (
    <div style={{ display:'flex', flexDirection:'column', gap:7 }}>
      <div style={{
        fontFamily:'JetBrains Mono, monospace', fontSize:6.5,
        letterSpacing:2.6, color: PC.GOLD, marginBottom:2, marginTop:8, fontWeight:500,
      }}>·  BAĞLI YAPIT  ·</div>
      <div style={{
        fontFamily:'Instrument Serif, serif', fontSize:8, color: PC.GOLD2,
        letterSpacing:1, opacity:0.85, fontStyle:'normal',
      }}>№ {film.no}</div>
      <div style={{ display:'flex', gap:10, alignItems:'flex-start' }}>
        <div style={{ flexShrink:0, boxShadow:'0 4px 14px -4px rgba(0,0,0,0.55)' }}>
          <PastelPoster id={film.id} w={posterW} h={posterH} no={null}/>
        </div>
        <div style={{ flex:1, minWidth:0 }}>
          <div style={{
            fontFamily:'Instrument Serif, serif', fontSize:16, lineHeight:1.02,
            letterSpacing:-0.35, color: PC.PAPER, fontStyle:'normal',
          }}>{film.title}</div>
          <div style={{
            height:1, width:18, background: PC.GOLD, marginTop:5, marginBottom:5, opacity:0.7,
          }}/>
          <div style={{
            fontFamily:'Instrument Serif, serif', fontSize:10.5, color:'rgba(251,243,220,0.72)',
            fontStyle:'normal',
          }}>{film.dir}</div>
          <div style={{
            fontFamily:'JetBrains Mono, monospace', fontSize:6.8, letterSpacing:1.6,
            color:'rgba(251,243,220,0.5)', marginTop:6,
          }}>{film.country} · {film.year} · {mmFmt(film.runtime)}</div>
          <div style={{
            fontFamily:'JetBrains Mono, monospace', fontSize:6.8, letterSpacing:1.4,
            color: PC.GOLD, marginTop:4, fontWeight:500,
          }}>◆ {film.award}</div>
        </div>
      </div>
      <div style={{
        marginTop:5, paddingTop:7,
        borderTop:'0.5px solid rgba(184,151,101,0.22)',
        fontFamily:'Instrument Serif, serif', fontSize:11.5, lineHeight:1.28,
        color:'rgba(251,243,220,0.88)', letterSpacing:0.15, fontStyle:'normal',
      }}>
        <span style={{ color: PC.GOLD, fontSize:14, lineHeight:1, verticalAlign:'-1px' }}>“</span>
        {film.tagline}
        <span style={{ color: PC.GOLD, fontSize:14, lineHeight:1, verticalAlign:'-1px' }}>”</span>
      </div>
    </div>
  );
}

// Helper: bir filmle ilgili quote, bts ve rec'i bul (FilmCard back için)
function findRelated(filmId) {
  return {
    quote: (window.QUOTES || []).find(q => q.filmId === filmId),
    bts:   (window.BTS    || []).find(b => b.filmId === filmId),
    rec:   (window.RECS   || []).find(r => r.filmId === filmId),
  };
}

// ─── FILM CARD (ön: poster + künye; arka: alıntı, BTS, rec özeti) ──────────
function PFilmCard({ film, w, tint = PC.T_PAPER }) {
  const [flipped, toggle] = useFlip();
  const posterW = w - 44;
  const posterH = Math.round(posterW * 1.32);
  const rel = findRelated(film.id);
  const front = (
    <>
      <div style={{ marginTop:14 }}>
        <PastelPoster id={film.id} w={posterW} h={posterH} no={`№ ${film.no}`}/>
      </div>
      <div style={{ marginTop:10, color: PC.INK }}>
        <div style={{ display:'flex', justifyContent:'space-between', alignItems:'baseline' }}>
          <div style={{ fontFamily:'JetBrains Mono, monospace', fontSize:7, opacity:0.5, letterSpacing:1.8 }}>{film.no} · {film.country}</div>
          <div style={{ fontFamily:'JetBrains Mono, monospace', fontSize:7, opacity:0.5, letterSpacing:1.4 }}>{film.year}</div>
        </div>
        <div style={{
          fontFamily:'Instrument Serif, serif', fontSize:23, lineHeight:1.0, marginTop:5,
          letterSpacing:-0.5, fontStyle:'normal', fontWeight:400,
        }}>{film.title}</div>
        <div style={{
          height:1, width:22, background: PC.GOLD2, marginTop:7, marginBottom:5, opacity:0.55,
        }}/>
        <div style={{
          fontFamily:'Instrument Serif, serif', fontSize:11.5, fontStyle:'normal',
          color: PC.INK2,
        }}>{film.dir}</div>
        <div style={{
          fontFamily:'Instrument Serif, serif', fontSize:11, letterSpacing:0.1,
          color: PC.ACCENT, marginTop:8, lineHeight:1.2, fontStyle:'normal',
        }}>
          <span style={{ color: PC.GOLD2, fontSize:13, verticalAlign:'-1px' }}>“</span>
          {film.tagline}
          <span style={{ color: PC.GOLD2, fontSize:13, verticalAlign:'-1px' }}>”</span>
        </div>
      </div>
    </>
  );
  const back = (
    <div style={{ display:'flex', flexDirection:'column', gap:8 }}>
      <div style={{
        fontFamily:'JetBrains Mono, monospace', fontSize:7,
        letterSpacing:2.2, color: PC.ACCENT,
      }}>BAĞLI ZİNCİRLER · № {film.no}</div>
      <div style={{
        fontFamily:'Instrument Serif, serif', fontSize:17, lineHeight:1.03,
        color: PC.PAPER, letterSpacing:-0.3, fontStyle:'normal',
      }}>{film.title}</div>
      <div style={{
        fontFamily:'JetBrains Mono, monospace', fontSize:7,
        color:'rgba(251,243,220,0.55)', letterSpacing:1.3,
      }}>{film.dir} · {film.year} · {mmFmt(film.runtime)}</div>
      <div style={{
        fontFamily:'JetBrains Mono, monospace', fontSize:7,
        color: PC.ACCENT, letterSpacing:1.2, marginTop:2,
      }}>🏆 {film.award}</div>

      {rel.quote && (
        <div style={{ marginTop:6, paddingTop:6, borderTop:'0.5px dashed rgba(251,243,220,0.22)' }}>
          <div style={{ fontSize:6.5, color: PC.ACCENT, fontFamily:'JetBrains Mono, monospace', letterSpacing:1.6, marginBottom:3 }}>¶ SES</div>
          <div style={{ fontFamily:'Instrument Serif, serif', fontSize:11.5, lineHeight:1.2, color:'rgba(251,243,220,0.92)', fontStyle:'normal' }}>“{rel.quote.text}”</div>
          <div style={{ fontFamily:'JetBrains Mono, monospace', fontSize:6.5, color:'rgba(251,243,220,0.55)', letterSpacing:1, marginTop:2 }}>— {rel.quote.who}</div>
        </div>
      )}
      {rel.bts && (
        <div style={{ marginTop:4, paddingTop:6, borderTop:'0.5px dashed rgba(251,243,220,0.22)' }}>
          <div style={{ fontSize:6.5, color: PC.ACCENT, fontFamily:'JetBrains Mono, monospace', letterSpacing:1.6, marginBottom:3 }}>◯ KAMERA ARKASI</div>
          <div style={{ fontFamily:'Instrument Serif, serif', fontSize:11.5, lineHeight:1.18, color:'rgba(251,243,220,0.92)', fontStyle:'normal' }}>{rel.bts.title}</div>
        </div>
      )}
      {rel.rec && (
        <div style={{ marginTop:4, paddingTop:6, borderTop:'0.5px dashed rgba(251,243,220,0.22)' }}>
          <div style={{ fontSize:6.5, color: PC.ACCENT, fontFamily:'JetBrains Mono, monospace', letterSpacing:1.6, marginBottom:3 }}>→ ŞUNU DA İZLE</div>
          <div style={{ fontFamily:'Instrument Serif, serif', fontSize:13, lineHeight:1.05, color: PC.PAPER, fontStyle:'normal' }}>{rel.rec.to}</div>
          <div style={{ fontFamily:'JetBrains Mono, monospace', fontSize:6.5, color:'rgba(251,243,220,0.55)', letterSpacing:1, marginTop:2 }}>BAĞ · {rel.rec.by}</div>
        </div>
      )}
    </div>
  );
  return (
    <div style={{ padding:'6px 3px 0', width:w, boxSizing:'border-box', contain:'layout' }}>
      <FlipSurface flipped={flipped} onTap={toggle} tint={tint} frontPad="12px 12px 16px" backChildren={back}>
        {front}
      </FlipSurface>
    </div>
  );
}

// ─── SPEC CARD ─────────────────────────────────────────────────────────────
function PSpecCard({ film, w, tint = PC.T_SKY }) {
  const [flipped, toggle] = useFlip();
  const Row = ({ k, v }) => (
    <div style={{ display:'flex', justifyContent:'space-between', padding:'3px 0', borderBottom:`0.5px dashed ${PC.LINE}`, gap:6 }}>
      <span style={{ color: PC.INK2, fontSize:7.5, letterSpacing:1.4, fontFamily:'JetBrains Mono, monospace' }}>{k}</span>
      <span style={{ color: PC.INK, fontSize:8.5, textAlign:'right', whiteSpace:'nowrap', overflow:'hidden', textOverflow:'ellipsis', fontFamily:'JetBrains Mono, monospace' }}>{v}</span>
    </div>
  );
  const front = (
    <>
      <div style={{ display:'flex', justifyContent:'space-between', alignItems:'baseline', marginTop:8, marginBottom:8 }}>
        <span style={{ fontFamily:'Instrument Serif, serif', color: PC.GOLD2, fontSize:13, letterSpacing:0.5, fontStyle:'normal' }}>№ {film.no}</span>
        <span style={{ color: PC.ACCENT, fontSize:7, letterSpacing:2 }}>KÜNYE ▽</span>
      </div>
      <div style={{
        fontFamily:'Instrument Serif, serif', color: PC.INK, fontSize:15, lineHeight:1.0,
        letterSpacing:-0.3, marginBottom:6, fontStyle:'normal',
      }}>{film.title}</div>
      <div style={{ height:1, width:18, background: PC.GOLD2, opacity:0.5, marginBottom:9 }}/>
      <Row k="FORMAT"  v={film.format}/>
      <Row k="ORAN"    v={film.ratio}/>
      <Row k="SÜRE"    v={mmFmt(film.runtime)}/>
      <Row k="ÖDÜL"    v={film.award}/>
      <Row k="MENŞE"   v={`${film.country} · ${film.year}`}/>
    </>
  );
  return (
    <div style={{ padding:'6px 3px 0', width:w, boxSizing:'border-box', contain:'layout' }}>
      <FlipSurface flipped={flipped} onTap={toggle} tint={tint}
        frontPad="14px 12px"
        backChildren={<FilmBack film={film} w={w}/>}>
        <div style={{ fontFamily:'JetBrains Mono, monospace' }}>{front}</div>
      </FlipSurface>
    </div>
  );
}

// ─── QUOTE CARD ────────────────────────────────────────────────────────────
function PQuoteCard({ q, w, tint = PC.T_PLUM }) {
  const [flipped, toggle] = useFlip();
  const film = (window.FILM_BY_ID || {})[q.filmId];
  const front = (
    <>
      <div style={{
        color: PC.GOLD2, fontFamily:'JetBrains Mono, monospace', fontSize:8,
        letterSpacing:2.8, marginBottom:11, marginTop:6, fontWeight:600,
        textAlign:'left',
      }}>SESLER</div>
      <div style={{ borderLeft:`2px solid ${PC.GOLD2}`, paddingLeft:12 }}>
        <div style={{
          fontFamily:'Instrument Serif, serif', fontStyle:'normal',
          color: PC.INK, fontSize:21, lineHeight:1.32, letterSpacing:0,
          textAlign:'left',
        }}>“{q.text}”</div>
      </div>
      <div style={{ height:1, width:28, background: PC.GOLD2, opacity:0.5, marginTop:15, marginBottom:7 }}/>
      <div style={{
        fontFamily:'Instrument Serif, serif', fontSize:14, color: PC.INK2,
        letterSpacing:0.1, fontStyle:'normal', textAlign:'left',
      }}>{q.who}</div>
      <div style={{
        fontFamily:'JetBrains Mono, monospace', fontSize:7.5, color: PC.INK2,
        opacity:0.6, letterSpacing:1.4, marginTop:4, textAlign:'left',
      }}>{q.ref}</div>
    </>
  );
  return (
    <div style={{ padding:'6px 3px 0', width:w, boxSizing:'border-box', contain:'layout' }}>
      <FlipSurface flipped={flipped} onTap={toggle} tint={tint}
        frontPad="16px 14px"
        backChildren={<FilmBack film={film} w={w}/>}>
        {front}
      </FlipSurface>
    </div>
  );
}

// ─── BTS CARD ──────────────────────────────────────────────────────────────
function PBTSCard({ b, w, tint = PC.T_SAGE }) {
  const [flipped, toggle] = useFlip();
  const film = (window.FILM_BY_ID || {})[b.filmId];
  const firstChar = (b.body || '').trim().charAt(0);
  const rest = (b.body || '').trim().slice(1);
  const front = (
    <>
      <div style={{ display:'flex', alignItems:'center', gap:8, marginBottom:8, marginTop:8 }}>
        <div style={{
          width:14, height:14, borderRadius:'50%',
          border:`0.8px solid ${PC.GOLD2}`, position:'relative',
        }}>
          <div style={{ position:'absolute', inset:3, borderRadius:'50%', background: PC.GOLD }}/>
        </div>
        <span style={{
          fontFamily:'JetBrains Mono, monospace', fontSize:6.8, color: PC.GOLD2,
          letterSpacing:2.6, fontWeight:500,
        }}>{b.tag} · KAYIT</span>
      </div>
      <div style={{
        fontFamily:'Instrument Serif, serif', color: PC.INK, fontSize:15.5, lineHeight:1.06,
        letterSpacing:-0.3, fontStyle:'normal',
      }}>{b.title}</div>
      <div style={{ height:1, width:18, background: PC.GOLD2, opacity:0.5, marginTop:8, marginBottom:8 }}/>
      <div style={{
        fontFamily:'Instrument Serif, serif', color: PC.INK2, fontSize:11,
        lineHeight:1.38, letterSpacing:0.1, fontStyle:'normal',
      }}>
        <span style={{
          float:'left', fontFamily:'Instrument Serif, serif',
          fontSize:28, lineHeight:0.85, color: PC.GOLD,
          paddingRight:4, paddingTop:2, fontStyle:'normal',
        }}>{firstChar}</span>
        {rest}
      </div>
    </>
  );
  return (
    <div style={{ padding:'6px 3px 0', width:w, boxSizing:'border-box', contain:'layout' }}>
      <FlipSurface flipped={flipped} onTap={toggle} tint={tint}
        frontPad="14px 14px"
        backChildren={<FilmBack film={film} w={w}/>}>
        {front}
      </FlipSurface>
    </div>
  );
}

// ─── REC CARD ──────────────────────────────────────────────────────────────
function PRecCard({ r, w, tint = PC.T_SUN }) {
  const [flipped, toggle] = useFlip();
  const film = (window.FILM_BY_ID || {})[r.filmId];
  const front = (
    <>
      <div style={{
        fontFamily:'JetBrains Mono, monospace', fontSize:6.8, color: PC.GOLD2,
        letterSpacing:2.6, marginTop:8, marginBottom:10, fontWeight:500,
      }}>·  ŞUNU SEVDİYSEN  ·</div>
      <div style={{
        fontFamily:'Instrument Serif, serif', color: PC.INK2, fontSize:13.5, lineHeight:1.05,
        letterSpacing:-0.2, marginBottom:4, fontStyle:'normal',
      }}>{r.from}</div>
      <div style={{ display:'flex', alignItems:'center', gap:8, margin:'10px 0' }}>
        <div style={{ flex:1, height:0.5, background: PC.GOLD2, opacity:0.45 }}/>
        <svg width="14" height="14" viewBox="0 0 14 14">
          <path d="M1 7h11M7 1.5l5.5 5.5L7 12.5" stroke={PC.GOLD2} fill="none" strokeWidth="1.1" strokeLinecap="round"/>
        </svg>
        <div style={{ flex:1, height:0.5, background: PC.GOLD2, opacity:0.45 }}/>
      </div>
      <div style={{
        fontFamily:'Instrument Serif, serif', color: PC.INK, fontSize:18, lineHeight:1.04,
        letterSpacing:-0.35, fontStyle:'normal',
      }}>{r.to}</div>
      <div style={{
        marginTop:9, fontFamily:'JetBrains Mono, monospace', fontSize:6.8, color: PC.INK2,
        letterSpacing:1.8, opacity:0.7,
      }}>
        BAĞ · {r.by}
      </div>
    </>
  );
  return (
    <div style={{ padding:'6px 3px 0', width:w, boxSizing:'border-box', contain:'layout' }}>
      <FlipSurface flipped={flipped} onTap={toggle} tint={tint}
        frontPad="14px 14px"
        backChildren={<FilmBack film={film} w={w}/>}>
        {front}
      </FlipSurface>
    </div>
  );
}

// ─── STAMP CARD (flipsiz; basit dokunma rotasyonu) ────────────────────────
function PStampCard({ s, w, tint = PC.T_CORAL }) {
  const [tapped, setTapped] = pUseState(false);
  const stampBig = (
    <div style={{ textAlign:'center' }}>
      <div style={{ fontFamily:'JetBrains Mono, monospace', fontSize:11, letterSpacing:3, color:PC.GOLD2, fontWeight:600 }}>{s.small}</div>
      <div style={{ fontFamily:'Instrument Serif, serif', color:PC.INK, fontSize:120, lineHeight:0.9, letterSpacing:-4, margin:'14px 0' }}>{s.big}</div>
      <div style={{ fontFamily:'JetBrains Mono, monospace', fontSize:10, letterSpacing:2, color:PC.INK2, opacity:0.7 }}>{s.tiny}</div>
    </div>
  );
  const lp = useLongPress(() => ({ tint, front: stampBig, back: null, edition: 'BEN İZLEDİM · DAMGA' }));
  const onTap = (e) => {
    if (lp.fired.current) { lp.fired.current = false; return; }
    setTapped(t => !t);
  };
  return (
    <div style={{ padding:'6px 3px 0', width:w, boxSizing:'border-box', contain:'layout' }}>
      <div onClick={onTap} onPointerDown={lp.onStart} style={{
        background: tint, padding:'16px 12px', cursor:'pointer',
        borderRadius:2, userSelect:'none', WebkitTouchCallout:'none',
        boxShadow: tapped
          ? sh(`inset 0 0 0 0.5px ${PC.GOLD2}`, `inset 0 0 0 0.5px ${PC.GOLD2}, 0 14px 26px -10px rgba(31,24,18,0.28)`)
          : sh(`inset 0 0 0 0.5px ${PC.HAIR}`, `inset 0 0 0 0.5px ${PC.HAIR}, 0 4px 14px -8px rgba(31,24,18,0.16)`),
        transition: 'transform 420ms cubic-bezier(.2,.85,.3,1), box-shadow 360ms',
        transform: tapped ? 'scale(1.025) rotate(-0.6deg)' : 'scale(1)',
      }}>
        <div style={{ display:'flex', justifyContent:'space-between', alignItems:'baseline', color: PC.INK }}>
          <span style={{ fontFamily:'JetBrains Mono, monospace', fontSize:7, letterSpacing:2.4, color: PC.GOLD2, fontWeight:500 }}>{s.small}</span>
          <span style={{ fontFamily:'JetBrains Mono, monospace', fontSize:6.5, opacity:0.6, letterSpacing:1.6 }}>{s.tiny}</span>
        </div>
        <div style={{
          fontFamily:'Instrument Serif, serif', color: PC.INK, fontStyle:'normal',
          fontSize: w*0.82, lineHeight:0.88, letterSpacing:-3, marginTop:6, textAlign:'center',
          transform: tapped ? 'rotate(6deg) scale(1.04)' : 'rotate(0deg)',
          transition:'transform 520ms cubic-bezier(.2,.85,.3,1)',
          textShadow: '0 1px 0 rgba(184,151,101,0.18)',
        }}>{s.big}</div>
        <div style={{ display:'flex', justifyContent:'space-between', marginTop:10 }}>
          {Array.from({length:8}).map((_,i)=>(
            <div key={i} style={{
              width:4, height:4, border:`0.6px solid ${PC.GOLD2}`, opacity:0.55,
              background: tapped && i%2===0 ? PC.GOLD : 'transparent',
              transition:'background 300ms', borderRadius:'50%',
            }}/>
          ))}
        </div>
      </div>
    </div>
  );
}

// ─── MOVEMENT CARD (flipsiz) ──────────────────────────────────────────────
function PMovementCard({ name, w, tint = PC.T_CREAM }) {
  const [tapped, setTapped] = pUseState(false);
  const idx = pUseRef(Math.floor(Math.random()*40)+15).current;
  const moveBig = (
    <div>
      <div style={{ fontFamily:'JetBrains Mono, monospace', fontSize:11, letterSpacing:3, color:PC.GOLD2, fontWeight:600 }}>AKIM · {String(idx).padStart(2,'0')}</div>
      <div style={{ height:1, width:36, background:PC.GOLD2, opacity:0.5, margin:'12px 0' }}/>
      <div style={{ fontFamily:'Instrument Serif, serif', fontSize:46, lineHeight:1.05, color:PC.INK, letterSpacing:-1 }}>{name}</div>
      <div style={{ fontFamily:'JetBrains Mono, monospace', fontSize:11, color:PC.INK2, letterSpacing:2, marginTop:16, opacity:0.7 }}>◆ sinema kanonunda yer alan bir akım</div>
    </div>
  );
  const lp = useLongPress(() => ({ tint, front: moveBig, back: null, edition: 'BEN İZLEDİM · AKIM' }));
  const onTap = (e) => {
    if (lp.fired.current) { lp.fired.current = false; return; }
    setTapped(t => !t);
  };
  return (
    <div style={{ padding:'6px 3px 0', width:w, boxSizing:'border-box', contain:'layout' }}>
      <div onClick={onTap} onPointerDown={lp.onStart} style={{
        background: tint, padding:'16px 12px', cursor:'pointer', borderRadius:2,
        userSelect:'none', WebkitTouchCallout:'none',
        boxShadow: tapped
          ? sh(`inset 0 0 0 0.5px ${PC.GOLD2}`, `inset 0 0 0 0.5px ${PC.GOLD2}, 0 12px 24px -10px rgba(31,24,18,0.24)`)
          : sh(`inset 0 0 0 0.5px ${PC.HAIR}`, `inset 0 0 0 0.5px ${PC.HAIR}, 0 4px 14px -8px rgba(31,24,18,0.14)`),
        transition: 'transform 420ms cubic-bezier(.2,.85,.3,1), box-shadow 360ms',
        transform: tapped ? 'scale(1.025)' : 'scale(1)',
      }}>
        <div style={{
          fontFamily:'JetBrains Mono, monospace', fontSize:6.8,
          letterSpacing:2.6, color: PC.GOLD2, fontWeight:500,
        }}>
          AKIM · {String(idx).padStart(2,'0')}
        </div>
        <div style={{ height:1, width:18, background: PC.GOLD2, opacity:0.5, marginTop:8 }}/>
        <div style={{
          fontFamily:'Instrument Serif, serif', fontSize:22, lineHeight:1.0, color: PC.INK,
          marginTop:8, letterSpacing:-0.55, fontStyle:'normal',
        }}>{name}</div>
        <div style={{
          fontFamily:'JetBrains Mono, monospace', fontSize:6.5, color: PC.INK2, letterSpacing:1.8,
          marginTop:10, opacity: tapped ? 0.9 : 0.45, transition:'opacity 320ms',
        }}>{tapped ? '◆ kanona kayıtlı' : 'kanonda yer alır'}</div>
      </div>
    </div>
  );
}

// ─── RIBBON MARQUEE ───────────────────────────────────────────────────────
function PRibbon({ text, w, dir='left' }) {
  return (
    <div style={{ width:w, padding:'6px 3px 0', boxSizing:'border-box', contain:'layout' }}>
      <div style={{
        padding:'10px 0', overflow:'hidden', whiteSpace:'nowrap',
        background: PC.T_CREAM, borderRadius: 2,
        boxShadow: `inset 0 0 0 0.5px ${PC.GOLD2}, 0 1px 0 rgba(31,24,18,0.04)`,
      }}>
        <div style={{
          display:'inline-block', whiteSpace:'nowrap',
          animation:`ribbon-${dir} 26s linear infinite`,
          fontFamily:'JetBrains Mono, monospace', color: PC.INK2, opacity:0.95,
          fontSize:8.5, letterSpacing:3.5, fontWeight:500,
        }}>
          {Array.from({length:6}).map((_,i)=>(
            <span key={i} style={{ paddingRight:22 }}>
              <span style={{ color: PC.GOLD, marginRight:14 }}>◆</span>
              {text}
            </span>
          ))}
        </div>
      </div>
    </div>
  );
}

window.PFilmCard     = PFilmCard;
window.PSpecCard     = PSpecCard;
window.PQuoteCard    = PQuoteCard;
window.PBTSCard      = PBTSCard;
window.PRecCard      = PRecCard;
window.PStampCard    = PStampCard;
window.PMovementCard = PMovementCard;
window.PRibbon       = PRibbon;
window.PC            = PC;
