/* global React, ReactDOM */
const { useState, useEffect, useRef } = React;

// =========================================================================
// PoloDeck — Water polo referee assessment landing page
// Tokens lifted directly from PoloDeck Design System v1.0 (RD-42 Phase 1)
// =========================================================================

const T = {
  ink: { 900: "#0a2540", 700: "#1a3656", 500: "#4a5e7a", 400: "#7a8ba5", 300: "#a8b3c4" },
  paper: { bg: "#fbfaf5", card: "#ffffff", sunken: "#f5f3ec", warm: "#faf7ed" },
  accent: { 700: "#0d3a7a", 500: "#1b4fa8", 300: "#4a7fd4", tint: "#eaf0fb" },
  success: { fg: "#0d7f3f", bg: "#ecf7ef", line: "#c5e4cf" },
  warning: { fg: "#a66d00", bg: "#fbf4e4", line: "#ecd9a8" },
  danger: { fg: "#a91e1e", bg: "#fbecec", line: "#ecc5c5" },
  neutral: { fg: "#4a5e7a", bg: "#f1f0ea", line: "#dcdacf" },
  border: { subtle: "#ebe7da", medium: "#d5cfbc" },
  shadow: {
    subtle: "0 1px 2px rgba(10,37,64,0.04), 0 0 0 1px rgba(10,37,64,0.04)",
    card: "0 1px 3px rgba(10,37,64,0.06), 0 0 0 1px rgba(10,37,64,0.04)",
    lifted: "0 4px 12px rgba(10,37,64,0.08), 0 0 0 1px rgba(10,37,64,0.04)"
  },
  font: {
    sans: "'IBM Plex Sans', -apple-system, system-ui, sans-serif",
    mono: "'IBM Plex Mono', 'SF Mono', Menlo, monospace"
  }
};

const APP_URL = "https://game.polodeck.app";

// ----- Atoms -----
const Eyebrow = ({ children, tone = T.ink[400], style }) =>
<span style={{
  fontFamily: T.font.sans, fontSize: 11, fontWeight: 600,
  letterSpacing: "0.12em", textTransform: "uppercase", color: tone, ...style
}}>{children}</span>;


const Mono = ({ children, style }) =>
<span style={{ fontFamily: T.font.mono, fontFeatureSettings: '"tnum"', ...style }}>{children}</span>;


const Pill = ({ tone = "neutral", children, style }) => {
  const t = T[tone];
  return (
    <span style={{
      display: "inline-flex", alignItems: "center", gap: 6,
      fontFamily: T.font.sans, fontSize: 11, fontWeight: 500,
      padding: "3px 9px", borderRadius: 999, letterSpacing: "0.01em",
      color: t.fg, background: t.bg, ...style
    }}>{children}</span>);

};

const Btn = ({ variant = "primary", children, onClick, href, style }) => {
  const base = {
    display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 8,
    fontFamily: T.font.sans, fontSize: 15, fontWeight: 600, letterSpacing: "-0.005em",
    padding: "13px 22px", borderRadius: 12, border: "1px solid transparent",
    cursor: "pointer", textDecoration: "none",
    transition: "all 120ms ease-out"
  };
  const variants = {
    primary: { background: T.accent[500], color: "#fff" },
    ghost: { background: "transparent", color: T.ink[900], border: `1px solid ${T.border.medium}` },
    onDark: { background: "#fff", color: T.accent[700] }
  };
  const Tag = href ? "a" : "button";
  return (
    <Tag
      href={href} onClick={onClick} target={href ? "_blank" : undefined} rel={href ? "noopener" : undefined}
      onMouseEnter={(e) => {
        if (variant === "primary") e.currentTarget.style.background = T.accent[700];
        if (variant === "ghost") e.currentTarget.style.background = T.paper.sunken;
      }}
      onMouseLeave={(e) => {
        if (variant === "primary") e.currentTarget.style.background = T.accent[500];
        if (variant === "ghost") e.currentTarget.style.background = "transparent";
      }}
      style={{ ...base, ...variants[variant], ...style }}>
      {children}</Tag>);

};

// =========================================================================
// Nav
// =========================================================================
const Nav = () => {
  const [scrolled, setScrolled] = useState(false);
  useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 8);
    window.addEventListener("scroll", onScroll);
    return () => window.removeEventListener("scroll", onScroll);
  }, []);
  return (
    <React.Fragment>
      <div role="status" aria-live="polite" style={{
        position: "sticky", top: 0, zIndex: 51,
        background: T.ink[900], color: "#fff",
        textAlign: "center", padding: "7px 16px",
        fontFamily: T.font.sans, fontSize: 11.5, fontWeight: 600,
        letterSpacing: "0.12em", textTransform: "uppercase",
        whiteSpace: "nowrap",
        display: "flex", justifyContent: "center", alignItems: "center", gap: 10, height: "30px"
      }}>
        <span aria-hidden style={{
          width: 7, height: 7, borderRadius: "50%",
          background: T.accent[500], display: "inline-block",
          boxShadow: `0 0 0 4px ${T.accent[500]}33`,
          animation: "pdPulse 1.8s ease-in-out infinite"
        }} />
        Currently in beta testing
      </div>
      <style>{`@keyframes pdPulse { 0%,100%{opacity:1} 50%{opacity:.4} }`}</style>
    <nav style={{
        position: "sticky", top: 31, zIndex: 50,
        backdropFilter: "blur(14px)",
        background: scrolled ? "rgba(251, 250, 245, 0.86)" : "transparent",
        borderBottom: scrolled ? `1px solid ${T.border.subtle}` : "1px solid transparent",
        transition: "background 200ms ease, border-color 200ms ease"
      }}>
      <div style={{ maxWidth: 1200, margin: "0 auto", padding: "0 32px", height: 75,
          display: "flex", alignItems: "center", justifyContent: "space-between" }}>
        <a href="#top" style={{ display: "flex", alignItems: "center", textDecoration: "none", color: T.ink[900] }}>
          <Lockup height={64} cropped />
        </a>
        <div style={{ display: "flex", gap: 32, alignItems: "center" }}>
          {[["Features", "#features"], ["How it works", "#how"], ["Pricing", "#pricing"], ["FAQ", "#faq"], ["About", "#about"]].map(([l, h]) =>
            <a key={l} href={h} style={{ fontFamily: T.font.sans, fontSize: 14, fontWeight: 500, color: T.ink[500], textDecoration: "none" }}>{l}</a>
            )}
        </div>
        <Btn variant="primary" href={APP_URL} style={{ padding: "10px 18px", fontSize: 14 }}>
          Open app <span aria-hidden>→</span>
        </Btn>
      </div>
    </nav>
    </React.Fragment>);

};

