// Sales Page v2 — Sections 4 through 10
// All sections defined here, wired into App() via window exports at the bottom.

// Proxy so tokens are read lazily at render time (main file sets window.SP_TOKENS)
const S = new Proxy({}, { get: (_, k) => window.SP_TOKENS[k] });

// Reveal-on-scroll hook + component — subtle fade + lift as element enters viewport
function useReveal() {
  const ref = React.useRef(null);
  const [visible, setVisible] = React.useState(false);
  React.useEffect(() => {
    if (!ref.current) return;
    const el = ref.current;
    const io = new IntersectionObserver((entries) => {
      entries.forEach(e => {
        if (e.isIntersecting) { setVisible(true); io.unobserve(el); }
      });
    }, { threshold: 0.12, rootMargin: '0px 0px -60px 0px' });
    io.observe(el);
    return () => io.disconnect();
  }, []);
  return [ref, visible];
}

function Reveal({ children, delay = 0, y = 24, style = {} }) {
  const [ref, visible] = useReveal();
  return (
    <div ref={ref} style={{
      opacity: visible ? 1 : 0,
      transform: visible ? 'translateY(0)' : `translateY(${y}px)`,
      transition: `opacity 700ms cubic-bezier(.2,.8,.2,1) ${delay}ms, transform 800ms cubic-bezier(.2,.8,.2,1) ${delay}ms`,
      ...style,
    }}>
      {children}
    </div>
  );
}

// ─────────────────────────────────────────────────────────────
// Shared small building blocks
// ─────────────────────────────────────────────────────────────

// Generic image placeholder — warm dashed frame with a caption hint.
// HANDOFF: pass `src="path/to/real.jpg"` to replace the placeholder with a real image.
function ImgPlaceholder({ aspect = '16 / 10', label, hint, bg = 'rgba(255,255,255,0.7)', border = S.rule, dark = false, kind = 'image', src, alt = '' }) {
  if (src) {
    return (
      <img
        src={src} alt={alt}
        style={{ width:'100%', aspectRatio: aspect, objectFit:'cover', borderRadius: 3, display:'block' }}
      />
    );
  }
  return (
    <div data-placeholder="true" data-placeholder-kind={kind} data-placeholder-hint={hint} style={{
      width:'100%', aspectRatio: aspect,
      background: bg,
      border: `1px dashed ${border}`,
      borderRadius: 3,
      display:'flex', flexDirection:'column', alignItems:'center', justifyContent:'center',
      padding: 20, textAlign:'center', position:'relative', overflow:'hidden',
    }}>
      <div style={{
        fontFamily: S.sans, fontSize: 10, letterSpacing:'0.18em',
        textTransform:'uppercase', color: dark ? 'rgba(255,255,255,0.7)' : S.muted, fontWeight:600,
        marginBottom: 6,
      }}>
        {label || 'Image · placeholder'}
      </div>
      {hint && (
        <div style={{
          fontFamily: S.serif, fontStyle:'italic', fontSize: 14,
          color: dark ? 'rgba(255,255,255,0.88)' : S.body, maxWidth: 320, lineHeight: 1.4,
        }}>
          {hint}
        </div>
      )}
    </div>
  );
}

function PrimaryButton({ children, color = S.accent }) {
  return (
    <button data-sp-cta style={{
      background: color, color: '#f6efdd', border:`1px solid ${S.accentInk}`,
      padding:'16px 36px', fontSize:14, fontWeight:600, letterSpacing:'0.14em',
      textTransform:'uppercase', fontFamily: S.sans,
      borderRadius: 2, cursor:'pointer',
      boxShadow:`0 2px 0 ${S.accentInk}, 0 6px 14px -10px rgba(60,30,15,0.2)`,
      display:'inline-flex', alignItems:'center', gap:12,
      transition: 'transform 180ms ease, box-shadow 180ms ease',
    }}>
      {children}
    </button>
  );
}

// Punchier CTA button — softened, more typeset, less app-UI
function BigCta({ children, color, href = 'https://members.creativepianoacademy.com/cart-bach/' }) {
  const bg = color || S.olive;
  const stroke = '#4b4a1c';
  const [hover, setHover] = React.useState(false);
  return (
    <a data-sp-cta href={href}
      onMouseEnter={()=>setHover(true)}
      onMouseLeave={()=>setHover(false)}
      style={{
        position:'relative', overflow:'hidden',
        background: bg,
        color: '#f6efdd', border:'none', textDecoration:'none',
        padding:'20px 48px', fontSize:15, fontWeight:600, letterSpacing:'0.14em',
        textTransform:'uppercase', fontFamily: S.sans,
        borderRadius: 2, cursor:'pointer',
        boxShadow: hover
          ? `0 2px 0 ${stroke}, 0 14px 28px -14px rgba(60,60,20,0.3)`
          : `0 2px 0 ${stroke}, 0 6px 18px -10px rgba(60,60,20,0.22)`,
        display:'inline-flex', alignItems:'center', gap:12,
        transform: hover ? 'translateY(-1px)' : 'translateY(0)',
        transition: 'transform 220ms ease, box-shadow 220ms ease',
      }}
    >
      <span style={{ position:'relative', zIndex: 1 }}>{children}</span>
    </a>
  );
}

// Section eyebrow — small kicker label used above each section's headline
function Eyebrow({ children, color, dark = false }) {
  const c = color || (dark ? '#e8b89c' : S.accent);
  return (
    <div style={{ display:'flex', alignItems:'center', gap:14, justifyContent:'center', marginBottom: 22 }}>
      <div style={{ width:28, height:1, background: c }}/>
      <div style={{ fontSize:12, letterSpacing:'0.22em', textTransform:'uppercase', color: c, fontWeight:500, fontFamily: S.sans }}>
        {children}
      </div>
      <div style={{ width:28, height:1, background: c }}/>
    </div>
  );
}

