/* Page sections — Hero, Trust, Leverage, Operational, How, Demo, Outcomes, PracSuite, Testimonials, Pricing, FAQ, CTA, Footer */

const { useState: uS, useEffect: uE, useRef: uR, useMemo: uM, useState, useEffect } = React;

/* ============== NAV ============== */
function Nav({ tweaks, onToggleTheme }) {
  const [scrolled, setScrolled] = uS(false);
  uE(() => {
    const h = () => setScrolled(window.scrollY > 12);
    window.addEventListener('scroll', h, { passive: true });
    return () => window.removeEventListener('scroll', h);
  }, []);
  return (
    <header className="nav" style={{
      position: 'fixed', top: 0, left: 0, right: 0, zIndex: 50,
      transition: 'all .3s',
      background: scrolled ? 'color-mix(in oklab, var(--bg) 88%, transparent)' : 'transparent',
      backdropFilter: scrolled ? 'blur(12px) saturate(140%)' : 'none',
      WebkitBackdropFilter: scrolled ? 'blur(12px) saturate(140%)' : 'none',
      borderBottom: scrolled ? '1px solid var(--line)' : '1px solid transparent',
    }}>
      <div className="container-wide" style={{
        height: 64, display: 'flex', alignItems: 'center', justifyContent: 'space-between',
      }}>
        <a href="index.html" style={{ display: 'flex', alignItems: 'center', gap: 8, fontFamily: 'var(--font-display)', fontWeight: 600, letterSpacing: '-0.02em', fontSize: 18 }}>
          <Icon.Logo size={24}/> Arcline
        </a>
        <nav className="hide-mobile" style={{ display: 'flex', gap: 28, fontSize: 14, color: 'var(--fg-2)' }}>
          <a href="#leverage">Why Arcline</a>
          <a href="#how">How it works</a>
          <a href="#demo">Live demo</a>
          <a href="pricing.html">Pricing</a>
          <a href="#faq">FAQ</a>
        </nav>
        <div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
          <button className="btn btn-ghost btn-sm hide-mobile" onClick={onToggleTheme} title="Toggle light/dark">
            <Icon.Sun size={14}/>
          </button>
          <a className="btn btn-ghost btn-sm hide-mobile" href="demo.html">Sign in</a>
          <a className="btn btn-primary btn-sm" href="demo.html">
            Book a demo <span className="btn-arrow"><Icon.Arrow size={12}/></span>
          </a>
        </div>
      </div>
    </header>
  );
}

/* ============== HERO ============== */
const HEADLINES = {
  reception: {
    pre: 'AI reception, built for clinics.',
    main: <>Give your front desk back the time to <span className="serif-italic accent-text">grow the clinic</span></>,
    sub: "Arcline answers calls, books with the right practitioner, navigates claim pathways, and writes everything back to PracSuite — so your reception team is free for the work that lifts conversion, retention, and patient experience.",
  },
  patients: {
    pre: 'AI reception, built for clinics.',
    main: <>AI reception built for health clinics, so your <span className="serif-italic accent-text">front desk can focus on patients</span></>,
    sub: "Arcline handles the repetitive, rules-based phone work — bookings, rescheduling, claim pathways, after-hours calls — while your team stays present for the patient in front of them.",
  },
  revenue: {
    pre: 'AI reception, built for clinics.',
    main: <>Turn repetitive phone work into <span className="serif-italic accent-text">better service</span>, more bookings, stronger revenue.</>,
    sub: "Arcline captures the calls your team can't get to, books them correctly the first time, and routes complex claims — so demand stops leaking and your front desk gets its day back.",
  },
};

