// Crafted mini-site previews for the portfolio. Each is a small composition
// that hints at the brand/product — better than solid blocks.

// ─── Hamilton SRLA — educational, sage green, school-spirit typography ───
window.PreviewSRLA = ({ size = 'md' }) => {
  const scale = size === 'lg' ? 1.2 : size === 'sm' ? 0.8 : 1;
  return (
    <div style={{ position: 'absolute', inset: 0, background: '#3E5A38', overflow: 'hidden' }}>
      {/* diagonal scrim */}
      <div style={{ position: 'absolute', inset: 0,
        background: 'radial-gradient(ellipse at 20% 10%, #5A7C52 0%, transparent 55%), linear-gradient(135deg, #3E5A38 0%, #2C4528 100%)' }} />
      {/* grid */}
      <div style={{ position: 'absolute', inset: 0, opacity: 0.08,
        backgroundImage: 'linear-gradient(rgba(255,255,255,0.8) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.8) 1px, transparent 1px)',
        backgroundSize: '40px 40px' }} />
      {/* top-left tag */}
      <div style={{ position: 'absolute', top: 24 * scale, left: 24 * scale,
        fontFamily: TC.mono, fontSize: 10 * scale, color: 'rgba(255,255,255,0.55)',
        letterSpacing: 2, textTransform: 'uppercase' }}>
        Est. 1931 · Hamilton High
      </div>
      {/* center wordmark */}
      <div style={{ position: 'absolute', inset: 0, display: 'flex',
        alignItems: 'center', justifyContent: 'center', flexDirection: 'column', padding: 32 }}>
        <div style={{
          fontFamily: TC.serif, color: '#F7F3E4',
          fontSize: 82 * scale, fontStyle: 'italic', lineHeight: 0.88, letterSpacing: -2.2,
          textAlign: 'center', textShadow: '0 2px 20px rgba(0,0,0,0.25)',
        }}>
          Hamilton<br />
          <span style={{ fontStyle: 'normal', fontFamily: TC.serif }}>S·R·L·A</span>
        </div>
        <div style={{ marginTop: 18 * scale, fontFamily: TC.mono, fontSize: 11 * scale,
          color: 'rgba(255,255,255,0.7)', letterSpacing: 3, textTransform: 'uppercase' }}>
          Social · Responsibility · Learning · Academy
        </div>
      </div>
      {/* bottom strip */}
      <div style={{ position: 'absolute', left: 0, right: 0, bottom: 0,
        padding: `${14 * scale}px ${24 * scale}px`,
        display: 'flex', justifyContent: 'space-between',
        borderTop: '1px solid rgba(247,243,228,0.18)',
        fontFamily: TC.mono, fontSize: 10 * scale, color: 'rgba(255,255,255,0.55)',
        letterSpacing: 1.5, textTransform: 'uppercase' }}>
        <span>◗ Apply · 2026</span>
        <span>srla.hamilton.org</span>
      </div>
    </div>
  );
};

// ─── Glance — speed reading app, deep blue, kinetic type ───
window.PreviewGlance = ({ size = 'md' }) => {
  const scale = size === 'lg' ? 1.2 : size === 'sm' ? 0.8 : 1;
  const [w, setW] = React.useState('focus');
  React.useEffect(() => {
    const words = ['focus', 'read', 'glance', 'absorb', 'focus', 'read'];
    let i = 0;
    const id = setInterval(() => { i = (i + 1) % words.length; setW(words[i]); }, 520);
    return () => clearInterval(id);
  }, []);
  return (
    <div style={{ position: 'absolute', inset: 0,
      background: 'radial-gradient(ellipse at 70% 50%, #3C5577 0%, #1E2E4A 100%)',
      overflow: 'hidden' }}>
      {/* horizontal scan line */}
      <div style={{ position: 'absolute', top: '50%', left: 0, right: 0, height: 1,
        background: 'linear-gradient(90deg, transparent 0%, rgba(214,133,100,0.8) 50%, transparent 100%)',
        transform: 'translateY(-50%)' }} />
      {/* left counter */}
      <div style={{ position: 'absolute', top: 28 * scale, left: 28 * scale,
        fontFamily: TC.mono, fontSize: 11 * scale, color: 'rgba(255,255,255,0.55)',
        letterSpacing: 1.5, display: 'flex', alignItems: 'center', gap: 8 }}>
        <span style={{ width: 6, height: 6, borderRadius: 3, background: '#D68564', animation: 'atPulse 1.2s infinite' }} />
        <span>450 WPM</span>
      </div>
      <div style={{ position: 'absolute', top: 28 * scale, right: 28 * scale,
        fontFamily: TC.mono, fontSize: 11 * scale, color: 'rgba(255,255,255,0.55)', letterSpacing: 1.5 }}>
        Chapter 3 · pg. 47
      </div>
      {/* center giant word */}
      <div style={{ position: 'absolute', inset: 0, display: 'flex',
        alignItems: 'center', justifyContent: 'center' }}>
        <div style={{
          fontFamily: TC.serif, fontSize: 96 * scale, fontStyle: 'italic',
          color: '#F7F3E4', letterSpacing: -3, lineHeight: 1,
          position: 'relative',
        }}>
          <span style={{ color: '#D68564' }}>{w[Math.floor(w.length / 2)]}</span>
          <span style={{ position: 'absolute', left: '-1em', top: 0, color: 'rgba(247,243,228,0.35)' }}>
            {w.slice(0, Math.floor(w.length / 2))}
          </span>
          <span style={{ position: 'absolute', left: '100%', top: 0, color: 'rgba(247,243,228,0.35)', marginLeft: '-0.1em' }}>
            {w.slice(Math.floor(w.length / 2) + 1)}
          </span>
        </div>
      </div>
      {/* bottom progress */}
      <div style={{ position: 'absolute', left: 28 * scale, right: 28 * scale, bottom: 28 * scale }}>
        <div style={{ height: 2, background: 'rgba(255,255,255,0.1)', borderRadius: 1, overflow: 'hidden' }}>
          <div style={{ width: '38%', height: '100%', background: '#D68564' }} />
        </div>
        <div style={{ marginTop: 10, display: 'flex', justifyContent: 'space-between',
          fontFamily: TC.mono, fontSize: 10 * scale, color: 'rgba(255,255,255,0.45)', letterSpacing: 1.2 }}>
          <span>02:14</span>
          <span>glance.guama.dev</span>
          <span>05:48</span>
        </div>
      </div>
    </div>
  );
};