// PoloDeck mark — scoreboard + ball + trajectory. Sourced from the
// brand-kit mark-only SVG (uploads/PoloDeck Logo/favicon/mark-only.svg).
const Logo = ({ size = 32, mono = false }) => {
  const stroke = mono ? "#FFFFFF" : "#0B1F3A";
  const ball = mono ? "#0B1F3A" : "#FFD23F";
  const water = mono ? "#FFFFFF" : "#1E6FBA";
  const trail = mono ? "#FFFFFF" : "#E63946";
  return (
    <svg width={size} height={size} viewBox="0 0 84 84" fill="none" aria-hidden style={{ display: "block", width: "45px", height: "45px" }}>
      <g transform="translate(0 12)">
        {/* Scoreboard frame */}
        <rect x="6" y="10" width="72" height="38" fill="none" stroke={stroke} strokeWidth="2.5" />
        {/* Scoreboard grid */}
        <line x1="6" y1="22" x2="78" y2="22" stroke={stroke} strokeWidth="0.7" opacity="0.35" />
        <line x1="6" y1="34" x2="78" y2="34" stroke={stroke} strokeWidth="0.7" opacity="0.35" />
        <line x1="22" y1="10" x2="22" y2="48" stroke={stroke} strokeWidth="0.7" opacity="0.35" />
        <line x1="38" y1="10" x2="38" y2="48" stroke={stroke} strokeWidth="0.7" opacity="0.35" />
        <line x1="54" y1="10" x2="54" y2="48" stroke={stroke} strokeWidth="0.7" opacity="0.35" />
        <line x1="70" y1="10" x2="70" y2="48" stroke={stroke} strokeWidth="0.7" opacity="0.35" />
        {/* Waterline */}
        <line x1="0" y1="48" x2="84" y2="48" stroke={water} strokeWidth="3" strokeLinecap="round" />
        {/* Ball trajectory */}
        <path d="M14 40 Q34 22 56 26" fill="none" stroke={trail} strokeWidth="1.6" strokeDasharray="2.5 2.5" />
        {/* Water polo ball */}
        <circle cx="57" cy="27" r="8.3" fill={ball} stroke={stroke} strokeWidth="1.4" />
        <path d="M 48.7 27 Q 57 23.68 65.3 27" fill="none" stroke={stroke} strokeWidth="1.12" />
        <path d="M 48.7 27 Q 57 30.32 65.3 27" fill="none" stroke={stroke} strokeWidth="1.12" />
        <path d="M 57 18.7 Q 53.68 27 57 35.3" fill="none" stroke={stroke} strokeWidth="1.12" />
        <path d="M 57 18.7 Q 60.32 27 57 35.3" fill="none" stroke={stroke} strokeWidth="1.12" />
      </g>
    </svg>);

};

// PoloDeck full lockup — mark + wordmark, sourced from the brand-kit
// polodeck-lockup-full-color.svg (viewBox 272×164).
const Lockup = ({ height = 96, variant = "full-color", cropped = false }) => {
  const stroke = variant === "white" ? "#FFFFFF" : "#0B1F3A";
  const ballFill = variant === "full-color" ? "#FFD23F" : variant === "white" ? "#0B1F3A" : "#FFFFFF";
  const water = variant === "full-color" ? "#1E6FBA" : stroke;
  const trail = variant === "full-color" ? "#E63946" : stroke;
  const text = stroke;
  // Tight viewBox crops the brand-kit's safe-area padding so the mark fills the
  // available height — used in chrome (nav, footer) where the surrounding
  // layout already provides breathing room.
  const vb = cropped ? "50 32 172 116" : "0 0 272 164";
  return (
    <svg viewBox={vb} height={height} fill="none" aria-label="PoloDeck" style={{ display: "block" }}>
      <g transform="translate(52 16) scale(2)">
        <rect x="6" y="10" width="72" height="38" fill="none" stroke={stroke} strokeWidth="2.5" />
        <line x1="6" y1="22" x2="78" y2="22" stroke={stroke} strokeWidth="0.7" opacity="0.35" />
        <line x1="6" y1="34" x2="78" y2="34" stroke={stroke} strokeWidth="0.7" opacity="0.35" />
        <line x1="22" y1="10" x2="22" y2="48" stroke={stroke} strokeWidth="0.7" opacity="0.35" />
        <line x1="38" y1="10" x2="38" y2="48" stroke={stroke} strokeWidth="0.7" opacity="0.35" />
        <line x1="54" y1="10" x2="54" y2="48" stroke={stroke} strokeWidth="0.7" opacity="0.35" />
        <line x1="70" y1="10" x2="70" y2="48" stroke={stroke} strokeWidth="0.7" opacity="0.35" />
        <line x1="0" y1="48" x2="84" y2="48" stroke={water} strokeWidth="3" strokeLinecap="round" />
        <path d="M14 40 Q34 22 56 26" fill="none" stroke={trail} strokeWidth="1.6" strokeDasharray="2.5 2.5" />
        <circle cx="57" cy="27" r="8.3" fill={ballFill} stroke={stroke} strokeWidth="1.4" />
        <path d="M 48.7 27 Q 57 23.68 65.3 27" fill="none" stroke={stroke} strokeWidth="1.12" />
        <path d="M 48.7 27 Q 57 30.32 65.3 27" fill="none" stroke={stroke} strokeWidth="1.12" />
        <path d="M 57 18.7 Q 53.68 27 57 35.3" fill="none" stroke={stroke} strokeWidth="1.12" />
        <path d="M 57 18.7 Q 60.32 27 57 35.3" fill="none" stroke={stroke} strokeWidth="1.12" />
      </g>
      <text x="136" y="116" textAnchor="middle" dominantBaseline="hanging"
      fontFamily="'Space Grotesk', system-ui, sans-serif"
      fontWeight="700" fontSize="28" letterSpacing="-0.7" fill={text}>PoloDeck</text>
    </svg>);

};

// =========================================================================
// Hero
// =========================================================================
const Hero = () =>
<section data-screen-label="01 Hero" id="top" style={{ padding: "60px 32px 80px" }}>
    <div style={{ maxWidth: 1200, margin: "0 auto",
    display: "grid", gridTemplateColumns: "1.05fr 0.95fr",
    gap: 64, alignItems: "center" }}>
      <div>
        <Eyebrow tone={T.accent[500]}>The water polo real-time match review & data platform</Eyebrow>
        <h1 style={{
        fontFamily: T.font.sans, fontWeight: 700,
        fontSize: "clamp(44px, 5.6vw, 68px)", lineHeight: 1.02,
        letterSpacing: "-0.025em", margin: "20px 0 0", color: T.ink[900],
        textWrap: "balance"
      }}>
          Capture the game. Coach the moment. <em style={{ fontStyle: "italic", fontWeight: 600, color: T.accent[500] }}>Develop both players & referees.</em>
        </h1>
        <p style={{
        fontFamily: T.font.sans, fontSize: 18, lineHeight: 1.55, fontWeight: 400,
        color: T.ink[500], maxWidth: 560, marginTop: 24, textWrap: "pretty"
      }}>PoloDeck is the pool-side companion for Coaches & Delegates to build world-class players & referees. Capture every key event in the pool and every referee decision in real time, then turn the record into clear, development-focused feedback — for referees, teams and athletes alike. The game moves too fast for memory; PoloDeck makes structured review easy.

      </p>
        <div style={{ display: "flex", gap: 12, marginTop: 32, flexWrap: "wrap" }}>
          <Btn variant="primary" href={APP_URL}>Try PoloDeck free <span aria-hidden>→</span></Btn>
          <Btn variant="ghost" onClick={() => document.querySelector("#how")?.scrollIntoView({ behavior: "smooth" })}>
            See how it works
          </Btn>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "20px 32px", marginTop: 36, maxWidth: 520 }}>
          <Stat n="Delegates" label="Real-time logging" />
          <Stat n="Coaches" label="Teachable moments" />
          <Stat n="Referees" label="Self-assessment" />
          <Stat n="Players" label="Development history" />
        </div>
      </div>
      <PhoneMockup />
    </div>
  </section>;