// ─────────────────────────────────────────────────────────────
// §4 Inside the course
// Product reveal + three alternating image/text rows
// ─────────────────────────────────────────────────────────────
function FeatureRow({ n, title, body, hint, flip = false, imgAspect = '4 / 3' }) {
  return (
    <Reveal>
    <div data-sp-grid-2 style={{
      display:'grid',
      gridTemplateColumns: flip ? '1fr 1fr' : '1fr 1fr',
      gap: 56, alignItems:'center',
      direction: flip ? 'rtl' : 'ltr',
    }}>
      <div style={{ direction:'ltr' }}>
        <ImgPlaceholder aspect={imgAspect} hint={hint} label={`Feature ${n} · placeholder`}/>
      </div>
      <div style={{ direction:'ltr' }}>
        <div style={{
          fontFamily: S.serif, fontStyle:'italic', color: S.accent,
          fontSize: 22, fontWeight: 400, marginBottom: 8,
        }}>
          {String(n).padStart(2,'0')}
        </div>
        <h3 data-sp-h3 style={{
          fontFamily: S.serif, fontWeight: 500,
          fontSize: 34, lineHeight: 1.2, color: S.ink,
          margin: '0 0 18px', letterSpacing: -0.3, textWrap:'pretty',
        }}>
          {title}
        </h3>
        <p data-sp-body style={{
          fontFamily: S.sans, fontSize: 17, lineHeight: 1.75,
          color: S.body, margin: 0, maxWidth: 520,
        }}>
          {body}
        </p>
      </div>
    </div>
    </Reveal>
  );
}

