// ============================================================================
// Creator landing — "Parisian" restyle
// ----------------------------------------------------------------------------
// - Completely off Evora design system (per direction).
// - Palette: charcoal / ivory / dusty rose + champagne gold accents.
// - OF-blue button + 💙🤍 emojis are preserved EXACTLY (compliance signal).
// - Socials now render as branded buttons (IG / YT / X / TikTok), each
//   carrying their own platform hue so the OF-blue hero doesn't read as
//   "the only color on the page" — it reads as "the biggest of many".
// - Theme-driven so the same component renders three artboards:
//   Parisian Ivory · Warm Cream · Midnight Charcoal.
// ============================================================================

const { useState, useRef, useEffect } = React;

// Inline lucide-equivalent icons (UMD lucide doesn't return React components,
// so we draw our own minimal versions).
const BadgeCheck = ({ size = 18, style, strokeWidth = 2 }) => (
  <svg viewBox="0 0 24 24" width={size} height={size} style={style} aria-hidden="true">
    <path
      d="M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z"
      fill={style?.fill || 'currentColor'}
    />
    <path d="m9 12 2 2 4-4" fill="none" stroke={style?.color || '#fff'} strokeWidth={strokeWidth} strokeLinecap="round" strokeLinejoin="round" />
  </svg>
);
const MapPin = ({ size = 12, style }) => (
  <svg viewBox="0 0 24 24" width={size} height={size} fill="none" stroke={style?.color || 'currentColor'} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" style={style}>
    <path d="M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z"/>
    <circle cx="12" cy="10" r="3"/>
  </svg>
);
const Clock = ({ size = 12, style }) => (
  <svg viewBox="0 0 24 24" width={size} height={size} fill="none" stroke={style?.color || 'currentColor'} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" style={style}>
    <circle cx="12" cy="12" r="10"/>
    <polyline points="12 6 12 12 16 14"/>
  </svg>
);
const ArrowUpRight = ({ size = 14, style, className }) => (
  <svg viewBox="0 0 24 24" width={size} height={size} fill="none" stroke={style?.color || 'currentColor'} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" style={style} className={className}>
    <path d="M7 17 17 7"/>
    <path d="M7 7h10v10"/>
  </svg>
);

// ---------- THEMES ----------------------------------------------------------
// Three palettes, same structural rules.
// Variables used throughout the component:
//   bg          page background (solid or gradient)
//   ink         primary text
//   inkSoft     secondary text
//   inkMuted    tertiary text / meta
//   card        surface fill (translucent)
//   cardBorder  hairline
//   ring        photo ring & subtle dividers
//   rose        dusty-rose accent (tagline dot, underline, small flourishes)
//   gold        champagne-gold accent (verified tick, sparkle, em dashes)
//   grainOpacity noise overlay strength
// ---------------------------------------------------------------------------

const THEMES = {
  ivory: {
    label: 'Parisian Ivory',
    bg: 'radial-gradient(ellipse at 50% 0%, #F2EBE2 0%, #E8DFD4 55%, #D9CFC3 100%)',
    ink: '#1F1C1A',
    inkSoft: '#4A4440',
    inkMuted: '#8A817A',
    card: 'rgba(255,255,255,0.55)',
    cardStrong: 'rgba(255,255,255,0.75)',
    cardBorder: 'rgba(31,28,26,0.08)',
    ring: '#C9B7A4',
    rose: '#B87A7A',
    gold: '#B08A4E',
    hairline: 'rgba(31,28,26,0.12)',
    grainOpacity: 0.06,
    isDark: false,
  },
  cream: {
    label: 'Warm Cream',
    bg: 'radial-gradient(ellipse at 50% 0%, #FAF3EA 0%, #F1E3D3 60%, #E3CFBB 100%)',
    ink: '#2A211C',
    inkSoft: '#5A4A40',
    inkMuted: '#9C8878',
    card: 'rgba(255,255,255,0.6)',
    cardStrong: 'rgba(255,255,255,0.82)',
    cardBorder: 'rgba(42,33,28,0.08)',
    ring: '#D7B89A',
    rose: '#C27A6A',
    gold: '#B8904A',
    hairline: 'rgba(42,33,28,0.12)',
    grainOpacity: 0.05,
    isDark: false,
  },
  midnight: {
    label: 'Midnight Charcoal',
    bg: 'radial-gradient(ellipse at 50% 0%, #2A252A 0%, #1A1618 55%, #0F0D0E 100%)',
    ink: '#F4EDE4',
    inkSoft: '#C6B9AC',
    inkMuted: '#8A7F75',
    card: 'rgba(255,255,255,0.04)',
    cardStrong: 'rgba(255,255,255,0.07)',
    cardBorder: 'rgba(255,255,255,0.09)',
    ring: '#4A3F3A',
    rose: '#D49A99',
    gold: '#D4B37A',
    hairline: 'rgba(255,255,255,0.1)',
    grainOpacity: 0.04,
    isDark: true,
  },
};

