// All sections of the Balduino landing.
// Order: Nav, Hero (video), Manifesto, Features, HowItWorks, Army, Testimonials, Verse, FAQ, Footer

const { useEffect, useRef, useState } = React;

// ─── Hook: intersection-observer reveals ──────────────────────────────────
function useReveal() {
  useEffect(() => {
    const els = document.querySelectorAll('.reveal');
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {if (e.isIntersecting) e.target.classList.add('in');});
    }, { threshold: 0.12, rootMargin: '0px 0px -40px 0px' });
    els.forEach((el) => io.observe(el));
    return () => io.disconnect();
  });
}

// ─── Hook: subtle parallax via scrollY ────────────────────────────────────
function useScrollY() {
  const [y, setY] = useState(0);
  useEffect(() => {
    let raf = 0;
    const onScroll = () => {
      cancelAnimationFrame(raf);
      raf = requestAnimationFrame(() => setY(window.scrollY));
    };
    onScroll();
    window.addEventListener('scroll', onScroll, { passive: true });
    return () => window.removeEventListener('scroll', onScroll);
  }, []);
  return y;
}

// ───────────────────────────────────────────────────────────────────────────
// NAV
// ───────────────────────────────────────────────────────────────────────────
function Nav() {
  const [scrolled, setScrolled] = useState(false);
  useEffect(() => {
    const on = () => setScrolled(window.scrollY > 24);
    on();
    window.addEventListener('scroll', on, { passive: true });
    return () => window.removeEventListener('scroll', on);
  }, []);

  return (
    <header style={{
      position: 'fixed', top: 0, left: 0, right: 0, zIndex: 50,
      transition: 'background .3s ease, border-color .3s ease, backdrop-filter .3s ease',
      background: scrolled ? 'rgba(7,11,20,.72)' : 'transparent',
      backdropFilter: scrolled ? 'blur(14px) saturate(140%)' : 'none',
      borderBottom: `1px solid ${scrolled ? 'rgba(255,255,255,.06)' : 'transparent'}`
    }}>
      <div className="wrap" style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '18px 32px' }}>
        <Lockup accent="var(--accent)" />
        <nav style={{ display: 'flex', gap: 32, alignItems: 'center' }}>
          <a href="#features" style={navLink}>El sistema</a>
          <a href="#ejercito" style={navLink}>Ejército</a>
          <a href="#faq" style={navLink}>Preguntas</a>
          <a className="btn btn-primary" style={{ padding: '10px 18px', fontSize: 13 }} href="#descarga">
            Descargar
          </a>
        </nav>
      </div>
    </header>);

}
const navLink = { fontSize: 13.5, color: 'var(--cloud)', fontWeight: 500, letterSpacing: '-.005em' };