/* Animated headline — splits children into words and staggers them in */
function AnimatedHeadline({ node }) {
  // Walk react children and produce {text, italic, accent} word tokens, preserving spans for italic/accent
  const words = uM(() => {
    const out = [];
    const walk = (n, italic, accent) => {
      if (n == null || n === false) return;
      if (typeof n === 'string') {
        n.split(/(\s+)/).forEach(part => {
          if (!part) return;
          if (/^\s+$/.test(part)) { out.push({ space: true }); return; }
          out.push({ text: part, italic, accent });
        });
        return;
      }
      if (Array.isArray(n)) { n.forEach(c => walk(c, italic, accent)); return; }
      if (n.props) {
        const cls = n.props.className || '';
        const isItalic = italic || cls.includes('serif-italic');
        const isAccent = accent || cls.includes('accent-text');
        walk(n.props.children, isItalic, isAccent);
      }
    };
    walk(node);
    return out;
  }, [node]);
  return (
    <span style={{ display: 'inline' }}>
      {words.map((w, i) => {
        if (w.space) return ' ';
        const cls = [w.italic && 'serif-italic', w.accent && 'accent-text'].filter(Boolean).join(' ');
        return (
          <span key={i} className="ah-word" style={{ display: 'inline-block', overflow: 'hidden', verticalAlign: 'baseline', paddingBottom: '0.44em', marginBottom: '-0.14em', paddingRight: '0.25em', marginRight: '-0.25em', lineHeight: 1.08 }}>
            <span className={cls} style={{
              display: 'inline-block',
              animation: `ahRise .9s cubic-bezier(.2,.7,.2,1) ${i * 60}ms both`,
            }}>
              {w.text}
            </span>
          </span>
        );
      })}
      <style>{`
        @keyframes ahRise {
          from { transform: translateY(110%); opacity: 0; filter: blur(6px); }
          to   { transform: translateY(0); opacity: 1; filter: blur(0); }
        }
      `}</style>
    </span>
  );
}

function Hero({ headlineKey = 'reception', scenario, onScenarioChange }) {
  const h = HEADLINES[headlineKey] || HEADLINES.reception;
  return (
    <section className="hero" style={{ paddingTop: 110, paddingBottom: 'var(--section-y)', position: 'relative', overflow: 'hidden' }}>
      <AuroraBackdrop/>
      <div className="container-wide" style={{ position: 'relative', zIndex: 1 }}>
        {/* CENTERED HEAD */}
        <div style={{ textAlign: 'center', maxWidth: 980, margin: '0 auto' }}>
          <div style={{ display: 'inline-flex', alignItems: 'center', gap: 10, padding: '6px 14px 6px 10px', border: '1px solid var(--line)', borderRadius: 999, marginBottom: 28, background: 'color-mix(in oklab, var(--bg-card) 80%, transparent)', backdropFilter: 'blur(8px)' }}>
            <span className="dot-live"/>
            <span className="mono" style={{ color: 'var(--fg-2)', fontSize: 11 }}>Live in 40+ Australian clinics · made in Perth</span>
          </div>
          <h1 className="h-display animated-headline" key={headlineKey} style={{ marginBottom: 24, textWrap: 'balance', lineHeight: 1.05 }}>
            <AnimatedHeadline node={h.main}/>
          </h1>
          <p className="lede" style={{ margin: '0 auto 36px', maxWidth: '60ch', fontSize: 'clamp(16px, 1.35vw, 19px)' }}>{h.sub}</p>
          <div style={{ display: 'flex', gap: 10, justifyContent: 'center', flexWrap: 'wrap', alignItems: 'center' }}>
            <a className="btn btn-primary btn-lg" href="demo.html">
              Book a 20-min walkthrough <span className="btn-arrow"><Icon.Arrow size={14}/></span>
            </a>
            <a className="btn btn-ghost btn-lg" style={{ background: 'color-mix(in oklab, var(--bg-card) 70%, transparent)', backdropFilter: 'blur(8px)' }} href="#demo">
              <Icon.Play size={12}/> Hear it on a live call
            </a>
          </div>
        </div>

        {/* THREE PREVIEW CARDS */}
        <HeroCards scenario={scenario} onScenarioChange={onScenarioChange}/>
      </div>
    </section>
  );
}

