// funnel-pages.jsx — Páginas auxiliares del funnel.
//
// Vivieron antes dentro de la landing scrollable. Ahora la landing es solo
// el funnel (interrupt → poll → hero), y estas viven en rutas separadas
// con un único CTA gigante: "Aplicar a Workspace AI" que regresa a /.
//
// Expone window.FeaturesPage, window.SuperpoderesPage, window.VideosPage,
// window.PreciosPage. El router decide cuál mostrar según el path.

(function () {
  const { useState, useEffect, useRef } = React;

  const C = {
    bg: '#0B0E14',
    bgCard: '#11151D',
    bgTerminal: '#0E1219',
    border: 'rgba(255,255,255,0.08)',
    borderActive: 'rgba(249,115,22,0.5)',
    t0: '#FAFAFA',
    t1: '#B6BAC4',
    t2: '#7A7F8B',
    t3: '#4F5562',
    accent: '#F97316',
    accentSoft: 'rgba(249,115,22,0.16)',
    accentGlow: 'rgba(249,115,22,0.55)',
    success: '#10B981',
  };
  const HEAD_FONT = "'Geist',-apple-system,sans-serif";
  const UI_FONT = "'Geist',-apple-system,sans-serif";
  const MONO_FONT = "'Geist Mono', ui-monospace, Menlo, monospace";

  function _Header({ ctaLabel }) {
    return (
      <header style={{
        display: 'flex', alignItems: 'center', justifyContent: 'space-between',
        gap: 12, flexWrap: 'wrap',
        padding: 'clamp(14px, 3vw, 24px) clamp(16px, 4vw, 40px)',
        borderBottom: `1px solid ${C.border}`,
      }}>
        <a href="/" style={{
          textDecoration: 'none',
          fontFamily: HEAD_FONT, fontWeight: 700, fontSize: 16,
          color: C.t0, letterSpacing: '0.2px',
          flexShrink: 0,
        }}>
          workspace<span style={{ color: C.accent }}>.ai</span>
        </a>
        <div style={{ display: 'flex', alignItems: 'center', gap: 12, flexShrink: 0 }}>
          <a href="/login" style={{
            color: C.t2, textDecoration: 'none',
            fontFamily: UI_FONT, fontSize: 13.5, fontWeight: 500,
            whiteSpace: 'nowrap',
          }}>Iniciar sesión</a>
          <a href="/" style={{
            display: 'inline-flex', alignItems: 'center', gap: 6,
            padding: '9px 14px', borderRadius: 10,
            background: C.accent, color: '#fff', textDecoration: 'none',
            fontFamily: UI_FONT, fontSize: 12.5, fontWeight: 700,
            boxShadow: `0 14px 30px -14px ${C.accentGlow}`,
            whiteSpace: 'nowrap',
          }}>
            {ctaLabel || 'Aplicar'}
            <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round"><path d="M5 12h14M13 5l7 7-7 7"/></svg>
          </a>
        </div>
      </header>
    );
  }

  function _FinalCTA({ label }) {
    return (
      <div style={{
        margin: 'clamp(48px, 8vw, 96px) auto 0',
        textAlign: 'center', maxWidth: 720,
      }}>
        <a href="/" style={{
          display: 'inline-flex', alignItems: 'center', gap: 12,
          padding: '20px 36px', borderRadius: 14,
          background: C.accent, color: '#fff', textDecoration: 'none',
          fontFamily: UI_FONT, fontSize: 'clamp(16px, 2vw, 18px)',
          fontWeight: 700, letterSpacing: '-0.1px',
          boxShadow: `0 24px 60px -18px ${C.accentGlow}`,
        }}>
          {label || 'Aplicar a Workspace AI'}
          <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round"><path d="M5 12h14M13 5l7 7-7 7"/></svg>
        </a>
      </div>
    );
  }

  function _Shell({ children, headerCta }) {
    return (
      <div style={{ position: 'fixed', inset: 0, background: C.bg, color: C.t0, overflow: 'auto', fontFamily: UI_FONT }}>
        <_Header ctaLabel={headerCta} />
        <main style={{
          maxWidth: 1080, margin: '0 auto',
          padding: 'clamp(36px, 6vw, 80px) clamp(20px, 4vw, 40px) clamp(48px, 8vw, 96px)',
        }}>
          {children}
        </main>
      </div>
    );
  }

  // ── /features ─────────────────────────────────────────────────────────
  const FEATURES = [
    { id: 'vault', title: 'Vault', tagline: 'Todo el conocimiento del proyecto, en un solo lugar.', body: 'Documentos Markdown con historial de versiones automático. Carpetas anidadas, búsqueda full-text en español, edición colaborativa, comentarios por bloque.' },
    { id: 'tracker', title: 'Tracker', tagline: 'Kanban + fases que se mueven solos.', body: 'Tareas con prioridad, asignación, fases ordenadas, locks automáticos al pasar a "en progreso". Mueve tareas con un mensaje desde Claude.' },
    { id: 'observer', title: 'Observer view', tagline: 'Tu cliente ve el avance sin reuniones.', body: 'Rol read-only para invitar al cliente. Ve fases, entregables, tareas cerradas y comentarios. Cero acceso a docs internos.' },
    { id: 'cronograma', title: 'Cronograma', tagline: 'Las fases del proyecto en una sola pantalla.', body: 'Timeline visual de todas las fases activas y queued. Drag para reordenar. Vista de proyecto que cualquier stakeholder entiende.' },
    { id: 'fathom', title: 'Fathom', tagline: 'Tus puntos de acción de Fathom se vuelven tareas.', body: 'Conecta tu Fathom. Los action items de cada llamada llegan al kanban del proyecto correcto con un click. Sin copy-paste.' },
    { id: 'codigo', title: 'Agente de código', tagline: 'Asignas la tarea. El agente la entrega.', body: 'Conecta tu VPS desde la UI. Cada tarea técnica se puede mandar a Claude Code, que corre en tu servidor y entrega el cambio con un commit.' },
  ];

  function FeaturesPage() {
    return (
      <_Shell>
        <div style={{
          fontFamily: UI_FONT, fontWeight: 700, fontSize: 12,
          letterSpacing: '1.6px', textTransform: 'uppercase',
          color: C.accent, marginBottom: 18,
        }}>adentro</div>
        <h1 style={{
          fontFamily: HEAD_FONT, fontWeight: 800,
          fontSize: 'clamp(40px, 7vw, 80px)',
          lineHeight: 1.02, letterSpacing: '-0.03em',
          color: C.t0, margin: '0 0 18px',
        }}>El workspace.</h1>
        <p style={{
          fontFamily: UI_FONT, fontSize: 'clamp(16px, 2vw, 18px)',
          lineHeight: 1.6, color: C.t1,
          margin: '0 0 56px', maxWidth: 720,
        }}>
          Seis módulos pensados para que Claude pueda operar tu negocio entero desde claude.ai. Cada uno con su propia superficie y su propio rol.
        </p>
        <div style={{
          display: 'grid',
          gridTemplateColumns: 'repeat(auto-fit, minmax(280px, 1fr))',
          gap: 18,
        }}>
          {FEATURES.map((f) => (
            <div key={f.id} style={{
              padding: 'clamp(20px, 3vw, 28px)',
              background: C.bgCard, border: `1px solid ${C.border}`,
              borderRadius: 16,
            }}>
              <div style={{ fontFamily: HEAD_FONT, fontWeight: 700, fontSize: 24, color: C.t0, letterSpacing: '-0.02em', marginBottom: 6 }}>{f.title}</div>
              <div style={{ fontFamily: UI_FONT, fontStyle: 'italic', fontSize: 14, color: C.accent, marginBottom: 12 }}>{f.tagline}</div>
              <div style={{ fontFamily: UI_FONT, fontSize: 14, color: C.t1, lineHeight: 1.6 }}>{f.body}</div>
            </div>
          ))}
        </div>
        <_FinalCTA />
      </_Shell>
    );
  }

  // ── /superpoderes ─────────────────────────────────────────────────────
  // Agrupados por categoría con naming claro. Cada grupo es una capability
  // que Claude desbloquea cuando lo conectas vía MCP.
  // Cada superpoder tiene:
  //   - title: verbo accionable (lo que CLAUDE HACE, no el módulo abstracto)
  //   - desc: una línea concreta
  //   - prompts: 3-4 ejemplos REALES de lo que el visitor diría a Claude
  //   - reply: 2-4 líneas de cómo "responde" Claude para el terminal demo
  //   - icon: SVG inline (clean, sin depender de lucide)
  //   - count: cantidad real de tools MCP subyacentes
  // Naming literal tipo "superpoder" — nombres cortos de poder, NO
  // descripciones. La descripción va abajo del título. Español neutro
  // (NUNCA argentinismos: armá/cerrá/mostrame/mandame están prohibidos).
  const SUPERPODERES = [
    {
      key: 'projects',
      title: 'Materialización',
      desc: 'Le dices qué quieres lanzar. Claude arma fases, tareas, prioridades y asignaciones.',
      count: 14,
      icon: (
        <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round">
          <rect x="3" y="3" width="6" height="18" rx="1.2"/>
          <rect x="10.5" y="3" width="6" height="12" rx="1.2"/>
          <rect x="18" y="3" width="3.5" height="8" rx="1"/>
        </svg>
      ),
      demoPrompt: 'Crea un proyecto para lanzar mi curso en 4 semanas',
      demoReply: [
        'Proyecto creado: "Curso Q4 2026"',
        '4 fases con orden lógico de dependencias',
        '18 tareas asignadas con prioridades',
        'Doc inicial: "Plan de lanzamiento.md"',
      ],
      prompts: [
        'Crea un proyecto para lanzar mi curso en 4 semanas',
        'Muéstrame todas las tareas urgentes que vencen esta semana',
        'Cierra la fase de diseño y mueve las pendientes a desarrollo',
        'Sube esta tarea a prioridad alta y reasígnala a Sofía',
      ],
    },
    {
      key: 'vault',
      title: 'Memoria perpetua',
      desc: 'Markdown con historial. Claude escribe, lee, busca y mantiene viva la documentación de tu equipo.',
      count: 11,
      icon: (
        <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round">
          <path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20V3H6.5A2.5 2.5 0 0 0 4 5.5z"/>
          <path d="M4 19.5A2.5 2.5 0 0 0 6.5 22H20"/>
          <path d="M9 7h7M9 11h7"/>
        </svg>
      ),
      demoPrompt: 'Documenta lo que decidimos en esta sesión',
      demoReply: [
        'Doc creado en /sesiones/2026-05-16.md',
        'Estructura: contexto · decisiones · next steps',
        'Indexado en búsqueda full-text',
        'Versión 1 guardada en historial',
      ],
      prompts: [
        'Documenta lo que decidimos en esta sesión',
        'Resume todos los specs del proyecto en una página',
        'Restaura la versión de ayer del README',
        'Busca la última doc de pricing y mándamela',
      ],
    },
    {
      key: 'bitacora',
      title: 'Visión continua',
      desc: 'Bitácora continua del proyecto. Resúmenes ejecutivos en segundos.',
      count: 7,
      icon: (
        <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round">
          <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
          <polyline points="14 2 14 8 20 8"/>
          <line x1="8" y1="13" x2="16" y2="13"/>
          <line x1="8" y1="17" x2="13" y2="17"/>
        </svg>
      ),
      demoPrompt: 'Dame un resumen ejecutivo del mes para mi reporte',
      demoReply: [
        '23 entradas analizadas en 4 proyectos',
        'Top moves: 3 deals cerrados · $14k cobrado',
        'Blockers detectados: 2 (en fase Diseño)',
        'Resumen pegado en /reportes/mayo-2026.md',
      ],
      prompts: [
        '¿Qué pasó esta semana en el proyecto Marketing?',
        'Registra: hoy cerré 3 deals con clientes nuevos',
        'Dame un resumen ejecutivo del mes para mi reporte',
      ],
    },
    {
      key: 'pagos',
      title: 'Cobranza automática',
      desc: 'Hitos de cobro vinculados a entregables reales. Claude detecta cuándo facturar.',
      count: 5,
      icon: (
        <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round">
          <rect x="2" y="6" width="20" height="13" rx="2"/>
          <path d="M2 10h20"/>
          <path d="M7 15h3"/>
        </svg>
      ),
      demoPrompt: 'Crea un hito de $5,000 USD al cerrar la fase 2',
      demoReply: [
        'Hito vinculado a fase: "Desarrollo MVP"',
        'Trigger: al cerrar 100% de tareas de la fase',
        'Cliente notificado por email automáticamente',
        'Aparece en /negocio/pagos como pendiente',
      ],
      prompts: [
        'Crea un hito de $5,000 USD al cerrar la fase 2',
        '¿Qué entregables tengo cobrables este mes?',
        'Marca este pago como cobrado',
      ],
    },
    {
      key: 'code',
      title: 'Ejecución remota',
      desc: 'Claude escribe y ejecuta código real en tu servidor. Tú das la orden; el código aparece corriendo.',
      count: 9,
      icon: (
        <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round">
          <polyline points="4 17 10 11 4 5"/>
          <line x1="12" y1="19" x2="20" y2="19"/>
        </svg>
      ),
      demoPrompt: 'Refactoriza el módulo de auth en mi servidor',
      demoReply: [
        'Sesión iniciada en vps-prod (uptime 14d)',
        'Branch: refactor/auth-2026-05',
        'Logs en vivo en el workspace',
        'Lock automático mientras corre',
      ],
      prompts: [
        'Refactoriza el módulo de auth en mi servidor',
        'Muéstrame los logs de la sesión activa',
        'Manda este cambio a la sesión que tengo abierta',
      ],
    },
    {
      key: 'team',
      title: 'Mando quirúrgico',
      desc: 'Roles exactos por miembro. Observers para clientes. Claude reporta toda la actividad.',
      count: 6,
      icon: (
        <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round">
          <path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/>
          <circle cx="8.5" cy="7" r="4"/>
          <path d="M22 21v-2a4 4 0 0 0-3-3.87"/>
          <path d="M16 3.13a4 4 0 0 1 0 7.75"/>
        </svg>
      ),
      demoPrompt: 'Invita a Sofía como Editor al proyecto Marketing',
      demoReply: [
        'Invitación enviada a sofia@team.com',
        'Rol: Editor (tareas + docs, no billing)',
        'Scope: solo proyecto "Marketing 2026"',
        'Notificación pendiente en su email',
      ],
      prompts: [
        'Invita a Sofía como Editor al proyecto Marketing',
        'Quítale acceso a esta persona del workspace',
        'Dame la actividad del equipo de esta semana',
      ],
    },
  ];

  // ── Terminal demo (auto-rotating) ──────────────────────────────────
  // Muestra UN ejemplo a la vez, ciclando entre los 6 superpoderes. Cada
  // ciclo: typewriter del prompt → reveal escalonado de las 4 líneas de
  // respuesta → pausa → siguiente. El visitor puede tocar las flechas
  // para avanzar manualmente sin esperar.
  function _TerminalDemo() {
    const [idx, setIdx] = useState(0);
    const [phase, setPhase] = useState('typing'); // 'typing' | 'replying' | 'done'
    const [typed, setTyped] = useState(0);
    const cur = SUPERPODERES[idx];
    const fullPrompt = cur.demoPrompt;

    // Type writer del prompt
    useEffect(() => {
      setTyped(0);
      setPhase('typing');
      let i = 0;
      const t = setInterval(() => {
        i += 1;
        setTyped(i);
        if (i >= fullPrompt.length) {
          clearInterval(t);
          // Pausa breve antes de mostrar la respuesta
          setTimeout(() => setPhase('replying'), 320);
        }
      }, 24);
      return () => clearInterval(t);
    }, [idx, fullPrompt]);

    // Reply reveal escalonado, luego "done", luego auto-advance
    useEffect(() => {
      if (phase !== 'replying') return;
      const totalRevealMs = cur.demoReply.length * 380 + 400;
      const tDone = setTimeout(() => setPhase('done'), totalRevealMs);
      return () => clearTimeout(tDone);
    }, [phase, idx, cur.demoReply.length]);

    // Auto-advance al siguiente cuando el ciclo termina
    useEffect(() => {
      if (phase !== 'done') return;
      const t = setTimeout(() => setIdx((i) => (i + 1) % SUPERPODERES.length), 3200);
      return () => clearTimeout(t);
    }, [phase]);

    const goPrev = () => { setIdx((i) => (i - 1 + SUPERPODERES.length) % SUPERPODERES.length); };
    const goNext = () => { setIdx((i) => (i + 1) % SUPERPODERES.length); };

    return (
      <div style={{
        position: 'relative',
        background: C.bgTerminal,
        border: `1px solid ${C.border}`,
        borderRadius: 18,
        padding: 'clamp(20px, 3vw, 32px) clamp(22px, 3.5vw, 36px)',
        marginBottom: 'clamp(40px, 6vw, 64px)',
        boxShadow: `0 30px 80px -30px ${C.accentGlow}, inset 0 1px 0 rgba(255,255,255,.03)`,
        overflow: 'hidden',
      }}>
        {/* glow naranja sutil de fondo */}
        <div aria-hidden style={{
          position: 'absolute', inset: 0, pointerEvents: 'none',
          background: 'radial-gradient(ellipse at 20% 0%, rgba(249,115,22,0.10), transparent 50%)',
          opacity: 0.7,
        }} />

        {/* Topbar del terminal */}
        <div style={{
          position: 'relative', zIndex: 1,
          display: 'flex', alignItems: 'center', gap: 10,
          paddingBottom: 18, borderBottom: `1px solid ${C.border}`,
          marginBottom: 18,
        }}>
          <div style={{ display: 'flex', gap: 5 }}>
            <span style={{ width: 10, height: 10, borderRadius: '50%', background: '#3a3f4d' }} />
            <span style={{ width: 10, height: 10, borderRadius: '50%', background: '#3a3f4d' }} />
            <span style={{ width: 10, height: 10, borderRadius: '50%', background: '#3a3f4d' }} />
          </div>
          <span style={{
            fontFamily: MONO_FONT, fontSize: 12, color: C.t2,
            letterSpacing: 0.5, marginLeft: 6,
          }}>
            workspace › claude · {cur.key}
          </span>
          <div style={{ flex: 1 }} />
          <span style={{
            display: 'inline-flex', alignItems: 'center', gap: 6,
            fontFamily: MONO_FONT, fontSize: 11, color: 'rgba(16,185,129,0.85)',
            letterSpacing: 0.5,
          }}>
            <span style={{
              width: 6, height: 6, borderRadius: '50%',
              background: C.success,
              animation: 'sp-live-pulse 1.4s ease-in-out infinite',
            }} />
            LIVE
          </span>
        </div>

        {/* Línea de prompt */}
        <div style={{ position: 'relative', zIndex: 1, fontFamily: MONO_FONT, fontSize: 'clamp(14px, 1.8vw, 17px)', lineHeight: 1.55, color: C.t0, minHeight: 28 }}>
          <span style={{ color: C.accent, marginRight: 10 }}>$</span>
          {fullPrompt.slice(0, typed)}
          {phase === 'typing' && (
            <span style={{
              display: 'inline-block', width: '0.55ch', marginLeft: 2,
              color: C.accent,
              animation: 'sp-caret 0.85s steps(1) infinite',
            }}>▍</span>
          )}
        </div>

        {/* Reply lines */}
        <div style={{
          position: 'relative', zIndex: 1,
          marginTop: 18,
          display: 'flex', flexDirection: 'column', gap: 8,
          minHeight: cur.demoReply.length * 28,
        }}>
          {cur.demoReply.map((line, i) => (
            <div
              key={`${idx}-${i}`}
              style={{
                opacity: phase === 'typing' ? 0 : 1,
                transform: phase === 'typing' ? 'translateY(4px)' : 'translateY(0)',
                transition: 'opacity .35s ease, transform .35s ease',
                transitionDelay: phase !== 'typing' ? `${i * 0.38}s` : '0s',
                display: 'flex', alignItems: 'flex-start', gap: 12,
                fontFamily: MONO_FONT, fontSize: 'clamp(13px, 1.55vw, 15px)',
                color: C.t1, lineHeight: 1.55,
              }}
            >
              <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke={C.success} strokeWidth="3" strokeLinecap="round" strokeLinejoin="round" style={{ flexShrink: 0, marginTop: 4 }}>
                <polyline points="20 6 9 17 4 12"/>
              </svg>
              <span>{line}</span>
            </div>
          ))}
        </div>

        {/* Controles + indicador */}
        <div style={{
          position: 'relative', zIndex: 1,
          marginTop: 24, paddingTop: 18, borderTop: `1px solid ${C.border}`,
          display: 'flex', alignItems: 'center', gap: 14,
        }}>
          <button onClick={goPrev} className="sp-arrow" aria-label="anterior">
            <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
              <polyline points="15 18 9 12 15 6"/>
            </svg>
          </button>
          <div style={{ display: 'flex', gap: 5 }}>
            {SUPERPODERES.map((_, i) => (
              <button
                key={i}
                onClick={() => setIdx(i)}
                aria-label={`Ir al ejemplo ${i + 1}`}
                style={{
                  width: i === idx ? 22 : 6,
                  height: 6,
                  borderRadius: 3,
                  background: i === idx ? C.accent : 'rgba(255,255,255,0.12)',
                  border: 'none', padding: 0, cursor: 'pointer',
                  transition: 'all .25s ease',
                }}
              />
            ))}
          </div>
          <button onClick={goNext} className="sp-arrow" aria-label="siguiente">
            <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
              <polyline points="9 18 15 12 9 6"/>
            </svg>
          </button>
          <div style={{ flex: 1 }} />
          <span style={{
            fontFamily: MONO_FONT, fontSize: 11.5, color: C.t2,
            letterSpacing: 0.5,
          }}>
            {String(idx + 1).padStart(2, '0')} / {String(SUPERPODERES.length).padStart(2, '0')}
          </span>
        </div>

        <style>{`
          @keyframes sp-live-pulse {
            0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16,185,129,.5); }
            50%      { opacity: 0.45; box-shadow: 0 0 0 6px rgba(16,185,129,0); }
          }
          @keyframes sp-caret {
            0%, 50% { opacity: 1; }
            51%, 100% { opacity: 0; }
          }
          .sp-arrow {
            display: inline-flex; align-items: center; justify-content: center;
            width: 28px; height: 28px; border-radius: 8px;
            background: rgba(255,255,255,0.04);
            border: 1px solid rgba(255,255,255,0.08);
            color: ${C.t2}; cursor: pointer;
            transition: all .15s ease;
          }
          .sp-arrow:hover {
            color: ${C.t0};
            background: rgba(255,255,255,0.08);
            border-color: rgba(255,255,255,0.16);
          }
        `}</style>
      </div>
    );
  }

  // ── Card individual del grid de superpoderes ─────────────────────────
  // Click para expandir/colapsar. Solo una abierta a la vez (controla
  // SuperpoderesPage). Cuando está abierta, glow naranja sutil + reveal
  // de los prompts en formato terminal.
  function _SuperCard({ data, isOpen, onToggle }) {
    return (
      <div
        onClick={onToggle}
        style={{
          padding: 'clamp(22px, 3vw, 28px)',
          background: C.bgCard,
          border: `1px solid ${isOpen ? C.borderActive : C.border}`,
          borderRadius: 16,
          cursor: 'pointer',
          transition: 'border-color .2s ease, transform .15s ease, box-shadow .25s ease',
          boxShadow: isOpen
            ? `0 24px 60px -24px ${C.accentGlow}, inset 0 1px 0 rgba(255,255,255,.04)`
            : '0 1px 0 rgba(255,255,255,.02)',
          transform: isOpen ? 'translateY(-2px)' : 'translateY(0)',
        }}
      >
        <div style={{ display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 14, marginBottom: 12 }}>
          <span style={{
            width: 40, height: 40, borderRadius: 10,
            background: C.accentSoft, color: C.accent,
            display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
            flexShrink: 0,
          }}>
            {data.icon}
          </span>
          <span style={{
            fontFamily: MONO_FONT, fontSize: 11,
            color: C.t3, letterSpacing: 1, marginTop: 6,
          }}>
            {String(data.count).padStart(2, '0')} CMD
          </span>
        </div>
        <div style={{
          fontFamily: HEAD_FONT, fontWeight: 700, fontSize: 'clamp(18px, 2.2vw, 22px)',
          color: C.t0, letterSpacing: '-0.012em', marginBottom: 8, lineHeight: 1.25,
        }}>
          {data.title}
        </div>
        <div style={{
          fontFamily: UI_FONT, fontSize: 14, color: C.t2,
          lineHeight: 1.55, marginBottom: isOpen ? 18 : 0,
        }}>
          {data.desc}
        </div>

        {/* Prompts expandidos */}
        <div style={{
          maxHeight: isOpen ? 600 : 0,
          opacity: isOpen ? 1 : 0,
          overflow: 'hidden',
          transition: 'max-height .35s ease, opacity .25s ease',
        }}>
          <div style={{
            paddingTop: 14, borderTop: `1px solid ${C.border}`,
            display: 'flex', flexDirection: 'column', gap: 8,
          }}>
            <div style={{
              fontFamily: MONO_FONT, fontSize: 11, color: C.t3,
              letterSpacing: 1, textTransform: 'uppercase', marginBottom: 4,
            }}>
              Ejemplos
            </div>
            {data.prompts.map((p, i) => (
              <div key={i} style={{
                fontFamily: MONO_FONT, fontSize: 13, lineHeight: 1.5,
                color: C.t1,
                padding: '8px 12px', borderRadius: 8,
                background: 'rgba(255,255,255,0.02)',
                border: '1px solid rgba(255,255,255,0.04)',
                display: 'flex', alignItems: 'flex-start', gap: 8,
              }}>
                <span style={{ color: C.accent, flexShrink: 0 }}>$</span>
                <span>{p}</span>
              </div>
            ))}
          </div>
        </div>

        {/* Toggle indicator */}
        <div style={{
          marginTop: isOpen ? 14 : 12,
          fontFamily: MONO_FONT, fontSize: 11, color: C.t3,
          letterSpacing: 0.8, textTransform: 'uppercase',
          display: 'inline-flex', alignItems: 'center', gap: 6,
        }}>
          <span style={{
            display: 'inline-block', width: 8, height: 8,
            borderTop: `2px solid ${C.t3}`, borderRight: `2px solid ${C.t3}`,
            transform: isOpen ? 'rotate(-45deg)' : 'rotate(135deg)',
            transition: 'transform .25s ease',
          }} />
          {isOpen ? 'Cerrar ejemplos' : 'Ver ejemplos'}
        </div>
      </div>
    );
  }

  function SuperpoderesPage() {
    const [openKey, setOpenKey] = useState(SUPERPODERES[0].key);
    const totalCmds = SUPERPODERES.reduce((a, s) => a + s.count, 0);
    return (
      <_Shell headerCta="Aplicar">
        {/* System tag superior — mismo lenguaje que [ EL SISTEMA OPERATIVO ] del hero */}
        <div style={{
          fontFamily: MONO_FONT, fontWeight: 600,
          fontSize: 'clamp(13px, 1.5vw, 16px)',
          letterSpacing: '0.06em',
          color: 'rgba(249,115,22,0.85)',
          marginBottom: 'clamp(18px, 2.5vw, 26px)',
        }}>
          [ {totalCmds} SUPERPODERES · {SUPERPODERES.length} CATEGORÍAS ]
        </div>

        <h1 style={{
          fontFamily: HEAD_FONT, fontWeight: 800,
          fontSize: 'clamp(38px, 6vw, 72px)',
          lineHeight: 1.05, letterSpacing: '-0.03em',
          color: C.t0, margin: '0 0 22px',
        }}>
          Claude no solo conversa.<br/>
          <span style={{ color: C.accent }}>Opera tu workspace.</span>
        </h1>

        <p style={{
          fontFamily: UI_FONT, fontSize: 'clamp(16px, 2vw, 19px)',
          lineHeight: 1.55, color: C.t1,
          margin: '0 0 clamp(36px, 5vw, 56px)', maxWidth: 720,
        }}>
          Cada superpoder es una acción que Claude ejecuta dentro de tu workspace sin que tú abras la app. Lo conectas una vez, le dices qué quieres, y aparece hecho.
        </p>

        {/* Terminal demo auto-rotando los 6 ejemplos */}
        <_TerminalDemo />

        {/* Section header del grid */}
        <div style={{
          display: 'flex', alignItems: 'baseline', justifyContent: 'space-between',
          marginBottom: 18, flexWrap: 'wrap', gap: 12,
        }}>
          <div style={{
            fontFamily: HEAD_FONT, fontWeight: 700,
            fontSize: 'clamp(22px, 3vw, 30px)',
            color: C.t0, letterSpacing: '-0.02em',
          }}>
            Todas las capacidades
          </div>
          <div style={{
            fontFamily: MONO_FONT, fontSize: 12, color: C.t3,
            letterSpacing: 0.8, textTransform: 'uppercase',
          }}>
            tap para ver ejemplos
          </div>
        </div>

        {/* Grid de superpoderes — solo una card abierta a la vez */}
        <div style={{
          display: 'grid',
          gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))',
          gap: 16,
          alignItems: 'start',
        }}>
          {SUPERPODERES.map((s) => (
            <_SuperCard
              key={s.key}
              data={s}
              isOpen={openKey === s.key}
              onToggle={() => setOpenKey((k) => k === s.key ? null : s.key)}
            />
          ))}
        </div>

        <_FinalCTA label="Quiero darle superpoderes a Claude" />
      </_Shell>
    );
  }

  // ── /videos ───────────────────────────────────────────────────────────
  function VideosPage() {
    const wistiaUrl = (id) => `https://fast.wistia.net/embed/iframe/${id}?seo=false&videoFoam=true`;
    return (
      <_Shell>
        <div style={{ fontFamily: UI_FONT, fontWeight: 700, fontSize: 12, letterSpacing: '1.6px', textTransform: 'uppercase', color: C.accent, marginBottom: 18 }}>casos reales</div>
        <h1 style={{ fontFamily: HEAD_FONT, fontWeight: 800, fontSize: 'clamp(36px, 6vw, 72px)', lineHeight: 1.05, letterSpacing: '-0.03em', color: C.t0, margin: '0 0 48px' }}>
          Workspace AI en acción.
        </h1>
        <section style={{ marginBottom: 56 }}>
          <h2 style={{ fontFamily: HEAD_FONT, fontWeight: 700, fontSize: 'clamp(22px, 3vw, 30px)', letterSpacing: '-0.02em', color: C.t0, margin: '0 0 18px' }}>
            Cómo facturé $2,200 USD en 9 días delegando todo en mi workspace.
          </h2>
          <div style={{ position: 'relative', paddingTop: '56.25%', borderRadius: 16, overflow: 'hidden', background: C.bgCard, border: `1px solid ${C.border}` }}>
            <iframe
              src={wistiaUrl('7j0riygyvq')}
              title="Workspace para todos"
              allow="autoplay; fullscreen"
              allowFullScreen
              style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', border: 0 }}
            />
          </div>
        </section>
        <section>
          <h2 style={{ fontFamily: HEAD_FONT, fontWeight: 700, fontSize: 'clamp(22px, 3vw, 30px)', letterSpacing: '-0.02em', color: C.t0, margin: '0 0 8px' }}>
            Workspace para developers.
          </h2>
          <p style={{ fontFamily: UI_FONT, fontSize: 14, color: C.t2, lineHeight: 1.55, margin: '0 0 18px', maxWidth: 720 }}>
            Ejemplo delegando a Claude Code el desarrollo de un agente IA para un cliente real de $2,200 USD. Claude revisa las tareas y deja comentarios en el workspace.
          </p>
          <div style={{ position: 'relative', paddingTop: '56.25%', borderRadius: 16, overflow: 'hidden', background: C.bgCard, border: `1px solid ${C.border}` }}>
            <iframe
              src={wistiaUrl('zqc53iwnla')}
              title="Workspace para developers"
              allow="autoplay; fullscreen"
              allowFullScreen
              style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', border: 0 }}
            />
          </div>
        </section>
        <_FinalCTA />
      </_Shell>
    );
  }

  // ── /precios ──────────────────────────────────────────────────────────
  function PreciosPage() {
    const INCLUYE = [
      'Workspace personalizado por IA en tu primer minuto',
      '60 superpoderes de Claude conectado',
      'Sesiones de Claude Code en tu VPS',
      'Tareas, documentos, fases y proyectos ilimitados',
      'Observer view para tu cliente',
      'Integración con Fathom para action items',
    ];
    return (
      <_Shell>
        <div style={{ fontFamily: UI_FONT, fontWeight: 700, fontSize: 12, letterSpacing: '1.6px', textTransform: 'uppercase', color: C.accent, marginBottom: 18 }}>precios</div>
        <h1 style={{ fontFamily: HEAD_FONT, fontWeight: 800, fontSize: 'clamp(40px, 6vw, 76px)', lineHeight: 1.02, letterSpacing: '-0.03em', color: C.t0, margin: '0 0 18px' }}>
          Un solo plan.<br/><span style={{ color: C.accent }}>Todo incluido.</span>
        </h1>
        <p style={{ fontFamily: UI_FONT, fontSize: 'clamp(16px, 2vw, 19px)', lineHeight: 1.6, color: C.t1, margin: '0 0 40px', maxWidth: 720 }}>
          Cobramos solo a operadores aceptados. El precio te llega en el email de aceptación. Cancelas cuando quieras escribiendo a soporte.
        </p>
        <div style={{
          padding: 'clamp(24px, 3.5vw, 36px)',
          background: C.bgCard, border: `1px solid ${C.border}`,
          borderRadius: 18, maxWidth: 720, marginBottom: 32,
        }}>
          <div style={{ fontFamily: UI_FONT, fontWeight: 700, fontSize: 12, letterSpacing: 1.6, textTransform: 'uppercase', color: C.accent, marginBottom: 10 }}>¿Qué incluye?</div>
          <ul style={{ listStyle: 'none', padding: 0, margin: 0, display: 'flex', flexDirection: 'column', gap: 12 }}>
            {INCLUYE.map((item, i) => (
              <li key={i} style={{ display: 'flex', alignItems: 'flex-start', gap: 12, fontFamily: UI_FONT, fontSize: 15, lineHeight: 1.55, color: C.t1 }}>
                <span style={{ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', width: 22, height: 22, borderRadius: 6, background: C.accentSoft, color: C.accent, flexShrink: 0, marginTop: 1 }}>
                  <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
                </span>
                <span>{item}</span>
              </li>
            ))}
          </ul>
        </div>
        <_FinalCTA label="Aplicar para conocer el precio" />
      </_Shell>
    );
  }

  window.FeaturesPage = FeaturesPage;
  window.SuperpoderesPage = SuperpoderesPage;
  window.VideosPage = VideosPage;
  window.PreciosPage = PreciosPage;
})();