// ───────────────────────────────────────────────────────────────────────────
// HERO — full-bleed video with text overlay
// ───────────────────────────────────────────────────────────────────────────
function Hero() {
  const videoRef = useRef(null);
  const y = useScrollY();

  useEffect(() => {
    // Force-mute. React doesn't always set `muted` correctly on initial render,
    // so we set it imperatively on the DOM node and pin volume to 0.
    const v = videoRef.current;
    if (v) {
      v.muted = true;
      v.defaultMuted = true;
      v.volume = 0;
      v.play().catch(() => {});
      // Re-assert if anything tries to unmute later.
      const reMute = () => {v.muted = true;v.volume = 0;};
      v.addEventListener('volumechange', reMute);
      return () => v.removeEventListener('volumechange', reMute);
    }
  }, []);

  return (
    <section style={{
      position: 'relative',
      minHeight: '100svh',
      width: '100%',
      overflow: 'hidden',
      display: 'flex',
      alignItems: 'flex-end',
      paddingBottom: 80
    }}>
      {/* Video background */}
      <div style={{
        position: 'absolute',
        inset: 0,
        zIndex: 0,
        transform: `translateY(${y * 0.15}px) scale(${1 + y * 0.0002})`,
        transformOrigin: 'center'
      }}>
        <video
          ref={videoRef}
          src="assets/balduino-hero.mp4"
          autoPlay
          loop
          muted
          playsInline
          preload="auto"
          style={{
            position: 'absolute',
            inset: 0,
            width: '100%',
            height: '100%',
            objectFit: 'cover',
            objectPosition: 'center'
          }} />
        
      </div>

      {/* Cinematic gradient overlays for legibility */}
      <div style={{
        position: 'absolute', inset: 0, zIndex: 1, pointerEvents: 'none',
        background:
        'linear-gradient(180deg, rgba(7,11,20,.55) 0%, rgba(7,11,20,.15) 30%, rgba(7,11,20,.55) 70%, rgba(7,11,20,1) 100%)'
      }} />
      <div style={{
        position: 'absolute', inset: 0, zIndex: 1, pointerEvents: 'none',
        background: 'linear-gradient(90deg, rgba(7,11,20,.7) 0%, rgba(7,11,20,.25) 45%, transparent 70%)'
      }} />

      {/* Vignette */}
      <div style={{
        position: 'absolute', inset: 0, zIndex: 1, pointerEvents: 'none',
        boxShadow: 'inset 0 0 240px 40px rgba(0,0,0,.6)'
      }} />

      {/* Content */}
      <div className="wrap" style={{ position: 'relative', zIndex: 2, width: '100%' }}>
        <div style={{ maxWidth: 720 }}>
          <h1 className="reveal d1 h-hero" style={{ textShadow: '0 2px 30px rgba(0,0,0,.6)' }}>
            Recupera tu atención.<br />
            <span className="display accent-up">
              Vuelve a Dios.
            </span>
          </h1>

          <p className="reveal d2 lead" style={{ marginTop: 26, maxWidth: 560, textShadow: '0 2px 20px rgba(0,0,0,.5)' }}>Balduino bloquea las apps que roban tu día, obliga a parar y orar a tus horas, y convierte cada sesión de enfoque en un templario para tu ejército.



          </p>

          <div className="reveal d3" style={{ marginTop: 36, display: 'flex', gap: 18, alignItems: 'center', flexWrap: 'wrap' }}>
            <StoreBadges />
            <a href="#manifesto" className="btn btn-ghost" style={{ background: 'rgba(7,11,20,.4)', backdropFilter: 'blur(8px)' }}>
              Por qué Balduino
            </a>
          </div>

          <div className="reveal d4" style={{ marginTop: 42, display: 'flex', gap: 26, alignItems: 'center' }}>
            <Stars />
            <div style={{ fontSize: 13, color: 'var(--cloud)' }}>
              <b style={{ color: 'var(--mist)' }}>4.8</b> · 2.300+ caballeros activos
            </div>
          </div>
        </div>
      </div>

      {/* Scroll indicator */}
      <div className="reveal d5" style={{
        position: 'absolute', bottom: 28, left: '50%', transform: 'translateX(-50%)',
        zIndex: 2, display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 8
      }}>
        <span style={{ fontSize: 10, letterSpacing: '.22em', textTransform: 'uppercase', color: 'var(--muted)' }}>
          Continúa
        </span>
        <span style={{
          width: 1, height: 36,
          background: 'linear-gradient(180deg, var(--muted), transparent)',
          animation: 'heroScrollPulse 2.4s ease-in-out infinite'
        }} />
      </div>

      <style>{`
        @keyframes heroScrollPulse {
          0%, 100% { opacity: .3; transform: scaleY(.6); transform-origin: top; }
          50% { opacity: 1; transform: scaleY(1); transform-origin: top; }
        }
      `}</style>
    </section>);

}

function Arrow() {
  return (
    <svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <path d="M3 8h10M9 4l4 4-4 4" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" />
    </svg>);

}
function Stars() {
  return (
    <div style={{ display: 'flex', gap: 3 }}>
      {Array.from({ length: 5 }).map((_, i) =>
      <svg key={i} width="14" height="14" viewBox="0 0 16 16" aria-hidden="true">
          <path d="M8 1.5l1.95 3.94 4.35.63-3.15 3.07.74 4.32L8 11.42 4.11 13.46l.74-4.32L1.7 6.07l4.35-.63L8 1.5z"
        fill="var(--gold)" />
        </svg>
      )}
    </div>);

}

// ───────────────────────────────────────────────────────────────────────────
// MANIFESTO
// ───────────────────────────────────────────────────────────────────────────
function ManifestoPhoneVideo() {
  const ref = useRef(null);
  const [ready, setReady] = useState(false);

  useEffect(() => {
    const v = ref.current;
    if (!v) return;
    v.muted = true;
    v.defaultMuted = true;
    v.volume = 0;
    const onReady = () => setReady(true);
    if (v.readyState >= 3) onReady();
    v.addEventListener('canplay', onReady);
    v.addEventListener('playing', onReady);
    v.play().catch(() => {});
    return () => {
      v.removeEventListener('canplay', onReady);
      v.removeEventListener('playing', onReady);
    };
  }, []);

  return (
    <video
      ref={ref}
      src="assets/manifesto-phone.mp4"
      autoPlay
      loop
      muted
      playsInline
      preload="auto"
      style={{
        position: 'absolute',
        inset: 0,
        width: '100%',
        height: '100%',
        objectFit: 'contain',
        mixBlendMode: 'lighten',
        opacity: ready ? 1 : 0,
        transform: ready ? 'translateY(0) scale(1)' : 'translateY(14px) scale(0.985)',
        transition: 'opacity .9s ease, transform 1.1s cubic-bezier(.2,.7,.2,1)'
      }} />);

}