/* Subtle aurora lines + glow backdrop — restrained */
function AuroraBackdrop() {
  return (
    <div aria-hidden style={{ position: 'absolute', inset: 0, pointerEvents: 'none', zIndex: 0, overflow: 'hidden' }}>
      {/* glow */}
      <div style={{
        position: 'absolute', top: -160, left: '50%', transform: 'translateX(-50%)',
        width: 'min(1100px, 110%)', height: 720,
        background:
          'radial-gradient(45% 60% at 30% 40%, color-mix(in oklab, var(--accent) 22%, transparent), transparent 70%),' +
          'radial-gradient(40% 55% at 70% 50%, color-mix(in oklab, var(--accent) 14%, transparent), transparent 70%),' +
          'radial-gradient(30% 40% at 50% 30%, color-mix(in oklab, var(--accent-2) 18%, transparent), transparent 70%)',
        filter: 'blur(40px)',
        opacity: 0.85,
      }}/>
      {/* flowing lines */}
      <svg viewBox="0 0 1440 700" preserveAspectRatio="none" style={{
        position: 'absolute', top: 0, left: 0, width: '100%', height: 700,
        opacity: 0.55,
      }}>
        <defs>
          <linearGradient id="ln1" x1="0" x2="1" y1="0" y2="0">
            <stop offset="0" stopColor="var(--accent)" stopOpacity="0"/>
            <stop offset="0.5" stopColor="var(--accent)" stopOpacity="0.55"/>
            <stop offset="1" stopColor="var(--accent)" stopOpacity="0"/>
          </linearGradient>
          <linearGradient id="ln2" x1="0" x2="1" y1="0" y2="0">
            <stop offset="0" stopColor="var(--accent-2)" stopOpacity="0"/>
            <stop offset="0.5" stopColor="var(--accent-2)" stopOpacity="0.4"/>
            <stop offset="1" stopColor="var(--accent-2)" stopOpacity="0"/>
          </linearGradient>
        </defs>
        {Array.from({length: 7}).map((_, i) => {
          const y = 80 + i * 26;
          const a = 18 + i * 4;
          return (
            <path key={i}
              d={`M -50 ${y} C 360 ${y - a}, 720 ${y + a}, 1080 ${y - a/2} S 1500 ${y + a/2}, 1500 ${y}`}
              fill="none" stroke={i % 2 === 0 ? 'url(#ln1)' : 'url(#ln2)'}
              strokeWidth="1"
              style={{ animation: `lineFlow ${8 + i}s ease-in-out ${i * 0.4}s infinite alternate` }}
            />
          );
        })}
      </svg>
      {/* dotted noise wash */}
      <div style={{
        position: 'absolute', inset: 0,
        backgroundImage: 'radial-gradient(circle, var(--line) 1px, transparent 1px)',
        backgroundSize: '22px 22px',
        WebkitMaskImage: 'radial-gradient(60% 60% at 50% 30%, black, transparent 85%)',
        maskImage: 'radial-gradient(60% 60% at 50% 30%, black, transparent 85%)',
        opacity: 0.4,
      }}/>
      <style>{`
        @keyframes lineFlow {
          from { transform: translateX(0); }
          to { transform: translateX(-30px); }
        }
      `}</style>
    </div>
  );
}

/* Three preview cards — distinctive, each shows a different facet of Arcline */
function HeroCards({ scenario, onScenarioChange }) {
  return (
    <div style={{ marginTop: 72, position: 'relative', zIndex: 2 }}>
      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 18 }} className="hero-cards-grid">
        <HeroCard
          eyebrow="Live call"
          title="Answers in under a second"
          sub="Hear Arcline handle a real workers-comp booking, with PracSuite writing back live."
          tag="312ms latency"
        >
          <CardLiveCall scenario={scenario}/>
        </HeroCard>

        <HeroCard
          eyebrow="Bookings"
          title="Calendar fills itself"
          sub="Right practitioner, right pathway, right item code — the first time, every time."
          tag="+148 this month"
          highlight
        >
          <CardCalendar/>
        </HeroCard>

        <HeroCard
          eyebrow="Operations"
          title="Claims, routed correctly"
          sub="WC · CDM · MVA · DVA — Arcline knows the rules your front desk shouldn't have to memorise."
          tag="0 billing reworks"
        >
          <CardClaims/>
        </HeroCard>
      </div>

      {/* scenario picker — tucked under live-call card, only triggers card 1 */}
      <div style={{ display: 'flex', justifyContent: 'flex-start', marginTop: 10, gap: 4, padding: '0 4px' }} className="hero-scenarios">
        <span className="mono" style={{ fontSize: 10, color: 'var(--fg-4)', letterSpacing: '0.08em', textTransform: 'uppercase', alignSelf: 'center', marginRight: 8 }}>Try:</span>
        {Object.entries(SCENARIOS).map(([k, v]) => (
          <button key={k} onClick={() => onScenarioChange(k)} style={{
            border: '1px solid', borderColor: scenario === k ? 'var(--fg)' : 'var(--line)',
            background: scenario === k ? 'var(--fg)' : 'transparent',
            color: scenario === k ? 'var(--bg)' : 'var(--fg-3)',
            fontFamily: 'var(--font-mono)', fontSize: 10, letterSpacing: '0.04em',
            padding: '5px 9px', borderRadius: 999, transition: 'all .2s',
            textTransform: 'uppercase', cursor: 'pointer',
          }}>
            {k.replace('_', ' ')}
          </button>
        ))}
      </div>

      <style>{`
        @media (max-width: 980px) {
          .hero-cards-grid { grid-template-columns: 1fr !important; }
        }
        @media (max-width: 720px) {
          .hero-scenarios { flex-wrap: wrap; }
        }
      `}</style>
    </div>
  );
}