// ---------- FONT PAIRINGS ---------------------------------------------------

const FONT_PAIRS = {
  editorial: {
    label: 'Editorial (serif display)',
    display: "'Fraunces', 'Times New Roman', serif",
    body: "'Inter', -apple-system, sans-serif",
    mono: "'JetBrains Mono', monospace",
    displayWeight: 400,
    displayTracking: '-0.03em',
    // Fraunces at ~opsz high reads like a fashion masthead.
    displayStyle: "font-variation-settings: 'opsz' 144, 'SOFT' 50;",
  },
  chic: {
    label: 'Chic (soft grotesk)',
    display: "'Instrument Serif', 'Times New Roman', serif",
    body: "'Inter', -apple-system, sans-serif",
    mono: "'JetBrains Mono', monospace",
    displayWeight: 400,
    displayTracking: '-0.02em',
    displayStyle: '',
  },
  modern: {
    label: 'Modern (all-sans)',
    display: "'Inter', -apple-system, sans-serif",
    body: "'Inter', -apple-system, sans-serif",
    mono: "'JetBrains Mono', monospace",
    displayWeight: 600,
    displayTracking: '-0.035em',
    displayStyle: '',
  },
};

// ---------- DATA ------------------------------------------------------------

const creator = {
  name: 'Cali Jess',
  handle: 'calijess',
  verified: true,
  online: true,
  location: 'New York',
  tagline: '40 · ca · sports mama',
  replyWindow: 'replies in ~2h',
  stats: [
    { platform: 'instagram', count: '1.2M' },
    { platform: 'tiktok', count: '847K' },
  ],
  // Primary gated link (OF). Color + emojis carry the signal — unchanged.
  primary: {
    url: 'https://evora.link/jennyrose/p',
    gated: true,
  },
  // Branded social buttons — each keeps its own platform color so the
  // OF-blue doesn't feel singled out. Listed in rough reach order.
  socials: [
    {
      id: 'ig',
      label: 'Instagram',
      hint: '@calijess · 1.2M',
      url: 'https://instagram.com/calijess',
      brand: 'instagram',
    },
    {
      id: 'tt',
      label: 'TikTok',
      hint: '@calijess · 847K',
      url: 'https://tiktok.com/@calijess',
      brand: 'tiktok',
    },
    {
      id: 'yt',
      label: 'YouTube',
      hint: 'vlogs, weekly-ish',
      url: 'https://youtube.com/@calijess',
      brand: 'youtube',
    },
    {
      id: 'x',
      label: 'Twitter / X',
      hint: '@calijess',
      url: 'https://x.com/calijess',
      brand: 'x',
    },
  ],
};

// Brand palette per platform. `tint` is a softer color used for the
// subtle button wash so social buttons read dimmer than the OF one.
const BRAND = {
  instagram: {
    rail: 'linear-gradient(180deg, #F58529 0%, #DD2A7B 50%, #8134AF 100%)',
    icon: '#E85A9C',
    tint: '#DD2A7B',
  },
  tiktok: {
    rail: 'linear-gradient(180deg, #25F4EE 0%, #FE2C55 100%)',
    icon: '#FE2C55',
    tint: '#FE2C55',
  },
  youtube: { rail: '#FF0033', icon: '#FF4757', tint: '#FF0033' },
  x: { rail: '#E8E8E8', icon: '#E8E8E8', tint: '#FFFFFF' },
  spotify: { rail: '#1DB954', icon: '#1DB954', tint: '#1DB954' },
};