function Manifesto() {
  return (
    <section id="manifesto" style={{
      padding: '70px 0 60px',
      position: 'relative',
      background: '#000',
      // Cover the page-level background gradient layers so the phone video's
      // black frame blends in seamlessly.
      zIndex: 1
    }}>
      <div className="wrap-narrow" style={{ textAlign: 'center' }}>
        <div className="reveal eyebrow gold"></div>
        <h2 className="reveal d1 h-section display" style={{ marginTop: 18 }}>
          El diablo no quiere que ores.<br />
          <span style={{ color: 'var(--muted)' }}>Quiere que sigas haciendo scroll.</span>
        </h2>

        {/* Phone video. Black background blends into the page via mix-blend-mode: lighten
                           so the device floats free of any rectangle. Fades in on first playable frame
                           so the user never sees a black placeholder. */}
        <div className="reveal d2" style={{
          marginTop: 24,
          marginLeft: 'auto',
          marginRight: 'auto',
          maxWidth: 'min(380px, 80vw)',
          aspectRatio: '9 / 16',
          position: 'relative',
          pointerEvents: 'none'
        }}>
          <ManifestoPhoneVideo />
        </div>

        <p className="reveal d2 lead" style={{ marginTop: 28 }}>Cada día despiertas con un plan: estudiar, trabajo, familia, Cristo, ganar dinero. A las dos horas ya estás en un reel de gente que no conoces. El día se evaporó. te sientes culpable de no haber hecho nada y "mañana empiezo en serio".



        </p>
        <p className="reveal d3 lead" style={{ marginTop: 18 }}>


        </p>
      </div>
    </section>);

}

// ───────────────────────────────────────────────────────────────────────────
// FEATURES
// ───────────────────────────────────────────────────────────────────────────
const FEATURES = [
{
  icon: <IconShield />,
  title: 'Bloqueador de distracciones',
  body: 'Instagram, TikTok, X, lo que sea. Cuando estás en sesión o en hora de oración, la app no abre. Punto.'
},
{
  icon: <IconTimer />,
  title: 'Sesiones de enfoque',
  body: 'Pomodoros que dan minutos de foco y desbloquean personajes. El tiempo deja de evaporarse.'
},
{
  icon: <IconChurch />,
  title: 'Horarios de oración',
  body: 'Configuras tus horas. A esa hora todo se bloquea hasta que oras. Cero excusas, oración generada.'
},
{
  icon: <IconSword />,
  title: 'Ejército de templarios',
  body: '58 personajes en cuatro rangos. Cada sesión gana puntos, cada punto te acerca a una pieza nueva.'
},
{
  icon: <IconBook />,
  title: 'Biblia + planes de lectura',
  body: 'Versión integrada con planes para leerla entera. Sin notificaciones absurdas. Sin gamificación falsa.'
},
{
  icon: <IconFlame />,
  title: 'Rachas que no perdonan',
  body: 'Un día sin oración se ve. Un mes sin romper la racha también. Disciplina visible.'
}];


function Features() {
  return (
    <section id="features" style={{ padding: '70px 0 80px', position: 'relative' }}>
      <div className="wrap">
        <div style={{ maxWidth: 720 }}>
          <div className="reveal eyebrow">El sistema</div>
          <h2 className="reveal d1 h-section" style={{ marginTop: 16 }}>
            Seis herramientas. <span className="display accent-up">Una sola guerra.</span>
          </h2>
          <p className="reveal d2 lead" style={{ marginTop: 22, maxWidth: 600 }}>
            Balduino no es un bloqueador. No es una app de oración. Es la pieza que faltaba entre las dos.
          </p>
        </div>

        <div style={{
          marginTop: 60,
          display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 20
        }}>
          {FEATURES.map((f, i) =>
          <div key={i} className={`reveal d${i % 3 + 1} card`} style={{ padding: 28 }}>
              <div style={{
              width: 44, height: 44, borderRadius: 12,
              background: 'linear-gradient(180deg, rgba(255,90,54,.18), rgba(255,90,54,.05))',
              border: '1px solid rgba(255,90,54,.25)',
              display: 'flex', alignItems: 'center', justifyContent: 'center',
              color: 'var(--accent)'
            }}>{f.icon}</div>
              <h3 className="h-feature" style={{ marginTop: 22 }}>{f.title}</h3>
              <p className="body" style={{ marginTop: 10, fontSize: 14.5 }}>{f.body}</p>
            </div>
          )}
        </div>
      </div>
    </section>);

}

// Inline icons (geometric, no emoji)
function IconShield() {
  return <svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M12 3l8 3v6c0 5-3.5 8.5-8 9-4.5-.5-8-4-8-9V6l8-3z" stroke="currentColor" strokeWidth="1.7" strokeLinejoin="round" /><path d="M9 12l2 2 4-4" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" /></svg>;
}
function IconTimer() {
  return <svg width="20" height="20" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="13" r="8" stroke="currentColor" strokeWidth="1.7" /><path d="M12 9v4l3 2M9 3h6" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" /></svg>;
}
function IconChurch() {
  return <svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M12 3v4M10 5h4M5 21V11l7-4 7 4v10M5 21h14M10 21v-5h4v5" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" /></svg>;
}
function IconSword() {
  return <svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M14.5 3h6v6M20 4l-9 9M4 16l4 4M6 14l4 4M3 21l4-1 7-7-3-3-7 7-1 4z" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" /></svg>;
}
function IconBook() {
  return <svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4 5a2 2 0 012-2h12v18H6a2 2 0 01-2-2V5z" stroke="currentColor" strokeWidth="1.7" strokeLinejoin="round" /><path d="M4 19a2 2 0 012-2h12M11 7v6M9 10h4" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" /></svg>;
}
function IconFlame() {
  return <svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M12 3c1 4 5 5 5 9a5 5 0 11-10 0c0-2 1-3 2-4 0 1 1 2 2 2 0-3 0-5 1-7z" stroke="currentColor" strokeWidth="1.7" strokeLinejoin="round" /></svg>;
}