const Divider = () => <div style={{ width: 1, height: 36, background: T.border.subtle }} />;
const Stat = ({ n, label }) =>
<div>
    <div style={{ fontFamily: T.font.sans, fontWeight: 700, fontSize: 17, color: T.ink[900], letterSpacing: "-0.01em" }}>{n}</div>
    <div style={{ fontFamily: T.font.sans, fontSize: 11, fontWeight: 600, letterSpacing: "0.1em", textTransform: "uppercase", color: T.ink[400], marginTop: 4 }}>{label}</div>
  </div>;


// ---- Phone mockup (Actions tab mid-game) ----
const PhoneMockup = () =>
<div style={{ display: "flex", justifyContent: "center", position: "relative" }}>
    {/* soft halo */}
    <div style={{
    position: "absolute", width: "82%", height: "82%", borderRadius: "50%",
    background: `radial-gradient(closest-side, ${T.accent.tint}, transparent 70%)`,
    filter: "blur(10px)", top: "9%", left: "9%", zIndex: 0
  }} />
    <div style={{
    position: "relative", zIndex: 1,
    width: 360, aspectRatio: "9 / 19.5",
    background: "#1a1a1c", borderRadius: 44,
    padding: 11, boxShadow: "0 30px 60px -20px rgba(10,37,64,0.25), 0 8px 20px -10px rgba(10,37,64,0.15)"
  }}>
      <div style={{
      width: "100%", height: "100%", borderRadius: 34,
      background: T.paper.bg, overflow: "hidden",
      display: "flex", flexDirection: "column",
      position: "relative"
    }}>
        {/* notch */}
        <div style={{ position: "absolute", top: 8, left: "50%", transform: "translateX(-50%)",
        width: 100, height: 26, borderRadius: 14, background: "#1a1a1c", zIndex: 5 }} />
        {/* status bar */}
        <div style={{ display: "flex", justifyContent: "space-between", padding: "12px 26px 0",
        fontFamily: T.font.mono, fontSize: 11, color: T.ink[900], fontWeight: 600 }}>
          <span>9:41</span><span style={{ marginLeft: "auto", display: "flex", gap: 4, alignItems: "center" }}>●●●● 5G ▮</span>
        </div>
        {/* game header */}
        <div style={{ padding: "20px 18px 14px", borderBottom: `1px solid ${T.border.subtle}` }}>
          <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}>
            <Eyebrow>NSW Premier League · QF</Eyebrow>
            <Pill tone="warning"><Mono style={{ fontSize: 10 }}>Q3 · 4:12</Mono></Pill>
          </div>
          <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginTop: 12 }}>
            <TeamScore name="DRU" score={5} />
            <Mono style={{ fontSize: 13, color: T.ink[400] }}>vs</Mono>
            <TeamScore name="MAN" score={4} right />
          </div>
        </div>
        {/* tabs */}
        <div style={{ display: "flex", padding: "10px 14px 0", gap: 4 }}>
          {["Setup", "Actions", "Score", "Notes", "Assess"].map((t, i) =>
        <div key={t} style={{
          flex: 1, textAlign: "center", padding: "8px 0", fontSize: 11, fontWeight: 600,
          fontFamily: T.font.sans,
          color: i === 1 ? T.accent[500] : T.ink[400],
          borderBottom: i === 1 ? `2px solid ${T.accent[500]}` : "2px solid transparent"
        }}>{t}</div>
        )}
        </div>
        {/* action tiles */}
        <div style={{ padding: "14px 14px 8px", display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8 }}>
          <ActionTile color="#fbbf24" label="Major Foul" />
          <ActionTile color="#f87171" label="Penalty" />
          <ActionTile color="#2563eb" label="Turnover" />
          <ActionTile color="#a78bfa" label="No Call" />
        </div>
        {/* action log header */}
        <div style={{ padding: "8px 18px 6px", display: "flex", justifyContent: "space-between" }}>
          <Eyebrow>Action log · this quarter</Eyebrow>
          <Mono style={{ fontSize: 10, color: T.ink[400] }}>11 entries</Mono>
        </div>
        {/* log rows */}
        <div style={{ padding: "0 14px", display: "flex", flexDirection: "column", gap: 6, overflow: "hidden" }}>
          <LogRow type="Penalty" tone="warning" team="MAN" cap="6" time="Q3 · 5:08"
        note="Discuss with Bill — not sure attacker was facing goal." />
          <LogRow type="Major Foul" tone="success" team="DRU" cap="3" time="Q3 · 4:42" />
          <LogRow type="Turnover" tone="success" team="MAN" cap="11" time="Q3 · 4:21" />
          <LogRow type="No Call" tone="danger" team="DRU" cap="9" time="Q3 · 4:12"
        note="Held under, should have been a major." />
        </div>
        {/* home indicator */}
        <div style={{ marginTop: "auto", padding: "10px 0 8px", display: "flex", justifyContent: "center" }}>
          <div style={{ width: 120, height: 4, borderRadius: 4, background: T.ink[300] }} />
        </div>
      </div>
    </div>
  </div>;


const TeamScore = ({ name, score, right }) =>
<div style={{ textAlign: right ? "right" : "left", display: "flex", alignItems: "center", gap: 10, flexDirection: right ? "row-reverse" : "row" }}>
    <div style={{ width: 28, height: 28, borderRadius: "50%",
    background: right ? "#dc2626" : T.accent[500], color: "#fff",
    display: "flex", alignItems: "center", justifyContent: "center",
    fontFamily: T.font.sans, fontSize: 11, fontWeight: 700 }}>{name.slice(0, 1)}</div>
    <div>
      <div style={{ fontFamily: T.font.sans, fontSize: 12, fontWeight: 600, color: T.ink[700] }}>{name}</div>
      <Mono style={{ fontSize: 24, fontWeight: 700, color: T.ink[900] }}>{score}</Mono>
    </div>
  </div>;


const ActionTile = ({ color, label }) =>
<div style={{
  background: T.paper.card, borderRadius: 12, padding: "12px 12px",
  boxShadow: T.shadow.subtle, display: "flex", alignItems: "center", gap: 8
}}>
    <div style={{ width: 8, height: 32, borderRadius: 4, background: color }} />
    <div>
      <div style={{ fontFamily: T.font.sans, fontSize: 12, fontWeight: 600, color: T.ink[900] }}>{label}</div>
      <div style={{ fontFamily: T.font.sans, fontSize: 10, color: T.ink[400], marginTop: 2 }}>Tap to log</div>
    </div>
  </div>;