function HeroCard({ eyebrow, title, sub, tag, highlight, children }) {
  return (
    <div className="hero-card" style={{
      position: 'relative',
      background: 'color-mix(in oklab, var(--bg-card) 88%, transparent)',
      backdropFilter: 'blur(14px) saturate(140%)',
      WebkitBackdropFilter: 'blur(14px) saturate(140%)',
      border: '1px solid var(--line)',
      borderRadius: 22,
      padding: 18,
      display: 'flex', flexDirection: 'column',
      boxShadow: highlight
        ? '0 24px 60px -24px color-mix(in oklab, var(--accent) 45%, transparent), 0 0 0 1px var(--line)'
        : '0 12px 40px -20px rgba(10,12,14,0.18), 0 0 0 1px var(--line)',
      transition: 'transform .35s cubic-bezier(.2,.7,.2,1), box-shadow .35s',
    }}
      onMouseEnter={(e) => e.currentTarget.style.transform = 'translateY(-4px)'}
      onMouseLeave={(e) => e.currentTarget.style.transform = 'translateY(0)'}
    >
      {/* visual region */}
      <div style={{
        height: 220, borderRadius: 14, overflow: 'hidden',
        background: 'var(--bg-2)',
        border: '1px solid var(--line-2)',
        position: 'relative',
        marginBottom: 18,
      }}>
        {children}
      </div>
      {/* meta */}
      <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 10 }}>
        <span className="mono" style={{ fontSize: 10, color: 'var(--accent)', letterSpacing: '0.1em', textTransform: 'uppercase' }}>{eyebrow}</span>
        {tag && <span className="chip chip-outline" style={{ fontSize: 10 }}>{tag}</span>}
      </div>
      <h3 style={{ fontSize: 18, fontWeight: 500, letterSpacing: '-0.015em', margin: '0 0 6px', fontFamily: 'var(--font-display)' }}>{title}</h3>
      <p style={{ fontSize: 13, color: 'var(--fg-3)', lineHeight: 1.5, margin: 0, textWrap: 'pretty' }}>{sub}</p>
    </div>
  );
}

/* Card 1 — live call: mini transcript */
function CardLiveCall({ scenario }) {
  const data = SCENARIOS[scenario] || SCENARIOS.workers_comp;
  const [shown, setShown] = useState(0);
  useEffect(() => {
    setShown(0);
    const id = setInterval(() => setShown(s => s + 1 > data.lines.length ? 0 : s + 1), 1800);
    return () => clearInterval(id);
  }, [scenario]);
  const lines = data.lines.slice(0, Math.min(shown, 3));
  return (
    <div style={{ position: 'absolute', inset: 0, padding: 14, display: 'flex', flexDirection: 'column', gap: 8, background: 'linear-gradient(180deg, color-mix(in oklab, var(--accent) 8%, var(--bg-2)), var(--bg-2))' }}>
      <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
        <div style={{ display: 'flex', gap: 6, alignItems: 'center' }}>
          <span className="dot-live"/>
          <span className="mono" style={{ fontSize: 9, letterSpacing: '0.08em', textTransform: 'uppercase', color: 'var(--fg-3)' }}>Live · {data.caller.split(' ')[0]}</span>
        </div>
        <Waveform bars={10} height={14}/>
      </div>
      <div style={{ flex: 1, display: 'flex', flexDirection: 'column', gap: 6, justifyContent: 'flex-end', overflow: 'hidden' }}>
        {lines.map((ln, i) => (
          <div key={i} style={{
            alignSelf: ln.who === 'ai' ? 'flex-start' : 'flex-end',
            maxWidth: '88%',
            background: ln.who === 'ai' ? 'var(--bg-card)' : 'var(--fg)',
            color: ln.who === 'ai' ? 'var(--fg)' : 'var(--bg)',
            border: ln.who === 'ai' ? '1px solid var(--line)' : 'none',
            borderRadius: 10, padding: '6px 9px',
            fontSize: 11, lineHeight: 1.35,
            animation: 'bubbleIn .4s cubic-bezier(.2,.7,.2,1)',
            textWrap: 'pretty',
          }}>
            {ln.text.length > 70 ? ln.text.slice(0, 68) + '…' : ln.text}
          </div>
        ))}
      </div>
    </div>
  );
}

