// ─── Bolivia Joven — Página "Únete" (Funnel de Conversión) ───────────────────
const { useRef } = React;
const {
  Navbar, Footer, useReveal,
  UsersIcon, GraduationIcon, BookOpenIcon, AwardIcon, CoinsIcon, CheckCircleIcon,
  InfoIcon, RocketIcon, BellIcon, ClockIcon, ChevronDownIcon, ArrowRightIcon, SparklesIcon,
} = window;

const ACC = {
  red:   { solid:'var(--red)',   bg:'rgba(162,0,50,0.13)',  brd:'rgba(162,0,50,0.28)' },
  gold:  { solid:'var(--gold)',  bg:'rgba(233,211,108,0.1)', brd:'rgba(233,211,108,0.24)' },
  green: { solid:'var(--green)', bg:'rgba(31,113,67,0.14)',  brd:'rgba(31,113,67,0.3)' },
};

const scrollTo = (id) => (e) => { e.preventDefault(); document.querySelector(id)?.scrollIntoView({behavior:'smooth'}); };

// ═══════════════════════════════════════════════════════════════════
// 1 · HERO EMOCIONAL
// ═══════════════════════════════════════════════════════════════════
const JoinHero = () => (
  <section id="top" style={{position:'relative',display:'flex',alignItems:'center',justifyContent:'center',overflow:'hidden',background:'#0e0e0e',padding:'170px 24px 110px',minHeight:'92vh'}}>
    <div style={{position:'absolute',inset:0,overflow:'hidden'}}>
      <div style={{position:'absolute',width:'66vw',height:'66vw',top:'-22%',left:'-14%',background:'radial-gradient(circle, rgba(162,0,50,0.4) 0%, transparent 62%)',animation:'blob1 9s ease-in-out infinite'}}/>
      <div style={{position:'absolute',width:'52vw',height:'52vw',bottom:'-16%',right:'-10%',background:'radial-gradient(circle, rgba(233,211,108,0.14) 0%, transparent 62%)',animation:'blob2 11s ease-in-out infinite'}}/>
      <div style={{position:'absolute',width:580,height:580,right:-120,top:'50%',marginTop:-290,border:'1px solid rgba(162,0,50,0.12)',transform:'rotate(45deg)',animation:'floatGeo 8s ease-in-out infinite'}}/>
      <div style={{position:'absolute',width:380,height:380,right:-30,top:'50%',marginTop:-190,border:'1px solid rgba(233,211,108,0.06)',transform:'rotate(45deg)',animation:'floatGeo 8s ease-in-out infinite 1s'}}/>
      <div style={{position:'absolute',inset:0,backgroundImage:'linear-gradient(rgba(255,255,255,0.02) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,0.02) 1px,transparent 1px)',backgroundSize:'80px 80px'}}/>
      <div style={{position:'absolute',inset:0,background:'linear-gradient(180deg,rgba(10,10,10,0.3) 0%,rgba(10,10,10,0.55) 58%,rgba(20,20,20,0.96) 100%)'}}/>
    </div>
    <div style={{position:'relative',zIndex:2,textAlign:'center',maxWidth:960,margin:'0 auto'}}>
      <h1 className="font-anton hero-t2" style={{fontSize:'clamp(2rem,6.5vw,5rem)',lineHeight:0.98,letterSpacing:'0.01em',textTransform:'uppercase',color:'#fff',marginBottom:30}}>
        El futuro de Bolivia no se espera,<br/><span style={{color:'var(--gold)'}}>se construye.</span> ¿Estás listo?
      </h1>
      <p className="hero-t3" style={{fontSize:'clamp(1rem,2.4vw,1.2rem)',color:'rgba(255,255,255,0.72)',lineHeight:1.75,maxWidth:680,margin:'0 auto 44px'}}>
        No somos una organización más; somos la red de jóvenes líderes más ambiciosa del país. Buscamos personas dispuestas a dejar una huella imborrable. Las convocatorias abren por temporadas limitadas — descubre por qué deberías ser el próximo en ingresar.
      </p>
      <div className="hero-t4">
        <a href="#beneficios" onClick={scrollTo('#beneficios')} className="btn-primary" style={{fontSize:15,padding:'15px 36px'}}>
          Ver Beneficios y Requisitos <ChevronDownIcon size={17}/>
        </a>
      </div>
    </div>
  </section>
);