// ============================================================================
// FONT LOADER — pulls in all three pairings so the Tweaks toggle is instant.
// ============================================================================
const FontLoader = () => (
  <style>{`
    @import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,300;9..144,400;9..144,500;9..144,600&family=Instrument+Serif:ital@0;1&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

    @keyframes pulseDot {
      0%, 100% { opacity: 1; transform: scale(1); }
      50%      { opacity: 0.55; transform: scale(1.18); }
    }
    @keyframes fadeSwap {
      from { opacity: 0; transform: translateY(4px); }
      to   { opacity: 1; transform: translateY(0); }
    }
    @keyframes shimmer {
      0%, 100% { opacity: 0.35; }
      50%      { opacity: 0.7; }
    }
    @keyframes holdPulse {
      0%, 100% { transform: scale(1); opacity: 0.8; }
      50%      { transform: scale(1.12); opacity: 1; }
    }

    .cl-grain::before {
      content: '';
      position: absolute; inset: 0; pointer-events: none;
      opacity: 0.35;
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='2.4' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0.5 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
      background-size: 120px 120px;
      mix-blend-mode: soft-light;
    }
    .cl-grain-dark::before { opacity: 0.25; }

    .cl-hairline { height: 1px; background: currentColor; opacity: 0.14; }
  `}</style>
);

// ============================================================================
// PROFILE PHOTO — placeholder for a real photo, w/ ring accent
// ============================================================================
const ProfilePhoto = ({ theme, size = 104 }) => {
  // Simplified — single frame, one hairline. Meant for a real photo drop-in.
  return (
    <div className="relative" style={{ width: size, height: size }}>
      <div
        className="absolute inset-0 rounded-full overflow-hidden flex items-center justify-center"
        style={{
          background: theme.isDark
            ? 'linear-gradient(135deg, #3a2f2a 0%, #2a2220 60%, #1a1512 100%)'
            : 'linear-gradient(135deg, #e8dbc9 0%, #d4c0a8 60%, #b89880 100%)',
          border: `1px solid ${theme.hairline}`,
          boxShadow: theme.isDark
            ? 'inset 0 -10px 20px rgba(0,0,0,0.3)'
            : 'inset 0 -10px 24px rgba(0,0,0,0.1)',
        }}
      >
        <span
          style={{
            fontFamily: "'Fraunces', serif",
            fontWeight: 300,
            fontStyle: 'italic',
            fontSize: size * 0.42,
            color: theme.isDark ? 'rgba(244,237,228,0.35)' : 'rgba(31,28,26,0.22)',
            letterSpacing: '-0.04em',
            lineHeight: 1,
            marginTop: -2,
          }}
        >
          {creator.name[0]}
        </span>
      </div>
      {/* Online dot — green */}
      <div
        className="absolute rounded-full"
        style={{
          width: 14,
          height: 14,
          right: 2,
          bottom: 2,
          background: '#2DD673',
          border: `2.5px solid ${theme.isDark ? '#0F0D0E' : '#F2EBE2'}`,
          animation: 'pulseDot 2.4s ease-in-out infinite',
        }}
      />
    </div>
  );
};