// ─── Generic placeholder with brand-flavored composition ───
window.PreviewGeneric = ({ title, kind, base, tag, pattern = 'stripes', size = 'md', url }) => {
  const scale = size === 'lg' ? 1.2 : size === 'sm' ? 0.8 : 1;
  const patterns = {
    stripes: 'repeating-linear-gradient(-38deg, transparent 0 14px, rgba(255,255,255,0.05) 14px 15px)',
    dots: 'radial-gradient(rgba(255,255,255,0.12) 1px, transparent 1.6px)',
    grid: 'linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px)',
    arcs: 'repeating-radial-gradient(circle at 30% 100%, transparent 0 30px, rgba(255,255,255,0.05) 30px 32px)',
  };
  const bgSize = pattern === 'dots' ? '14px 14px' : pattern === 'grid' ? '36px 36px' : 'auto';
  return (
    <div style={{ position: 'absolute', inset: 0,
      background: `linear-gradient(135deg, ${base} 0%, ${base}EE 100%)`,
      overflow: 'hidden' }}>
      <div style={{ position: 'absolute', inset: 0, backgroundImage: patterns[pattern], backgroundSize: bgSize }} />
      {/* corner marks */}
      <div style={{ position: 'absolute', top: 16 * scale, left: 16 * scale,
        fontFamily: TC.mono, fontSize: 10 * scale, color: 'rgba(255,255,255,0.55)',
        letterSpacing: 1.5, textTransform: 'uppercase' }}>
        {tag}
      </div>
      <div style={{ position: 'absolute', top: 16 * scale, right: 16 * scale, display: 'flex', gap: 4 }}>
        <div style={{ width: 6, height: 6, borderRadius: 3, background: 'rgba(255,255,255,0.35)' }} />
        <div style={{ width: 6, height: 6, borderRadius: 3, background: 'rgba(255,255,255,0.35)' }} />
        <div style={{ width: 6, height: 6, borderRadius: 3, background: 'rgba(255,255,255,0.35)' }} />
      </div>

      {/* center */}
      <div style={{ position: 'absolute', inset: 0, display: 'flex',
        flexDirection: 'column', alignItems: 'center', justifyContent: 'center',
        padding: 24 * scale, textAlign: 'center' }}>
        <div style={{
          fontFamily: TC.serif, fontSize: 54 * scale, fontStyle: 'italic',
          color: '#F7F3E4', letterSpacing: -1.2, lineHeight: 0.95,
          textShadow: '0 2px 16px rgba(0,0,0,0.2)',
        }}>{title}</div>
        <div style={{
          fontFamily: TC.mono, fontSize: 10 * scale, marginTop: 14 * scale,
          color: 'rgba(255,255,255,0.65)', letterSpacing: 2,
          textTransform: 'uppercase',
        }}>{kind}</div>
      </div>

      <div style={{ position: 'absolute', left: 0, right: 0, bottom: 0,
        padding: `${10 * scale}px ${16 * scale}px`,
        borderTop: '1px solid rgba(247,243,228,0.15)',
        fontFamily: TC.mono, fontSize: 10 * scale,
        color: 'rgba(255,255,255,0.5)',
        display: 'flex', justifyContent: 'space-between' }}>
        <span>◗ Live</span>
        <span>{url}</span>
      </div>
    </div>
  );
};

// Utility: browser chrome bar for hero frames
window.BrowserBar = ({ url, dark }) => (
  <div style={{
    display: 'flex', alignItems: 'center', gap: 8,
    padding: '10px 14px',
    background: dark ? '#22201C' : '#EFE7D7',
    borderBottom: `1px solid ${dark ? 'rgba(255,255,255,0.08)' : 'rgba(0,0,0,0.05)'}`,
  }}>
    <div style={{ display: 'flex', gap: 6 }}>
      <div style={{ width: 10, height: 10, borderRadius: 5, background: '#E26D5C' }} />
      <div style={{ width: 10, height: 10, borderRadius: 5, background: '#D8B26E' }} />
      <div style={{ width: 10, height: 10, borderRadius: 5, background: '#8BA872' }} />
    </div>
    <div style={{
      flex: 1, textAlign: 'center',
      fontFamily: TC.mono, fontSize: 11,
      color: dark ? 'rgba(255,255,255,0.55)' : '#6B5F52',
      letterSpacing: 0.5,
    }}>{url}</div>
    <div style={{ width: 14, height: 14, opacity: 0.3 }}>
      <svg viewBox="0 0 14 14" fill="none" stroke="currentColor" strokeWidth="1.3"
        style={{ color: dark ? '#fff' : '#000' }}>
        <circle cx="7" cy="7" r="2" />
        <circle cx="7" cy="2" r="1" />
        <circle cx="7" cy="12" r="1" />
      </svg>
    </div>
  </div>
);