// ═══════════════════════════════════════════════════════════════════
// 2 · BENEFICIOS
// ═══════════════════════════════════════════════════════════════════
const BENEFITS = [
  { icon:UsersIcon,     accent:'red',   title:'Una Comunidad Imparable',
    text:'Una red de jóvenes bolivianos que comparten tu mismo sentimiento y urgencia de hacer de Bolivia un lugar mejor.' },
  { icon:GraduationIcon,accent:'gold',  title:'Voluntariados y Capacitación',
    text:'Participa tanto en voluntariados que te nutren el alma, como en seminarios y charlas exclusivas dictadas por expertos de diversas industrias.' },
  { icon:BookOpenIcon,  accent:'green', title:'Acceso Total a Clubes',
    text:'Entrada libre a los "Clubes Bolivia Joven": espacios dinámicos donde debatirás y aprenderás de emprendedurismo, literatura, cine y habilidades blandas.' },
  { icon:AwardIcon,     accent:'red',   title:'Reconocimiento y Meritocracia',
    text:'Valoramos el esfuerzo real. Participa por premios y distinciones anuales diseñadas para los miembros más activos e impactantes de la organización.' },
];

const Benefits = () => {
  const ref = useRef(null);
  useReveal(ref);
  return (
    <section id="beneficios" ref={ref} className="section-base" style={{background:'var(--bg)',borderTop:'1px solid var(--border)'}}>
      <div className="section-inner">
        <div style={{textAlign:'center',maxWidth:640,margin:'0 auto 56px'}}>
          <div className="reveal" style={{display:'flex',justifyContent:'center',marginBottom:12}}><div className="gold-line"/></div>
          <h2 className="reveal reveal-d1 font-anton" style={{fontSize:'clamp(1.9rem,4.5vw,3.2rem)',textTransform:'uppercase',color:'#fff',lineHeight:1.08}}>
            Lo que significa ser parte<br/>de <span style={{color:'var(--gold)'}}>nuestra red</span>
          </h2>
        </div>
        <div style={{display:'grid',gridTemplateColumns:'repeat(auto-fit,minmax(300px,1fr))',gap:24}}>
          {BENEFITS.map((b,i)=>{
            const a = ACC[b.accent];
            return (
              <div key={b.title} className={`benefit reveal reveal-d${(i%2)+1}`} data-accent={b.accent}>
                <span className="benefit-num">0{i+1}</span>
                <div style={{width:58,height:58,borderRadius:14,background:a.bg,border:`1px solid ${a.brd}`,display:'flex',alignItems:'center',justifyContent:'center',marginBottom:24}}>
                  <b.icon size={27} style={{color:a.solid}}/>
                </div>
                <h3 className="font-anton" style={{fontSize:'1.5rem',letterSpacing:'0.02em',color:'#fff',marginBottom:14,textTransform:'uppercase',lineHeight:1.12}}>{b.title}</h3>
                <p style={{fontSize:'0.95rem',lineHeight:1.8,color:'rgba(255,255,255,0.62)'}}>{b.text}</p>
              </div>
            );
          })}
        </div>
      </div>
    </section>
  );
};