// ============================================================================
// OF BUTTON — DO NOT CHANGE COLOR OR EMOJIS
// ============================================================================
const OFButton = ({ url, theme }) => {
  // Flow: idle (tap) → age-gate (confirm 18+) → hold (press & hold to reveal)
  //       → armed (long-press menu is now available; instruct user to tap Open Link)
  const [state, setState] = useState('idle');
  const [holding, setHolding] = useState(false);
  const [progress, setProgress] = useState(0); // 0 → 1
  const rafRef = useRef(null);
  const startRef = useRef(0);
  const HOLD_MS = 750;

  // Drive the progress bar while held
  useEffect(() => {
    if (!holding) {
      cancelAnimationFrame(rafRef.current);
      // If released before arming, smoothly drain
      if (state === 'hold') {
        const drainStart = performance.now();
        const startVal = progress;
        const drain = (t) => {
          const k = Math.min(1, (t - drainStart) / 220);
          const v = startVal * (1 - k);
          setProgress(v);
          if (k < 1) rafRef.current = requestAnimationFrame(drain);
        };
        rafRef.current = requestAnimationFrame(drain);
      }
      return () => cancelAnimationFrame(rafRef.current);
    }
    startRef.current = performance.now() - progress * HOLD_MS;
    const tick = (t) => {
      const p = Math.min(1, (t - startRef.current) / HOLD_MS);
      setProgress(p);
      if (p >= 1) {
        setState('armed');
        setHolding(false);
        // Haptic on supported devices
        if (navigator.vibrate) navigator.vibrate(12);
        return;
      }
      rafRef.current = requestAnimationFrame(tick);
    };
    rafRef.current = requestAnimationFrame(tick);
    return () => cancelAnimationFrame(rafRef.current);
    // eslint-disable-next-line
  }, [holding]);

  // ── STATE 1: AGE GATE ─────────────────────────────────────────────────────
  if (state === 'verifying') {
    return (
      <div
        className="w-full rounded-[14px] relative overflow-hidden"
        style={{
          background: 'linear-gradient(180deg, #00AFF0 0%, #009EDA 100%)',
          boxShadow: '0 1px 0 rgba(255,255,255,0.2) inset, 0 18px 40px -20px rgba(0,175,240,0.5)',
          border: '1px solid rgba(0,0,0,0.15)',
          animation: 'fadeSwap 200ms ease-out',
        }}
      >
        <div className="px-4 py-3.5">
          <div
            className="text-white text-[10px] uppercase text-center font-medium"
            style={{ fontFamily: 'var(--font-mono)', letterSpacing: '0.28em', opacity: 0.85 }}
          >
            confirm you're 18+
          </div>
          <div
            className="mt-1 text-white text-center text-[12px]"
            style={{ fontFamily: 'var(--font-body)', opacity: 0.82, lineHeight: 1.4 }}
          >
            This link contains adult content. You must be 18 or older to continue.
          </div>
          <div className="mt-3 grid grid-cols-[1fr_auto] gap-2">
            <button
              onClick={() => setState('hold')}
              className="py-2.5 rounded-[10px] text-white font-semibold text-[14px] transition-transform active:scale-[0.97]"
              style={{
                background: 'rgba(255,255,255,0.2)',
                backdropFilter: 'blur(8px)',
                border: '1px solid rgba(255,255,255,0.3)',
                fontFamily: 'var(--font-body)',
              }}
            >
              Yes, I'm 18+
            </button>
            <button
              onClick={() => setState('idle')}
              className="px-3.5 rounded-[10px] text-white/80 text-[12.5px] font-medium transition-colors hover:bg-white/10"
              style={{ fontFamily: 'var(--font-body)' }}
            >
              Cancel
            </button>
          </div>
        </div>
      </div>
    );
  }

  // ── STATES 2+3: HOLD + ARMED ──────────────────────────────────────────────
  // These share one `<a>` — so the native long-press menu attaches to a real
  // link target. Before the hold completes, href is "#" (no navigation even if
  // a hurried user taps). Once filled, href becomes the real URL.
  if (state === 'hold' || state === 'armed') {
    const armed = state === 'armed';
    const pct = Math.round(progress * 100);

    const start = (e) => {
      if (armed) return;
      e.preventDefault?.();
      setHolding(true);
    };
    const end = () => {
      if (armed) return;
      setHolding(false);
    };

    const label = armed
      ? 'Tap "Open Link" ↑'
      : holding
      ? 'Keep holding…'
      : 'Press & hold';
    const sub = armed
      ? 'A menu should now appear — choose "Open Link"'
      : holding
      ? `${pct}%`
      : 'Hold the button to continue';

    return (
      <div className="relative">
        {/* Helper caption above the button — guides first-timers */}
        <div
          className="mb-2 flex items-center justify-center gap-1.5 text-[10px] uppercase"
          style={{
            color: theme.inkMuted,
            fontFamily: 'var(--font-mono)',
            letterSpacing: '0.22em',
            opacity: armed ? 1 : 0.8,
            transition: 'opacity 200ms',
          }}
        >
          <svg
            viewBox="0 0 24 24"
            width={12}
            height={12}
            fill="none"
            stroke="currentColor"
            strokeWidth={2}
            strokeLinecap="round"
            strokeLinejoin="round"
            aria-hidden="true"
            style={{
              animation: armed ? 'none' : 'holdPulse 1.6s ease-in-out infinite',
            }}
          >
            <path d="M9 11V6a3 3 0 1 1 6 0v5" />
            <path d="M9 11V4a2 2 0 0 0-4 0v10l3 7h9l2-8-7-2" />
          </svg>
          <span>{armed ? 'almost there' : 'press & hold to continue'}</span>
        </div>

        <a
          href={armed ? url : '#'}
          onMouseDown={start}
          onMouseUp={end}
          onMouseLeave={end}
          onTouchStart={start}
          onTouchEnd={end}
          onTouchCancel={end}
          onContextMenu={(e) => {
            // If user long-presses before the fill completes, prevent it —
            // we want them to see the full "armed" state first.
            if (!armed) e.preventDefault();
          }}
          onClick={(e) => {
            // A quick tap shouldn't navigate; they must hold.
            if (!armed) e.preventDefault();
          }}
          draggable={false}
          className="group relative w-full flex items-center gap-3.5 rounded-[14px] p-3.5 text-left overflow-hidden select-none"
          style={{
            background: 'linear-gradient(180deg, #00AFF0 0%, #009EDA 100%)',
            border: '1px solid rgba(0,0,0,0.15)',
            boxShadow: armed
              ? '0 1px 0 rgba(255,255,255,0.2) inset, 0 0 0 3px rgba(0,175,240,0.28)'
              : '0 1px 0 rgba(255,255,255,0.2) inset',
            textDecoration: 'none',
            WebkitTouchCallout: armed ? 'default' : 'none',
            transform: holding ? 'scale(0.992)' : 'scale(1)',
            transition: 'transform 120ms, box-shadow 220ms',
          }}
          aria-label="Private link — press and hold"
        >
          {/* PROGRESS FILL — darker blue wipes left→right, stays filled when armed */}
          <div
            className="absolute inset-0 pointer-events-none"
            style={{
              background: 'linear-gradient(180deg, #0088C2 0%, #0074A8 100%)',
              transformOrigin: 'left center',
              transform: `scaleX(${armed ? 1 : progress})`,
              transition: holding ? 'none' : 'transform 160ms ease-out',
              opacity: 0.92,
            }}
          />
          {/* Leading edge shimmer while holding */}
          {holding && progress < 1 && (
            <div
              className="absolute top-0 bottom-0 pointer-events-none"
              style={{
                left: `${progress * 100}%`,
                width: 2,
                background: 'rgba(255,255,255,0.55)',
                boxShadow: '0 0 12px 2px rgba(255,255,255,0.5)',
                transform: 'translateX(-1px)',
              }}
            />
          )}

          {/* Left rail */}
          <div
            className="absolute top-2 bottom-2 left-0 w-[3px] rounded-r-full z-10"
            style={{ background: 'rgba(255,255,255,0.5)' }}
          />

          {/* Icon chip */}
          <div
            className="relative z-10 w-10 h-10 rounded-[10px] flex items-center justify-center shrink-0 ml-1"
            style={{
              background: 'rgba(255,255,255,0.18)',
              border: '1px solid rgba(255,255,255,0.28)',
            }}
          >
            <svg viewBox="0 0 24 24" width={20} height={20} fill="white" aria-hidden="true">
              <path d="M12 21s-7-4.5-9.5-9A5.5 5.5 0 0 1 12 6.5 5.5 5.5 0 0 1 21.5 12c-2.5 4.5-9.5 9-9.5 9z"/>
            </svg>
          </div>

          <div className="relative z-10 flex-1 min-w-0">
            <div
              className="text-[14.5px] font-medium tracking-tight text-white"
              style={{ fontFamily: 'var(--font-body)' }}
            >
              {label}
            </div>
            <div
              className="text-[11.5px] truncate"
              style={{
                color: 'rgba(255,255,255,0.85)',
                fontFamily: 'var(--font-body)',
                fontVariantNumeric: 'tabular-nums',
              }}
            >
              {sub}
            </div>
          </div>

          <div className="relative z-10 flex items-center gap-1 text-[18px] leading-none shrink-0 pr-1">
            <span>💙</span>
            <span>🤍</span>
          </div>
        </a>

        {armed && (
          <button
            onClick={() => {
              setState('idle');
              setProgress(0);
            }}
            className="mt-2 w-full text-center text-[11px]"
            style={{
              color: theme.inkMuted,
              fontFamily: 'var(--font-mono)',
              letterSpacing: '0.12em',
              textTransform: 'uppercase',
            }}
          >
            reset
          </button>
        )}
      </div>
    );
  }

  // ── STATE 0: IDLE ─────────────────────────────────────────────────────────
  return (
    <button
      onClick={() => setState('verifying')}
      className="group relative w-full flex items-center gap-3.5 rounded-[14px] p-3.5 transition-all hover:-translate-y-[1px] text-left"
      style={{
        background: 'linear-gradient(180deg, #00AFF0 0%, #009EDA 100%)',
        border: '1px solid rgba(0,0,0,0.15)',
        boxShadow: '0 1px 0 rgba(255,255,255,0.2) inset',
      }}
      aria-label="Private link"
    >
      <div
        className="absolute top-2 bottom-2 left-0 w-[3px] rounded-r-full"
        style={{ background: 'rgba(255,255,255,0.5)' }}
      />

      <div
        className="w-10 h-10 rounded-[10px] flex items-center justify-center shrink-0 ml-1"
        style={{
          background: 'rgba(255,255,255,0.15)',
          border: '1px solid rgba(255,255,255,0.25)',
        }}
      >
        <svg viewBox="0 0 24 24" width={20} height={20} fill="white" aria-hidden="true">
          <path d="M12 21s-7-4.5-9.5-9A5.5 5.5 0 0 1 12 6.5 5.5 5.5 0 0 1 21.5 12c-2.5 4.5-9.5 9-9.5 9z"/>
        </svg>
      </div>

      <div className="flex-1 min-w-0">
        <div
          className="text-[14.5px] font-medium tracking-tight text-white"
          style={{ fontFamily: 'var(--font-body)' }}
        >
          Private
        </div>
        <div
          className="text-[11.5px] truncate"
          style={{ color: 'rgba(255,255,255,0.75)', fontFamily: 'var(--font-body)' }}
        >
          18+ only
        </div>
      </div>

      <div className="flex items-center gap-1 text-[18px] leading-none shrink-0 pr-1">
        <span>💙</span>
        <span>🤍</span>
      </div>
    </button>
  );
};