function Section4() {
  return (
    <section data-sp-section="s4" style={{
      background: '#faf7ee', padding: '104px 60px 96px',
      fontFamily: S.sans, position:'relative', overflow:'hidden',
    }}>
      <window.SP_Blemish fill="#efe6d4" opacity={0.18} style={{ width: 620, height: 620, top: -160, left: -240 }}/>
      <window.SP_Blemish fill="#f0dfcf" opacity={0.14} style={{ width: 520, height: 520, bottom: -180, right: -200 }}/>

      {/* Decorative sheet fragments */}
      <span data-sp-decor><window.SP_SheetFrag n={3} width={260} rotate={8} opacity={0.09} style={{ top: 240, right: 28 }}/></span>
      <span data-sp-decor><window.SP_SheetFrag n={7} width={240} rotate={-6} opacity={0.08} style={{ bottom: 180, left: 32 }}/></span>
      <span data-sp-decor><window.SP_SheetFrag src="eighthnote" width={110} rotate={-8} opacity={0.08} style={{ top: 760, left: 40 }}/></span>

      <div style={{ maxWidth: 840, margin:'0 auto 72px', textAlign:'center', position:'relative' }}>
        <h2 data-sp-h2 style={{
          fontFamily: S.serif, fontWeight: 400,
          fontSize: 44, lineHeight: 1.2, color: S.ink,
          margin: '0 0 20px', letterSpacing: -0.5, textWrap:'pretty',
        }}>
          Inside the course, everything is laid out to help you learn the piece in a calm, practical, step-by-step way.
        </h2>
        <p style={{
          fontFamily: S.serif, fontStyle:'italic', fontSize: 20, color: S.muted,
          margin: 0,
        }}>
          Here's what that looks like...
        </p>
      </div>

      {/* Product reveal — big, wide hero shot of the course interface */}
      <div style={{ maxWidth: 1080, margin: '0 auto 96px', position:'relative' }}>
        <ImgPlaceholder
          aspect="16 / 9"
          label="Course interface · product reveal"
          hint="Full-bleed mockup of the course dashboard or lesson player — the main hero image for this section. Shows lesson list, video, and play-along tool in one shot."
        />
      </div>

      {/* Three alternating feature rows */}
      <div style={{ maxWidth: 1100, margin: '0 auto', display:'flex', flexDirection:'column', gap: 96 }}>
        <FeatureRow
          n={1}
          title="13 Focused Core Lessons"
          body="I guide you through Prelude in C across 13 clear lessons, covering the piece bar by bar in small, manageable sections so you always know what to work on next."
          hint="Screenshot of the 13-lesson list/outline — numbered, with thumbnails and short titles. Should feel like a well-organised course index."
        />
        <FeatureRow
          n={2}
          flip
          title="Play-Along Software To Practise With"
          body="Alongside the lessons, you can use the play-along software to slow things down, speed them up, repeat sections, and practise at a pace that works for you."
          hint="Screenshot of the play-along software — tempo slider, loop controls, section repeat markers. Hero screenshot of the tool itself."
        />
        <FeatureRow
          n={3}
          title="4 Full Performances To Work From"
          body="You'll also get four full performances of the piece, including two with a metronome to help you join the sections together steadily as you learn, and two freer versions so you can hear more of the flow and musical expression."
          hint="Grid or stack of the four performance thumbnails — e.g. a dark video-frame style with a small ♪ icon. Two labelled ‘with metronome’, two ‘expressive’."
        />
      </div>

      {/* Closing bridge */}
      <div style={{ maxWidth: 720, margin: '96px auto 0', textAlign:'center', position:'relative' }}>
        <div style={{
          fontFamily: S.script, fontWeight: 500,
          fontSize: 30, lineHeight: 1.3, color: S.ink, textWrap:'pretty',
        }}>
          But there is another layer to the course that makes it much more than a simple walkthrough.
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────
// §5 Deeper inside the course — DARK band for contrast
// ─────────────────────────────────────────────────────────────
function DeepBullet({ children }) {
  return (
    <li style={{
      display:'flex', gap: 14, alignItems:'flex-start',
      margin: '0 0 14px',
    }}>
      <span style={{
        flexShrink: 0, marginTop: 10, width: 6, height: 6, borderRadius:'50%',
        background: '#e8b89c',
      }}/>
      <span style={{
        fontFamily: S.sans, fontSize: 16, lineHeight: 1.65,
        color: 'rgba(251,247,239,0.95)',
      }}>{children}</span>
    </li>
  );
}

function DeepBlock({ number, title, children, hint, accent = true, dark = true }) {
  return (
    <Reveal>
    <div style={{
      background: 'rgba(255,255,255,0.035)',
      border: '1px solid rgba(255,255,255,0.07)',
      padding: '36px 36px 40px',
      borderRadius: 3,
      display:'flex', flexDirection:'column', gap: 22,
    }}>
      <ImgPlaceholder
        aspect="16 / 10"
        label={`Lesson ${number} · placeholder`}
        hint={hint}
        bg="rgba(255,255,255,0.04)"
        border="rgba(255,255,255,0.14)"
        dark
      />
      <div style={{
        fontFamily: S.serif, fontStyle:'italic', color:'#e8b89c',
        fontSize: 20, fontWeight: 400,
      }}>
        Lesson · {String(number).padStart(2,'0')}
      </div>
      <h3 data-sp-h3 style={{
        fontFamily: S.serif, fontWeight: 500,
        fontSize: 26, lineHeight: 1.25, color:'#fbf7ef',
        margin: 0, letterSpacing: -0.2, textWrap:'pretty',
      }}>
        {title}
      </h3>
      <div style={{ fontFamily: S.sans, fontSize: 16, lineHeight: 1.75, color: 'rgba(251,247,239,0.92)' }}>
        {children}
      </div>
    </div>
    </Reveal>
  );
}

function Section5() {
  return (
    <section data-sp-section="s5" style={{
      background: '#1c1a17',
      color:'#fbf7ef',
      padding: '112px 60px 112px',
      fontFamily: S.sans, position:'relative', overflow:'hidden',
    }}>
      {/* faint warm glow in the corners */}
      <window.SP_Blemish fill="#b8533a" opacity={0.18} style={{ width: 700, height: 700, top: -260, right: -260 }}/>
      <window.SP_Blemish fill="#6b4a38" opacity={0.22} style={{ width: 620, height: 620, bottom: -240, left: -220 }}/>

      {/* Faint sheet fragment in margin, inverted for dark bg */}
      <span data-sp-decor><window.SP_SheetFrag n={1} width={320} rotate={-5} opacity={0.06} dark style={{ top: 180, left: 24 }}/></span>
      <span data-sp-decor><window.SP_SheetFrag n={8} width={260} rotate={6} opacity={0.05} dark style={{ bottom: 220, right: 28 }}/></span>

      <div style={{ maxWidth: 820, margin:'0 auto 72px', textAlign:'center', position:'relative' }}>
        <h2 data-sp-h2 style={{
          fontFamily: S.serif, fontWeight: 400,
          fontSize: 44, lineHeight: 1.2, color:'#fbf7ef',
          margin: 0, letterSpacing: -0.5, textWrap:'pretty',
        }}>
          Here's where we move beyond simply learning the notes, and start exploring the extra depth, expression, and possibility inside Prelude in C.
        </h2>
      </div>

      {/* Block 1 — From Notes to Music (wider, because it has bullets) */}
      <div style={{ maxWidth: 1100, margin: '0 auto 64px', position:'relative' }}>
        <div data-sp-grid-2 style={{
          background:'rgba(255,255,255,0.035)',
          border:'1px solid rgba(255,255,255,0.07)',
          padding: '48px 56px 52px',
          borderRadius: 3,
          display:'grid',
          gridTemplateColumns:'1fr 1.2fr', gap: 56,
          alignItems:'center',
        }}>
          <div>
            <ImgPlaceholder
              aspect="4 / 5"
              label="Flagship lesson · placeholder"
              hint="Portrait-orientation hero image. Could be a close-up of hands on keys with a phrase arc overlay, or an abstract ‘mountain and cliff’ dynamics illustration in warm ink."
              bg="rgba(255,255,255,0.04)"
              border="rgba(255,255,255,0.14)"
              dark
            />
          </div>
          <div>
            <div style={{
              fontFamily: S.serif, fontStyle:'italic', color:'#e8b89c',
              fontSize: 20, marginBottom: 10,
            }}>
              Lesson · 01
            </div>
            <h3 data-sp-h3 style={{
              fontFamily: S.serif, fontWeight: 500,
              fontSize: 32, lineHeight: 1.2, color:'#fbf7ef',
              margin: '0 0 18px', letterSpacing: -0.3, textWrap:'pretty',
            }}>
              From Notes to Music – Elevating Your Performance of Bach's Prelude in C
            </h3>
            <p style={{
              fontFamily: S.sans, fontSize: 17, lineHeight: 1.7,
              color:'rgba(251,247,239,0.95)', margin: '0 0 22px',
            }}>
              This lesson goes right to the heart of what most people find hardest about this piece... not getting through the notes, but making it actually sound musical, expressive, and alive.
            </p>
            <div style={{
              fontFamily: S.sans, fontSize: 14, letterSpacing:'0.14em', textTransform:'uppercase',
              color:'#e8b89c', fontWeight: 600, marginBottom: 16,
            }}>
              Inside it, I show you how to:
            </div>
            <ul style={{ listStyle:'none', padding: 0, margin: 0 }}>
              <DeepBullet>bring out the hidden melody in the piece so your playing sounds more shaped and refined right away</DeepBullet>
              <DeepBullet>avoid that flat, monotonous sound by using my simple "mountain" and "cliff" ideas to shape the dynamics and flow</DeepBullet>
              <DeepBullet>understand what phrasing actually means in practical terms, so the music starts to move more naturally from one idea to the next</DeepBullet>
              <DeepBullet>spot the tension and release points in the piece, and use them to make the Prelude feel far more expressive and alive</DeepBullet>
              <DeepBullet>let the music breathe and connect more naturally, so it feels less like a chain of chords and more like a real musical journey</DeepBullet>
              <DeepBullet>play with more feeling and instinct, in a way that can be developed and trained rather than feeling vague or out of reach</DeepBullet>
            </ul>
          </div>
        </div>
      </div>

      {/* Blocks 2 & 3 side-by-side */}
      <div style={{
        maxWidth: 1100, margin: '0 auto',
        display:'grid', gridTemplateColumns:'1fr 1fr', gap: 28, position:'relative',
      }}>
        <DeepBlock
          number="2"
          title="To Pedal or Not to Pedal? - How To Play The Piece Without The Sustain Pedal"
          hint="A close-up of a foot on the sustain pedal, or two side-by-side score snippets (‘with pedal’ / ‘without pedal’) to visualise the choice."
        >
          <p style={{ margin:'0 0 14px' }}>
            It's completely normal to want to play this piece with the sustain pedal first as it gives you that smooth, natural and rewarding sound right from the start.
          </p>
          <p style={{ margin:'0 0 14px' }}>
            Thats why we use it. This may be enough for you and if so, thats completely fine.
          </p>
          <p style={{ margin:'0 0 14px' }}>
            However, if you did want to explore what this piece has to offer without using the pedal... I give you everything you need to explore the deeper layers of finger control, and get that legato and smooth sound without relying on the pedal.
          </p>
          <p style={{ margin: 0, fontStyle:'italic', color:'#e8b89c' }}>
            It's truly rewarding and could give you a deeper understanding and connection to the piece.
          </p>
        </DeepBlock>

        <DeepBlock
          number="3"
          title="Beyond Prelude In C - Ideas For Creativity, Experimentation and Play"
          hint="A loose, improvisational visual — e.g. a score with notes breaking free / scattering, or hands hovering freely above the keys. Signals ‘creative, experimental.’"
        >
          <p style={{ margin:'0 0 14px' }}>
            A lot of us spend time learning a piece, then just moving on. Never quite knowing how to use those skills in other areas of your playing.
          </p>
          <p style={{ margin:'0 0 14px', fontStyle:'italic', color:'#e8b89c' }}>
            This lesson helps change that.
          </p>
          <p style={{ margin: 0 }}>
            I show you how to take those skills, patterns and shapes you've spent all that time and energy developing inside Prelude in C... and use them in a free, creative way so you can create your own music and really internalise those skills so they become part of you.
          </p>
        </DeepBlock>
      </div>

      {/* Closing handoff */}
      <div style={{ maxWidth: 760, margin: '88px auto 0', textAlign:'center', position:'relative' }}>
        <p style={{
          fontFamily: S.serif, fontSize: 22, fontStyle:'italic', lineHeight: 1.5,
          color:'rgba(251,247,239,0.9)', margin: 0, textWrap:'pretty',
        }}>
          Taken together, these extra lessons make this a far richer piece study, helping you learn Prelude in C properly, play it more musically, and get far more value from the work you put in.
        </p>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────
// §6 Testimonials
// ─────────────────────────────────────────────────────────────
function TestimonialCard({ quote, name, role }) {
  return (
    <Reveal>
    <div style={{
      background: '#fffefb',
      padding: '36px 34px 32px',
      borderRadius: 3,
      boxShadow: '0 1px 0 rgba(0,0,0,0.04), 0 20px 60px -20px rgba(40,30,20,0.12)',
      display:'flex', flexDirection:'column', gap: 22,
    }}>
      <div style={{
        fontFamily: S.serif, fontSize: 64, lineHeight: 0.6, color: S.accent,
        opacity: 0.6, height: 26,
      }}>
        “
      </div>
      <p style={{
        fontFamily: S.serif, fontSize: 18, lineHeight: 1.55, color: S.ink,
        margin: 0, fontStyle:'italic', textWrap:'pretty', flex: 1,
      }}>
        Placeholder testimonial. A warm, specific quote about how the course helped this student feel the piece differently — 2–3 sentences, conversational.
      </p>
      <div style={{ display:'flex', alignItems:'center', gap: 14, marginTop: 8 }}>
        <div style={{
          width: 44, height: 44, borderRadius:'50%',
          background: S.accentSoft,
          display:'flex', alignItems:'center', justifyContent:'center',
          fontFamily: S.serif, fontWeight: 500, color: S.accent, fontSize: 16,
        }}>
          {name.split(' ').map(s=>s[0]).join('')}
        </div>
        <div>
          <div style={{ fontFamily: S.sans, fontSize: 14, fontWeight: 600, color: S.ink }}>
            {name}
          </div>
          <div style={{ fontFamily: S.sans, fontSize: 12, color: S.muted, letterSpacing:'0.05em' }}>
            {role}
          </div>
        </div>
      </div>
    </div>
    </Reveal>
  );
}

function Section6() {
  return (
    <section data-sp-section="s6" style={{
      background: '#faf7f0', padding: '88px 60px 88px',
      fontFamily: S.sans, position:'relative', overflow:'hidden',
      borderTop: `1px solid ${S.ruleSoft}`,
    }}>
      <window.SP_Blemish fill="#ead9c6" opacity={0.22} style={{ width: 520, height: 520, top: -140, right: -200 }}/>
      <window.SP_Blemish fill="#e8e0cf" opacity={0.32} style={{ width: 520, height: 520, bottom: -180, left: -200 }}/>

      <span data-sp-decor><window.SP_SheetFrag n={6} width={220} rotate={-7} opacity={0.07} style={{ top: 60, left: 28 }}/></span>
      <span data-sp-decor><window.SP_SheetFrag src="accent" width={200} rotate={4} opacity={0.07} style={{ bottom: 60, right: 40 }}/></span>

      <div style={{ maxWidth: 820, margin:'0 auto 44px', textAlign:'center', position:'relative' }}>
      </div>

      <div style={{
        maxWidth: 1180, margin:'0 auto',
        display:'grid', gridTemplateColumns:'repeat(3, 1fr)', gap: 28,
        position:'relative',
      }} data-sp-grid-3>
        <TestimonialCard name="Emma Laurent" role="Self-taught · 4 years"/>
        <TestimonialCard name="David Whitaker" role="Returning pianist"/>
        <TestimonialCard name="Priya Shah" role="Intermediate learner"/>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────
// §7 Stack & CTA
// ─────────────────────────────────────────────────────────────
function StackItem({ n, children }) {
  return (
    <li style={{
      display:'grid', gridTemplateColumns:'auto 1fr', gap: 18, alignItems:'flex-start',
      padding: '14px 0',
    }}>
      <span style={{
        flexShrink: 0, marginTop: 2,
        width: 26, height: 26, borderRadius: '50%',
        background: 'transparent',
        border: `1.2px solid ${S.olive}`,
        display:'flex', alignItems:'center', justifyContent:'center',
      }}>
        <svg width="13" height="13" viewBox="0 0 13 13" aria-hidden>
          <path d="M2.5 7 L5.3 9.5 L10.5 3.8" stroke={S.olive} strokeWidth="1.6" fill="none" strokeLinecap="round" strokeLinejoin="round"/>
        </svg>
      </span>
      <span style={{
        fontFamily: S.sans, fontSize: 17, lineHeight: 1.7, color: S.body,
        paddingTop: 2,
      }}>{children}</span>
    </li>
  );
}

function Section7() {
  return (
    <section data-sp-section="s7" style={{
      background: S.bgWhite, padding: '0 60px 120px',
      fontFamily: S.sans, position:'relative', overflow:'hidden',
    }}>
      <window.SP_Blemish fill="#e5d8c1" opacity={0.26} style={{ width: 620, height: 620, top: 120, left: -240 }}/>
      <window.SP_Blemish fill="#e8c9b4" opacity={0.22} style={{ width: 520, height: 520, bottom: -200, right: -200 }}/>

      {/* Decorative sheet fragment in right margin */}
      <span data-sp-decor><window.SP_SheetFrag n={2} width={240} rotate={7} opacity={0.08} style={{ top: 300, right: 28 }}/></span>
      <span data-sp-decor><window.SP_SheetFrag src="quarterrest" width={100} rotate={-5} opacity={0.08} style={{ top: 480, left: 44 }}/></span>

      {/* Bridging product shot — straddles §6 boundary */}
      <div style={{
        maxWidth: 980, margin: '0 auto',
        transform: 'translateY(-96px)',
        marginBottom: -40,
        position:'relative', zIndex: 2,
      }}>
        <div style={{
          borderRadius: 6, overflow:'hidden',
          boxShadow: '0 30px 80px -30px rgba(40,30,20,0.38), 0 10px 24px -12px rgba(40,30,20,0.22)',
          background: '#fbf7ef',
        }}>
          <ImgPlaceholder
            aspect="21 / 9"
            label="Product shot · bridging image"
            hint="Wide hero-style shot of the full product — could be a laptop + tablet showing the course UI, or a flat-lay of the lessons/sheet music/keyboard. Sits half in the testimonials section, half in the CTA section to link the two."
          />
        </div>
      </div>

      <div data-sp-card style={{
        maxWidth: 820, margin:'0 auto', textAlign:'center', position:'relative',
        background: '#fcfaf5',
        borderRadius: 6,
        padding: '72px 64px 80px',
        boxShadow: '0 1px 0 rgba(0,0,0,0.04), 0 30px 80px -30px rgba(40,30,20,0.28), 0 12px 28px -14px rgba(40,30,20,0.16)',
      }}>

        <h2 data-sp-h2 style={{
          fontFamily: S.serif, fontWeight: 400,
          fontSize: 40, lineHeight: 1.2, color: S.ink,
          margin: '0 0 48px', letterSpacing: -0.5, textWrap:'pretty',
        }}>
          If This Approach To Learning This Beautiful Piece Sounds Good To You... Here's Everything Included In The Course.
        </h2>

        <div style={{
          padding: '0',
          marginBottom: 56,
          textAlign:'left',
          maxWidth: 680, margin: '0 auto 56px',
        }}>
          <ul style={{ listStyle:'none', padding: 0, margin: 0, display:'flex', flexDirection:'column', gap: 0, borderTop: `0.5px solid ${S.rule}` }}>
            <li style={{ display:'none' }}/>
            <StackItem n={1}><strong style={{ color: S.ink, fontWeight: 600 }}>13 focused core lessons</strong> guiding you through the piece bar by bar in small, manageable sections</StackItem>
            <StackItem n={2}><strong style={{ color: S.ink, fontWeight: 600 }}>Play-along software</strong> so you can slow things down, repeat sections, and practise at a pace that works for you</StackItem>
            <StackItem n={3}><strong style={{ color: S.ink, fontWeight: 600 }}>4 full performances</strong> to learn from, including metronome versions and freer, more musical versions</StackItem>
            <StackItem n={4}>A dedicated <strong style={{ color: S.ink, fontWeight: 600 }}>From Notes to Music</strong> lesson to help you shape the piece with more flow, expression, and polish</StackItem>
            <StackItem n={5}>A practical lesson on playing the piece <strong style={{ color: S.ink, fontWeight: 600 }}>without the sustain pedal</strong>, so you can build more legato, control, and refinement</StackItem>
            <StackItem n={6}>A <strong style={{ color: S.ink, fontWeight: 600 }}>Beyond Prelude in C</strong> lesson to help you carry the musical ideas from the piece into freer, more creative playing of your own</StackItem>
          </ul>
        </div>

        {/* Price line */}
        <div style={{
          fontFamily: S.sans, fontSize: 13, letterSpacing:'0.24em', textTransform:'uppercase',
          color: S.muted, fontWeight: 600, margin: '0 0 8px',
        }}>
          All For A Single Payment Of
        </div>
        <div style={{
          fontFamily: S.serif, fontWeight: 400, color: S.accent,
          fontSize: 96, lineHeight: 1, letterSpacing: -3,
          margin: '0 0 36px',
        }}>
          $67
        </div>

        <BigCta>Start Learning Prelude In C Today</BigCta>

        <div style={{ fontSize: 13, letterSpacing:'0.08em', color: S.muted, marginTop: 22 }}>
          One-Time Payment  ·  Lifetime Access  ·  30-Day Guarantee
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────
// §8 Guarantee
// ─────────────────────────────────────────────────────────────
function GuaranteeSeal({ size = 260 }) {
  // scalloped outer ring — 36 bumps around a circle, like the reference stamp
  const bumps = 36;
  const scalloped = [];
  const rOuter = 95;
  const rInner = 88;
  for (let i = 0; i < bumps * 2; i++) {
    const angle = (i / (bumps * 2)) * Math.PI * 2;
    const r = i % 2 === 0 ? rOuter : rInner;
    scalloped.push([100 + Math.cos(angle) * r, 100 + Math.sin(angle) * r]);
  }
  const scallopPath = 'M ' + scalloped.map(([x, y]) => `${x.toFixed(2)} ${y.toFixed(2)}`).join(' L ') + ' Z';

  // ring of 24 stars between the two inner circles
  const stars = [];
  const starCount = 24;
  for (let i = 0; i < starCount; i++) {
    const a = (i / starCount) * Math.PI * 2 - Math.PI / 2;
    const x = 100 + Math.cos(a) * 70;
    const y = 100 + Math.sin(a) * 70;
    stars.push({ x, y });
  }

  // curved path for top text (MONEY BACK) — baseline at r=66, ascenders extend outward to ~r=73
  // Top arc: runs left→right along the TOP of the band, sweep=1 (clockwise), text reads upright
  const topTextPath = 'M 34 100 A 66 66 0 0 1 166 100';
  // Bottom arc: runs left→right along the BOTTOM of the band, sweep=0 (counter-clockwise)
  // baseline at r=74, ascenders extend inward to ~r=67 — letters upright toward center
  const bottomTextPath = 'M 26 100 A 74 74 0 0 0 174 100';

  const inkDark = '#7a2f1d';   // deep terracotta for text
  const ringFill = S.accent;    // main terracotta
  const ringFillDeep = '#a4422d';

  return (
    <svg
      viewBox="0 0 200 200"
      width={size}
      height={size}
      aria-label="30 Day Money Back Guarantee" data-sp-seal
      role="img"
      style={{ display:'block', margin:'0 auto', filter: 'drop-shadow(0 8px 20px rgba(120, 50, 30, 0.18))' }}
      xmlns="http://www.w3.org/2000/svg"
    >
      <defs>
        <path id="seal-top-arc" d={topTextPath}/>
        <path id="seal-bottom-arc" d={bottomTextPath}/>
      </defs>

      {/* scalloped outer ring */}
      <path d={scallopPath} fill={ringFill}/>

      {/* subtle dark edge on scallops */}
      <circle cx="100" cy="100" r="86" fill="none" stroke={ringFillDeep} strokeWidth="0.8" opacity="0.4"/>

      {/* inner cream center */}
      <circle cx="100" cy="100" r="78" fill="#fbf7ef"/>

      {/* terracotta band (where the curved text sits) */}
      <circle cx="100" cy="100" r="70" fill="none" stroke={ringFill} strokeWidth="18"/>

      {/* cream inner edges of band */}
      <circle cx="100" cy="100" r="61" fill="none" stroke="#fbf7ef" strokeWidth="1.2" opacity="0.8"/>
      <circle cx="100" cy="100" r="79" fill="none" stroke="#fbf7ef" strokeWidth="1.2" opacity="0.8"/>

      {/* curved text along top & bottom of the band */}
      <text fontFamily="DM Sans, sans-serif" fontWeight="700" fontSize="9.5" letterSpacing="2.4" fill="#fbf7ef">
        <textPath xlinkHref="#seal-top-arc" href="#seal-top-arc" startOffset="50%" textAnchor="middle">
          MONEY BACK
        </textPath>
      </text>
      <text fontFamily="DM Sans, sans-serif" fontWeight="700" fontSize="9.5" letterSpacing="2.4" fill="#fbf7ef">
        <textPath xlinkHref="#seal-bottom-arc" href="#seal-bottom-arc" startOffset="50%" textAnchor="middle">
          GUARANTEE
        </textPath>
      </text>

      {/* divider stars (3 & 9 o'clock) between top & bottom text */}
      <g fill="#fbf7ef">
        <path d="M 168 100 l 0 -4 l 1.2 2.8 l 2.8 1.2 l -2.8 1.2 l -1.2 2.8 l -1.2 -2.8 l -2.8 -1.2 l 2.8 -1.2 Z"/>
        <path d="M 32 100 l 0 -4 l 1.2 2.8 l 2.8 1.2 l -2.8 1.2 l -1.2 2.8 l -1.2 -2.8 l -2.8 -1.2 l 2.8 -1.2 Z"/>
      </g>

      {/* inner circle — "30 DAY" */}
      <circle cx="100" cy="100" r="42" fill={ringFill}/>
      <circle cx="100" cy="100" r="42" fill="none" stroke="#fbf7ef" strokeWidth="1.4"/>
      <circle cx="100" cy="100" r="38" fill="none" stroke="#fbf7ef" strokeWidth="0.6" opacity="0.5"/>

      <text x="100" y="102" textAnchor="middle" fontFamily="Fraunces, serif" fontSize="36" fontWeight="600" fill="#fbf7ef" letterSpacing="-1">30</text>
      <text x="100" y="120" textAnchor="middle" fontFamily="DM Sans, sans-serif" fontSize="10" fontWeight="700" letterSpacing="2.5" fill="#fbf7ef">DAY</text>
    </svg>
  );
}

function Section8() {
  return (
    <section data-sp-section="s8" style={{
      background: '#fcfaf5', padding: '96px 60px 104px',
      fontFamily: S.sans, position:'relative', overflow:'hidden',
      borderTop: `1px solid ${S.ruleSoft}`,
    }}>
      <window.SP_Blemish fill="#ead9c6" opacity={0.22} style={{ width: 520, height: 520, top: -160, right: -180 }}/>

      <span data-sp-decor><window.SP_SheetFrag n={9} width={240} rotate={5} opacity={0.07} style={{ bottom: 140, left: 32 }}/></span>

      <div data-sp-grid-2 style={{
        maxWidth: 1040, margin:'0 auto', position:'relative',
        display:'grid', gridTemplateColumns:'280px 1fr', gap: 64, alignItems:'center',
        /* mobile: single column */
      }}>
        <div>
          <GuaranteeSeal size={260}/>
        </div>

        <div>
          <div style={{
            fontFamily: S.sans, fontSize: 12, letterSpacing:'0.22em',
            textTransform:'uppercase', color: S.accent, fontWeight: 500, marginBottom: 14,
          }}>
            Still not sure?
          </div>
          <h2 data-sp-h2 style={{
            fontFamily: S.serif, fontStyle:'italic', fontWeight: 400,
            fontSize: 34, lineHeight: 1.25, color: S.ink,
            margin: '0 0 22px', letterSpacing: -0.3, textWrap:'pretty',
          }}>
            Let me take the risk off your shoulders...
          </h2>
          <h3 data-sp-h3 style={{
            fontFamily: S.serif, fontWeight: 500,
            fontSize: 24, lineHeight: 1.3, color: S.ink,
            margin: '0 0 20px', textWrap:'pretty',
          }}>
            Here's Your 30-Day, No-Questions-Asked Money-Back Guarantee
          </h3>
          <p data-sp-body style={{ fontFamily: S.sans, fontSize: 16, lineHeight: 1.75, color: S.body, margin:'0 0 16px' }}>
            I'm very confident you'll love learning Prelude in C this way, and what it does for your playing more broadly, so I'm backing the piece study with a full 30-day money-back guarantee.
          </p>
          <p data-sp-body style={{ fontFamily: S.sans, fontSize: 16, lineHeight: 1.75, color: S.body, margin:'0 0 16px' }}>
            This course gives you everything you need to learn this beautiful piece in a way that feels clear, musical, and genuinely rewarding... that is, if you actually use it and put the time in. I can't practise the piece for you. But I have given you a clear path, the lessons, the play-along tools, and the extra depth to help you get a really satisfying result.
          </p>
          <p data-sp-body style={{ fontFamily: S.sans, fontSize: 16, lineHeight: 1.75, color: S.body, margin:'0 0 16px' }}>
            As soon as you complete checkout, you'll get an email with immediate access to the full piece study and all the lessons. From there, you can get started right away and work through it at your own pace.
          </p>
          <p data-sp-body style={{ fontFamily: S.sans, fontSize: 16, lineHeight: 1.75, color: S.body, margin: 0 }}>
            And if for any reason you decide it's not for you, just email me and my team within 30 days of purchase and we'll send you a full refund.
          </p>
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────
// §9 FAQ
// ─────────────────────────────────────────────────────────────
function FaqItem({ q, a, open, onToggle }) {
  const contentRef = React.useRef(null);
  const [maxH, setMaxH] = React.useState(0);

  React.useLayoutEffect(() => {
    if (contentRef.current) {
      setMaxH(contentRef.current.scrollHeight);
    }
  }, [a, open]);

  return (
    <div style={{
      background: open ? '#eeecd4' : '#fbf9f2',
      border: `1px solid ${open ? S.olive : '#e6dfc3'}`,
      borderRadius: 6,
      boxShadow: open
        ? '0 10px 30px -14px rgba(90,90,30,0.20)'
        : '0 1px 0 rgba(40,30,20,0.02)',
      transition: 'background 260ms ease, border-color 260ms ease, box-shadow 260ms ease',
      overflow:'hidden',
    }}>
      <button
        onClick={onToggle}
        aria-expanded={open}
        style={{
          width:'100%', textAlign:'left', background:'transparent', border:'none',
          padding:'22px 28px', cursor:'pointer',
          display:'flex', alignItems:'center', justifyContent:'space-between', gap: 24,
        }}>
        <span data-sp-faq-q style={{
          fontFamily: S.serif, fontWeight: 500, fontSize: 19,
          color: S.ink, lineHeight: 1.35, textWrap:'pretty',
        }}>
          {q}
        </span>
        <span style={{
          flexShrink: 0,
          width: 32, height: 32, borderRadius: '50%',
          background: open ? S.olive : 'transparent',
          border: `1px solid ${S.olive}`,
          display:'flex', alignItems:'center', justifyContent:'center',
          transition: 'background 260ms ease, border-color 260ms ease, transform 260ms cubic-bezier(.2,.8,.2,1)',
          transform: open ? 'rotate(180deg)' : 'rotate(0deg)',
        }}>
          <svg width="12" height="12" viewBox="0 0 12 12" aria-hidden>
            <path d="M2 4.5 L6 8.5 L10 4.5" stroke={open ? '#fbf7ef' : S.olive} strokeWidth="1.8" fill="none" strokeLinecap="round" strokeLinejoin="round"/>
          </svg>
        </span>
      </button>
      <div style={{
        maxHeight: open ? maxH : 0,
        opacity: open ? 1 : 0,
        transition: 'max-height 420ms cubic-bezier(.2,.8,.2,1), opacity 300ms ease',
        overflow:'hidden',
      }}>
        <div ref={contentRef} data-sp-faq-a style={{
          padding:'0 28px 24px',
          fontFamily: S.sans, fontSize: 16, lineHeight: 1.75, color: S.body,
          maxWidth: 760,
        }}>
          {a}
        </div>
      </div>
    </div>
  );
}

function Section9() {
  const [openIdx, setOpenIdx] = React.useState(0);
  const toggle = (i) => setOpenIdx(openIdx === i ? null : i);
  return (
    <section data-sp-section="s9" style={{
      background: S.bgWhite, padding: '104px 60px 104px',
      fontFamily: S.sans, position:'relative', overflow:'hidden',
      borderTop: `1px solid ${S.ruleSoft}`,
    }}>
      <window.SP_Blemish fill="#e5d8c1" opacity={0.24} style={{ width: 520, height: 520, bottom: -180, right: -180 }}/>

      {/* Decorative sheet fragment in left margin */}
      <span data-sp-decor><window.SP_SheetFrag n={5} width={220} rotate={-8} opacity={0.08} style={{ top: 180, left: 30 }}/></span>
      <span data-sp-decor><window.SP_SheetFrag n={3} width={220} rotate={6} opacity={0.07} style={{ bottom: 200, right: 30 }}/></span>

      <div style={{ maxWidth: 820, margin:'0 auto', position:'relative' }}>
        <div style={{ textAlign:'center', marginBottom: 56 }}>
          <h2 data-sp-h2 style={{
            fontFamily: S.serif, fontWeight: 400,
            fontSize: 44, lineHeight: 1.15, color: S.ink,
            margin: 0, letterSpacing: -0.5, textWrap:'pretty',
          }}>
            A Few Common Questions
          </h2>
        </div>

        <div style={{ display:'flex', flexDirection:'column', gap: 14 }}>
          <FaqItem
            open={openIdx === 0} onToggle={() => toggle(0)}
            q="Is this too advanced for me?"
            a="Not at all. The whole course is built to make the piece feel clear, manageable, and realistic to learn, even if it feels a bit daunting from the outside. We go through it in small sections, step by step, so you always know what to focus on next."
          />
          <FaqItem
            open={openIdx === 1} onToggle={() => toggle(1)}
            q="What if I already know some of the piece?"
            a="That's absolutely fine. A lot of people coming to this kind of course already sort of play Prelude in C, but are not happy with how it sounds yet. This piece study will still help you polish it, shape it more musically, and understand the piece much more deeply."
          />
          <FaqItem
            open={openIdx === 2} onToggle={() => toggle(2)}
            q="Why do we learn the piece with the sustain pedal?"
            a={<>
              <p style={{ margin:'0 0 12px' }}>
                For most of us, learning the piece with the sustain pedal gives the most immediate, natural, and satisfying way into the music. It gives us control over smoothness and musicality without needing years of training to develop the very fine finger control necessary to get a sound we would be proud of.
              </p>
              <p style={{ margin: 0 }}>
                However, once you have the piece under your fingers, we explore how to play it without the sustain pedal so you always have the option to explore the specific finger techniques and develop that deeper level of control.
              </p>
            </>}
          />
          <FaqItem
            open={openIdx === 3} onToggle={() => toggle(3)}
            q="How is the course delivered?"
            a="As soon as you join, you'll get immediate access by email. Inside, everything is laid out clearly, so you can work through the lessons, use the play-along software, and return to the performances and extra lessons whenever you like."
          />
          <FaqItem
            open={openIdx === 4} onToggle={() => toggle(4)}
            q="What if I'm short on time?"
            a="That is exactly why the course is structured the way it is. You do not have to wrestle with the whole piece at once. The lessons are broken down into manageable sections, so even if your practice time is limited, you can keep making progress without feeling overwhelmed."
          />
          <FaqItem
            open={openIdx === 5} onToggle={() => toggle(5)}
            q="What if I'm not naturally musical?"
            a="That is one of the big myths this course pushes against. Musicality is not being treated here like some mysterious gift you either have or do not have. A big part of the piece study is showing you practical ways to shape the sound, phrase the music, and make the piece breathe more naturally."
          />
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────
// §10 Final CTA — dark bookend mirroring §5
// ─────────────────────────────────────────────────────────────
function Section10() {
  return (
    <section data-sp-section="s10" style={{
      background:'#1c1a17', color:'#fbf7ef',
      padding: '112px 60px 120px',
      fontFamily: S.sans, position:'relative', overflow:'hidden', textAlign:'center',
    }}>
      <window.SP_Blemish fill="#b8533a" opacity={0.2} style={{ width: 700, height: 700, top: -260, left: -260 }}/>
      <window.SP_Blemish fill="#6b4a38" opacity={0.24} style={{ width: 620, height: 620, bottom: -240, right: -220 }}/>

      {/* Faint sheet fragment, inverted for dark bg */}
      <span data-sp-decor><window.SP_SheetFrag n={4} width={280} rotate={6} opacity={0.05} dark style={{ top: 80, right: 24 }}/></span>

      <div style={{ maxWidth: 820, margin:'0 auto', position:'relative' }}>
        {/* small treble clef mark — uses the user asset as a CSS mask so it can be tinted warm */}
        <div
          aria-hidden
          style={{
            width: 38, height: 60, margin:'0 auto 28px',
            backgroundColor: '#e8b89c',
            WebkitMaskImage: "url('assets/trebleclef.svg')",
            maskImage: "url('assets/trebleclef.svg')",
            WebkitMaskSize: 'contain', maskSize: 'contain',
            WebkitMaskRepeat: 'no-repeat', maskRepeat: 'no-repeat',
            WebkitMaskPosition: 'center', maskPosition: 'center',
            opacity: 0.8,
          }}
        />

        <div style={{
          fontFamily: S.serif, fontStyle:'italic', fontSize: 22, color:'#e8b89c',
          marginBottom: 22, textWrap:'pretty',
        }}>
          If this feels like the right way for you to learn Prelude in C, you can get started today.
        </div>

        <h2 data-sp-h2 style={{
          fontFamily: S.serif, fontWeight: 400,
          fontSize: 48, lineHeight: 1.15, color:'#fbf7ef',
          margin: '0 0 12px', letterSpacing: -0.5, textWrap:'pretty',
        }}>
          Join The Full Bach's Prelude in C Piece Study
        </h2>
        <div style={{
          fontFamily: S.serif, fontStyle:'italic', fontSize: 26, color:'#e8b89c',
          marginBottom: 44,
        }}>
          For A Single Payment Of $67
        </div>

        <BigCta>Start Prelude In C Today</BigCta>

        <div style={{ fontSize: 13, letterSpacing:'0.08em', color:'rgba(251,247,239,0.78)', marginTop: 20 }}>
          One-Time Payment  ·  Lifetime Access  ·  30-Day Guarantee
        </div>
      </div>
    </section>
  );
}

// Export to global so the main file can compose them
Object.assign(window, {
  SP_Section4: Section4,
  SP_Section5: Section5,
  SP_Section6: Section6,
  SP_Section7: Section7,
  SP_Section8: Section8,
  SP_Section9: Section9,
  SP_Section10: Section10,
  SP_BigCta: BigCta,
});