const LogRow = ({ type, tone, team, cap, time, note }) => {
  const t = T[tone];
  return (
    <div style={{
      background: T.paper.card, borderRadius: 10, padding: "8px 10px 8px 0",
      display: "flex", boxShadow: T.shadow.subtle, position: "relative",
      overflow: "hidden"
    }}>
      <div style={{ width: 4, alignSelf: "stretch", background: t.fg, borderRadius: "10px 0 0 10px", flexShrink: 0 }} />
      <div style={{ flex: 1, paddingLeft: 10 }}>
        <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", gap: 6 }}>
          <div style={{ display: "flex", alignItems: "center", gap: 6, minWidth: 0 }}>
            <span style={{ fontFamily: T.font.sans, fontSize: 12, fontWeight: 700, color: T.ink[900] }}>{type}</span>
            <Mono style={{ fontSize: 10, color: T.ink[400] }}>· {team} · #{cap}</Mono>
          </div>
          <Pill tone={tone} style={{ fontSize: 9, padding: "2px 7px" }}>
            {tone === "success" ? "Correct" : tone === "warning" ? "Unsure" : "Incorrect"}
          </Pill>
        </div>
        <Mono style={{ fontSize: 10, color: T.ink[400] }}>{time}</Mono>
        {note &&
        <div style={{ fontFamily: T.font.sans, fontSize: 11, color: T.ink[700], marginTop: 4, lineHeight: 1.35 }}>
            {note}
          </div>
        }
      </div>
    </div>);

};

// =========================================================================
// Features grid
// =========================================================================
const Features = () => {
  const cards = [
  { icon: "📋", t: "Capture the whole game live",
    d: "Goals, major fouls, penalties, turnovers, no-calls, cards, timeouts, incidents \u2014 logged in two taps with cap number, quarter and time. Voice dictation on every note so you never fall behind the action. Your game data should help you win in the game, not just for the next one." },
  { icon: "⭐", t: "Research-based referee assessment",
    d: "Rate referees across positioning, communication, decision-making and game management with behaviour-anchored scales. Self-assessment sits side-by-side with delegate assessment. Informed by research from World Aquatics, FIFA & World Rugby." },
  { icon: "🎬", t: "Coach the moment",
    d: "Coaches turn the match record into teachable moments. Every event is timestamped and tagged \u2014 review specific phases with players, attach feedback, and build a development thread that runs across games and seasons." },
  { icon: "📈", t: "A development history that compounds",
    d: "Players, referees and teams accumulate a structured record over time. Dashboards show correct-decision %, assessment trends, action-type breakdowns and weighted overalls \u2014 every game adds to the picture." },
  { icon: "📱", t: "Mobile-first, works offline",
    d: "All in the palm of your hand \u2014 no laptops needed. Log an entire game with voice recording for easy in-game use. Works offline, so patchy wifi inside a venue won\u2019t lose your work." },
  { icon: "🔗", t: "Share without accounts",
    d: "Lock a game and generate a secure, read-only link. Referees, coaches and players see their report in any browser \u2014 no login, no friction \u2014 and feedback flows immediately, not days later." }];

  return (
    <section data-screen-label="02 Features" id="features" style={{ padding: "100px 32px", background: T.paper.sunken, borderTop: `1px solid ${T.border.subtle}` }}>
      <div style={{ maxWidth: 1200, margin: "0 auto" }}>
        <div style={{ maxWidth: 760, marginBottom: 56 }}>
          <Eyebrow>What it does</Eyebrow>
          <h2 style={{
            fontFamily: T.font.sans, fontWeight: 700, fontSize: 44, lineHeight: 1.05,
            letterSpacing: "-0.025em", color: T.ink[900], margin: "16px 0 14px"
          }}>Built for the rhythm of a live game and the work that comes after.

          </h2>
          <p style={{ fontFamily: T.font.sans, fontSize: 18, lineHeight: 1.55, color: T.ink[500], margin: 0, textWrap: "pretty" }}>Every feature is designed for how the whole game actually works, one-handed, pool-side, at match pace, then with complete game analysis at your finger tips immediate following the game for review.

          </p>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 20 }}>
          {cards.map((c, i) =>
          <article key={c.t} style={{
            background: T.paper.card, borderRadius: 16, padding: "26px 26px",
            boxShadow: T.shadow.card, display: "flex", flexDirection: "column", gap: 14
          }}>
              <div style={{ display: "flex", alignItems: "flex-start", gap: 14 }}>
                <div style={{ width: 44, height: 44, flexShrink: 0, borderRadius: 12, background: T.accent.tint,
                display: "flex", alignItems: "center", justifyContent: "center", fontSize: 22 }}>
                  {c.icon}
                </div>
                <h3 style={{ fontFamily: T.font.sans, fontWeight: 700, fontSize: 19, lineHeight: 1.2,
                color: T.ink[900], margin: 0, letterSpacing: "-0.015em", flex: 1, alignSelf: "center", textWrap: "balance" }}>
                  {c.t}
                </h3>
                <Mono style={{ fontSize: 11, color: T.ink[400], alignSelf: "flex-start" }}>0{i + 1}</Mono>
              </div>
              <p style={{ fontFamily: T.font.sans, fontSize: 14.5, lineHeight: 1.55, color: T.ink[500], margin: 0, textWrap: "pretty" }}>
                {c.d}
              </p>
            </article>
          )}
        </div>
      </div>
    </section>);

};

// =========================================================================
// Who it's for
// =========================================================================
const WhoItsFor = () => {
  const roles = [
  { tag: "Delegate", t: "Run the match record",
    d: "Create and manage games. Log every decision and incident in real time. Assess referees across the four-domain framework. Lock and share secure reports.",
    bullets: ["Live decision logging", "Referee assessment", "Locked share reports"] },
  { tag: "Referee", t: "Own your development",
    d: "Self-assess across the same four-domain framework. Compare your view of the game with the delegate's, side-by-side, with verbatim notes against the moments that mattered.",
    bullets: ["Self-assessment", "Joint match review", "Decision history"] },
  { tag: "Coach", t: "Win the game, develop your team",
    d: "You or your manager/assistant coach track the game live. Using the live scoreboard to perform at your best. Tag teachable moments, attach feedback to specific phases, and build a development thread for every player on the squad.",
    bullets: ["Tagged review", "Teachable moments", "Player development log"] },
  { tag: "Player", t: "See your game, season by season",
    d: "Open coach-shared feedback in any browser. Review key moments. Build a structured development history that travels with you across games, clubs and seasons.",
    bullets: ["Coach feedback inbox", "Personal moments review", "Career development history"] }];

  return (
    <section data-screen-label="03 Who it's for" style={{ padding: "100px 32px", borderTop: `1px solid ${T.border.subtle}` }}>
      <div style={{ maxWidth: 1200, margin: "0 auto" }}>
        <div style={{ maxWidth: 720, marginBottom: 56 }}>
          <Eyebrow>Who it's for</Eyebrow>
          <h2 style={{ fontFamily: T.font.sans, fontWeight: 700, fontSize: 44, lineHeight: 1.05,
            letterSpacing: "-0.025em", color: T.ink[900], margin: "16px 0 14px" }}>
            One match record. <em style={{ fontStyle: "italic", color: T.accent[500], fontWeight: 600 }}>Four points of view.</em>
          </h2>
          <p style={{ fontFamily: T.font.sans, fontSize: 18, lineHeight: 1.55, color: T.ink[500], margin: 0, textWrap: "pretty" }}>
            PoloDeck captures the game once, then surfaces it to the right person in the right shape — for assessment, coaching, or personal review.
          </p>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(2, 1fr)", gap: 20 }}>
          {roles.map((r) =>
          <div key={r.tag} style={{
            background: T.paper.card, borderRadius: 16, padding: "30px 28px",
            boxShadow: T.shadow.card, display: "flex", flexDirection: "column", gap: 16
          }}>
              <Pill tone="neutral" style={{ alignSelf: "flex-start", background: T.accent.tint, color: T.accent[500] }}>
                {r.tag}
              </Pill>
              <h3 style={{ fontFamily: T.font.sans, fontWeight: 700, fontSize: 22, lineHeight: 1.2,
              color: T.ink[900], margin: 0, letterSpacing: "-0.02em" }}>
                {r.t}
              </h3>
              <p style={{ fontFamily: T.font.sans, fontSize: 14.5, lineHeight: 1.55, color: T.ink[500], margin: 0, textWrap: "pretty" }}>
                {r.d}
              </p>
              <ul style={{ listStyle: "none", padding: 0, margin: "auto 0 0", display: "flex", flexDirection: "column", gap: 8, paddingTop: 14, borderTop: `1px solid ${T.border.subtle}` }}>
                {r.bullets.map((b) =>
              <li key={b} style={{ fontFamily: T.font.sans, fontSize: 13, color: T.ink[700], display: "flex", gap: 10 }}>
                    <span style={{ color: T.accent[500] }}>→</span>{b}
                  </li>
              )}
              </ul>
            </div>
          )}
        </div>
      </div>
    </section>);

};

