// Beside — 4-slide deck for the website

// Reusable framed phone — IOSDevice fixed at 390x844, scalable
const Phone = ({ children, dark = true, scale = 1, tilt = 0, shadow = 'normal' }) => (
  <div style={{
    width: 390 * scale, height: 844 * scale,
    transform: `scale(${scale}) rotate(${tilt}deg)`,
    transformOrigin: 'top left',
    filter: shadow === 'big'
      ? 'drop-shadow(0 40px 80px rgba(0,0,0,0.5)) drop-shadow(0 0 60px rgba(123,95,230,0.18))'
      : 'drop-shadow(0 30px 60px rgba(0,0,0,0.45))',
  }}>
    <div style={{ width: 390, height: 844 }}>
      <IOSDevice width={390} height={844} dark={dark}>{children}</IOSDevice>
    </div>
  </div>
);

// Wordmark used on every slide
const DeckMark = ({ size = 22, color = '#fff', opacity = 1 }) => (
  <div style={{
    display: 'flex', alignItems: 'center', gap: 10,
    color, opacity, fontFamily: T.font,
  }}>
    <svg width={size + 4} height={size + 4} viewBox="0 0 24 24" fill="none">
      <path d="M5 4c0-1 .8-2 2-2h4a4 4 0 014 4v0a4 4 0 01-4 4H7c-1 0-2-.8-2-2V4z" fill={color}/>
      <path d="M5 14c0-1 .8-2 2-2h10a4 4 0 014 4v2a4 4 0 01-4 4H7c-1 0-2-.8-2-2v-6z" fill={color} opacity="0.5"/>
    </svg>
    <span style={{ fontSize: size, fontWeight: 600, letterSpacing: -0.5 }}>beside</span>
  </div>
);

const Eyebrow = ({ children, color = '#9D85F2' }) => (
  <div style={{
    fontSize: 18, fontWeight: 700, letterSpacing: 4,
    color, textTransform: 'uppercase',
  }}>{children}</div>
);

const FeatureRow = ({ icon, title, desc }) => (
  <div style={{ display: 'flex', gap: 18, alignItems: 'flex-start' }}>
    <div style={{
      width: 48, height: 48, borderRadius: 14, flexShrink: 0,
      background: 'rgba(123,95,230,0.16)', color: '#9D85F2',
      display: 'flex', alignItems: 'center', justifyContent: 'center',
      border: '1px solid rgba(123,95,230,0.3)',
    }}>{icon}</div>
    <div>
      <div style={{ fontSize: 22, fontWeight: 600, color: '#fff', letterSpacing: -0.3 }}>{title}</div>
      <div style={{ fontSize: 17, color: '#A8A8B5', marginTop: 6, lineHeight: 1.5, maxWidth: 460 }}>{desc}</div>
    </div>
  </div>
);