/* Card 2 — calendar filling */
function CardCalendar() {
  const [filled, setFilled] = useState([]);
  const slots = [
    { d: 'TUE', n: '28', t: '9:40', who: 'Dr Lim', tag: 'WC' },
    { d: 'TUE', n: '28', t: '11:15', who: 'Dr Reyes', tag: 'NEW' },
    { d: 'WED', n: '29', t: '8:20', who: 'Dr Okafor', tag: 'CDM' },
    { d: 'WED', n: '29', t: '2:30', who: 'Dr Lim', tag: 'DVA' },
    { d: 'THU', n: '30', t: '10:00', who: 'Dr Reyes', tag: 'WC' },
  ];
  useEffect(() => {
    let i = 0;
    const id = setInterval(() => {
      i++;
      if (i > slots.length) { setFilled([]); i = 0; }
      else setFilled(slots.slice(0, i));
    }, 900);
    return () => clearInterval(id);
  }, []);
  return (
    <div style={{ position: 'absolute', inset: 0, padding: 14, background: 'linear-gradient(180deg, color-mix(in oklab, var(--accent-2) 10%, var(--bg-2)), var(--bg-2))', display: 'flex', flexDirection: 'column', gap: 8 }}>
      <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
        <span className="mono" style={{ fontSize: 9, letterSpacing: '0.08em', textTransform: 'uppercase', color: 'var(--fg-3)' }}>This week · auto-filling</span>
        <span className="mono" style={{ fontSize: 9, color: 'var(--success)', display: 'inline-flex', alignItems: 'center', gap: 4 }}>
          <span style={{ width: 4, height: 4, borderRadius: '50%', background: 'var(--success)' }}/> live
        </span>
      </div>
      <div style={{ flex: 1, display: 'flex', flexDirection: 'column', gap: 4, overflow: 'hidden' }}>
        {slots.map((s, i) => {
          const isFilled = filled.includes(s);
          return (
            <div key={i} style={{
              display: 'grid', gridTemplateColumns: '34px 44px 1fr auto', gap: 8, alignItems: 'center',
              padding: '6px 8px', borderRadius: 8,
              background: isFilled ? 'var(--bg-card)' : 'transparent',
              border: '1px solid', borderColor: isFilled ? 'var(--line)' : 'var(--line-2)',
              opacity: isFilled ? 1 : 0.4,
              transition: 'all .4s',
            }}>
              <span className="mono" style={{ fontSize: 9, color: 'var(--fg-4)', textTransform: 'uppercase' }}>{s.d} {s.n}</span>
              <span className="mono" style={{ fontSize: 10, fontWeight: 500 }}>{s.t}</span>
              <span style={{ fontSize: 11, color: 'var(--fg-2)' }}>{s.who}</span>
              <span style={{ fontFamily: 'var(--font-mono)', fontSize: 9, padding: '2px 6px', borderRadius: 4, background: 'var(--accent-soft)', color: 'var(--accent)' }}>{s.tag}</span>
            </div>
          );
        })}
      </div>
    </div>
  );
}

