// ─────────────────────────────────────────────────────────────────────────────
// sandric — workshop edition
// Main app: tokens, products, hero variations, cards, page chrome.
// Cork-board surface + drag/snap come from workshop-bench.jsx (window globals).
// ─────────────────────────────────────────────────────────────────────────────

const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
  "hero": "specimen"
}/*EDITMODE-END*/;

// ── tokens ──────────────────────────────────────────────────────────────────
const TOK = {
  bg:    '#E9E5DA',
  cream: '#E9E5DA',
  paper: '#F6F3EB',
  paperWarm:  '#F4EFE0',
  paperCool:  '#F0EDE3',
  paperCream: '#F8F2E0',
  ink:   '#111110',
  sub:   'rgba(17,17,16,0.56)',
  hair:  'rgba(17,17,16,0.12)',
  rule:  'rgba(17,17,16,0.85)',
  ter:   '#B6371E',
  fr:    '"Fraunces", "Cormorant Garamond", Georgia, serif',
  sans:  '"Inter Tight", "Söhne", system-ui, sans-serif',
  mono:  '"JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace',
};

// ── Products ────────────────────────────────────────────────────────────────
// Each card now also carries: paper tone, pin color index, serial code.
const PRODUCTS = [
  { id: 'ah', n: '01', serial: 'SAN·2025·001·AH', name: 'Agent Handover',  domain: 'agenthandover.com', url: 'https://agenthandover.com', tag: 'AGENT',    kind: 'image', img: 'assets/agenthandover-mascot.png', blurb: 'An agent that learns how you decide and gets sharper every run.', meta: 'macOS · 2025',   paper: 'paper',      pin: 0, status: 'LIVE' },
  { id: 'dc', n: '02', serial: 'SAN·2025·002·DC', name: 'Dopamine Club',   domain: 'dopamine.club',     url: 'https://dopamine.club',     tag: 'HEALTH',   kind: 'type',  img: null,                              blurb: 'Evidence-based biohacking supplements, matched to what your brain and body actually need.', meta: 'Web · 2025', paper: 'paperCream', pin: 3, status: 'BETA' },
  { id: 'cl', n: '03', serial: 'SAN·2025·003·CL', name: 'Clime',           domain: 'clime.sh',          url: 'https://clime.sh',          tag: 'INFRA',    kind: 'type',  img: null,                              blurb: '846+ command-line tools, in one human-and-agent registry.',             meta: 'Web · 2025', paper: 'paperCool',  pin: 1, status: 'LIVE' },
  { id: 'ub', n: '04', serial: 'SAN·2025·004·UB', name: 'Unbury',          domain: 'unbury.app',        url: 'https://unbury.app',        tag: 'iOS',      kind: 'image', img: 'assets/unbury-cat.png',           blurb: 'On-device AI for the screenshots you forgot you took.',                  meta: 'iOS · 2025', paper: 'paperWarm',  pin: 2, status: 'LIVE' },
  { id: 'ae', n: '05', serial: 'SAN·2024·005·AE', name: 'AInthusiast',     domain: 'ainthusiast.com',   url: 'https://ainthusiast.com',   tag: 'RESEARCH', kind: 'image', img: 'assets/ainthusiast.png',          blurb: 'Independent research into how language models actually think.',          meta: 'Journal · 2024', paper: 'paper',  pin: 5, status: 'ACTIVE' },
  { id: 'ld', n: '06', serial: 'SAN·2026·006·LD', name: 'Latent Diaries',  domain: 'latentdiaries.com', url: 'https://latentdiaries.com', tag: 'ARCHIVE',  kind: 'type',  img: null,                              blurb: 'A time capsule of early human–AI conversations.',                       meta: 'Archive · 2026', paper: 'paperCream', pin: 4, status: 'SOON' },
];

const CARD_W = 330;
const CARD_H = 480;

// ── Barcode (deterministic from serial) ─────────────────────────────────────
function Barcode({ code, w = 130, h = 32 }) {
  const bars = useMemo(() => {
    let s = 0;
    for (let i = 0; i < code.length; i++) s = ((s * 131 + code.charCodeAt(i)) >>> 0);
    const out = [];
    let x = 0;
    let bar = true; // alternate, but with varying widths
    while (x < w - 1) {
      // pseudo-random width 1..3 for bars, 1..2 for gaps
      s = (s * 1103515245 + 12345) >>> 0;
      const span = bar ? (1 + (s % 3)) : (1 + ((s >>> 4) % 2));
      out.push({ x, w: span, bar });
      x += span;
      bar = !bar;
    }
    return out;
  }, [code, w]);

  const barH = h - 9;
  return (
    <svg width={w} height={h} aria-hidden style={{ display: 'block' }}>
      {bars.map((b, i) => b.bar && (
        <rect
          key={i}
          x={b.x}
          y={0}
          width={b.w}
          height={barH}
          fill={TOK.ink}
        />
      ))}
      <text x={0} y={h - 1} fontFamily={TOK.mono} fontSize="6.5" letterSpacing="0.12em" fill={TOK.ink}>
        {code}
      </text>
    </svg>
  );
}