// =========================================================================
// How it works (4 steps)
// =========================================================================
const HowItWorks = () => {
  const steps = [
  { n: "01", t: "Set up the game", d: "Teams, referees, pool, age group, gender. Pre-loaded competitions save time." },
  { n: "02", t: "Log decisions live", d: "Two taps per action during play. Foul alerts, scorecard, cap tracking — all automatic. Log an entire game from start to penalty shootout." },
  { n: "03", t: "Complete assessment", d: "After the match, rate each referee across four domains with quick behaviour anchors. Or share feedback and stats directly with your team." },
  { n: "04", t: "Lock & share", d: "Generate a secure read-only report link. The referees & players gets a specific, actionable game debrief." }];

  return (
    <section data-screen-label="03 How it works" id="how" style={{ padding: "100px 32px" }}>
      <div style={{ maxWidth: 1200, margin: "0 auto" }}>
        <div style={{ maxWidth: 720, marginBottom: 56 }}>
          <Eyebrow>How it works</Eyebrow>
          <h2 style={{ fontFamily: T.font.sans, fontWeight: 700, fontSize: 44, lineHeight: 1.05,
            letterSpacing: "-0.025em", color: T.ink[900], margin: "16px 0 0" }}>
            From first whistle to shared report.
          </h2>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 24 }}>
          {steps.map((s, i) =>
          <div key={s.n} style={{ position: "relative" }}>
              {i < 3 &&
            <div style={{ position: "absolute", top: 20, right: -16, width: 32, height: 1,
              background: T.border.subtle }} />
            }
              <div style={{
              width: 40, height: 40, borderRadius: 12,
              background: T.accent.tint, color: T.accent[500],
              display: "flex", alignItems: "center", justifyContent: "center",
              fontFamily: T.font.mono, fontSize: 14, fontWeight: 700
            }}>{s.n}</div>
              <h4 style={{ fontFamily: T.font.sans, fontWeight: 700, fontSize: 19, lineHeight: 1.25,
              color: T.ink[900], margin: "20px 0 10px", letterSpacing: "-0.015em" }}>
                {s.t}
              </h4>
              <p style={{ fontFamily: T.font.sans, fontSize: 14.5, lineHeight: 1.55, color: T.ink[500], margin: 0, textWrap: "pretty" }}>
                {s.d}
              </p>
            </div>
          )}
        </div>
      </div>
    </section>);

};

// =========================================================================
// Assessment preview (interactive demo)
// =========================================================================
const AssessmentPreview = () => {
  const domains = [
  { id: "positioning", label: "Positioning", desc: "Movement, sightlines, anticipation, recovery after a phase change." },
  { id: "communication", label: "Communication", desc: "Whistle clarity, signals, voice, dialogue with players and partner." },
  { id: "decisions", label: "Decision-making", desc: "Accuracy and consistency across the four action types and game pressure." },
  { id: "management", label: "Game management", desc: "Tempo, escalation, card discipline, control of contested phases." }];

  const [active, setActive] = useState("decisions");
  const a = domains.find((d) => d.id === active);
  return (
    <section data-screen-label="04 Assessment" style={{ padding: "100px 32px", background: T.ink[900], color: "#fff" }}>
      <div style={{ maxWidth: 1200, margin: "0 auto" }}>
        <div style={{ maxWidth: 720, marginBottom: 56 }}>
          <Eyebrow tone={T.accent[300]}>Referee development 4-domain framework</Eyebrow>
          <h2 style={{ fontFamily: T.font.sans, fontWeight: 700, fontSize: 44, lineHeight: 1.05,
            letterSpacing: "-0.025em", margin: "16px 0 14px", color: "#fff" }}>
            Structured assessments. <em style={{ fontStyle: "italic", color: T.accent[300], fontWeight: 600 }}>Behaviour-anchored.</em>
          </h2>
          <p style={{ fontFamily: T.font.sans, fontSize: 18, lineHeight: 1.55, color: T.ink[300], margin: 0, textWrap: "pretty", width: "920px" }}>Based on the leading referee development research from FIFA, World Rugby & World Aquatics. Self-assessment sits side-by-side with delegate assessment so referees can see exactly where their view differs.

          </p>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "0.9fr 1.1fr", gap: 56, alignItems: "start" }}>
          <div>
            {domains.map((d, i) =>
            <button
              key={d.id}
              onClick={() => setActive(d.id)}
              style={{
                width: "100%", textAlign: "left", background: "transparent", border: "none",
                padding: "22px 0", borderBottom: `1px solid rgba(255,255,255,0.12)`,
                cursor: "pointer", display: "flex", flexDirection: "column", gap: 8,
                transition: "all 120ms ease-out"
              }}>
              
                <div style={{ display: "flex", alignItems: "baseline", gap: 14 }}>
                  <Mono style={{ fontSize: 11, color: active === d.id ? T.accent[300] : "rgba(255,255,255,0.4)" }}>
                    0{i + 1}
                  </Mono>
                  <span style={{
                  fontFamily: T.font.sans, fontSize: 22, fontWeight: 600,
                  color: active === d.id ? "#fff" : "rgba(255,255,255,0.55)",
                  letterSpacing: "-0.015em"
                }}>{d.label}</span>
                </div>
                {active === d.id &&
              <div style={{ fontFamily: T.font.sans, fontSize: 14.5, lineHeight: 1.55,
                color: "rgba(255,255,255,0.78)", paddingLeft: 26, maxWidth: 380 }}>
                    {d.desc}
                  </div>
              }
              </button>
            )}
          </div>
          <AssessmentCard domain={a} />
        </div>
      </div>
    </section>);

};

const RatingScale = ({ value, color = T.accent[500] }) =>
<div style={{ display: "flex", gap: 4 }}>
    {[1, 2, 3, 4, 5].map((n) =>
  <div key={n} style={{
    width: 22, height: 22, borderRadius: 6,
    background: n <= value ? color : T.paper.sunken,
    border: `1px solid ${n <= value ? color : T.border.subtle}`,
    fontFamily: T.font.mono, fontSize: 11, fontWeight: 600,
    color: n <= value ? "#fff" : T.ink[400],
    display: "flex", alignItems: "center", justifyContent: "center"
  }}>{n}</div>
  )}
  </div>;