// ───────────────────────────────────────────────────────────────────────────
// HOW IT WORKS
// ───────────────────────────────────────────────────────────────────────────
function HowItWorks() {
  const steps = [
  { n: 'I', t: 'Elige tus horas', d: 'Configuras cuándo oras o trabajas y qué apps quieres que se bloqueen durante las sesiones.' },
  { n: 'II', t: 'Empieza una sesión', d: 'El temporizador arranca. Si abres cualquier app distractora, la pantalla te devuelve a Balduino.' },
  { n: 'III', t: 'Ora cuando suena', d: 'A la hora seleccionada todo se bloquea. Aparece la oración. Cuando terminas, tocas “Ya he orado” y se desbloquean las apps.' },
  { n: 'IV', t: 'Gana tu ejército', d: 'Cada sesión completada otorga puntos. Desbloqueas templarios y construye tus Ejércitos.' }];

  return (
    <section style={{ padding: '70px 0', position: 'relative' }}>
      <div className="wrap">
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline', flexWrap: 'wrap', gap: 20 }}>
          <div>
            <div className="reveal eyebrow gold"></div>
            <h2 className="reveal d1 h-section" style={{ marginTop: 16 }}>
              Cuatro pasos <span className="display accent-up">PARA ACERCARTE A DIOS</span>
            </h2>
          </div>
        </div>

        <div style={{ marginTop: 50, display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 32 }}>
          {steps.map((s, i) =>
          <div key={i} className={`reveal d${i + 1}`} style={{ background: 'transparent', padding: '8px 4px 0', minHeight: 220, display: 'flex', flexDirection: 'column' }}>
              <span className="display" style={{ fontSize: 28, color: 'var(--gold)', letterSpacing: '.08em' }}>{s.n}</span>
              <div style={{ marginTop: 'auto' }}>
                <h3 className="h-feature">{s.t}</h3>
                <p className="body" style={{ marginTop: 10, fontSize: 14.5 }}>{s.d}</p>
              </div>
            </div>
          )}
        </div>
      </div>
    </section>);

}

// ───────────────────────────────────────────────────────────────────────────
// ARMY OF TEMPLARS — visual showcase of one 4x4 terrain
// ───────────────────────────────────────────────────────────────────────────
const TIERS = {
  basico: { color: '#5A6068', label: 'Básico', glow: 'rgba(90,96,104,.4)' },
  normal: { color: '#1F7548', label: 'Normal', glow: 'rgba(31,117,72,.5)' },
  raro: { color: '#3D1C7A', label: 'Raro', glow: 'rgba(61,28,122,.55)' },
  legendario: { color: '#C8A25A', label: 'Legendario', glow: 'rgba(200,162,90,.65)' }
};

const GRID = [
{ img: 'assets/chars/escudo-card.jpg', tier: 'basico', name: 'Caballero Viejo' },
{ img: 'assets/chars/bandera-card.jpg', tier: 'normal', name: 'Portaestandarte' },
{ img: 'assets/chars/jinete-card.jpg', tier: 'raro', name: 'Jinete Cruzado' },
{ img: 'assets/chars/combate-card.jpg', tier: 'legendario', name: 'Comendador' },
{ img: 'assets/chars/monje-card.jpg', tier: 'basico', name: 'Monje Penitente' },
{ img: 'assets/chars/sabio-card.jpg', tier: 'normal', name: 'Guerrero Sabio' },
{ img: 'assets/chars/reverencia-card.jpg', tier: 'raro', name: 'Caballero Orante' },
{ img: 'assets/chars/heroico-card.jpg', tier: 'legendario', name: 'Héroe Templario' }];