// ═══════════════════════════════════════════════════════════════════
// 3 · TRANSPARENCIA — APORTE MENSUAL
// ═══════════════════════════════════════════════════════════════════
const Transparency = () => {
  const ref = useRef(null);
  useReveal(ref);
  return (
    <section ref={ref} className="section-base" style={{background:'var(--bg2)',borderTop:'1px solid var(--border)',borderBottom:'1px solid var(--border)'}}>
      <div className="section-inner">
        {/* Header */}
        <div style={{maxWidth:640,marginBottom:44}}>
          <div className="reveal gold-line"/>
          <h2 className="reveal reveal-d1 font-anton" style={{fontSize:'clamp(1.8rem,4.5vw,3rem)',textTransform:'uppercase',color:'#fff',lineHeight:1.1,marginBottom:16}}>
            Liderazgo con <span style={{color:'var(--gold)'}}>corresponsabilidad</span>
          </h2>
          <p className="reveal reveal-d2" style={{fontSize:'0.98rem',lineHeight:1.7,color:'rgba(255,255,255,0.6)'}}>
            Una vez aceptados, tanto los <strong style={{color:'#fff',fontWeight:600}}>miembros</strong> como los <strong style={{color:'#fff',fontWeight:600}}>directores</strong> realizan un aporte mensual simbólico — un compromiso compartido, transparente y en igualdad de condiciones para todos.
          </p>
        </div>
        {/* Content: stacks on mobile, side-by-side on wider screens */}
        <div style={{display:'grid',gridTemplateColumns:'repeat(auto-fit,minmax(min(100%,260px),1fr))',gap:24,alignItems:'stretch'}}>
          {/* Price card */}
          <div className="reveal reveal-d1" style={{borderRadius:18,padding:'clamp(24px,5vw,36px) clamp(20px,4vw,32px)',textAlign:'center',background:'linear-gradient(150deg,rgba(233,211,108,0.14) 0%,rgba(28,28,28,0.6) 70%)',border:'1px solid rgba(233,211,108,0.3)',boxSizing:'border-box'}}>
            <div style={{width:48,height:48,borderRadius:12,background:'rgba(233,211,108,0.16)',border:'1px solid rgba(233,211,108,0.35)',display:'flex',alignItems:'center',justifyContent:'center',margin:'0 auto 18px',flexShrink:0}}>
              <CoinsIcon size={22} style={{color:'var(--gold)'}}/>
            </div>
            <div style={{fontSize:10,letterSpacing:'0.12em',textTransform:'uppercase',color:'rgba(255,255,255,0.5)',marginBottom:8}}>Aporte mensual</div>
            <div style={{display:'flex',alignItems:'baseline',justifyContent:'center',gap:5,marginBottom:4}}>
              <span className="font-anton" style={{fontSize:'clamp(3rem,8vw,3.8rem)',color:'#fff',lineHeight:1}}>30</span>
              <span className="font-anton" style={{fontSize:'clamp(1.1rem,3vw,1.4rem)',color:'var(--gold)'}}>Bs.</span>
            </div>
            <div style={{fontSize:'0.8rem',color:'rgba(255,255,255,0.45)'}}>por miembro y director</div>
          </div>
          {/* Info note */}
          <div className="reveal reveal-d2" style={{display:'flex',alignItems:'flex-start',gap:14,background:'rgba(31,113,67,0.1)',border:'1px solid rgba(31,113,67,0.25)',borderRadius:14,padding:'22px 24px',boxSizing:'border-box'}}>
            <div style={{width:38,height:38,borderRadius:10,background:'rgba(31,113,67,0.16)',border:'1px solid rgba(31,113,67,0.3)',display:'flex',alignItems:'center',justifyContent:'center',flexShrink:0,marginTop:2}}>
              <InfoIcon size={18} style={{color:'var(--green)'}}/>
            </div>
            <div>
              <h3 style={{fontSize:'0.95rem',fontWeight:700,color:'var(--green)',marginBottom:6,fontFamily:"'Poppins',sans-serif"}}>¿Para qué sirve este aporte?</h3>
              <p style={{fontSize:'0.88rem',lineHeight:1.7,color:'rgba(255,255,255,0.68)'}}>
                Es el <strong style={{color:'var(--gold)',fontWeight:600}}>motor</strong> que nos permite financiar proyectos con mayor frecuencia, autogestión y un alcance masivo en todo el país.
              </p>
            </div>
          </div>
        </div>
      </div>
    </section>
  );
};