const AssessmentCard = ({ domain }) => {
  const ratings = {
    positioning: { delegate: 4, ref: 3, anchor: "Strong sightline through middle phases; lost track on the late 6-on-5 reset." },
    communication: { delegate: 3, ref: 4, anchor: "Whistle clear. Could be louder in player dialogue during contested resets." },
    decisions: { delegate: 4, ref: 3, anchor: "Major fouls 92% correct. Two missed holds in Q3 but recovered well after time-out." },
    management: { delegate: 5, ref: 4, anchor: "Calm escalation on Q4 brawl. Card discipline appropriate — kept the tempo without letting it slip." }
  };
  const r = ratings[domain.id];
  return (
    <div style={{
      background: T.paper.card, color: T.ink[900], borderRadius: 16, overflow: "hidden",
      boxShadow: "0 30px 60px -20px rgba(0,0,0,0.4)"
    }}>
      <div style={{ padding: "18px 22px", borderBottom: `1px solid ${T.border.subtle}`,
        display: "flex", justifyContent: "space-between", alignItems: "center" }}>
        <Eyebrow>Assessment · {domain.label}</Eyebrow>
        <Pill tone="neutral"><Mono style={{ fontSize: 10 }}>Locked · 24 Apr 2026</Mono></Pill>
      </div>
      <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr" }}>
        <div style={{ background: T.paper.sunken, padding: "22px" }}>
          <Eyebrow tone={T.accent[500]}>Delegate</Eyebrow>
          <div style={{ marginTop: 12 }}><RatingScale value={r.delegate} /></div>
          <div style={{ fontFamily: T.font.sans, fontSize: 13, lineHeight: 1.5, color: T.ink[700], marginTop: 14, textWrap: "pretty" }}>
            {r.anchor}
          </div>
        </div>
        <div style={{ padding: "22px", borderLeft: `1px solid ${T.border.subtle}` }}>
          <Eyebrow>Referee self-assessment</Eyebrow>
          <div style={{ marginTop: 12 }}><RatingScale value={r.ref} color={T.accent[300]} /></div>
          <div style={{ fontFamily: T.font.sans, fontSize: 13, lineHeight: 1.5, color: T.ink[500], marginTop: 14, fontStyle: "italic", textWrap: "pretty" }}>
            "Felt my positioning slipped late. Want to work on Q3 conditioning."
          </div>
        </div>
      </div>
      <div style={{ padding: "18px 22px", background: T.paper.warm, borderTop: `1px solid ${T.border.subtle}`,
        display: "flex", justifyContent: "space-between", alignItems: "center", gap: 16 }}>
        <div>
          <Eyebrow>Gap</Eyebrow>
          <Mono style={{ fontSize: 18, fontWeight: 700, color: T.ink[900], display: "block", marginTop: 2 }}>
            {r.delegate > r.ref ? "+" : ""}{r.delegate - r.ref}
          </Mono>
        </div>
        <div>
          <Eyebrow>Trend · last 5 games</Eyebrow>
          <Sparkline values={[2, 3, 3, 4, r.delegate]} />
        </div>
        <div>
          <Eyebrow>Weighted overall</Eyebrow>
          <Mono style={{ fontSize: 18, fontWeight: 700, color: T.success.fg, display: "block", marginTop: 2 }}>
            {(r.delegate * 1.6 + 1).toFixed(1)} / 10
          </Mono>
        </div>
      </div>
    </div>);

};

const Sparkline = ({ values }) => {
  const max = Math.max(...values);
  return (
    <svg width="100" height="24" viewBox="0 0 100 24" style={{ display: "block", marginTop: 4 }}>
      <polyline
        fill="none" stroke={T.accent[500]} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"
        points={values.map((v, i) => `${i / (values.length - 1) * 100},${24 - v / max * 22}`).join(" ")} />
      
      {values.map((v, i) =>
      <circle key={i} cx={i / (values.length - 1) * 100} cy={24 - v / max * 22} r="2.5" fill={T.accent[500]} />
      )}
    </svg>);

};

// =========================================================================
// About
// =========================================================================
const About = () =>
<section data-screen-label="05 About" id="about" style={{ padding: "120px 32px" }}>
    <div style={{ maxWidth: 760, margin: "0 auto", textAlign: "center" }}>
      <Eyebrow>About</Eyebrow>
      <h2 style={{ fontFamily: T.font.sans, fontWeight: 700, fontSize: 44, lineHeight: 1.05,
      letterSpacing: "-0.025em", color: T.ink[900], margin: "16px 0 32px" }}>
        Built by the Community, <em style={{ fontStyle: "italic", color: T.accent[500], fontWeight: 600 }}>for our game.</em>
      </h2>
      <p style={{ fontFamily: T.font.sans, fontSize: 19, lineHeight: 1.6, color: T.ink[700], textWrap: "pretty", margin: "0 0 24px" }}>PoloDeck was built in Australia by leading referees and coaches with over 30 years of water polo experience. Sick and tired of not getting real-time, evidence-based feedback and insight, and frustrated by paper-based, after-the-fact assessments that seemed out of touch with the game.

    </p>
      <p style={{ fontFamily: T.font.sans, fontSize: 19, lineHeight: 1.6, color: T.ink[700], textWrap: "pretty", margin: "0 0 32px" }}>Every feature has been tested in live water polo games and the feedback process has been validated by experienced referees, delegates, coaches & players. The goal is simple: replace memory and hand-scribbled notes with structured, respectful, evidence-based feedback that actually helps everyone develop in the game.

    </p>
      <Mono style={{ fontSize: 13, color: T.ink[400], letterSpacing: "0.05em" }}>
        Made in Sydney · Used on real games every weekend
      </Mono>
    </div>
  </section>;