// ────────────────────────────────────────────────────────────
// Slide 1 — Hero
// ────────────────────────────────────────────────────────────
const Slide1 = () => (
  <div className="slide" style={{
    background: `
      radial-gradient(60% 50% at 80% 50%, rgba(123,95,230,0.22) 0%, transparent 60%),
      radial-gradient(40% 40% at 20% 80%, rgba(255,59,48,0.10) 0%, transparent 60%),
      #0A0A0F
    `,
    padding: '80px 100px',
  }}>
    <div className="grain"/>
    {/* Top bar */}
    <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
      <DeckMark size={28}/>
      <div style={{ display: 'flex', gap: 32, color: '#6E6E7A', fontSize: 16, fontWeight: 500 }}>
        <span>Product</span><span>How it works</span><span>Trust & privacy</span><span style={{ color: '#fff' }}>Get the app</span>
      </div>
    </div>

    {/* Content row */}
    <div style={{ display: 'flex', alignItems: 'center', marginTop: 80, gap: 100 }}>
      <div style={{ flex: 1, maxWidth: 880 }}>
        <Eyebrow>Personal safety, quietly.</Eyebrow>
        <div style={{
          fontSize: 132, fontWeight: 800, letterSpacing: -4, lineHeight: 0.95,
          marginTop: 24, color: '#fff',
        }}>
          Someone is<br/>
          <span style={{
            background: 'linear-gradient(90deg, #9D85F2 0%, #E66A8E 100%)',
            WebkitBackgroundClip: 'text', WebkitTextFillColor: 'transparent',
            backgroundClip: 'text',
          }}>beside you.</span>
        </div>
        <div style={{
          fontSize: 28, color: '#A8A8B5', marginTop: 36, lineHeight: 1.4,
          maxWidth: 720, textWrap: 'pretty',
        }}>
          A pocket-sized safety net for late walks, blind dates, and taxis at 2am.
          One tap and the people you trust see exactly where you are.
        </div>

        {/* Mini stats */}
        <div style={{ display: 'flex', gap: 56, marginTop: 60 }}>
          {[
            ['< 3 s', 'from tap to alert'],
            ['Offline', 'SMS fallback, always'],
            ['E2E', 'encrypted on-device'],
          ].map(([k, v]) => (
            <div key={k} style={{ whiteSpace: 'nowrap' }}>
              <div style={{ fontSize: 38, fontWeight: 700, color: '#fff', letterSpacing: -1 }}>{k}</div>
              <div style={{ fontSize: 15, color: '#6E6E7A', marginTop: 4, fontWeight: 500 }}>{v}</div>
            </div>
          ))}
        </div>
      </div>

      {/* Phone */}
      <div style={{ position: 'relative', flexShrink: 0, width: 460, height: 844 }}>
        <div style={{
          position: 'absolute', inset: -40, borderRadius: '50%',
          background: 'radial-gradient(circle, rgba(123,95,230,0.25) 0%, transparent 60%)',
          filter: 'blur(40px)',
        }}/>
        <div style={{ position: 'relative' }}>
          <Phone scale={0.92} shadow="big"><SHome/></Phone>
        </div>
      </div>
    </div>

    {/* Footer slide indicator */}
    <div style={{
      position: 'absolute', bottom: 50, left: 100, right: 100,
      display: 'flex', justifyContent: 'space-between', alignItems: 'center',
      color: '#4A4A55', fontSize: 14, fontWeight: 500,
    }}>
      <span>01 — beside.app</span>
      <span>Tap → 5-second grace → live tracking starts</span>
    </div>
  </div>
);

// ────────────────────────────────────────────────────────────
// Slide 2 — SOS
// ────────────────────────────────────────────────────────────
const Slide2 = () => (
  <div className="slide" style={{
    background: `
      radial-gradient(50% 80% at 10% 50%, rgba(255,59,48,0.16) 0%, transparent 60%),
      #0A0A0F
    `,
    padding: '90px 100px',
  }}>
    <div className="grain"/>
    {/* Header */}
    <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
      <DeckMark size={22} opacity={0.6}/>
      <div style={{ color: '#4A4A55', fontSize: 14, fontWeight: 500 }}>02 — The critical path</div>
    </div>

    <div style={{ display: 'flex', alignItems: 'center', marginTop: 60, gap: 80 }}>
      {/* Two phones overlapping */}
      <div style={{ flex: '0 0 720px', position: 'relative', height: 880 }}>
        <div style={{
          position: 'absolute', inset: -60, borderRadius: '50%',
          background: 'radial-gradient(circle, rgba(255,59,48,0.25) 0%, transparent 60%)',
          filter: 'blur(40px)',
        }}/>
        <div style={{ position: 'absolute', left: 0, top: 20, zIndex: 1, transform: 'rotate(-4deg)' }}>
          <Phone shadow="big"><SCountdown/></Phone>
        </div>
        <div style={{ position: 'absolute', left: 320, top: 0, zIndex: 2, transform: 'rotate(3deg)' }}>
          <Phone shadow="big"><SActive/></Phone>
        </div>
      </div>

      {/* Copy */}
      <div style={{ flex: 1, maxWidth: 620 }}>
        <Eyebrow color="#FF6B62">SOS · the only red button</Eyebrow>
        <div style={{
          fontSize: 88, fontWeight: 800, letterSpacing: -2.5, lineHeight: 1,
          marginTop: 24, color: '#fff',
        }}>
          One tap.<br/>The whole circle.
        </div>
        <div style={{
          fontSize: 20, color: '#A8A8B5', marginTop: 28, lineHeight: 1.55,
          maxWidth: 540,
        }}>
          A five-second window to cancel false alarms — then your live location,
          an encrypted audio recording, and a one-tap call-link go to everyone
          you trust at the same time.
        </div>

        <div style={{ display: 'flex', flexDirection: 'column', gap: 28, marginTop: 50 }}>
          <FeatureRow
            icon={<I.MapPin size={22}/>}
            title="Live location, every 5 seconds"
            desc="They see where you are, where you've been, your battery and signal."/>
          <FeatureRow
            icon={<I.Mic size={22}/>}
            title="Encrypted recording on-device"
            desc="AES-256 before it leaves your phone. Even we can't read it."/>
          <FeatureRow
            icon={<I.Eye size={22}/>}
            title="Duress PIN"
            desc="If someone forces you to cancel, fake-cancel them. The alert keeps running silently."/>
        </div>
      </div>
    </div>
  </div>
);