// ═══════════════════════════════════════════════════════════════════
// 4 · REQUISITOS
// ═══════════════════════════════════════════════════════════════════
const Requirements = () => {
  const ref = useRef(null);
  useReveal(ref);
  const reqs = [
    { accent:'red',   title:'Mayoría de edad', text:'Es obligatorio ser mayor de 18 años para postular a la membresía nacional.' },
    { accent:'gold',  title:'CV actualizado',  text:'Prepara tu currículum al día; será parte de tu proceso de postulación.' },
    { accent:'green', title:'Tu propuesta de valor', text:'Ten claro cómo planeas aportar valor, talento o ideas a la asociación.' },
  ];
  return (
    <section id="requisitos" ref={ref} className="section-base" style={{background:'var(--bg)'}}>
      <div className="section-inner">
        <div style={{maxWidth:640,marginBottom:44}}>
          <div className="reveal gold-line"/>
          <h2 className="reveal reveal-d1 font-anton" style={{fontSize:'clamp(1.8rem,4.5vw,3rem)',textTransform:'uppercase',color:'#fff',lineHeight:1.1,marginBottom:16}}>
            ¿Cumples los <span style={{color:'var(--gold)'}}>requisitos</span>?
          </h2>
          <p className="reveal reveal-d2" style={{fontSize:'0.98rem',lineHeight:1.7,color:'rgba(255,255,255,0.6)'}}>
            Tres criterios simples antes de dar el paso. Si los cumples, estás a un clic de empezar.
          </p>
        </div>
        <div style={{display:'grid',gridTemplateColumns:'repeat(auto-fit,minmax(260px,1fr))',gap:18,marginBottom:24}}>
          {reqs.map((r,i)=>{
            const a = ACC[r.accent];
            return (
              <div key={r.title} className={`req reveal reveal-d${i+1}`}>
                <div style={{width:44,height:44,borderRadius:11,background:a.bg,border:`1px solid ${a.brd}`,display:'flex',alignItems:'center',justifyContent:'center',flexShrink:0}}>
                  <CheckCircleIcon size={21} style={{color:a.solid}}/>
                </div>
                <div>
                  <h3 style={{fontSize:'1.05rem',fontWeight:700,color:'#fff',marginBottom:6,fontFamily:"'Poppins',sans-serif"}}>{r.title}</h3>
                  <p style={{fontSize:'0.88rem',lineHeight:1.65,color:'rgba(255,255,255,0.58)'}}>{r.text}</p>
                </div>
              </div>
            );
          })}
        </div>
        {/* Age redirect note */}
        <div className="reveal reveal-d3" style={{display:'flex',alignItems:'flex-start',gap:16,background:'linear-gradient(120deg, rgba(233,211,108,0.1), rgba(28,28,28,0.4))',border:'1px solid rgba(233,211,108,0.28)',borderRadius:14,padding:'22px 26px'}}>
          <div style={{width:42,height:42,borderRadius:11,background:'rgba(233,211,108,0.16)',border:'1px solid rgba(233,211,108,0.32)',display:'flex',alignItems:'center',justifyContent:'center',flexShrink:0}}>
            <GraduationIcon size={20} style={{color:'var(--gold)'}}/>
          </div>
          <div>
            <h3 style={{fontSize:'1rem',fontWeight:700,color:'var(--gold)',marginBottom:6,fontFamily:"'Poppins',sans-serif"}}>¿Eres menor de 18? No te quedas fuera.</h3>
            <p style={{fontSize:'0.9rem',lineHeight:1.7,color:'rgba(255,255,255,0.68)'}}>
              Los menores de edad tienen un espacio hecho a su medida: nuestra división especial <strong style={{color:'#fff',fontWeight:600}}>"Redes Estudiantiles"</strong>, donde el liderazgo joven comienza a forjarse desde el colegio.
            </p>
          </div>
        </div>
      </div>
    </section>
  );
};

// ═══════════════════════════════════════════════════════════════════
// 5 · CONVOCATORIA (estado abierto/cerrado)
// ═══════════════════════════════════════════════════════════════════
// ── TOGGLE THIS to open/close the convocatoria ──────────────────────
const CONVOCATORIA_ABIERTA = false;
// ────────────────────────────────────────────────────────────────────