function ArmyShowcase() {
  return (
    <section id="ejercito" style={{ padding: '70px 0', position: 'relative' }}>
      <div className="wrap">
        <div style={{ display: 'grid', gridTemplateColumns: '.9fr 1.1fr', gap: 80, alignItems: 'center' }}>
          <div>
            <div className="reveal eyebrow"></div>
            <h2 className="reveal d1 h-section" style={{ marginTop: 16 }}>
              Cada sesión gana <span className="display accent-up">un templario</span> para tu ejército.
            </h2>
            <p className="reveal d2 lead" style={{ marginTop: 22 }}>
              58 personajes en cuatro rangos: Básico, Normal, Raro y Legendario.
            </p>
            <p className="reveal d3 lead" style={{ marginTop: 18 }}>
              Es una recompensa visible para algo invisible: un día más
              en el que ganaste, en lugar de perderlo haciendo scroll.
            </p>

            <div className="reveal d4" style={{ marginTop: 36, display: 'flex', gap: 20, flexWrap: 'wrap' }}>
              {Object.entries(TIERS).map(([k, v]) =>
              <div key={k} style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
                  <span style={{ width: 12, height: 12, borderRadius: 3, background: v.color, transform: 'rotate(45deg)', boxShadow: `0 0 10px ${v.glow}` }} />
                  <span style={{ fontSize: 13, color: 'var(--cloud)', letterSpacing: '.04em' }}>{v.label}</span>
                </div>
              )}
            </div>
          </div>

          <div className="reveal d2" style={{ position: 'relative' }}>
            <div style={{
              position: 'relative',
              padding: 22,
              borderRadius: 22,
              background:
              'radial-gradient(circle at 30% 20%, rgba(200,162,90,.08), transparent 60%),' +
              'linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.01))',
              border: '1px solid var(--stroke-strong)',
              boxShadow: '0 30px 80px -30px rgba(0,0,0,.7)'
            }}>
              <div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 12 }}>
                {GRID.map((c, i) => <TemplarCard key={i} char={c} idx={i} />)}
              </div>
              <div style={{ marginTop: 18, display: 'flex', justifyContent: 'space-between', alignItems: 'center', borderTop: '1px solid var(--stroke)', paddingTop: 14 }}>
                <div style={{ fontSize: 10, letterSpacing: '.22em', textTransform: 'uppercase', color: 'var(--muted)' }}></div>
                <div style={{ fontSize: 11, color: 'var(--gold)', fontWeight: 600 }}></div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>);

}

function TemplarCard({ char, idx }) {
  const t = TIERS[char.tier];
  return (
    <div style={{
      aspectRatio: '942 / 1234',
      borderRadius: 12,
      border: `1px solid ${char.tier === 'legendario' ? 'rgba(232,200,120,.55)' : 'rgba(255,255,255,.10)'}`,
      boxShadow: char.tier === 'legendario' ?
      `0 0 30px -5px ${t.glow}, 0 8px 24px -10px rgba(0,0,0,.5)` :
      `0 0 18px -8px ${t.glow}, 0 6px 18px -10px rgba(0,0,0,.45)`,
      position: 'relative',
      overflow: 'hidden',
      background: '#0d1018'
    }}>
      <img
        src={char.img}
        alt={char.name}
        loading="lazy"
        style={{
          position: 'absolute',
          inset: 0,
          width: '100%',
          height: '100%',
          objectFit: 'cover',
          objectPosition: 'center',
          display: 'block',
          transform: char.fit ? `scale(${char.fit})` : 'none',
          transformOrigin: 'center'
        }} />
      {/* Bottom gradient + label */}
      <div style={{
        position: 'absolute', left: 0, right: 0, bottom: 0,
        padding: '18px 8px 6px',
        background: 'linear-gradient(180deg, transparent, rgba(0,0,0,.75))',
        fontSize: 9,
        letterSpacing: '.08em',
        textTransform: 'uppercase',
        color: 'var(--mist)',
        textAlign: 'center',
        fontWeight: 600,
        whiteSpace: 'nowrap',
        overflow: 'hidden',
        textOverflow: 'ellipsis'
      }}>{char.name}</div>
    </div>);

}

// ───────────────────────────────────────────────────────────────────────────
// TESTIMONIALS
// ───────────────────────────────────────────────────────────────────────────
const TESTIMONIALS = [
{
  quote: 'Llevo 41 días sin abrir Instagram y, sinceramente, no lo extraño. Pensé que iba a aguantar dos semanas máximo.',
  name: 'Mateo R.', meta: 'Buenos Aires · Caballero'
},
{
  quote: 'Tengo 27 y nunca había orado en serio. El bloqueo te obliga a parar dos minutos y resulta que con eso alcanza. Me cambió el día.',
  name: 'Joaquín T.', meta: 'CDMX · Escudero'
},
{
  quote: 'Pensé que lo de los muñequitos iba a ser una boludez y me terminó enganchando. Cuando saqué el primer legendario casi grito en la oficina jaja.',
  name: 'Andrés V.', meta: 'Bogotá · Comendador'
},
{
  quote: 'En tres semanas recuperé las mañanas. Leí más Biblia este mes que en todo el año pasado, y no estoy exagerando.',
  name: 'Lucía P.', meta: 'Madrid · Escudera'
},
{
  quote: 'Soy programador, vivo pegado al cel. El bloqueador me devolvió como 3 horas al día. No es chiste.',
  name: 'Felipe R.', meta: 'Lima · Caballero'
},
{
  quote: 'Lo bueno es que no te manda una notificación más para que ores; directamente bloquea todo hasta que lo hacés. Suena heavy pero funciona.',
  name: 'Tomás L.', meta: 'Santiago · Comendador'
},
{
  quote: 'No me volvió perfecto. Me volvió alguien que al menos lo intenta todos los días. Y eso ya es muchísimo más de lo que tenía antes.',
  name: 'Sebastián O.', meta: 'Quito · Caballero'
},
{
  quote: 'Le instalé la app a mi viejo de 60. Ahora me manda capturas de los templarios que desbloquea. Está más enganchado que yo.',
  name: 'Martín V.', meta: 'Asunción · Escudero'
}];