// =========================================================================
// Pricing (placeholder — coming soon)
// =========================================================================
const Pricing = () =>
<section data-screen-label="06 Pricing" id="pricing" style={{ padding: "100px 32px", background: T.paper.sunken, borderTop: `1px solid ${T.border.subtle}` }}>
    <div style={{ maxWidth: 1200, margin: "0 auto" }}>
      <div style={{ maxWidth: 720, marginBottom: 48, textAlign: "center", marginInline: "auto" }}>
        <Eyebrow>Pricing</Eyebrow>
        <h2 style={{ fontFamily: T.font.sans, fontWeight: 700, fontSize: 44, lineHeight: 1.05,
        letterSpacing: "-0.025em", color: T.ink[900], margin: "16px 0 14px" }}>
          Pricing coming soon.
        </h2>
        <p style={{ fontFamily: T.font.sans, fontSize: 18, lineHeight: 1.55, color: T.ink[500], margin: 0, textWrap: "pretty" }}>
          Join now to be an early tester. Free during the soak period — help shape the platform that's defining how referees develop.
        </p>
      </div>
      <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 20 }}>
        {[
      { name: "Early tester", note: "Available now",
        features: ["Unlimited games", "All four assessment domains", "Locked share reports", "Voice dictation", "Priority feedback channel"],
        cta: "Try free", featured: true },
      { name: "Club", note: "Q3 2026",
        features: ["Everything in Early tester", "Up to 10 delegates", "Multi-referee dashboards", "Club-level competitions", "Branded report links"],
        cta: "Join waitlist" },
      { name: "Federation", note: "Q4 2026",
        features: ["Everything in Club", "Master delegate view", "State / region hierarchy", "Bulk import / SSO", "Annual development reports"],
        cta: "Talk to us" }].
      map((t) =>
      <div key={t.name} style={{
        background: t.featured ? T.ink[900] : T.paper.card,
        color: t.featured ? "#fff" : T.ink[900],
        borderRadius: 16, padding: "30px 28px",
        boxShadow: T.shadow.card, display: "flex", flexDirection: "column", gap: 18
      }}>
            <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}>
              <Eyebrow tone={t.featured ? T.accent[300] : T.ink[400]}>{t.name}</Eyebrow>
              <Pill tone={t.featured ? "neutral" : "neutral"}
          style={t.featured ? { background: "rgba(255,255,255,0.1)", color: "rgba(255,255,255,0.85)" } : {}}>
                <Mono style={{ fontSize: 10 }}>{t.note}</Mono>
              </Pill>
            </div>
            <div style={{ fontFamily: T.font.sans, fontSize: 36, fontWeight: 700, letterSpacing: "-0.03em",
          color: t.featured ? "#fff" : T.ink[900], paddingBottom: 16,
          borderBottom: `1px solid ${t.featured ? "rgba(255,255,255,0.16)" : T.border.subtle}` }}>
              {t.featured ? "Free" : "TBD"}
              <span style={{ fontSize: 14, fontWeight: 500, color: t.featured ? "rgba(255,255,255,0.55)" : T.ink[400], marginLeft: 8 }}>
                {t.featured ? "during beta testing" : ""}
              </span>
            </div>
            <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "flex", flexDirection: "column", gap: 10, flex: 1 }}>
              {t.features.map((f) =>
          <li key={f} style={{ display: "flex", gap: 10,
            fontFamily: T.font.sans, fontSize: 14,
            color: t.featured ? "rgba(255,255,255,0.88)" : T.ink[700] }}>
                  <span style={{ color: t.featured ? T.accent[300] : T.success.fg, flexShrink: 0 }}>✓</span>{f}
                </li>
          )}
            </ul>
            <Btn variant={t.featured ? "onDark" : "primary"}
        href={t.featured ? APP_URL : undefined}
        style={{ marginTop: "auto" }}>
              {t.cta} <span aria-hidden>→</span>
            </Btn>
          </div>
      )}
      </div>
    </div>
  </section>;


// =========================================================================
// FAQ
// =========================================================================
const FAQ = () => {
  const items = [
  ["Do I need to install anything?",
  "No. PoloDeck is a Progressive Web App — it runs in any modern browser. On iOS or Android you can add it to your home screen for a fullscreen, app-like experience, but a regular browser tab works just as well."],
  ["Does it really work offline at the pool?",
  "Yes. Everything you log saves to your phone first, then syncs to the cloud when you get a connection. Patchy wifi inside venues won't lose your work — even if you log a whole game offline, it'll sync the moment you're back online."],
  ["What does the referee actually see?",
  "When you lock a game, PoloDeck generates a secure read-only link. The referee opens it in any browser — no login, no account — and sees their full report: every logged decision, your verdicts, the four-domain assessment, and trend over time."],
  ["What's the assessment based on?",
  "The four-domain framework — positioning, communication, decision-making, game management — is informed by published referee development research from World Aquatics, FIFA and World Rugby. Each domain has behaviour-anchored scales rather than a vague 1–10."],
  ["Who has access to my data?",
  "Only you and the referees you explicitly share locked reports with. Games are private to your account by default. We don't sell data or run ads."],
  ["Will it work for water polo formats outside Australia?",
  "Yes. The data model handles any FINA / World Aquatics ruleset. Competition presets are configurable, so a federation can roll out their own age groups, periods and shot-clock variants."]];

  const [open, setOpen] = useState(0);
  return (
    <section data-screen-label="07 FAQ" id="faq" style={{ padding: "100px 32px" }}>
      <div style={{ maxWidth: 880, margin: "0 auto" }}>
        <div style={{ marginBottom: 48, textAlign: "center" }}>
          <Eyebrow>Questions</Eyebrow>
          <h2 style={{ fontFamily: T.font.sans, fontWeight: 700, fontSize: 44, lineHeight: 1.05,
            letterSpacing: "-0.025em", color: T.ink[900], margin: "16px 0 0" }}>
            Asked &amp; <em style={{ fontStyle: "italic", color: T.accent[500], fontWeight: 600 }}>answered.</em>
          </h2>
        </div>
        <div>
          {items.map(([q, a], i) =>
          <div key={q} style={{
            borderTop: `1px solid ${T.border.subtle}`,
            borderBottom: i === items.length - 1 ? `1px solid ${T.border.subtle}` : "none"
          }}>
              <button
              onClick={() => setOpen(open === i ? -1 : i)}
              style={{
                width: "100%", textAlign: "left", background: "transparent", border: "none",
                padding: "26px 4px", cursor: "pointer",
                display: "flex", justifyContent: "space-between", alignItems: "center", gap: 24
              }}>
              
                <span style={{ fontFamily: T.font.sans, fontSize: 18, fontWeight: 600,
                color: T.ink[900], letterSpacing: "-0.01em" }}>{q}</span>
                <span style={{ width: 28, height: 28, borderRadius: 8,
                background: open === i ? T.accent[500] : T.paper.sunken,
                color: open === i ? "#fff" : T.ink[500],
                display: "flex", alignItems: "center", justifyContent: "center",
                flexShrink: 0,
                transform: open === i ? "rotate(45deg)" : "rotate(0)",
                transition: "transform 220ms ease, background 200ms ease, color 200ms ease",
                fontSize: 18, fontWeight: 600 }}>+</span>
              </button>
              <div style={{
              maxHeight: open === i ? 240 : 0, overflow: "hidden",
              transition: "max-height 280ms ease, padding 280ms ease, opacity 280ms ease",
              opacity: open === i ? 1 : 0,
              padding: open === i ? "0 4px 26px" : "0 4px"
            }}>
                <p style={{ fontFamily: T.font.sans, fontSize: 15.5, lineHeight: 1.6,
                color: T.ink[500], margin: 0, maxWidth: 720, textWrap: "pretty" }}>
                  {a}
                </p>
              </div>
            </div>
          )}
        </div>
      </div>
    </section>);

};