// ── Plate ───────────────────────────────────────────────────────────────────
function Plate({ product, height = 188 }) {
  const isImg = product.kind === 'image' && product.img;

  // Custom typographic plates per product
  const renderType = () => {
    if (product.id === 'cl') {
      // Clime — CLI registry, mono wordmark "cli,me" with teal comma
      const compact = height < 130;
      return (
        <div style={{ position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center', padding: compact ? 14 : 22 }}>
          <div style={{
            fontFamily: TOK.mono,
            fontWeight: 700,
            fontSize: compact ? 38 : 56,
            letterSpacing: '-0.04em',
            color: TOK.ink,
            lineHeight: 1,
          }}>
            cli<span style={{ color: '#2A9D9D' }}>,</span>me
          </div>
          <div style={{
            marginTop: compact ? 8 : 14,
            fontFamily: TOK.mono,
            fontSize: compact ? 7.5 : 9,
            letterSpacing: '0.32em',
            color: TOK.sub,
            textTransform: 'uppercase',
          }}>
            $ &nbsp;846+ tools
          </div>
          <div style={{
            marginTop: compact ? 8 : 14,
            width: compact ? 26 : 36, height: 1.5, background: '#2A9D9D',
          }} />
        </div>
      );
    }
    if (product.id === 'dc') {
      // Dopamine Club — recreated logo card (avoids blurry low-res PNG)
      const compact = height < 130;
      const dcSize = compact ? 38 : 56;
      const labelSize = compact ? 10 : 13;
      const estSize = compact ? 6.5 : 8;
      return (
        <div style={{ position: 'absolute', inset: 0, display: 'flex', alignItems: 'center', justifyContent: 'center', padding: compact ? 12 : 18 }}>
          <div style={{
            position: 'relative',
            border: `2px solid ${TOK.ink}`,
            padding: compact ? '10px 36px 10px 14px' : '14px 50px 14px 18px',
            background: 'transparent',
            display: 'flex',
            flexDirection: 'column',
            alignItems: 'flex-start',
            gap: 2,
          }}>
            <div style={{
              fontFamily: TOK.fr,
              fontVariationSettings: '"opsz" 144, "SOFT" 60, "wght" 700',
              fontSize: dcSize,
              fontWeight: 700,
              letterSpacing: '-0.04em',
              color: TOK.ink,
              lineHeight: 0.85,
            }}>
              Dc
            </div>
            <div style={{
              fontFamily: TOK.fr,
              fontVariationSettings: '"opsz" 60, "SOFT" 60, "wght" 600',
              fontSize: labelSize,
              fontWeight: 600,
              letterSpacing: '-0.01em',
              color: TOK.ink,
              lineHeight: 1,
              marginTop: 4,
            }}>
              Dopamine
            </div>
            <div style={{
              fontFamily: TOK.fr,
              fontVariationSettings: '"opsz" 60, "SOFT" 60, "wght" 600',
              fontSize: labelSize,
              fontWeight: 600,
              letterSpacing: '-0.01em',
              color: TOK.ink,
              lineHeight: 1,
            }}>
              Club
            </div>
            {/* ESTD 2024 stacked vertical */}
            <div style={{
              position: 'absolute',
              right: compact ? 6 : 8,
              top: compact ? 8 : 12,
              fontFamily: TOK.mono,
              fontSize: estSize,
              fontWeight: 700,
              letterSpacing: '0.05em',
              color: TOK.ink,
              lineHeight: 1.15,
              textAlign: 'center',
            }}>
              ES<br/>TD<br/>20<br/>24
            </div>
          </div>
        </div>
      );
    }
    if (product.id === 'ld') {
      // Latent Diaries — italic serif, two-line wordmark with year
      const compact = height < 130;
      const fs = compact ? 32 : 44;
      return (
        <div style={{ position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center', padding: compact ? 12 : 18 }}>
          <div style={{
            fontFamily: TOK.fr,
            fontVariationSettings: '"opsz" 144, "SOFT" 100, "wght" 340',
            fontStyle: 'italic',
            fontSize: fs,
            letterSpacing: '0.04em',
            lineHeight: 0.95,
            color: TOK.ink,
            textAlign: 'center',
          }}>
            Latent
          </div>
          <div style={{
            fontFamily: TOK.fr,
            fontVariationSettings: '"opsz" 144, "SOFT" 100, "wght" 340',
            fontStyle: 'italic',
            fontSize: fs,
            letterSpacing: '0.04em',
            lineHeight: 0.95,
            color: TOK.ink,
            textAlign: 'center',
            marginTop: 4,
          }}>
            Diaries
          </div>
          <div style={{
            marginTop: compact ? 10 : 16,
            fontFamily: TOK.mono, fontSize: compact ? 7.5 : 9, letterSpacing: '0.5em', color: TOK.sub,
          }}>
            2 0 2 6
          </div>
        </div>
      );
    }
    // Default typographic plate
    return (
      <div style={{ position: 'absolute', inset: 0 }}>
        <div style={{
          position: 'absolute', left: 22, top: '50%', transform: 'translateY(-54%)',
          fontFamily: TOK.fr,
          fontVariationSettings: '"opsz" 144, "SOFT" 60, "wght" 360',
          fontStyle: 'italic',
          fontSize: 142, lineHeight: 0.84, letterSpacing: '-0.06em',
          color: TOK.ink,
        }}>
          {product.name.split(' ')[0]}
        </div>
        <div style={{
          position: 'absolute', left: 22, bottom: 30,
          width: 28, height: 2, background: TOK.ter,
        }}/>
      </div>
    );
  };

  return (
    <div style={{
      position: 'relative', height, marginTop: 14,
      background: '#EFEBE0',
      overflow: 'hidden',
      border: `1px solid ${TOK.hair}`,
      boxShadow: 'inset 0 1px 0 rgba(255,255,255,0.5), inset 0 -1px 0 rgba(0,0,0,0.04)',
    }}>
      {isImg ? (
        <img
          src={product.img}
          alt={product.name}
          draggable={false}
          style={{
            position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'contain', objectPosition: 'center',
            padding: 18,
            userSelect: 'none', pointerEvents: 'none',
            mixBlendMode: 'multiply',
          }}
        />
      ) : renderType()}

      {/* corner specimen mark */}
      <div aria-hidden style={{
        position: 'absolute', top: 6, right: 8,
        fontFamily: TOK.mono, fontSize: 8, letterSpacing: '0.16em', color: TOK.sub,
      }}>
        SPC·{product.n}
      </div>
    </div>
  );
}

// ── Card ────────────────────────────────────────────────────────────────────
function Card({ product, layout, onChange, onBringToTop, onCommit, dragLayerRef, cardW = CARD_W, cardH = CARD_H, dragEnabled = true }) {
  const ref = useRef(null);
  const [hover, setHover] = useState(false);
  const [dragging, setDragging] = useState(false);
  const dragRef = useRef(null);

  const onPointerDown = useCallback((e) => {
    if (!dragEnabled) return;
    if (e.target && e.target.closest('[data-no-drag]')) return;
    if (e.button !== 0 && e.pointerType === 'mouse') return;
    e.preventDefault();
    const layerRect = dragLayerRef.current.getBoundingClientRect();
    const cardRect  = ref.current.getBoundingClientRect();
    dragRef.current = {
      pointerId: e.pointerId,
      startX: e.clientX,
      startY: e.clientY,
      dx: e.clientX - cardRect.left,
      dy: e.clientY - cardRect.top,
      layerLeft: layerRect.left,
      layerTop: layerRect.top,
      moved: false,
    };
    setDragging(true);
    onBringToTop(product.id);
    try { ref.current.setPointerCapture(e.pointerId); } catch (_) {}
    document.body.classList.add('dragging');
  }, [dragLayerRef, product.id, onBringToTop, dragEnabled]);

  const onPointerMove = useCallback((e) => {
    const d = dragRef.current;
    if (!d) return;
    const dx = e.clientX - d.startX;
    const dy = e.clientY - d.startY;
    if (!d.moved && (Math.abs(dx) > 3 || Math.abs(dy) > 3)) d.moved = true;
    const nx = e.clientX - d.layerLeft - d.dx;
    const ny = e.clientY - d.layerTop - d.dy;
    onChange(product.id, { x: nx, y: ny });
  }, [onChange, product.id]);

  const finishDrag = useCallback((e, opts = {}) => {
    const d = dragRef.current;
    if (!d) return;
    const wasClick = !d.moved && !opts.cancel;
    const wasMoved = d.moved;
    dragRef.current = null;
    setDragging(false);
    document.body.classList.remove('dragging');
    try { ref.current.releasePointerCapture(d.pointerId); } catch (_) {}
    if (wasClick) {
      window.open(product.url, '_blank', 'noopener,noreferrer');
    } else if (wasMoved) {
      onCommit(product.id);
    }
  }, [product.url, onCommit, product.id]);

  const onPointerUp = useCallback((e) => finishDrag(e), [finishDrag]);
  const onPointerCancel = useCallback((e) => finishDrag(e, { cancel: true }), [finishDrag]);

  const onKeyDown = (e) => {
    if (e.key === 'Enter' || e.key === ' ') {
      e.preventDefault();
      window.open(product.url, '_blank', 'noopener,noreferrer');
    }
  };

  const liftRot   = dragging ? layout.rot * 0.25 : layout.rot;
  const liftScale = dragging ? 1.05 : (hover ? 1.012 : 1);
  const liftY     = dragging ? -8 : 0;

  // Lifted shadow is much taller — pin "lifts" off the cork
  const shadow = dragging
    ? '0 1px 0 rgba(0,0,0,0.05), 0 50px 70px -20px rgba(20, 12, 4, 0.55), 0 14px 24px rgba(20, 12, 4, 0.20)'
    : (hover
        ? '0 1px 0 rgba(0,0,0,0.05), 0 26px 36px -16px rgba(20, 12, 4, 0.40), 0 6px 10px rgba(20, 12, 4, 0.14)'
        : '0 1px 0 rgba(0,0,0,0.05), 0 16px 24px -14px rgba(20, 12, 4, 0.32), 0 3px 6px rgba(20, 12, 4, 0.10)');

  // Per-card paper tone for variation
  const paper = TOK[product.paper] || TOK.paper;

  // Compact (small mobile) sizing
  const compact = cardH < 380;
  const sz = compact ? {
    pad: '16px 14px 14px',
    spec: 8.5, status: 7.5,
    name: 22, domainTop: 4, domain: 9.5,
    plate: 110,
    blurbTop: 10, blurb: 11.5, blurbLh: 1.4,
    barW: 92, barH: 22, barL: 14, barB: 10,
    openR: 14, openB: 13, openFs: 8.5,
    rowGap: 10,
  } : {
    pad: '24px 22px 22px',
    spec: 9.5, status: 8.5,
    name: 30, domainTop: 5, domain: 10.5,
    plate: cardH < 460 ? 140 : 188,
    blurbTop: 12, blurb: 13.5, blurbLh: 1.46,
    barW: 140, barH: 32, barL: 22, barB: 16,
    openR: 20, openB: 22, openFs: 10,
    rowGap: 14,
  };

  return (
    <div
      ref={ref}
      role="link"
      tabIndex={0}
      aria-label={`${product.name} — ${product.domain}`}
      onPointerDown={dragEnabled ? onPointerDown : undefined}
      onPointerMove={dragEnabled ? onPointerMove : undefined}
      onPointerUp={dragEnabled ? onPointerUp : undefined}
      onPointerCancel={dragEnabled ? onPointerCancel : undefined}
      onClick={!dragEnabled ? (e) => {
        if (e.target && e.target.closest('[data-no-drag]')) return;
        window.open(product.url, '_blank', 'noopener,noreferrer');
      } : undefined}
      onMouseEnter={() => setHover(true)}
      onMouseLeave={() => setHover(false)}
      onKeyDown={onKeyDown}
      style={{
        position: 'absolute',
        left: layout.x,
        top: layout.y,
        width: cardW,
        height: cardH,
        transform: `translateY(${liftY}px) rotate(${liftRot}deg) scale(${liftScale})`,
        transformOrigin: '50% -10%',  // pivot near the pin
        transition: dragging ? 'none' : 'transform 320ms cubic-bezier(.2,.8,.2,1), box-shadow 240ms ease',
        zIndex: layout.z,
        cursor: dragEnabled ? (dragging ? 'grabbing' : 'grab') : 'pointer',
        background: paper,
        color: TOK.ink,
        border: `1px solid rgba(17,17,16,0.10)`,
        padding: sz.pad,
        fontFamily: TOK.sans,
        boxShadow: shadow,
        userSelect: 'none',
        touchAction: dragEnabled ? 'none' : 'manipulation',
        outline: 'none',
      }}
    >
      <PushPin idx={product.pin} size={22} />

      {/* Subtle paper texture overlay */}
      <div aria-hidden style={{
        position: 'absolute', inset: 0, pointerEvents: 'none',
        background:
          'repeating-linear-gradient(0deg, transparent 0 2px, rgba(0,0,0,0.012) 2px 3px), ' +
          'repeating-linear-gradient(90deg, transparent 0 2px, rgba(0,0,0,0.012) 2px 3px)',
        mixBlendMode: 'multiply',
      }} />

      {/* spec line */}
      <div style={{
        display: 'flex', justifyContent: 'space-between', alignItems: 'baseline',
        fontFamily: TOK.mono, fontSize: sz.spec, letterSpacing: '0.22em', color: TOK.sub,
        position: 'relative', zIndex: 1,
      }}>
        <span>№ {product.n} · {product.tag}</span>
        <span style={{
          color: product.status === 'SOON' ? TOK.sub : TOK.ter,
          border: `1px solid ${product.status === 'SOON' ? TOK.sub : TOK.ter}`,
          padding: '1px 6px',
          fontSize: sz.status,
        }}>{product.status}</span>
      </div>

      <div style={{ height: 1, background: TOK.hair, margin: `${sz.rowGap}px 0` }} />

      <div style={{
        fontFamily: TOK.fr, fontSize: sz.name, lineHeight: 1.02, fontWeight: 500, letterSpacing: '-0.018em',
        fontVariationSettings: '"opsz" 144, "SOFT" 50, "wght" 440',
        position: 'relative', zIndex: 1,
      }}>
        {product.name}
      </div>
      <div style={{
        fontFamily: TOK.mono, fontSize: sz.domain, letterSpacing: '0.04em', marginTop: sz.domainTop, color: TOK.sub,
        position: 'relative', zIndex: 1,
      }}>
        {product.domain}
      </div>

      <Plate product={product} height={sz.plate} />

      <div style={{
        fontSize: sz.blurb, lineHeight: sz.blurbLh, marginTop: sz.blurbTop, color: TOK.ink, fontFamily: TOK.sans,
        letterSpacing: '-0.005em',
        position: 'relative', zIndex: 1,
      }}>
        {product.blurb}
      </div>

      {/* Barcode strip — sits at the bottom-left */}
      <div style={{
        position: 'absolute', left: sz.barL, bottom: sz.barB,
        zIndex: 1,
      }}>
        <Barcode code={product.serial} w={sz.barW} h={sz.barH} />
      </div>

      <a
        data-no-drag
        href={product.url}
        target="_blank"
        rel="noopener noreferrer"
        onClick={(e) => e.stopPropagation()}
        onPointerDown={(e) => e.stopPropagation()}
        style={{
          position: 'absolute', right: sz.openR, bottom: sz.openB,
          fontFamily: TOK.mono, fontSize: sz.openFs, letterSpacing: '0.22em', fontWeight: 500,
          color: hover ? TOK.paper : TOK.ink,
          background: hover ? TOK.ink : 'transparent',
          padding: '5px 10px 4px',
          border: `1px solid ${TOK.ink}`,
          textDecoration: 'none',
          transition: 'background 160ms ease, color 160ms ease',
          zIndex: 2,
        }}
      >
        OPEN ↗
      </a>
    </div>
  );
}

// ── Toolbar button ──────────────────────────────────────────────────────────
function ToolBtn({ children, onClick, first }) {
  const [h, setH] = useState(false);
  return (
    <button
      onClick={onClick}
      onMouseEnter={() => setH(true)}
      onMouseLeave={() => setH(false)}
      style={{
        fontFamily: TOK.mono, fontSize: 10.5, letterSpacing: '0.22em', fontWeight: 500,
        color: h ? TOK.paper : TOK.ink,
        background: h ? TOK.ink : 'transparent',
        border: 'none',
        borderLeft: first ? 'none' : `1px solid ${TOK.ink}`,
        padding: '9px 16px 8px',
        cursor: 'pointer',
        transition: 'background 140ms ease, color 140ms ease',
      }}
    >
      {children}
    </button>
  );
}

// ── Hero variations ─────────────────────────────────────────────────────────

// (A) Literary — current direction, refined
function HeroLiterary() {
  return (
    <section style={{ display: 'grid', gridTemplateColumns: 'minmax(0,1.55fr) minmax(0,1fr)', gap: 64, marginTop: 96, alignItems: 'flex-end' }}>
      <div>
        <div style={{
          fontFamily: TOK.mono, fontSize: 11, letterSpacing: '0.22em', color: TOK.ter,
          display: 'inline-flex', alignItems: 'center', gap: 10,
        }}>
          <span style={{ width: 18, height: 1, background: TOK.ter, display: 'inline-block' }} />
          ENTRY № 06 · 2026.05.04
        </div>
        <h1 style={{
          fontFamily: TOK.fr,
          fontVariationSettings: '"opsz" 144, "SOFT" 80, "wght" 380',
          fontWeight: 400,
          fontSize: 'clamp(72px, 10vw, 168px)',
          lineHeight: 0.88,
          letterSpacing: '-0.04em',
          margin: '24px 0 0',
        }}>
          A small{' '}
          <em style={{ fontStyle: 'italic', color: TOK.ter, fontVariationSettings: '"opsz" 144, "SOFT" 100, "wght" 360' }}>workshop</em>,<br/>
          mostly always{' '}
          <em style={{ fontStyle: 'italic', fontVariationSettings: '"opsz" 144, "SOFT" 100, "wght" 360' }}>shipping</em>.
        </h1>
        <p style={{ fontSize: 19, lineHeight: 1.58, marginTop: 36, maxWidth: 620, color: TOK.ink, letterSpacing: '-0.005em' }}>
          Sandric is a one-person product studio operated by{' '}
          <span style={{ borderBottom: `1px solid ${TOK.ter}` }}>Sandro Andric</span>.
          Six small machines in active use across AI, health, and developer
          infrastructure. Below is what's on the bench — pick anything up,
          move it, click to open.
        </p>
      </div>

      <aside style={{
        paddingLeft: 28, borderLeft: `1px solid ${TOK.hair}`,
        fontFamily: TOK.mono, fontSize: 10.5, letterSpacing: '0.08em', lineHeight: 2.1, color: TOK.ink,
        minWidth: 0,
      }}>
        <div style={{ color: TOK.sub, marginBottom: 10, letterSpacing: '0.22em', fontSize: 10 }}>COLOPHON</div>
        {[['OPERATOR','SANDRO ANDRIC'],['LIVE','06'],['FOCUS','AI · HEALTH · INFRA'],['FUNDING','NONE'],['PACE','ONGOING']].map(([k,v]) => (
          <div key={k} style={{
            display: 'flex', justifyContent: 'space-between', gap: 12,
            borderBottom: `1px dotted ${TOK.hair}`,
            whiteSpace: 'nowrap',
          }}>
            <span style={{ color: TOK.sub }}>{k}</span>
            <span>{v}</span>
          </div>
        ))}
      </aside>
    </section>
  );
}

// (B) Filing card — the hero IS a giant index card pinned to the cork
function HeroFilingCard() {
  return (
    <section style={{ marginTop: 80, position: 'relative' }}>
      {/* the pin sits inside the card; we mount the card on a strip of cork */}
      <div style={{
        position: 'relative',
        background:
          'radial-gradient(ellipse at 30% 20%, #C49363 0%, #B07F4D 35%, #9A6A3A 80%)',
        padding: '64px 56px',
        boxShadow:
          'inset 0 0 60px rgba(40, 22, 6, 0.45), ' +
          '0 24px 50px -22px rgba(20, 14, 6, 0.40)',
        border: '10px solid #3A2410',
      }}>
        <div style={{
          position: 'relative',
          background: TOK.paperWarm,
          padding: '64px 72px 72px',
          maxWidth: 980,
          margin: '0 auto',
          boxShadow:
            '0 1px 0 rgba(0,0,0,0.05), ' +
            '0 30px 50px -20px rgba(20, 12, 4, 0.45), ' +
            '0 10px 20px rgba(20, 12, 4, 0.18)',
          border: '1px solid rgba(17,17,16,0.10)',
          transform: 'rotate(-0.6deg)',
        }}>
          <PushPin idx={0} size={28} />

          {/* Ruled lines (top) */}
          <div aria-hidden style={{
            position: 'absolute', left: 0, right: 0, top: 32, height: 2,
            background: TOK.ter, opacity: 0.85,
          }} />
          <div aria-hidden style={{
            position: 'absolute', left: 0, right: 0, top: 38, height: 1,
            background: TOK.ter, opacity: 0.45,
          }} />

          {/* punch hole */}
          <div aria-hidden style={{
            position: 'absolute', left: 26, top: '50%', width: 14, height: 14,
            borderRadius: '50%', background: '#9A6A3A',
            boxShadow: 'inset 0 1px 2px rgba(0,0,0,0.4)',
          }} />

          <div style={{
            display: 'grid', gridTemplateColumns: 'auto 1fr auto', gap: 24,
            fontFamily: TOK.mono, fontSize: 10.5, letterSpacing: '0.22em', color: TOK.sub,
            marginBottom: 24,
          }}>
            <span>FILE № 06</span>
            <span style={{ textAlign: 'center' }}>STUDIO RECORD · SANDRIC.</span>
            <span style={{ color: TOK.ter }}>2026.05.04</span>
          </div>

          <h1 style={{
            fontFamily: TOK.fr,
            fontVariationSettings: '"opsz" 144, "SOFT" 80, "wght" 360',
            fontWeight: 400,
            fontSize: 'clamp(60px, 8.4vw, 132px)',
            lineHeight: 0.92,
            letterSpacing: '-0.035em',
            margin: '0',
            textAlign: 'center',
          }}>
            <em style={{ fontStyle: 'italic' }}>sandric</em> — <span style={{ color: TOK.ter }}>workshop</span>
            <br/>
            <span style={{ fontSize: '0.55em', letterSpacing: '-0.01em' }}>est. 2024 · six live</span>
          </h1>

          <div style={{
            display: 'grid', gridTemplateColumns: '1fr auto 1fr', gap: 32, alignItems: 'center',
            marginTop: 36,
          }}>
            <div style={{ height: 1, background: TOK.hair }}/>
            <div style={{ fontFamily: TOK.mono, fontSize: 10, letterSpacing: '0.3em', color: TOK.sub }}>
              SIX MACHINES IN ACTIVE USE
            </div>
            <div style={{ height: 1, background: TOK.hair }}/>
          </div>

          <p style={{
            fontSize: 17, lineHeight: 1.6, marginTop: 24, color: TOK.ink,
            maxWidth: 640, marginLeft: 'auto', marginRight: 'auto', textAlign: 'center',
            letterSpacing: '-0.003em',
          }}>
            A one-person studio operated by Sandro Andric. AI, health, and
            developer infrastructure. Pick anything off the board below.
          </p>
        </div>
      </div>
    </section>
  );
}

// (C) Manifesto — bold typographic statement, no chrome
function HeroManifesto() {
  return (
    <section style={{ marginTop: 88, paddingBottom: 16 }}>
      <div style={{
        fontFamily: TOK.mono, fontSize: 11, letterSpacing: '0.24em', color: TOK.ter,
        display: 'flex', justifyContent: 'space-between',
      }}>
        <span>SANDRIC · WORKSHOP NOTES</span>
        <span>VOL. I · ENTRY № 06</span>
      </div>
      <div style={{ height: 1, background: TOK.ink, marginTop: 14 }} />

      <h1 style={{
        fontFamily: TOK.fr,
        fontVariationSettings: '"opsz" 144, "SOFT" 100, "wght" 360',
        fontWeight: 400,
        fontSize: 'clamp(80px, 12vw, 220px)',
        lineHeight: 0.84,
        letterSpacing: '-0.045em',
        margin: '40px 0 0',
      }}>
        <span style={{ color: TOK.sub }}>No</span><br/>
        side<br/>
        <em style={{ fontStyle: 'italic', color: TOK.ter, fontVariationSettings: '"opsz" 144, "SOFT" 100, "wght" 340' }}>projects</em>,<br/>
        only<br/>
        <em style={{ fontStyle: 'italic', fontVariationSettings: '"opsz" 144, "SOFT" 100, "wght" 340' }}>early</em><br/>
        ones.
      </h1>

      <div style={{
        display: 'grid', gridTemplateColumns: 'minmax(0,1fr) minmax(0,1.4fr)',
        gap: 56, alignItems: 'flex-end', marginTop: 72,
      }}>
        <div style={{
          fontFamily: TOK.mono, fontSize: 11, letterSpacing: '0.18em', color: TOK.ink, lineHeight: 2,
        }}>
          <div style={{ color: TOK.sub, marginBottom: 6 }}>OPERATED BY</div>
          <div style={{ borderBottom: `1px solid ${TOK.ink}`, display: 'inline-block', paddingBottom: 2 }}>
            SANDRO ANDRIC
          </div>
          <div style={{ marginTop: 18, color: TOK.sub }}>FOCUS</div>
          <div>AI · HEALTH · INFRA</div>
        </div>
        <p style={{
          fontSize: 19, lineHeight: 1.58, color: TOK.ink, maxWidth: 560,
          marginLeft: 'auto', letterSpacing: '-0.005em',
        }}>
          Six small machines in active use across AI, health, and developer
          infrastructure. Below is what's on the bench — pick anything up,
          move it, click to open.
        </p>
      </div>
    </section>
  );
}

// (D) Ledger — horizontal printed studio ledger, six rows of in-flight work
function HeroLedger() {
  const rows = [
    ['01', 'AGENT HANDOVER',  'AGENT',    'macOS',   'LIVE'],
    ['02', 'DOPAMINE CLUB',   'HEALTH',   'Web',     'BETA'],
    ['03', 'CLIME',           'INFRA',    'Web',     'LIVE'],
    ['04', 'UNBURY',          'iOS',      'iOS',     'LIVE'],
    ['05', 'AINTHUSIAST',     'RESEARCH', 'Journal', 'ACTIVE'],
    ['06', 'LATENT DIARIES',  'ARCHIVE',  'Archive', 'SOON'],
  ];
  return (
    <section style={{ marginTop: 88 }}>
      <div style={{
        fontFamily: TOK.mono, fontSize: 11, letterSpacing: '0.24em', color: TOK.sub,
        display: 'flex', justifyContent: 'space-between',
      }}>
        <span>LEDGER · IN-FLIGHT WORK</span>
        <span>VOL. I · 2026.05</span>
      </div>
      <div style={{ height: 2, background: TOK.ink, marginTop: 12 }} />
      <div style={{ height: 1, background: TOK.ink, marginTop: 3 }} />

      <h1 style={{
        fontFamily: TOK.fr,
        fontVariationSettings: '"opsz" 144, "SOFT" 80, "wght" 360',
        fontWeight: 400,
        fontSize: 'clamp(64px, 8.6vw, 132px)',
        lineHeight: 0.94,
        letterSpacing: '-0.035em',
        margin: '40px 0 8px',
      }}>
        sandric<span style={{ color: TOK.ter }}>.</span>{' '}
        <em style={{ fontStyle: 'italic', color: TOK.sub, fontVariationSettings: '"opsz" 144, "SOFT" 100, "wght" 340' }}>
          a one-person studio
        </em>
      </h1>
      <div style={{
        fontFamily: TOK.mono, fontSize: 11, letterSpacing: '0.22em', color: TOK.ter, marginBottom: 32,
      }}>
        STUDIO LEDGER · OPERATED BY SANDRO ANDRIC
      </div>

      <div style={{
        display: 'grid', gridTemplateColumns: '40px 1fr 110px 100px 80px',
        fontFamily: TOK.mono, fontSize: 11, letterSpacing: '0.18em', color: TOK.sub,
        padding: '8px 0', borderBottom: `1px solid ${TOK.ink}`,
      }}>
        <span>№</span>
        <span>NAME</span>
        <span>DOMAIN</span>
        <span>SURFACE</span>
        <span style={{ textAlign: 'right' }}>STATUS</span>
      </div>
      {rows.map((r, i) => (
        <div key={r[0]} style={{
          display: 'grid', gridTemplateColumns: '40px 1fr 110px 100px 80px',
          fontFamily: TOK.mono, fontSize: 13, letterSpacing: '0.06em',
          padding: '14px 0',
          borderBottom: `1px solid ${TOK.hair}`,
          color: TOK.ink,
          alignItems: 'baseline',
        }}>
          <span style={{ color: TOK.sub }}>{r[0]}</span>
          <span style={{
            fontFamily: TOK.fr, fontSize: 22, letterSpacing: '-0.01em',
            fontVariationSettings: '"opsz" 144, "SOFT" 60, "wght" 460',
          }}>{r[1]}</span>
          <span style={{ color: TOK.sub, fontSize: 10.5 }}>{r[2]}</span>
          <span style={{ color: TOK.sub, fontSize: 10.5 }}>{r[3]}</span>
          <span style={{
            textAlign: 'right',
            color: r[4] === 'SOON' ? TOK.sub : TOK.ter,
            fontWeight: 600,
          }}>{r[4]}</span>
        </div>
      ))}

      <p style={{
        fontSize: 17, lineHeight: 1.6, marginTop: 36, maxWidth: 620,
        color: TOK.ink, letterSpacing: '-0.005em',
      }}>
        Six small machines across AI, health, and developer infrastructure.
        Below is the bench — pick anything up, move it, click to open.
      </p>
    </section>
  );
}

// (E) Specimen — single-idea hero. The wordmark is the page; a small
// dictionary-style gloss sits beneath it, right-aligned to the wordmark's
// right edge. Vertical meta in the right margin. No eyebrow, no CTA.
function HeroSpecimen() {
  return (
    <section className="sd-hero" style={{
      marginTop: 56,
      position: 'relative',
      display: 'grid',
      gridTemplateColumns: 'minmax(0, 1fr) 32px',
      gap: 28,
      alignItems: 'flex-end',
      minHeight: '64vh',
      paddingBottom: 28,
    }}>
      {/* Main composition — wordmark stacked above gloss */}
      <div style={{
        display: 'inline-block',
        textAlign: 'right',
      }}>
        <h1 style={{
          fontFamily: TOK.fr,
          fontVariationSettings: '"opsz" 144, "SOFT" 60, "wght" 340',
          fontWeight: 400,
          fontSize: 'clamp(72px, 19vw, 296px)',
          lineHeight: 0.88,
          letterSpacing: '-0.052em',
          margin: 0,
          color: TOK.ink,
          textAlign: 'left',
        }}>
          sandric<span style={{ color: TOK.ter }}>.</span>
        </h1>

        {/* Gloss — left caption + right italic, justified across the
            wordmark's full width with a thin rule above */}
        <div className="sd-hero-gloss" style={{
          marginTop: 28,
          paddingTop: 16,
          borderTop: `1px solid ${TOK.ink}`,
          display: 'grid',
          gridTemplateColumns: 'auto 1fr',
          alignItems: 'baseline',
          gap: 32,
          textAlign: 'left',
        }}>
          <span style={{
            fontFamily: TOK.mono,
            fontSize: 11,
            letterSpacing: '0.22em',
            color: TOK.sub,
            textTransform: 'uppercase',
            whiteSpace: 'nowrap',
          }}>
            <span style={{ color: TOK.ter }}>n.</span> &nbsp;Sandric · /sand·ric/
          </span>
          <span style={{
            fontFamily: TOK.fr,
            fontVariationSettings: '"opsz" 24, "SOFT" 100, "wght" 380',
            fontStyle: 'italic',
            fontSize: 'clamp(18px, 1.4vw, 22px)',
            color: TOK.ink,
            letterSpacing: '-0.005em',
            textAlign: 'right',
            lineHeight: 1.3,
          }}>
            a small product studio, run alone, shipping six.
          </span>
        </div>
      </div>

      {/* Right margin — vertical meta */}
      <div className="sd-vmeta" style={{
        writingMode: 'vertical-rl',
        fontFamily: TOK.mono, fontSize: 10, letterSpacing: '0.34em',
        color: TOK.sub,
        textTransform: 'uppercase',
        alignSelf: 'flex-end',
        justifySelf: 'end',
        paddingBottom: 6,
        whiteSpace: 'nowrap',
      }}>
        Sandro Andric &nbsp;·&nbsp; <span style={{ color: TOK.ter }}>MMXXVI</span>
      </div>
    </section>
  );
}

function Hero({ which }) {
  if (which === 'card') return <HeroFilingCard />;
  if (which === 'manifesto') return <HeroManifesto />;
  if (which === 'ledger') return <HeroLedger />;
  if (which === 'specimen') return <HeroSpecimen />;
  return <HeroLiterary />;
}

// ── Mobile detection hook ───────────────────────────────────────────────────
function useIsMobile(breakpoint = 720) {
  const [isMobile, setIsMobile] = useState(
    typeof window !== 'undefined' ? window.innerWidth <= breakpoint : false
  );
  useEffect(() => {
    const onResize = () => setIsMobile(window.innerWidth <= breakpoint);
    window.addEventListener('resize', onResize);
    return () => window.removeEventListener('resize', onResize);
  }, [breakpoint]);
  return isMobile;
}

// ── Static card (mobile / no-drag) ──────────────────────────────────────────
function StaticCard({ product }) {
  const [hover, setHover] = useState(false);
  const paper = TOK[product.paper] || TOK.paper;
  return (
    <a
      href={product.url}
      target="_blank"
      rel="noopener noreferrer"
      onMouseEnter={() => setHover(true)}
      onMouseLeave={() => setHover(false)}
      style={{
        position: 'relative',
        display: 'block',
        width: '100%',
        background: paper,
        color: TOK.ink,
        border: `1px solid rgba(17,17,16,0.10)`,
        padding: '22px 20px 20px',
        fontFamily: TOK.sans,
        boxShadow:
          '0 1px 0 rgba(0,0,0,0.05), 0 16px 24px -14px rgba(20, 12, 4, 0.32), 0 3px 6px rgba(20, 12, 4, 0.10)',
        textDecoration: 'none',
        transition: 'transform 200ms ease, box-shadow 200ms ease',
        transform: hover ? 'translateY(-2px)' : 'none',
      }}
    >
      {/* Subtle paper texture overlay */}
      <div aria-hidden style={{
        position: 'absolute', inset: 0, pointerEvents: 'none',
        background:
          'repeating-linear-gradient(0deg, transparent 0 2px, rgba(0,0,0,0.012) 2px 3px), ' +
          'repeating-linear-gradient(90deg, transparent 0 2px, rgba(0,0,0,0.012) 2px 3px)',
        mixBlendMode: 'multiply',
      }} />

      {/* spec line */}
      <div style={{
        display: 'flex', justifyContent: 'space-between', alignItems: 'baseline',
        fontFamily: TOK.mono, fontSize: 9.5, letterSpacing: '0.22em', color: TOK.sub,
        position: 'relative', zIndex: 1,
      }}>
        <span>№ {product.n} · {product.tag}</span>
        <span style={{
          color: product.status === 'SOON' ? TOK.sub : TOK.ter,
          border: `1px solid ${product.status === 'SOON' ? TOK.sub : TOK.ter}`,
          padding: '1px 6px',
          fontSize: 8.5,
        }}>{product.status}</span>
      </div>

      <div style={{ height: 1, background: TOK.hair, margin: '12px 0 12px' }} />

      <div style={{
        fontFamily: TOK.fr, fontSize: 28, lineHeight: 1.02, fontWeight: 500, letterSpacing: '-0.018em',
        fontVariationSettings: '"opsz" 144, "SOFT" 50, "wght" 440',
        position: 'relative', zIndex: 1,
      }}>
        {product.name}
      </div>
      <div style={{
        fontFamily: TOK.mono, fontSize: 10.5, letterSpacing: '0.04em', marginTop: 5, color: TOK.sub,
        position: 'relative', zIndex: 1,
      }}>
        {product.domain}
      </div>

      <Plate product={product} />

      <div style={{
        fontSize: 14, lineHeight: 1.5, marginTop: 14, color: TOK.ink, fontFamily: TOK.sans,
        letterSpacing: '-0.005em',
        position: 'relative', zIndex: 1,
      }}>
        {product.blurb}
      </div>

      {/* Bottom row: barcode + OPEN */}
      <div style={{
        display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end',
        marginTop: 18, position: 'relative', zIndex: 1,
      }}>
        <Barcode code={product.serial} w={120} h={28} />
        <span style={{
          fontFamily: TOK.mono, fontSize: 10, letterSpacing: '0.22em', fontWeight: 500,
          color: hover ? TOK.paper : TOK.ink,
          background: hover ? TOK.ink : 'transparent',
          padding: '5px 10px 4px',
          border: `1px solid ${TOK.ink}`,
          transition: 'background 160ms ease, color 160ms ease',
        }}>
          OPEN ↗
        </span>
      </div>
    </a>
  );
}

// ── Workshop ────────────────────────────────────────────────────────────────
function Workshop() {
  const stageRef = useRef(null);
  const dragLayerRef = useRef(null);
  const [hint, setHint] = useState('drag to rearrange · click to open · cards snap on drop');

  // Responsive viewport tracking
  const [vw, setVw] = useState(typeof window !== 'undefined' ? window.innerWidth : 1200);
  useEffect(() => {
    const onResize = () => setVw(window.innerWidth);
    window.addEventListener('resize', onResize);
    return () => window.removeEventListener('resize', onResize);
  }, []);

  const isMobile = vw <= 720;
  const isTablet = vw > 720 && vw <= 1024;

  // Responsive grid + card sizing
  const cols = isMobile ? 1 : isTablet ? 2 : 3;
  const padX = isMobile ? 18 : 56;
  const cardW = isMobile
    ? Math.max(200, Math.min(vw - 90, 240))
    : (isTablet ? 300 : CARD_W);
  const cardH = isMobile ? 350 : CARD_H;
  const rows = Math.ceil(PRODUCTS.length / cols);
  const rowGap = isMobile ? 24 : 40;
  // useBench uses padY = 60 internally; match it here for consistent slot sizing
  const tidyHeight = 60 * 2 + rows * cardH + (rows - 1) * rowGap;
  // Default to stack on mobile so the page opens compact with the top card visible
  const initialMobileRef = useRef(typeof window !== 'undefined' && window.innerWidth <= 720);
  const [mode, setMode] = useState(initialMobileRef.current ? 'stack' : null);
  // On mobile, shrink the cork canvas for stack/scatter so it doesn't take the full tidy height
  const corkHeight = (isMobile && mode === 'stack')
    ? Math.max(cardH + 200, 460)
    : (isMobile && mode === 'scatter')
      ? Math.max(Math.ceil(tidyHeight * 0.55), cardH * 2 + 160)
      : tidyHeight;

  const tweaks = TWEAK_DEFAULTS;

  const { layouts, size, updateCard, bringToTop, commitDrop, arrange } = useBench({
    products: PRODUCTS,
    stageRef,
    dragLayerRef,
    cardW,
    cardH,
    cols,
    padX,
    initialMode: initialMobileRef.current ? 'stack' : null,
  });

  const doTidy    = () => { setHint('tidied · everything to a clean grid'); setMode('tidy'); };
  const doScatter = () => { setHint('scattered · soft snap on drop');       setMode('scatter'); };
  const doStack   = () => { setHint('stacked · click to fan out');          setMode('stack'); };

  // After mode + corkHeight changes propagate to the stage size, run arrange.
  // Initial mode is already reflected in useBench's initial layout, so skip the first run.
  const lastArrangedRef = useRef({
    mode: initialMobileRef.current ? 'stack' : null,
    h: 0,
    initialSkipped: false,
  });
  useEffect(() => {
    if (!mode) return;
    if (size.w < 100) return;
    // Skip the first effect run if it matches the initialMode useBench already used
    if (!lastArrangedRef.current.initialSkipped && lastArrangedRef.current.mode === mode) {
      lastArrangedRef.current.initialSkipped = true;
      lastArrangedRef.current.h = size.h;
      return;
    }
    if (lastArrangedRef.current.mode === mode && Math.abs(lastArrangedRef.current.h - size.h) < 8) return;
    lastArrangedRef.current = { mode, h: size.h, initialSkipped: true };
    arrange(mode);
  }, [mode, size.h, size.w, arrange]);

  return (
    <div style={{
      minHeight: '100vh', width: '100%',
      color: TOK.ink, background: TOK.bg,
      position: 'relative', fontFamily: TOK.sans,
    }}>
      <div className="sd-page" style={{ position: 'relative', zIndex: 1, padding: '32px 64px 0', maxWidth: 1440, margin: '0 auto' }}>
        {/* Top bar */}
        <header className="sd-header" style={{
          display: 'grid', gridTemplateColumns: 'auto 1fr auto', alignItems: 'baseline', gap: 40,
          fontFamily: TOK.mono, fontSize: 11, letterSpacing: '0.18em',
        }}>
          <a href="#" style={{
            fontFamily: TOK.fr, fontSize: 26, letterSpacing: '-0.02em', fontWeight: 500,
            fontVariationSettings: '"opsz" 144, "SOFT" 60, "wght" 480',
            justifySelf: 'start',
          }}>
            sandric<span style={{ color: TOK.ter }}>.</span>
          </a>
          <div className="sd-header-sub" style={{ color: TOK.sub, textAlign: 'center', whiteSpace: 'nowrap' }}>
            AN INDEPENDENT PRODUCT STUDIO · SIX LIVE
          </div>
          <nav className="sd-nav" style={{ display: 'flex', gap: 28, justifySelf: 'end', whiteSpace: 'nowrap' }}>
            <a href="#work" style={{ color: TOK.ink }}>WORK</a>
            <a href="#about" style={{ color: TOK.ink }}>ABOUT</a>
            <a href="mailto:sandro@sandric.co" style={{ color: TOK.ter }}>HELLO ↗</a>
          </nav>
        </header>
        <div style={{ height: 1, background: TOK.rule, marginTop: 16 }} />

        <Hero which={tweaks.hero} />

        {/* Section header */}
        <div id="work" className="sd-section-bar" style={{
          display: 'grid', gridTemplateColumns: 'auto 1fr auto', alignItems: 'center', gap: 24,
          marginTop: 128, position: 'sticky', top: 0, zIndex: 5,
          background: `linear-gradient(${TOK.bg} 78%, rgba(233,229,218,0))`,
          padding: '18px 0 12px',
        }}>
          <div style={{
            fontFamily: TOK.mono, fontSize: 11, letterSpacing: '0.24em',
            display: 'inline-flex', alignItems: 'center', gap: 14,
          }}>
            <span style={{ width: 22, height: 1, background: TOK.ink, display: 'inline-block' }} />
            <span style={{ whiteSpace: 'nowrap' }}>ON THE BENCH — 06 LIVE</span>
          </div>
          <div className="sd-rule" style={{ height: 1, background: TOK.hair }} />
          <div style={{ display: 'flex', gap: 0, border: `1px solid ${TOK.ink}` }}>
            <ToolBtn onClick={doTidy} first>TIDY</ToolBtn>
            <ToolBtn onClick={doScatter}>SCATTER</ToolBtn>
            <ToolBtn onClick={doStack}>STACK</ToolBtn>
          </div>
        </div>

        <div aria-live="polite" style={{
          fontFamily: TOK.mono, fontSize: 10.5, letterSpacing: '0.18em',
          color: TOK.sub, marginTop: 8, textTransform: 'uppercase',
        }}>
          {hint}
        </div>

        <div className="sd-bench" style={{ marginTop: 24 }}>
          <CorkBoard refEl={stageRef} height={corkHeight}>
            <div ref={dragLayerRef} style={{ position: 'absolute', inset: 0 }}>
              {layouts && layouts.map((l) => {
                const product = PRODUCTS.find(p => p.id === l.id);
                return (
                  <Card
                    key={product.id}
                    product={product}
                    layout={l}
                    onChange={updateCard}
                    onBringToTop={bringToTop}
                    onCommit={commitDrop}
                    dragLayerRef={dragLayerRef}
                    cardW={cardW}
                    cardH={cardH}
                  />
                );
              })}
            </div>
          </CorkBoard>
        </div>

        {/* About */}
        <section id="about" className="sd-section" style={{
          marginTop: 144,
          display: 'grid', gridTemplateColumns: 'minmax(0,1fr) minmax(0,1.4fr)',
          gap: 80, alignItems: 'flex-start',
          paddingTop: 48, borderTop: `1px solid ${TOK.hair}`,
        }}>
          <div>
            <div style={{
              fontFamily: TOK.mono, fontSize: 11, letterSpacing: '0.22em', color: TOK.sub,
              display: 'inline-flex', alignItems: 'center', gap: 12, marginBottom: 28,
            }}>
              <span style={{ width: 18, height: 1, background: TOK.sub, display: 'inline-block' }} />
              № 02 · ABOUT
            </div>
            <h2 style={{
              fontFamily: TOK.fr,
              fontSize: 'clamp(44px, 5vw, 72px)',
              fontWeight: 400, lineHeight: 0.98, letterSpacing: '-0.03em',
              fontVariationSettings: '"opsz" 144, "SOFT" 80, "wght" 380',
              margin: 0,
            }}>
              Sandro <em style={{ fontStyle: 'italic', fontVariationSettings: '"opsz" 144, "SOFT" 100, "wght" 360' }}>+</em> Andric{' '}
              <em style={{ fontStyle: 'italic', fontVariationSettings: '"opsz" 144, "SOFT" 100, "wght" 360' }}>=</em> sandric<span style={{ color: TOK.ter }}>.</span>
            </h2>
          </div>
          <div style={{ fontSize: 18, lineHeight: 1.62, maxWidth: 620, color: TOK.ink, paddingTop: 14, letterSpacing: '-0.005em' }}>
            Sandric started because side projects kept outgrowing the side. An AI
            that learns how you decide. A biohacking supplement platform with real research behind it. A CLI registry I built for myself that, eight hundred
            tools later, still isn't done.
            <br/><br/>
            Each one began as a question nobody was answering. At some point
            you stop calling it a hobby.
          </div>
        </section>

        {/* Footer */}
        <footer className="sd-footer" style={{
          marginTop: 120, padding: '32px 0 40px',
          borderTop: `1px solid ${TOK.rule}`,
          display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', gap: 24, alignItems: 'baseline',
          fontFamily: TOK.mono, fontSize: 11, letterSpacing: '0.2em',
        }}>
          <a href="mailto:sandro@sandric.co" style={{
            justifySelf: 'start', color: TOK.ink, borderBottom: `1px solid ${TOK.ink}`, paddingBottom: 2,
          }}>SANDRO@SANDRIC.CO</a>
          <div style={{ textAlign: 'center', color: TOK.sub }}>NO SIDE PROJECTS, ONLY EARLY ONES</div>
          <div style={{ textAlign: 'right', color: TOK.sub }}>© SANDRIC · MMXXVI</div>
        </footer>
      </div>

    </div>
  );
}

window.Workshop = Workshop;