function TestimonialCard({ t }) {
  return (
    <figure className="card" style={{
      padding: 28, margin: 0,
      display: 'flex', flexDirection: 'column',
      width: 360, minWidth: 360, flexShrink: 0
    }}>
      <Stars />
      <blockquote style={{
        margin: '18px 0 0', fontSize: 16, lineHeight: 1.55,
        fontFamily: 'var(--font-body)', fontWeight: 400, color: 'var(--mist)'
      }}>
        “{t.quote}”
      </blockquote>
      <figcaption style={{ marginTop: 'auto', paddingTop: 22, display: 'flex', alignItems: 'center', gap: 12 }}>
        <div style={{
          width: 36, height: 36, borderRadius: '50%',
          background: 'linear-gradient(135deg, var(--templar-mid), var(--templar-night))',
          border: '1px solid var(--stroke-strong)',
          display: 'flex', alignItems: 'center', justifyContent: 'center',
          color: 'var(--gold)', fontSize: 12, fontWeight: 700, letterSpacing: '.04em'
        }}>{t.name.slice(0, 1)}</div>
        <div style={{ fontSize: 13 }}>
          <div style={{ color: 'var(--mist)', fontWeight: 600 }}>{t.name}</div>
          <div style={{ color: 'var(--muted)', fontSize: 12 }}>{t.meta}</div>
        </div>
      </figcaption>
    </figure>);

}

function Testimonials() {
  // Duplicate the list so the marquee can loop seamlessly
  const loop = [...TESTIMONIALS, ...TESTIMONIALS];
  return (
    <section style={{ padding: '70px 0', overflow: 'hidden' }}>
      <div className="wrap">
        <div className="reveal eyebrow gold" style={{ textAlign: 'center' }}></div>
        <h2 className="reveal d1 h-section" style={{ marginTop: 16, textAlign: 'center' }}>
          No es teoría.<br />
          <span style={{ color: 'var(--muted)' }}>Es lo que están haciendo.</span>
        </h2>
      </div>

      <div className="reveal d2 marquee" style={{ marginTop: 60 }}>
        <div className="marquee-track">
          {loop.map((t, i) => <TestimonialCard key={i} t={t} />)}
        </div>
      </div>
    </section>);

}

// ───────────────────────────────────────────────────────────────────────────
// PRICING removed.
// ───────────────────────────────────────────────────────────────────────────

function PlayIcon() {
  return <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M3 2.5v19l16-9.5L3 2.5z" /></svg>;
}

// Official-style Google Play + App Store badges. White pill, brand glyph,
// two-line label. Side-by-side, tight crop.
function GooglePlayMark({ size = 30 }) {
  // Triangle with vertices TL(12,6), BL(12,104), RT(94,55).
  // Split by a horizontal axis at y=55 (left edge midpoint → right tip) and
  // a vertical axis at x=60 (from top edge P_top=(60,34.68) to bottom edge P_bot=(60,75.32)).
  // They cross at C=(60,55), creating 4 wedges:
  //   blue  = top-left quad     TL → P_top → C → (12,55) → TL
  //   yellow= top-right wedge   P_top → RT → C
  //   red   = bottom-right wedge C → RT → P_bot
  //   green = bottom-left quad   (12,55) → C → P_bot → BL
  return (
    <svg width={size} height={size * 1.10} viewBox="0 0 100 110" aria-hidden="true">
      <defs>
        <linearGradient id="gp-blue" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0" stopColor="#00D4FF" /><stop offset="1" stopColor="#0085F7" />
        </linearGradient>
        <linearGradient id="gp-green" x1="0" y1="1" x2="1" y2="0">
          <stop offset="0" stopColor="#00C167" /><stop offset="1" stopColor="#00F076" />
        </linearGradient>
        <linearGradient id="gp-yellow" x1="0" y1="0" x2="1" y2="0">
          <stop offset="0" stopColor="#FFD200" /><stop offset="1" stopColor="#FFA400" />
        </linearGradient>
        <linearGradient id="gp-red" x1="0" y1="0" x2="0" y2="1">
          <stop offset="0" stopColor="#FF3A44" /><stop offset="1" stopColor="#E5246C" />
        </linearGradient>
      </defs>
      {/* blue: top-left */}
      <path d="M12 6 L60 34.68 L60 55 L12 55 Z" fill="url(#gp-blue)" />
      {/* green: bottom-left */}
      <path d="M12 55 L60 55 L60 75.32 L12 104 Z" fill="url(#gp-green)" />
      {/* yellow: top-right wedge */}
      <path d="M60 34.68 L94 55 L60 55 Z" fill="url(#gp-yellow)" />
      {/* red: bottom-right wedge */}
      <path d="M60 55 L94 55 L60 75.32 Z" fill="url(#gp-red)" />
    </svg>);

}