/* Card 3 — claims router */
function CardClaims() {
  const claims = [
    { code: 'EML', label: 'Workers Comp', detail: 'Initial · 60min · pre-fill sent', state: 'routed' },
    { code: 'CDM', label: 'Care Plan', detail: '3 of 5 · bulk-bill applied', state: 'routed' },
    { code: 'DVA', label: 'Veterans Gold', detail: 'D904 · same clinician', state: 'routed' },
    { code: 'CTP', label: 'Motor Vehicle', detail: 'icare NSW · auth verified', state: 'routing' },
  ];
  const [active, setActive] = useState(0);
  useEffect(() => {
    const id = setInterval(() => setActive(a => (a + 1) % claims.length), 1400);
    return () => clearInterval(id);
  }, []);
  return (
    <div style={{ position: 'absolute', inset: 0, padding: 14, background: 'linear-gradient(180deg, color-mix(in oklab, var(--success) 8%, var(--bg-2)), var(--bg-2))', display: 'flex', flexDirection: 'column', gap: 8 }}>
      <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
        <span className="mono" style={{ fontSize: 9, letterSpacing: '0.08em', textTransform: 'uppercase', color: 'var(--fg-3)' }}>Claim pathways</span>
        <span className="mono" style={{ fontSize: 9, color: 'var(--fg-4)' }}>auto-routing</span>
      </div>
      <div style={{ flex: 1, display: 'flex', flexDirection: 'column', gap: 5, overflow: 'hidden' }}>
        {claims.map((c, i) => (
          <div key={i} style={{
            display: 'grid', gridTemplateColumns: '46px 1fr auto', gap: 8, alignItems: 'center',
            padding: '7px 9px', borderRadius: 8,
            background: active === i ? 'var(--bg-card)' : 'transparent',
            border: '1px solid', borderColor: active === i ? 'var(--accent)' : 'var(--line-2)',
            transition: 'all .4s',
          }}>
            <span className="mono" style={{ fontSize: 9, fontWeight: 600, padding: '2px 5px', borderRadius: 4, background: active === i ? 'var(--accent)' : 'var(--accent-soft)', color: active === i ? '#fff' : 'var(--accent)', textAlign: 'center' }}>{c.code}</span>
            <div style={{ minWidth: 0 }}>
              <div style={{ fontSize: 11, fontWeight: 500, lineHeight: 1.2 }}>{c.label}</div>
              <div style={{ fontSize: 10, color: 'var(--fg-3)', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>{c.detail}</div>
            </div>
            <span style={{ width: 16, height: 16, borderRadius: '50%', background: active === i ? 'var(--success)' : 'var(--line)', color: '#fff', display: 'inline-flex', alignItems: 'center', justifyContent: 'center', transition: 'all .3s' }}>
              {active === i && <Icon.Check size={9}/>}
            </span>
          </div>
        ))}
      </div>
    </div>
  );
}

function HeroPhoneComposition({ scenario, onScenarioChange }) {
  return (
    <div style={{ position: 'relative', display: 'flex', justifyContent: 'center', alignItems: 'center', minHeight: 640 }}>
      {/* dotted backdrop */}
      <div style={{
        position: 'absolute', inset: -20,
        backgroundImage: 'radial-gradient(circle, var(--line) 1px, transparent 1px)',
        backgroundSize: '20px 20px',
        WebkitMaskImage: 'radial-gradient(60% 60% at 50% 50%, black, transparent 80%)',
        maskImage: 'radial-gradient(60% 60% at 50% 50%, black, transparent 80%)',
        opacity: 0.6,
        zIndex: 0,
      }}/>

      {/* Floating "answered" card */}
      <div className="float-card" style={{
        position: 'absolute', top: 30, left: 0, zIndex: 3,
        background: 'var(--bg-card)', border: '1px solid var(--line)',
        borderRadius: 14, padding: '12px 14px', boxShadow: 'var(--shadow-md)',
        display: 'flex', gap: 10, alignItems: 'center',
        animation: 'floatA 6s ease-in-out infinite',
      }}>
        <div style={{ width: 30, height: 30, borderRadius: 8, background: 'var(--accent-soft)', color: 'var(--accent)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
          <Icon.Calendar size={14}/>
        </div>
        <div>
          <div style={{ fontSize: 12, fontWeight: 500, lineHeight: 1.2 }}>+148 bookings</div>
          <div className="mono" style={{ color: 'var(--fg-3)', fontSize: 10 }}>this month · after-hours</div>
        </div>
      </div>

      {/* Floating "PracSuite synced" card */}
      <div className="float-card" style={{
        position: 'absolute', bottom: 60, right: 0, zIndex: 3,
        background: 'var(--bg-card)', border: '1px solid var(--line)',
        borderRadius: 14, padding: '10px 12px', boxShadow: 'var(--shadow-md)',
        display: 'flex', gap: 8, alignItems: 'center',
        animation: 'floatB 7s ease-in-out infinite',
      }}>
        <PracSuiteMark size={22}/>
        <div>
          <div style={{ fontSize: 12, fontWeight: 500, lineHeight: 1.2 }}>Synced to PracSuite</div>
          <div className="mono" style={{ color: 'var(--success)', fontSize: 10, display: 'inline-flex', alignItems: 'center', gap: 4 }}>
            <span style={{ width: 4, height: 4, borderRadius: '50%', background: 'var(--success)' }}/>
            real-time · 2-way
          </div>
        </div>
      </div>

      {/* phone */}
      <div style={{ position: 'relative', zIndex: 2 }}>
        <PhoneMockup scenario={scenario} height={620}/>
      </div>

      {/* scenario switcher */}
      <div style={{
        position: 'absolute', bottom: -12, left: '50%', transform: 'translateX(-50%)',
        display: 'flex', gap: 4, padding: 4,
        background: 'var(--bg-card)', border: '1px solid var(--line)',
        borderRadius: 999, boxShadow: 'var(--shadow-sm)',
        zIndex: 5,
        flexWrap: 'wrap', justifyContent: 'center', maxWidth: 360,
      }}>
        {Object.entries(SCENARIOS).map(([k, v]) => (
          <button key={k} onClick={() => onScenarioChange(k)} style={{
            border: 'none',
            background: scenario === k ? 'var(--fg)' : 'transparent',
            color: scenario === k ? 'var(--bg)' : 'var(--fg-3)',
            fontFamily: 'var(--font-mono)',
            fontSize: 10, letterSpacing: '0.04em',
            padding: '6px 10px', borderRadius: 999, transition: 'all .2s',
            textTransform: 'uppercase',
          }}>
            {k.replace('_', ' ')}
          </button>
        ))}
      </div>

      <style>{`
        @keyframes floatA {
          0%, 100% { transform: translateY(0); }
          50% { transform: translateY(-10px); }
        }
        @keyframes floatB {
          0%, 100% { transform: translateY(0); }
          50% { transform: translateY(8px); }
        }
        @media (max-width: 720px) {
          .float-card { display: none !important; }
        }
      `}</style>
    </div>
  );
}

function PracSuiteMark({ size = 22 }) {
  return (
    <div style={{
      width: size + 8, height: size + 8, borderRadius: 6,
      background: 'var(--fg)', color: 'var(--bg)',
      display: 'flex', alignItems: 'center', justifyContent: 'center',
      fontFamily: 'var(--font-mono)', fontWeight: 600, fontSize: size * 0.55,
      letterSpacing: '-0.04em',
    }}>PS</div>
  );
}

/* ============== TRUST BAR ============== */
function TrustBar() {
  const items = [
    { mark: 'PS', label: 'PracSuite', sub: 'Native partner' },
    { mark: '◆', label: 'AHPRA-aware', sub: 'Clinical context' },
    { mark: '◐', label: 'Perth-built', sub: 'Local support' },
    { mark: '⏵', label: '< 400ms', sub: 'Voice latency' },
    { mark: '✓', label: 'SOC 2 + APP', sub: 'Compliance' },
    { mark: '24/7', label: 'After-hours', sub: 'Coverage' },
  ];
  return (
    <section className="trust" style={{ borderTop: '1px solid var(--line)', borderBottom: '1px solid var(--line)', background: 'var(--bg-2)' }}>
      <div className="container-wide" style={{ padding: '24px var(--container-pad)' }}>
        <div style={{ display: 'flex', flexWrap: 'wrap', gap: 8, justifyContent: 'space-between', alignItems: 'center' }}>
          <span className="mono" style={{ color: 'var(--fg-3)', fontSize: 10, letterSpacing: '0.12em', textTransform: 'uppercase' }}>
            Built for, and inside, real clinics →
          </span>
          <div style={{ display: 'flex', flexWrap: 'wrap', gap: 32, alignItems: 'center' }}>
            {items.map((x, i) => (
              <div key={i} style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
                <span style={{
                  width: 28, height: 28, borderRadius: 6,
                  background: 'var(--bg)', border: '1px solid var(--line)',
                  display: 'flex', alignItems: 'center', justifyContent: 'center',
                  fontFamily: 'var(--font-mono)', fontWeight: 500, fontSize: 11, color: 'var(--fg-2)',
                }}>{x.mark}</span>
                <div>
                  <div style={{ fontSize: 12.5, fontWeight: 500, lineHeight: 1.1 }}>{x.label}</div>
                  <div className="mono" style={{ fontSize: 9.5, color: 'var(--fg-4)', textTransform: 'uppercase', letterSpacing: '0.06em' }}>{x.sub}</div>
                </div>
              </div>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

window.Nav = Nav;
window.Hero = Hero;
window.TrustBar = TrustBar;
window.HEADLINES = HEADLINES;
window.PracSuiteMark = PracSuiteMark;