// ============================================================================
// SOCIAL BUTTON — branded per platform, shared row below the OF hero
// ============================================================================
const SocialButton = ({ social, theme, fonts }) => {
  const brand = BRAND[social.brand];
  let IconEl = null;
  if (social.brand === 'instagram') IconEl = window.InstagramIcon;
  if (social.brand === 'tiktok') IconEl = window.TikTokIcon;
  if (social.brand === 'youtube') IconEl = window.YouTubeIcon;
  if (social.brand === 'x') IconEl = window.XIcon;
  if (social.brand === 'spotify') IconEl = window.SpotifyIcon;

  // Subtle platform-tinted fill — dimmer than OF's full saturation.
  // Each gets a low-alpha color wash + matching rail + icon.
  const tint = brand.tint || brand.icon;
  return (
    <a
      href={social.url}
      target="_blank"
      rel="noreferrer noopener"
      className="group relative flex items-center gap-3.5 rounded-[14px] p-3.5 transition-all hover:-translate-y-[1px]"
      style={{
        background: theme.isDark
          ? `linear-gradient(180deg, ${tint}22 0%, ${tint}14 100%)`
          : `linear-gradient(180deg, ${tint}18 0%, ${tint}0d 100%)`,
        border: `1px solid ${tint}33`,
        backdropFilter: 'blur(10px)',
        WebkitBackdropFilter: 'blur(10px)',
      }}
    >
      {/* Left rail — platform color */}
      <div
        className="absolute top-2 bottom-2 left-0 w-[3px] rounded-r-full"
        style={{ background: brand.rail }}
      />

      {/* Icon chip */}
      <div
        className="w-10 h-10 rounded-[10px] flex items-center justify-center shrink-0 ml-1"
        style={{
          background: theme.isDark ? 'rgba(255,255,255,0.06)' : 'rgba(255,255,255,0.85)',
          border: `1px solid ${tint}40`,
          color: brand.icon,
        }}
      >
        {IconEl && <IconEl size={20} />}
      </div>

      {/* Label only — no hint */}
      <div className="flex-1 min-w-0">
        <div
          className="text-[14.5px] font-medium tracking-tight"
          style={{ color: theme.ink, fontFamily: 'var(--font-body)' }}
        >
          {social.label}
        </div>
      </div>

      <ArrowUpRight
        size={14}
        className="transition-all shrink-0 group-hover:translate-x-[1px] group-hover:-translate-y-[1px]"
        style={{ color: theme.inkMuted }}
      />
    </a>
  );
};