// ────────────────────────────────────────────────────────────
// Slide 3 — Safe Walk
// ────────────────────────────────────────────────────────────
const Slide3 = () => (
  <div className="slide" style={{
    background: `
      radial-gradient(60% 60% at 90% 30%, rgba(123,95,230,0.18) 0%, transparent 55%),
      #0A0A0F
    `,
    padding: '90px 100px',
  }}>
    <div className="grain"/>
    <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
      <DeckMark size={22} opacity={0.6}/>
      <div style={{ color: '#4A4A55', fontSize: 14, fontWeight: 500 }}>03 — Night-time companion</div>
    </div>

    <div style={{ display: 'flex', alignItems: 'center', marginTop: 60, gap: 80 }}>
      {/* Copy on left */}
      <div style={{ flex: 1, maxWidth: 620 }}>
        <Eyebrow>Safe Walk · the angel mode</Eyebrow>
        <div style={{
          fontSize: 88, fontWeight: 800, letterSpacing: -2.5, lineHeight: 1,
          marginTop: 24, color: '#fff',
        }}>
          Walked home<br/>together.
        </div>
        <div style={{
          fontSize: 20, color: '#A8A8B5', marginTop: 28, lineHeight: 1.55,
          maxWidth: 540,
        }}>
          Pick a destination and a friend. They see your route in real time —
          inside a browser, with no app to install. If you stop, deviate,
          or miss your ETA, they know first.
        </div>

        <div style={{ display: 'flex', flexDirection: 'column', gap: 28, marginTop: 50 }}>
          <FeatureRow
            icon={<I.Users size={22}/>}
            title="Angels don't need the app"
            desc="A magic link opens a live map in any browser. Grandma can be your angel."/>
          <FeatureRow
            icon={<I.AlertTriangle size={22}/>}
            title="Smart anomaly detection"
            desc="Off-route 150m for 90s, stopped 4 min outside a safe place, or ETA overrun by 20% — auto-alert."/>
          <FeatureRow
            icon={<I.CheckCircle size={22}/>}
            title="Auto-arrival"
            desc="Walk into your address — Safe Walk ends, your circle gets a green check."/>
        </div>
      </div>

      {/* Two phones — user view + angel web view */}
      <div style={{ flex: '0 0 760px', position: 'relative', height: 880 }}>
        <div style={{
          position: 'absolute', inset: -60, borderRadius: '50%',
          background: 'radial-gradient(circle, rgba(123,95,230,0.3) 0%, transparent 60%)',
          filter: 'blur(40px)',
        }}/>
        <div style={{ position: 'absolute', left: 0, top: 0, zIndex: 2, transform: 'rotate(-3deg)' }}>
          <Phone shadow="big"><SSafeWalkActive/></Phone>
        </div>
        <div style={{ position: 'absolute', left: 340, top: 30, zIndex: 1, transform: 'rotate(4deg)' }}>
          <Phone dark={false} shadow="big"><SAngelWeb/></Phone>
        </div>
      </div>
    </div>
  </div>
);