// =========================================================================
// Contact (collapsible form)
// =========================================================================
const Contact = () => {
  const [open, setOpen] = useState(false);
  const [sent, setSent] = useState(false);
  return (
    <section style={{ padding: "0 32px 100px" }}>
      <div style={{ maxWidth: 880, margin: "0 auto",
        background: T.paper.card, borderRadius: 16,
        boxShadow: T.shadow.card, overflow: "hidden" }}>
        <button onClick={() => setOpen(!open)} style={{
          width: "100%", textAlign: "left", padding: "26px 28px",
          background: "transparent", border: "none", cursor: "pointer",
          display: "flex", justifyContent: "space-between", alignItems: "center", gap: 24
        }}>
          <div>
            <Eyebrow>Contact</Eyebrow>
            <div style={{ fontFamily: T.font.sans, fontSize: 20, fontWeight: 700, color: T.ink[900], marginTop: 6, letterSpacing: "-0.015em" }}>
              Got a question, feedback, or want to bring PoloDeck to your federation?
            </div>
          </div>
          <span style={{
            width: 32, height: 32, borderRadius: 10, flexShrink: 0,
            background: open ? T.accent[500] : T.accent.tint,
            color: open ? "#fff" : T.accent[500],
            display: "flex", alignItems: "center", justifyContent: "center",
            fontSize: 20, fontWeight: 600,
            transform: open ? "rotate(45deg)" : "rotate(0)",
            transition: "all 220ms ease"
          }}>+</span>
        </button>
        <div style={{
          maxHeight: open ? 600 : 0, overflow: "hidden",
          transition: "max-height 320ms ease"
        }}>
          <div style={{ padding: "0 28px 28px" }}>
            {sent ?
            <div style={{ padding: "32px 0", textAlign: "center" }}>
                <Pill tone="success" style={{ fontSize: 12, padding: "5px 12px" }}>✓ Message sent</Pill>
                <div style={{ fontFamily: T.font.sans, fontSize: 16, color: T.ink[700], marginTop: 14 }}>
                  Thanks. We'll be in touch within 24 hours.
                </div>
              </div> :

            <form onSubmit={(e) => {e.preventDefault();setSent(true);}} style={{ display: "grid", gap: 14 }}>
                <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 14 }}>
                  <Input label="Your name" placeholder="Jane Delegate" />
                  <Input label="Email" type="email" placeholder="jane@waterpolo.org.au" />
                </div>
                <Input label="Federation / club (optional)" placeholder="Water Polo NSW" />
                <Textarea label="Message" placeholder="Tell us about your use case, feedback, or any questions about rolling PoloDeck out at your federation." />
                <div style={{ display: "flex", justifyContent: "flex-end", marginTop: 6 }}>
                  <Btn variant="primary">Send message <span aria-hidden>→</span></Btn>
                </div>
              </form>
            }
          </div>
        </div>
      </div>
    </section>);

};

const Input = ({ label, type = "text", placeholder }) =>
<label style={{ display: "flex", flexDirection: "column", gap: 6 }}>
    <Eyebrow>{label}</Eyebrow>
    <input type={type} placeholder={placeholder} style={{
    fontFamily: T.font.sans, fontSize: 15, color: T.ink[900],
    padding: "12px 14px", borderRadius: 12,
    border: `1px solid ${T.border.medium}`, background: T.paper.sunken,
    outline: "none", transition: "border-color 120ms ease"
  }}
  onFocus={(e) => e.target.style.borderColor = T.accent[500]}
  onBlur={(e) => e.target.style.borderColor = T.border.medium} />
  
  </label>;


const Textarea = ({ label, placeholder }) =>
<label style={{ display: "flex", flexDirection: "column", gap: 6 }}>
    <Eyebrow>{label}</Eyebrow>
    <textarea placeholder={placeholder} rows={4} style={{
    fontFamily: T.font.sans, fontSize: 15, color: T.ink[900],
    padding: "12px 14px", borderRadius: 12,
    border: `1px solid ${T.border.medium}`, background: T.paper.sunken,
    outline: "none", resize: "vertical", transition: "border-color 120ms ease"
  }}
  onFocus={(e) => e.target.style.borderColor = T.accent[500]}
  onBlur={(e) => e.target.style.borderColor = T.border.medium} />
  
  </label>;


// =========================================================================
// Final CTA + Footer
// =========================================================================
const FinalCTA = () =>
<section style={{ padding: "100px 32px", background: T.accent[700], color: "#fff" }}>
    <div style={{ maxWidth: 820, margin: "0 auto", textAlign: "center" }}>
      <h2 style={{ fontFamily: T.font.sans, fontWeight: 700, fontSize: "clamp(40px, 5vw, 56px)",
      lineHeight: 1.05, letterSpacing: "-0.025em", margin: 0, color: "#fff", textWrap: "balance" }}>
        Ready to put it to the test?
      </h2>
      <p style={{ fontFamily: T.font.sans, fontSize: 18, lineHeight: 1.55,
      color: "rgba(255,255,255,0.78)", marginTop: 18, marginBottom: 32, textWrap: "pretty" }}>
        Free to use. No install — runs in any modern browser. Pool-side tested.
      </p>
      <Btn variant="onDark" href={APP_URL} style={{ padding: "16px 28px", fontSize: 16 }}>
        Open PoloDeck <span aria-hidden>→</span>
      </Btn>
    </div>
  </section>;


const Footer = () =>
<footer style={{ padding: "44px 32px 32px", background: T.paper.bg, borderTop: `1px solid ${T.border.subtle}` }}>
    <div style={{ maxWidth: 1200, margin: "0 auto", display: "flex",
    justifyContent: "space-between", alignItems: "center", gap: 24, flexWrap: "wrap" }}>
      <div style={{ display: "flex", alignItems: "center", gap: 12 }}>
        <Lockup height={36} cropped />
        <Mono style={{ fontSize: 12, color: T.ink[400] }}>© 2026</Mono>
      </div>
      <div style={{ display: "flex", gap: 28, alignItems: "center" }}>
        <a href={APP_URL} style={{ fontFamily: T.font.sans, fontSize: 13, fontWeight: 500, color: T.ink[500], textDecoration: "none" }}>Open the app</a>
        <a href="#privacy" style={{ fontFamily: T.font.sans, fontSize: 13, fontWeight: 500, color: T.ink[500], textDecoration: "none" }}>Privacy</a>
        <a href="#terms" style={{ fontFamily: T.font.sans, fontSize: 13, fontWeight: 500, color: T.ink[500], textDecoration: "none" }}>Terms</a>
      </div>
    </div>
  </footer>;


// =========================================================================
// Tweaks
// =========================================================================
const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
  "accentHex": "#1b4fa8",
  "density": "comfy",
  "hideMockup": false
} /*EDITMODE-END*/;

// =========================================================================
// Root
// =========================================================================
const App = () => {
  const [tweaks, setTweak] = window.useTweaks ? window.useTweaks(TWEAK_DEFAULTS) : [TWEAK_DEFAULTS, () => {}];

  useEffect(() => {
    document.documentElement.style.setProperty("--accent", tweaks.accentHex || T.accent[500]);
  }, [tweaks]);

  const TweaksPanel = window.TweaksPanel;
  const TweakSection = window.TweakSection;
  const TweakColor = window.TweakColor;
  const TweakRadio = window.TweakRadio;
  const TweakToggle = window.TweakToggle;

  return (
    <div style={{ background: T.paper.bg, color: T.ink[700], minHeight: "100vh", fontFamily: T.font.sans }}>
      <Nav />
      <Hero />
      <Features />
      <WhoItsFor />
      <HowItWorks />
      <AssessmentPreview />
      <About />
      <Pricing />
      <FAQ />
      <Contact />
      <FinalCTA />
      <Footer />
      {TweaksPanel &&
      <TweaksPanel title="Tweaks">
          <TweakSection title="Accent">
            <TweakColor value={tweaks.accentHex} onChange={(v) => setTweak("accentHex", v)} />
          </TweakSection>
        </TweaksPanel>
      }
    </div>);

};

ReactDOM.createRoot(document.getElementById("root")).render(<App />);