// ============================================================================
// LANDING (theme-driven)
// ============================================================================
const Landing = ({ themeKey = 'ivory', fontKey = 'editorial', showReplyLine = true }) => {
  const theme = THEMES[themeKey];
  const fonts = FONT_PAIRS[fontKey];

  // CSS vars scoped to this landing instance
  const scopeStyle = {
    '--font-display': fonts.display,
    '--font-body': fonts.body,
    '--font-mono': fonts.mono,
    fontFamily: fonts.body,
    color: theme.ink,
  };

  return (
    <div
      className={`relative w-full h-full overflow-hidden cl-grain ${theme.isDark ? 'cl-grain-dark' : ''}`}
      style={{ ...scopeStyle, background: theme.bg }}
    >
      {/* Ambient blush glow behind primary — sits ABOVE background, BELOW content */}
      <div
        className="absolute pointer-events-none rounded-full blur-3xl"
        style={{
          width: 340,
          height: 340,
          left: '50%',
          top: '32%',
          transform: 'translateX(-50%)',
          background: `radial-gradient(circle, ${theme.rose}33 0%, transparent 70%)`,
          animation: 'shimmer 8s ease-in-out infinite',
        }}
      />

      <div className="relative z-10 px-6 pt-10 pb-12">
        {/* PROFILE PHOTO */}
        <div className="flex justify-center">
          <ProfilePhoto theme={theme} />
        </div>

        {/* NAME (serif display) + verified gold tick */}
        <div className="mt-5 flex items-center justify-center gap-2">
          <h1
            className="tracking-tight"
            style={{
              fontFamily: 'var(--font-display)',
              fontWeight: fonts.displayWeight,
              fontSize: 34,
              letterSpacing: fonts.displayTracking,
              lineHeight: 1.05,
              color: theme.ink,
            }}
          >
            {creator.name}
          </h1>
          {creator.verified && (
            <BadgeCheck
              size={18}
              strokeWidth={2}
              style={{ color: '#FFFFFF', fill: '#1D9BF0' }}
            />
          )}
        </div>

        {/* Handle + dusty-rose underline flourish */}
        <div className="mt-1 flex flex-col items-center">
          <div
            className="text-[13px]"
            style={{
              color: theme.inkSoft,
              fontFamily: 'var(--font-body)',
              fontWeight: 400,
            }}
          >
            @{creator.handle}
          </div>
          <div
            className="mt-2 h-px"
            style={{ width: 24, background: theme.rose, opacity: 0.7 }}
          />
        </div>

        {/* One uniform button stack — OF first, then socials. No divider labels. */}
        <div className="mt-8 space-y-2.5">
          <OFButton url={creator.primary.url} theme={theme} />
          {creator.socials.map((s) => (
            <SocialButton key={s.id} social={s} theme={theme} fonts={fonts} />
          ))}
        </div>

        {/* FOOTER — quiet signature */}
        <div className="mt-10 flex flex-col items-center gap-2">
          <div
            style={{
              fontFamily: 'var(--font-display)',
              fontStyle: 'italic',
              fontSize: 11,
              color: theme.inkMuted,
            }}
          >
            — with love, jess —
          </div>
        </div>
      </div>

      <FontLoader />
    </div>
  );
};

Object.assign(window, { Landing, THEMES, FONT_PAIRS });