// ────────────────────────────────────────────────────────────
// Slide 4 — The toolkit
// ────────────────────────────────────────────────────────────
const Slide4 = () => (
  <div className="slide" style={{
    background: `
      radial-gradient(50% 50% at 50% 0%, rgba(123,95,230,0.12) 0%, transparent 60%),
      #0A0A0F
    `,
    padding: '90px 100px',
  }}>
    <div className="grain"/>
    <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
      <DeckMark size={22} opacity={0.6}/>
      <div style={{ color: '#4A4A55', fontSize: 14, fontWeight: 500 }}>04 — When you need less than SOS</div>
    </div>

    <div style={{ textAlign: 'center', marginTop: 56 }}>
      <Eyebrow>The quiet toolkit</Eyebrow>
      <div style={{
        fontSize: 88, fontWeight: 800, letterSpacing: -2.5, lineHeight: 1,
        marginTop: 18, color: '#fff',
      }}>
        Not every danger<br/>
        <span style={{ color: '#9D85F2' }}>needs a red button.</span>
      </div>
      <div style={{
        fontSize: 20, color: '#A8A8B5', marginTop: 22, lineHeight: 1.5,
        maxWidth: 760, margin: '22px auto 0',
      }}>
        A creepy date. A long taxi. An aggressor at your shoulder.
        Beside has tools for the in-between moments, too.
      </div>
    </div>

    {/* Three phones row */}
    <div style={{
      display: 'flex', justifyContent: 'center', alignItems: 'flex-start',
      gap: 64, marginTop: 36,
    }}>
      <ToolCard
        title="Fake call"
        desc="A pre-scheduled incoming call that looks completely native — the polite way to leave."
        icon={<I.PhoneIncoming size={20}/>}
      ><Phone scale={0.55}><SFakeIncoming/></Phone></ToolCard>

      <ToolCard
        title="Stealth mode"
        desc="Disguised as a real calculator. Type 9110 = to unlock the safety UI."
        icon={<I.Calculator size={20}/>}
        accent
      ><Phone scale={0.55}><SCalc/></Phone></ToolCard>

      <ToolCard
        title="Check-in timer"
        desc="Set 40 minutes. If you don't tap I'm safe before it ends, SOS fires for you."
        icon={<I.Clock size={20}/>}
      ><Phone scale={0.55}><SCheckIn/></Phone></ToolCard>
    </div>
  </div>
);

const ToolCard = ({ title, desc, icon, children, accent }) => (
  <div style={{
    width: 340, display: 'flex', flexDirection: 'column', alignItems: 'center',
  }}>
    <div style={{ textAlign: 'center', marginBottom: 32, padding: '0 12px' }}>
      <div style={{
        display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
        width: 44, height: 44, borderRadius: 12,
        background: 'rgba(123,95,230,0.16)', border: '1px solid rgba(123,95,230,0.3)',
        color: '#9D85F2', marginBottom: 14,
      }}>{icon}</div>
      <div style={{ fontSize: 28, fontWeight: 700, color: '#fff', letterSpacing: -0.5, whiteSpace: 'nowrap' }}>{title}</div>
      <div style={{ fontSize: 16, color: '#A8A8B5', marginTop: 10, lineHeight: 1.5, textWrap: 'pretty' }}>{desc}</div>
    </div>
    <div style={{ height: 464, position: 'relative', width: 215 }}>
      {accent && <div style={{
        position: 'absolute', inset: -40, borderRadius: 40,
        background: 'radial-gradient(circle, rgba(123,95,230,0.35) 0%, transparent 60%)',
        filter: 'blur(35px)',
      }}/>}
      <div style={{ position: 'relative' }}>{children}</div>
    </div>
  </div>
);

// Render each slide into its container
ReactDOM.createRoot(document.getElementById('slide-1')).render(<Slide1/>);
ReactDOM.createRoot(document.getElementById('slide-2')).render(<Slide2/>);
ReactDOM.createRoot(document.getElementById('slide-3')).render(<Slide3/>);
ReactDOM.createRoot(document.getElementById('slide-4')).render(<Slide4/>);

// Hide splash once mounted
const splash = document.getElementById('splash');
if (splash) {
  setTimeout(() => {
    splash.classList.add('hide');
    setTimeout(() => splash.remove(), 400);
  }, 100);
}