function AppleMark({ size = 26 }) {
  return (
    <svg width={size} height={size * 1.18} viewBox="0 0 384 452" aria-hidden="true">
      <path fill="#0A0A0A" d="M318 240c-1-46 37-68 39-69-21-31-54-35-66-36-28-3-55 17-69 17-14 0-36-16-60-16-31 0-59 18-75 46-32 56-8 138 23 183 15 22 33 47 57 46 23-1 31-15 59-15s35 15 59 14c24 0 40-22 55-44 17-25 24-49 25-50-1 0-48-18-47-76zM272 102c12-15 21-36 19-57-18 1-40 12-53 27-11 13-22 35-19 55 21 2 42-10 53-25z" />
    </svg>);

}

function StoreBadges({ align = 'flex-start', size = 'md' }) {
  const isLg = size === 'lg';
  const height = isLg ? 56 : 48;
  return (
    <div style={{
      display: 'flex',
      columnGap: 10,
      rowGap: 8,
      alignItems: 'center',
      justifyContent: align,
      flexWrap: 'wrap'
    }}>
      <a
        href="https://play.google.com/store/apps/details?id=com.huertodefe"
        target="_blank"
        rel="noopener noreferrer"
        aria-label="Descargar en Google Play"
        style={{
          display: 'inline-flex',
          alignItems: 'center',
          borderRadius: 14,
          filter: 'drop-shadow(0 6px 14px rgba(0,0,0,.35)) drop-shadow(0 1px 2px rgba(0,0,0,.3))',
          transition: 'transform .2s ease, filter .2s ease',
          textDecoration: 'none'
        }}
        onMouseEnter={(e) => {
          e.currentTarget.style.transform = 'translateY(-2px)';
          e.currentTarget.style.filter = 'drop-shadow(0 10px 20px rgba(0,0,0,.45)) drop-shadow(0 2px 3px rgba(0,0,0,.35))';
        }}
        onMouseLeave={(e) => {
          e.currentTarget.style.transform = 'translateY(0)';
          e.currentTarget.style.filter = 'drop-shadow(0 6px 14px rgba(0,0,0,.35)) drop-shadow(0 1px 2px rgba(0,0,0,.3))';
        }}>
        
        <img
          src="assets/store-android.png"
          alt="Descargar en Google Play"
          style={{ height: height, width: 'auto', display: 'block' }} />
        
      </a>

      <a
        href="#descarga"
        aria-label="Descargar en App Store"
        style={{
          display: 'inline-flex',
          alignItems: 'center',
          borderRadius: 14,
          filter: 'drop-shadow(0 6px 14px rgba(0,0,0,.35)) drop-shadow(0 1px 2px rgba(0,0,0,.3))',
          transition: 'transform .2s ease, filter .2s ease',
          textDecoration: 'none'
        }}
        onMouseEnter={(e) => {
          e.currentTarget.style.transform = 'translateY(-2px)';
          e.currentTarget.style.filter = 'drop-shadow(0 10px 20px rgba(0,0,0,.45)) drop-shadow(0 2px 3px rgba(0,0,0,.35))';
        }}
        onMouseLeave={(e) => {
          e.currentTarget.style.transform = 'translateY(0)';
          e.currentTarget.style.filter = 'drop-shadow(0 6px 14px rgba(0,0,0,.35)) drop-shadow(0 1px 2px rgba(0,0,0,.3))';
        }}>
        
        <img
          src="assets/store-ios.png"
          alt="Descargar en App Store"
          style={{ height: height, width: 'auto', display: 'block' }} />
        
      </a>
    </div>);

}

// ───────────────────────────────────────────────────────────────────────────
// FAQ
// ───────────────────────────────────────────────────────────────────────────
const FAQS = [
{ q: '¿Necesito una cuenta?',
  a: 'No. Balduino funciona 100% en tu celular. No subimos tus datos a ninguna nube. La suscripción se gestiona con tu cuenta de Google Play.' },
{ q: '¿Es solo para católicos?',
  a: 'No. La oración generada usa textos cristianos universales (Padrenuestro, Avemaría opcional, Salmos). Hay católicos y evangélicos usándola.' },
{ q: '¿El bloqueador funciona con apps que se actualizan?',
  a: 'Sí. Usamos las APIs nativas de Android para detectar las apps en primer plano. Agregas las que quieras que se bloqueen y listo.' },
{ q: '¿Qué pasa si pierdo una hora de oración?',
  a: 'Se rompe la racha del día. No se castiga con culpa. Mañana hay otra batalla.' },
{ q: '¿Hay versión iOS?',
  a: 'Todavía no. Estamos enfocados en hacer la versión Android lo mejor posible antes de portarla. Estamos trabajando en tenerla lista lo antes posible, no te preocupes.' }];