const Convocatoria = () => {
  const ref = useRef(null);
  useReveal(ref);
  const isOpen = CONVOCATORIA_ABIERTA;

  return (
    <section id="convocatoria" ref={ref} style={{position:'relative',overflow:'hidden'}}>
      <div style={{position:'absolute',inset:0,background:'#0e0e0e'}}>
        <div style={{position:'absolute',inset:0,background:'linear-gradient(135deg, rgba(162,0,50,0.92) 0%, rgba(125,6,38,0.85) 45%, rgba(20,20,20,0.2) 80%)'}}/>
        <div style={{position:'absolute',top:'-28%',right:'-10%',width:'52vw',height:'52vw',background:'radial-gradient(circle, rgba(233,211,108,0.16) 0%, transparent 62%)'}}/>
        <div style={{position:'absolute',inset:0,backgroundImage:'repeating-linear-gradient(-52deg,transparent,transparent 40px,rgba(255,255,255,0.02) 40px,rgba(255,255,255,0.02) 41px)'}}/>
        <div style={{position:'absolute',right:-90,bottom:-90,width:420,height:420,border:'1px solid rgba(233,211,108,0.1)',transform:'rotate(45deg)'}}/>
        <div style={{position:'absolute',inset:0,background:'linear-gradient(180deg,transparent 0%,rgba(10,10,10,0.45) 100%)'}}/>
      </div>

      <div className="section-base" style={{position:'relative',zIndex:2}}>
        <div className="section-inner" style={{maxWidth:760,margin:'0 auto',textAlign:'center'}}>
          {/* Status badge */}
          <div className="reveal" style={{display:'inline-flex',alignItems:'center',gap:9,marginBottom:26,padding:'8px 18px',borderRadius:30,
            background: isOpen?'rgba(31,113,67,0.9)':'rgba(0,0,0,0.5)',
            border:`1px solid ${isOpen?'rgba(255,255,255,0.4)':'rgba(255,255,255,0.2)'}`}}>
            <span style={{width:9,height:9,borderRadius:'50%',background:isOpen?'#fff':'rgba(255,255,255,0.5)',boxShadow:isOpen?'0 0 10px #fff':'none'}}/>
            <span style={{fontSize:12,fontWeight:700,letterSpacing:'0.12em',textTransform:'uppercase',color:'#fff'}}>
              {isOpen ? 'Convocatoria Abierta' : 'Convocatoria Cerrada'}
            </span>
          </div>

          <h2 className="reveal reveal-d1 font-anton" style={{fontSize:'clamp(2.2rem,6vw,4.2rem)',textTransform:'uppercase',color:'#fff',lineHeight:1.0,marginBottom:22,textShadow:'0 4px 40px rgba(0,0,0,0.5)'}}>
            {isOpen ? <>Tu momento es <span style={{color:'var(--gold)'}}>ahora</span></> : <>Vuelve <span style={{color:'var(--gold)'}}>pronto</span></>}
          </h2>
          <p className="reveal reveal-d2" style={{fontSize:'1.1rem',color:'rgba(255,255,255,0.82)',lineHeight:1.75,maxWidth:540,margin:'0 auto 44px'}}>
            {isOpen
              ? 'La postulación se realiza vía Google Forms. Necesitarás tu propuesta de valor y tu CV actualizado. El proceso toma menos de 10 minutos.'
              : 'Las inscripciones están cerradas por ahora. Déjanos tu correo y serás el primero en enterarte cuando abramos la próxima temporada.'}
          </p>

          {/* Dynamic action */}
          {isOpen ? (
            <a href="#" target="_blank" rel="noopener noreferrer"
              className="reveal reveal-d3 apply-pulse"
              style={{display:'inline-flex',alignItems:'center',gap:12,background:'var(--gold)',color:'#141414',fontWeight:700,fontSize:'1.15rem',letterSpacing:'0.02em',padding:'20px 48px',borderRadius:12,textDecoration:'none',transition:'transform 0.3s ease, background 0.3s ease'}}
              onMouseEnter={e=>{e.currentTarget.style.background='#f5e07a';e.currentTarget.style.transform='translateY(-3px) scale(1.02)';}}
              onMouseLeave={e=>{e.currentTarget.style.background='var(--gold)';e.currentTarget.style.transform='translateY(0) scale(1)';}}>
              <RocketIcon size={22}/> Aplicar Ahora vía Google Forms
            </a>
          ) : (
            <a href="https://forms.google.com/REEMPLAZAR_URL" target="_blank" rel="noopener noreferrer"
              className="reveal reveal-d3"
              style={{display:'inline-flex',alignItems:'center',gap:12,background:'var(--gold)',color:'#141414',fontWeight:700,fontSize:'1.15rem',letterSpacing:'0.02em',padding:'20px 48px',borderRadius:12,textDecoration:'none',transition:'transform 0.3s ease, background 0.3s ease'}}
              onMouseEnter={e=>{e.currentTarget.style.background='#f5e07a';e.currentTarget.style.transform='translateY(-3px) scale(1.02)';}}
              onMouseLeave={e=>{e.currentTarget.style.background='var(--gold)';e.currentTarget.style.transform='translateY(0) scale(1)';}}>
              <ArrowRightIcon size={22}/> Registrar mi interés
            </a>
          )}

          {/* Secondary info */}
          <div className="reveal reveal-d4" style={{display:'flex',alignItems:'center',justifyContent:'center',gap:8,marginTop:32,color:'rgba(255,255,255,0.55)',fontSize:'0.85rem'}}>
            <ClockIcon size={15}/>
            <span>{isOpen ? 'Cierre de postulaciones: plazas limitadas por temporada.' : 'Próxima temporada: por anunciar.'}</span>
          </div>

        </div>
      </div>
    </section>
  );
};

// ═══════════════════════════════════════════════════════════════════
// APP
// ═══════════════════════════════════════════════════════════════════
const JoinPage = () => (
  <React.Fragment>
    <Navbar page="join" />
    <main>
      <JoinHero />
      <Benefits />
      <Transparency />
      <Requirements />
      <Convocatoria />
    </main>
    <Footer page="join" />
  </React.Fragment>
);

ReactDOM.createRoot(document.getElementById('root')).render(<JoinPage />);