function FAQ() {
  const [open, setOpen] = useState(0);
  return (
    <section id="faq" style={{ padding: '70px 0' }}>
      <div className="wrap-narrow">
        <div className="reveal eyebrow gold" style={{ textAlign: 'center' }}></div>
        <h2 className="reveal d1 h-section" style={{ marginTop: 16, textAlign: 'center' }}>
          Antes de descargar.
        </h2>

        <div style={{ marginTop: 60, display: 'flex', flexDirection: 'column', gap: 4 }}>
          {FAQS.map((f, i) => {
            const isOpen = open === i;
            return (
              <div key={i} className="reveal" style={{
                borderTop: '1px solid var(--stroke)',
                borderBottom: i === FAQS.length - 1 ? '1px solid var(--stroke)' : 'none'
              }}>
                <button onClick={() => setOpen(isOpen ? -1 : i)} style={{
                  width: '100%', padding: '22px 0', background: 'transparent', border: 'none',
                  color: 'var(--mist)', textAlign: 'left',
                  display: 'flex', justifyContent: 'space-between', alignItems: 'center',
                  fontSize: 17, fontWeight: 500, cursor: 'default', fontFamily: 'inherit'
                }}>
                  {f.q}
                  <span style={{
                    width: 28, height: 28, borderRadius: '50%', border: '1px solid var(--stroke-strong)',
                    display: 'flex', alignItems: 'center', justifyContent: 'center',
                    color: 'var(--cloud)', fontSize: 14,
                    transform: isOpen ? 'rotate(45deg)' : 'rotate(0deg)',
                    transition: 'transform .25s ease, border-color .25s ease',
                    borderColor: isOpen ? 'var(--accent)' : 'var(--stroke-strong)'
                  }}>+</span>
                </button>
                <div style={{
                  maxHeight: isOpen ? 200 : 0,
                  overflow: 'hidden',
                  transition: 'max-height .35s ease, opacity .35s ease',
                  opacity: isOpen ? 1 : 0
                }}>
                  <p className="body" style={{ paddingBottom: 22, paddingRight: 40, margin: 0 }}>{f.a}</p>
                </div>
              </div>);

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

}

// ───────────────────────────────────────────────────────────────────────────
// FINAL CTA + FOOTER
// ───────────────────────────────────────────────────────────────────────────
function FinalCTA() {
  return (
    <section id="descarga" style={{ padding: '80px 0 30px' }}>
      <div className="wrap-narrow" style={{ textAlign: 'center' }}>
        <h2 className="reveal h-section display accent-up" style={{ fontWeight: 600, fontSize: 'clamp(42px, 5.5vw, 75px)' }}>
          Hoy es el día,<br />
          <span style={{ color: "rgb(255, 255, 255)" }}>caballero.</span>
        </h2>
        <div className="reveal d1" style={{ marginTop: 22, display: 'flex', justifyContent: 'center' }}>
          <StoreBadges align="center" size="lg" />
        </div>
      </div>
    </section>);

}

function Footer() {
  return (
    <footer style={{ borderTop: '1px solid var(--stroke)', padding: '40px 0 50px', marginTop: 40 }}>
      <div className="wrap" style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', flexWrap: 'wrap', gap: 30 }}>
        <div>
          <Lockup accent="var(--accent)" />
          <p style={{ marginTop: 18, fontSize: 13, color: 'var(--muted)', maxWidth: 320, lineHeight: 1.6 }}>
            En honor a Balduino IV, rey templario leproso de Jerusalén — fortaleza espiritual frente a la debilidad.
          </p>
        </div>

        <div style={{ display: 'flex', gap: 60, flexWrap: 'wrap' }}>
          <div>
            <div style={{ fontSize: 11, letterSpacing: '.18em', textTransform: 'uppercase', color: 'var(--muted-deep)', marginBottom: 14 }}>App</div>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 10, fontSize: 13.5 }}>
              <a href="#features" style={{ color: 'var(--cloud)' }}>Características</a>
              <a href="#descarga" style={{ color: 'var(--cloud)' }}>Descargar</a>
              <a href="#faq" style={{ color: 'var(--cloud)' }}>Preguntas</a>
            </div>
          </div>
          <div>
            <div style={{ fontSize: 11, letterSpacing: '.18em', textTransform: 'uppercase', color: 'var(--muted-deep)', marginBottom: 14 }}>Legal</div>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 10, fontSize: 13.5 }}>
              <a href="legal/privacidad.html" style={{ color: 'var(--cloud)' }}>Privacidad</a>
              <a href="legal/terminos.html" style={{ color: 'var(--cloud)' }}>Términos</a>
              <a href="#" style={{ color: 'var(--cloud)' }}>Contacto</a>
            </div>
          </div>
        </div>
      </div>
      <div className="wrap" style={{ marginTop: 50, paddingTop: 24, borderTop: '1px solid var(--stroke)', fontSize: 12, color: 'var(--muted-deep)', display: 'flex', justifyContent: 'space-between', flexWrap: 'wrap', gap: 12 }}>
        <span>© 2026 Balduino. Soli Deo gloria.</span>
        <span>Hecho con disciplina</span>
      </div>
    </footer>);

}

Object.assign(window, {
  useReveal, useScrollY,
  Nav, Hero, Manifesto, Features, HowItWorks,
  ArmyShowcase, Testimonials, FAQ,
  FinalCTA, Footer
});