/* polish/leren-herhaalsessie-frames.jsx
   Herhaal-runner — focus-flow voor 12 kaarten over 4 vakken.
   Twee frames in deze basis-run:
   - Kaart-flip-moment (3/12, antwoord-zijde, 4 grade-knoppen)
   - Sessie-einde-rapport (9/12 goed, +18 XP, +24 Snaps, streak 12 → 13)
   Sidebar blijft staan — gebruiker kan altijd uit de sessie via nav.
*/

const SESSIE_KAARTEN = [
  { subject: 'biologie', source: 'Bio H3 — Cellen' },
  { subject: 'engels',   source: 'Engels U5 — Past Tenses' },
  { subject: 'wiskunde', source: 'Wis H4 — Vergelijkingen' },
  { subject: 'geschiedenis', source: 'Gesch H7 — Industrialisatie' },
];

const HUIDIGE_KAART = {
  subject: 'biologie',
  source: 'Biologie voor jou · havo-3 · H3',
  front: 'Wat is mitose?',
  back: 'Een vorm van celdeling waarbij uit één moedercel twee identieke dochtercellen ontstaan.',
  note: 'Belangrijk: het DNA wordt eerst verdubbeld vóór de deling.',
};

/* ─── FRAME 1 — Kaart-flip-moment ─────────────────────────── */
function FrameSessieKaart({ t }) {
  return (
    <LerenPage t={t}
      title="Herhaling"
      subtitle="12 kaarten · 4 vakken · ~ 8 min"
      url="snapsnel.nl/leren/herhaling"
      rightExtra={<SessieControls t={t} />}
    >
      <div style={{ display: 'flex', flexDirection: 'column', gap: 18 }}>
        <SessieVoortgangsBalk t={t} idx={3} total={12} verdeling={[
          { subject: 'biologie',     done: 2, total: 5 },
          { subject: 'engels',       done: 0, total: 4 },
          { subject: 'wiskunde',     done: 0, total: 2 },
          { subject: 'geschiedenis', done: 0, total: 1 },
        ]} />

        <FlashcardDeck t={t} card={HUIDIGE_KAART}
          flipped idx={3} total={12} showStackHint />

        <div style={{
          display: 'flex', alignItems: 'center', gap: 10,
          padding: '11px 14px', borderRadius: 8,
          background: t.cardSunken, border: `1px solid ${t.border}`,
        }}>
          <PulseMascot size={26} mood="thinking" />
          <span style={{ fontSize: 12, color: t.fgMute, fontWeight: 600, lineHeight: 1.5, flex: 1 }}>
            Geen druk — kies eerlijk hoe het ging. We plannen op basis daarvan wanneer je deze kaart weer ziet.
          </span>
        </div>
      </div>
    </LerenPage>
  );
}

function SessieControls({ t }) {
  return (
    <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
      <BtnGhost t={t} icon="pause">Pauzeer</BtnGhost>
      <BtnGhost t={t} icon="x">Stop sessie</BtnGhost>
    </div>
  );
}

function SessieVoortgangsBalk({ t, idx, total, verdeling }) {
  return (
    <div style={{
      background: t.card, border: `1px solid ${t.border}`,
      borderRadius: 10, padding: '14px 16px',
      display: 'flex', flexDirection: 'column', gap: 10,
    }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
        <span style={{ fontFamily: 'Fredoka One', fontSize: 14, color: t.fg }}>
          Kaart {idx} / {total}
        </span>
        <span style={{ flex: 1 }} />
        <span style={{ fontSize: 11, color: t.fgMute, fontWeight: 700 }}>
          ~ {Math.max(1, Math.round((total - idx) * 0.6))} min resterend
        </span>
      </div>

      <div style={{
        display: 'flex', height: 6, borderRadius: 999,
        overflow: 'hidden', background: t.cardSunken, border: `1px solid ${t.border}`,
      }}>
        {verdeling.map((v, i) => {
          const c = SUBJECTS[v.subject] || t.fgMute;
          const flexTotal = v.total;
          const fillFlex  = v.done;
          return (
            <div key={i} style={{
              flex: flexTotal,
              display: 'flex',
              borderRight: i < verdeling.length - 1 ? `1px solid ${t.bg}` : 'none',
            }}>
              <div style={{ background: c, flex: fillFlex }} />
              <div style={{ flex: flexTotal - fillFlex }} />
            </div>
          );
        })}
      </div>

      <div style={{ display: 'flex', flexWrap: 'wrap', gap: 12 }}>
        {verdeling.map((v, i) => {
          const c = SUBJECTS[v.subject] || t.fgMute;
          return (
            <div key={i} style={{
              display: 'inline-flex', alignItems: 'center', gap: 6,
              fontSize: 11, color: t.fgDim, fontWeight: 700,
            }}>
              <span style={{ width: 8, height: 8, borderRadius: 999, background: c }} />
              <SubjectChip t={t} subject={v.subject} size="sm" iconOnly />
              <span>{v.done} / {v.total}</span>
            </div>
          );
        })}
      </div>
    </div>
  );
}

/* ─── FRAME 2 — Sessie-einde-rapport ─────────────────────── */
function FrameSessieRapport({ t }) {
  return (
    <LerenPage t={t}
      title="Herhaling"
      subtitle="Sessie afgerond · 12 kaarten · 8 min"
      url="snapsnel.nl/leren/herhaling/klaar"
    >
      <div style={{ display: 'flex', flexDirection: 'column', gap: 18 }}>
        <RapportHero t={t} />

        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 14 }}>
          <RapportStat t={t} icon="check-circle" label="Goed beantwoord"
            value="9 / 12" sub="3 zien we morgen weer terug" />
          <RapportStat t={t} icon="clock" label="Tijd"
            value="8 min" sub="gemiddeld 40 sec per kaart" />
          <RapportStat t={t} icon="zap" label="XP verdiend"
            value="+18 XP" sub="level 7 · 91 / 272 naar level 8" accent="primary" />
          <RapportStat t={t} icon="sparkles" label="Snaps"
            value="+24 Snaps" sub="totaal 1.264 · streak 12 → 13" accent="gold" />
        </div>

        <WatHebJeGeleerdCard t={t} />

        <div style={{ display: 'flex', gap: 10, justifyContent: 'flex-end', flexWrap: 'wrap' }}>
          <BtnGhost t={t} icon="arrow-left">Terug naar Leren</BtnGhost>
          <BtnGhost t={t} icon="repeat">Nóg een rondje</BtnGhost>
          <BtnPrimary t={t} icon="arrow-right">Naar Oefenen — toets-mini-quiz</BtnPrimary>
        </div>
      </div>
    </LerenPage>
  );
}

function RapportHero({ t }) {
  const dark = t.mode === 'dark';
  return (
    <div style={{
      background: t.card, border: `1px solid ${t.border}`,
      borderRadius: 10, padding: '22px 24px',
      display: 'flex', alignItems: 'center', gap: 18,
    }}>
      <PulseMascot size={64} mood="celebrating" />
      <div style={{ flex: 1, minWidth: 0 }}>
        <div style={{
          fontSize: 10.5, color: t.primary, fontWeight: 800,
          letterSpacing: 0.6, textTransform: 'uppercase', marginBottom: 4,
        }}>Sessie afgerond</div>
        <h1 style={{
          margin: 0, fontFamily: 'Fredoka One', fontSize: 24,
          color: t.fg, lineHeight: 1.15, letterSpacing: '-0.01em',
        }}>Klaar voor vandaag — netjes door 12 kaarten.</h1>
        <p style={{
          margin: '8px 0 0', fontSize: 13.5, color: t.fgDim,
          lineHeight: 1.6, fontWeight: 500,
        }}>Drie kaarten zaten lastig — die zien we morgen weer. De rest mag nu even rusten.</p>
      </div>
    </div>
  );
}

function RapportStat({ t, icon, label, value, sub, accent }) {
  const dark = t.mode === 'dark';
  const accentColor = accent === 'primary' ? t.primary
                    : accent === 'gold'    ? t.gold
                    : t.fgDim;
  return (
    <div style={{
      background: t.card, border: `1px solid ${t.border}`,
      borderRadius: 10, padding: 16,
      display: 'flex', flexDirection: 'column', gap: 6,
    }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
        <PI name={icon} size={14} color={accentColor} strokeWidth={2.4} />
        <span style={{ fontSize: 11, color: t.fgMute, fontWeight: 800, letterSpacing: 0.4, textTransform: 'uppercase' }}>
          {label}
        </span>
      </div>
      <div style={{
        fontFamily: 'Fredoka One', fontSize: 22, color: accent ? accentColor : t.fg,
        letterSpacing: '-0.005em', lineHeight: 1.1,
      }}>{value}</div>
      <div style={{ fontSize: 11.5, color: t.fgDim, fontWeight: 600, lineHeight: 1.5 }}>{sub}</div>
    </div>
  );
}

function WatHebJeGeleerdCard({ t }) {
  const onderwerpen = [
    { subject: 'biologie',     count: 5, topic: 'Mitose, organellen, osmose' },
    { subject: 'engels',       count: 4, topic: 'Past tenses & onregelmatige werkwoorden' },
    { subject: 'wiskunde',     count: 2, topic: 'Vergelijkingen oplossen' },
    { subject: 'geschiedenis', count: 1, topic: 'Industriële Revolutie — start' },
  ];
  return (
    <div style={{
      background: t.card, border: `1px solid ${t.border}`,
      borderRadius: 10, padding: '16px 18px',
      display: 'flex', flexDirection: 'column', gap: 12,
    }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
        <PI name="bookmark" size={14} color={t.fgDim} strokeWidth={2.4} />
        <span style={{ fontFamily: 'Fredoka One', fontSize: 14, color: t.fg }}>
          Wat zat er in deze sessie?
        </span>
      </div>
      <div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
        {onderwerpen.map((o, i) => (
          <div key={i} style={{
            display: 'flex', alignItems: 'center', gap: 10,
            padding: '8px 10px', borderRadius: 8,
            background: t.cardSunken, border: `1px solid ${t.border}`,
          }}>
            <SubjectChip t={t} subject={o.subject} size="sm" iconOnly />
            <span style={{ fontSize: 12.5, color: t.fg, fontWeight: 700, flex: 1 }}>
              {o.topic}
            </span>
            <span style={{ fontSize: 11, color: t.fgMute, fontWeight: 800, whiteSpace: 'nowrap' }}>
              {o.count} kaart{o.count > 1 ? 'en' : ''}
            </span>
          </div>
        ))}
      </div>
    </div>
  );
}

Object.assign(window, {
  FrameSessieKaart, FrameSessieRapport,
  FrameSessieFront, FrameSessiePostGrade, FrameSessiePauze,
  FrameSessieRapportMastered,
});

/* ─── FRAME 6 — Sessie-rapport: hoofdstuk gemastered ─────────
   Speciale variant van het rapport. Deze sessie heeft het laatste
   subkopje van een hoofdstuk naar 4/4 mastery getild. Hero is
   pijler-blauw getint, mastery-delta-card vervangt 'wat hebben we
   gedaan', en de standaard CTA-rij wordt vervangen door een
   prominente cross-pijler HandoffCard naar Oefenen.
   ────────────────────────────────────────────────────────────── */
function FrameSessieRapportMastered({ t }) {
  return (
    <LerenPage t={t}
      title="Herhaling"
      subtitle="Sessie afgerond · 12 kaarten · 8 min · hoofdstuk beheerst"
      url="snapsnel.nl/leren/herhaling/klaar"
    >
      <div style={{ display: 'flex', flexDirection: 'column', gap: 18 }}>
        <RapportHeroMastered t={t} />

        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 14 }}>
          <RapportStat t={t} icon="check-circle" label="Goed beantwoord"
            value="12 / 12" sub="100% — perfect ritme" />
          <RapportStat t={t} icon="clock" label="Tijd"
            value="8 min" sub="gemiddeld 40 sec per kaart" />
          <RapportStat t={t} icon="zap" label="XP verdiend"
            value="+45 XP" sub="level 7 · 136 / 272 naar level 8" accent="primary" />
          <RapportStat t={t} icon="sparkles" label="Snaps"
            value="+75 Snaps" sub="incl. mastery-bonus · streak 12 → 13" accent="gold" />
        </div>

        <MasteryDeltaCard t={t} />

        <HandoffCard t={t} pillar="oefenen" direction="to"
          mascot={<PulseMascot size={48} mood="encouraging" />}
          hideArrow
          title="Klaar om te oefenen?"
          subtitle="Je beheerst de stof. In Oefenen ga je 'm toepassen op echte toetsvragen — daar leer je 'm écht vasthouden onder druk."
        >
          <div style={{
            display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap',
            paddingTop: 4,
          }}>
            <HandoffBadge t={t} pillar="oefenen" direction="to" label="Naar Oefenen" />
            <span style={{ flex: 1 }} />
            <OefenenStartButton t={t} />
          </div>
        </HandoffCard>

        <div style={{
          display: 'flex', gap: 10, justifyContent: 'flex-end', flexWrap: 'wrap',
          paddingTop: 2,
        }}>
          <BtnGhost t={t} icon="arrow-left">Terug naar Leren</BtnGhost>
          <BtnGhost t={t} icon="calendar">Onderhoudsherhaling plannen</BtnGhost>
        </div>
      </div>
    </LerenPage>
  );
}

/* Hero-variant: pijler-blauw getinte achtergrond, kicker boven titel,
   grotere mascot, "HOOFDSTUK BEHEERST"-uppercase. */
function RapportHeroMastered({ t }) {
  const dark = t.mode === 'dark';
  const blue = pillarColor('leren', dark);
  return (
    <div style={{
      background: `color-mix(in oklch, ${blue} 6%, transparent)`,
      border: `1px solid color-mix(in oklch, ${blue} 24%, transparent)`,
      borderRadius: 10, padding: '24px 26px',
      display: 'flex', alignItems: 'center', gap: 20,
    }}>
      <PulseMascot size={80} mood="celebrating" />
      <div style={{ flex: 1, minWidth: 0 }}>
        <div style={{
          display: 'inline-flex', alignItems: 'center', gap: 6,
          fontSize: 11, color: blue, fontWeight: 800,
          letterSpacing: 0.7, textTransform: 'uppercase', marginBottom: 6,
        }}>
          <PI name="award" size={12} color={blue} strokeWidth={2.6} />
          Hoofdstuk beheerst
        </div>
        <h1 style={{
          margin: 0, fontFamily: 'Fredoka One', fontSize: 26,
          color: t.fg, lineHeight: 1.15, letterSpacing: '-0.01em',
        }}>Je kent dit hoofdstuk!</h1>
        <p style={{
          margin: '8px 0 0', fontSize: 13.5, color: t.fgDim,
          lineHeight: 1.6, fontWeight: 500,
        }}>De Gouden Eeuw — alle 4 subkopjes op mastery.</p>
      </div>
    </div>
  );
}

/* Mastery-delta: 4 subkopjes met before→after MasteryDots.
   Het laatste subkopje krijgt een groene check + delta — dat is wat
   deze sessie heeft opgeleverd. De andere drie zijn al langer mastered
   en worden subtieler getoond. */
function MasteryDeltaCard({ t }) {
  const dark = t.mode === 'dark';
  const greenInk = dark ? '#22C55E' : '#15803D';
  const subkopjes = [
    { title: 'VOC en wereldhandel',         before: 4, after: 4, deltaThisSession: false },
    { title: 'Republiek der Zeven Provinciën', before: 4, after: 4, deltaThisSession: false },
    { title: 'Rembrandt en de schilderkunst', before: 4, after: 4, deltaThisSession: false },
    { title: 'Wetenschap en Spinoza',       before: 3, after: 4, deltaThisSession: true },
  ];
  return (
    <div style={{
      background: t.card, border: `1px solid ${t.border}`,
      borderRadius: 10, padding: '16px 18px',
      display: 'flex', flexDirection: 'column', gap: 12,
    }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
        <PI name="bookmark" size={14} color={t.fgDim} strokeWidth={2.4} />
        <span style={{ fontFamily: 'Fredoka One', fontSize: 14, color: t.fg }}>
          Hoofdstuk-voortgang
        </span>
        <span style={{ flex: 1 }} />
        <span style={{
          fontSize: 10, color: t.fgMute, fontWeight: 800,
          letterSpacing: 0.4, textTransform: 'uppercase',
        }}>De Gouden Eeuw</span>
      </div>

      <div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
        {subkopjes.map((s, i) => {
          const muted = !s.deltaThisSession;
          return (
            <div key={i} style={{
              display: 'grid',
              gridTemplateColumns: '24px 1fr auto',
              gap: 12, alignItems: 'center',
              padding: '8px 10px', borderRadius: 8,
              background: s.deltaThisSession
                ? (dark ? 'rgba(34,197,94,0.08)' : 'rgba(21,128,61,0.05)')
                : 'transparent',
              border: s.deltaThisSession
                ? `1px solid ${dark ? 'rgba(34,197,94,0.22)' : 'rgba(21,128,61,0.18)'}`
                : `1px solid transparent`,
              opacity: muted ? 0.62 : 1,
            }}>
              <SubjectChip t={t} subject="geschiedenis" size="sm" iconOnly />

              <span style={{
                fontSize: 12.5, color: t.fg, fontWeight: 700,
                overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
              }}>{s.title}</span>

              <div style={{
                display: 'flex', alignItems: 'center', gap: 8,
                fontSize: 11, fontWeight: 800, whiteSpace: 'nowrap',
              }}>
                {s.deltaThisSession ? (
                  <>
                    <span style={{ color: t.fgMute }}>{s.before}/4</span>
                    <PI name="arrow-right" size={11} color={t.fgMute} strokeWidth={2.6} />
                    <span style={{
                      display: 'inline-flex', alignItems: 'center', gap: 4,
                      color: greenInk,
                    }}>
                      {s.after}/4
                      <PI name="check" size={12} color={greenInk} strokeWidth={3} />
                    </span>
                  </>
                ) : (
                  <span style={{
                    display: 'inline-flex', alignItems: 'center', gap: 4,
                    color: t.fgMute,
                  }}>
                    {s.after}/4
                    <PI name="check" size={11} color={t.fgMute} strokeWidth={2.6} />
                  </span>
                )}
              </div>
            </div>
          );
        })}
      </div>

      <div style={{
        paddingTop: 10, borderTop: `1px dashed ${t.border}`,
        fontSize: 12, color: t.fgMute, fontWeight: 600, lineHeight: 1.5,
      }}>
        Pulse plant onderhouds-herhalingen — ongeveer 1× per week, 3 minuten.
      </div>
    </div>
  );
}

/* Oefenen-pijler-kleur primary CTA, single-line, radius 10. */
function OefenenStartButton({ t }) {
  const dark = t.mode === 'dark';
  const green = pillarColor('oefenen', dark);
  return (
    <button style={{
      display: 'inline-flex', alignItems: 'center', gap: 7,
      padding: '10px 16px', borderRadius: 10,
      background: green, color: dark ? '#0A0F1E' : '#FFFFFF',
      border: 'none', cursor: 'pointer',
      fontFamily: 'Nunito', fontSize: 13, fontWeight: 800,
      letterSpacing: 0.1, whiteSpace: 'nowrap',
    }}>
      Start Oefenen — toets-mini-quiz
      <PI name="arrow-right" size={14} strokeWidth={2.6} />
    </button>
  );
}

/* ─── FRAME 3 — Kaart-front (vraagzijde, kaart 5/12) ─────────
   Sam ziet alléén de vraag. Geen grade-knoppen, één primary CTA
   "Toon antwoord". Pulse moedigt aan om eerst zelf te formuleren.
   ────────────────────────────────────────────────────────────── */
function FrameSessieFront({ t }) {
  return (
    <LerenPage t={t}
      title="Herhaling"
      subtitle="12 kaarten · 4 vakken · ~ 8 min"
      url="snapsnel.nl/leren/herhaling"
      rightExtra={<SessieControls t={t} />}
    >
      <div style={{ display: 'flex', flexDirection: 'column', gap: 18 }}>
        <SessieVoortgangsBalk t={t} idx={5} total={12} verdeling={[
          { subject: 'biologie',     done: 3, total: 5 },
          { subject: 'engels',       done: 2, total: 4 },
          { subject: 'wiskunde',     done: 0, total: 2 },
          { subject: 'geschiedenis', done: 0, total: 1 },
        ]} />

        <FlashcardDeck t={t} card={HUIDIGE_KAART}
          flipped={false} idx={5} total={12} showStackHint
          flipCtaSub="Probeer eerst zelf het antwoord te formuleren." />

        <div style={{
          display: 'flex', alignItems: 'center', gap: 10,
          padding: '11px 14px', borderRadius: 10,
          background: t.cardSunken, border: `1px solid ${t.border}`,
        }}>
          <PulseMascot size={26} mood="thinking" />
          <span style={{ fontSize: 12, color: t.fgMute, fontWeight: 600, lineHeight: 1.5, flex: 1 }}>
            Neem even de tijd. Hardop zeggen helpt.
          </span>
        </div>
      </div>
    </LerenPage>
  );
}

/* ─── FRAME 4 — Post-grade feedback ──────────────────────────
   Tussenstate na "Goed". Kaart krijgt subtiel groene tint, vinkje +
   "Goed gedaan — morgen weer". Pulse=happy. Voortgangsbalk is al
   bijgewerkt naar 6/12 (auto-advance impliceert volgende kaart).
   ────────────────────────────────────────────────────────────── */
function FrameSessiePostGrade({ t }) {
  const dark = t.mode === 'dark';
  const greenTint = dark ? 'rgba(34,197,94,0.10)' : 'rgba(21,128,61,0.06)';
  const greenBorder = dark ? 'rgba(34,197,94,0.32)' : 'rgba(21,128,61,0.28)';
  const greenInk = dark ? '#22C55E' : '#15803D';
  return (
    <LerenPage t={t}
      title="Herhaling"
      subtitle="12 kaarten · 4 vakken · ~ 8 min"
      url="snapsnel.nl/leren/herhaling"
      rightExtra={<SessieControls t={t} />}
    >
      <div style={{ display: 'flex', flexDirection: 'column', gap: 18 }}>
        <SessieVoortgangsBalk t={t} idx={6} total={12} verdeling={[
          { subject: 'biologie',     done: 4, total: 5 },
          { subject: 'engels',       done: 2, total: 4 },
          { subject: 'wiskunde',     done: 0, total: 2 },
          { subject: 'geschiedenis', done: 0, total: 1 },
        ]} />

        {/* Kaart met groen-getinte achtergrond */}
        <div style={{
          background: greenTint,
          border: `1px solid ${greenBorder}`,
          borderRadius: 10, padding: '24px 26px',
          display: 'flex', flexDirection: 'column', gap: 14,
        }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
            <SubjectChip t={t} subject={HUIDIGE_KAART.subject} size="sm" iconOnly />
            <span style={{ fontSize: 11.5, color: t.fgDim, fontWeight: 700 }}>
              {HUIDIGE_KAART.source}
            </span>
            <span style={{ flex: 1 }} />
            <span style={{ fontSize: 11, color: t.fgMute, fontWeight: 800, letterSpacing: 0.3 }}>
              Kaart 6 / 12
            </span>
          </div>

          <div style={{
            display: 'flex', alignItems: 'center', gap: 12,
            padding: '14px 16px', borderRadius: 10,
            background: dark ? 'rgba(34,197,94,0.16)' : 'rgba(21,128,61,0.10)',
            border: `1px solid ${greenBorder}`,
          }}>
            <div style={{
              width: 32, height: 32, borderRadius: 999,
              display: 'flex', alignItems: 'center', justifyContent: 'center',
              background: greenInk, color: dark ? '#0A0F1E' : '#FFFFFF',
              flexShrink: 0,
            }}>
              <PI name="check" size={18} strokeWidth={3} />
            </div>
            <div style={{ flex: 1, minWidth: 0 }}>
              <div style={{
                fontFamily: 'Fredoka One', fontSize: 17, color: greenInk,
                lineHeight: 1.2, letterSpacing: '-0.005em',
              }}>Goed gedaan — morgen weer</div>
              <div style={{ fontSize: 12, color: t.fgDim, fontWeight: 600, marginTop: 3 }}>
                Mitose · genoteerd als 'Goed'.
              </div>
            </div>
          </div>

          <div style={{
            paddingTop: 12, borderTop: `1px dashed ${t.border}`,
            display: 'flex', alignItems: 'center', gap: 10,
          }}>
            <PulseMascot size={28} mood="happy" />
            <span style={{ fontSize: 12.5, color: t.fgDim, fontWeight: 600, lineHeight: 1.5, flex: 1 }}>
              Lekker bezig. Volgende kaart komt eraan.
            </span>
            <span style={{
              display: 'inline-flex', alignItems: 'center', gap: 6,
              fontSize: 11, color: t.fgMute, fontWeight: 700,
              fontStyle: 'italic',
            }}>
              <PulseSpinner color={t.fgMute} />
              Volgende kaart…
            </span>
          </div>
        </div>
      </div>
    </LerenPage>
  );
}

function PulseSpinner({ color }) {
  return (
    <span style={{
      display: 'inline-block', width: 10, height: 10, borderRadius: 999,
      border: `2px solid ${color}`, borderTopColor: 'transparent',
      animation: 'pulseSpin 0.9s linear infinite',
    }}>
      <style>{`@keyframes pulseSpin{from{transform:rotate(0)}to{transform:rotate(360deg)}}`}</style>
    </span>
  );
}

/* ─── FRAME 5 — Vroege-stop modal ────────────────────────────
   Modal-overlay binnen view. Achterliggende flow gedimd zichtbaar.
   Twee CTA's: Doorgaan (primary) / Pauzeren en stoppen (secondary).
   Geen Pulse-card IN modal — Pulse blijft op de gedimde flow erachter.
   ────────────────────────────────────────────────────────────── */
function FrameSessiePauze({ t }) {
  return (
    <LerenPage t={t}
      title="Herhaling"
      subtitle="12 kaarten · 4 vakken · ~ 8 min"
      url="snapsnel.nl/leren/herhaling"
      rightExtra={<SessieControls t={t} />}
    >
      {/* Achterliggende (gedimde) flow — zelfde als FrameSessieKaart */}
      <div style={{ position: 'relative' }}>
        <div style={{
          display: 'flex', flexDirection: 'column', gap: 18,
          opacity: 0.35, pointerEvents: 'none',
          filter: 'blur(0.5px)',
        }}>
          <SessieVoortgangsBalk t={t} idx={6} total={12} verdeling={[
            { subject: 'biologie',     done: 4, total: 5 },
            { subject: 'engels',       done: 2, total: 4 },
            { subject: 'wiskunde',     done: 0, total: 2 },
            { subject: 'geschiedenis', done: 0, total: 1 },
          ]} />
          <FlashcardDeck t={t} card={HUIDIGE_KAART}
            flipped idx={6} total={12} showStackHint />
        </div>

        {/* Dim-overlay */}
        <div style={{
          position: 'absolute', inset: -4, borderRadius: 12,
          background: t.mode === 'dark'
            ? 'rgba(8,12,24,0.55)'
            : 'rgba(15,23,42,0.18)',
          backdropFilter: 'blur(1px)',
          pointerEvents: 'none',
        }} />

        {/* Modal */}
        <div style={{
          position: 'absolute', top: '50%', left: '50%',
          transform: 'translate(-50%, -50%)',
          width: 'min(440px, calc(100% - 32px))',
          background: t.card, border: `1px solid ${t.borderStrong}`,
          borderRadius: 14, padding: '22px 24px',
          boxShadow: t.mode === 'dark'
            ? '0 24px 60px rgba(0,0,0,0.55), 0 4px 12px rgba(0,0,0,0.3)'
            : '0 20px 50px rgba(15,23,42,0.18), 0 4px 12px rgba(15,23,42,0.08)',
          display: 'flex', flexDirection: 'column', gap: 14,
        }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
            <div style={{
              width: 32, height: 32, borderRadius: 10,
              display: 'flex', alignItems: 'center', justifyContent: 'center',
              background: t.cardSunken, border: `1px solid ${t.border}`,
              color: t.fgDim,
            }}>
              <PI name="pause" size={15} strokeWidth={2.6} />
            </div>
            <h2 style={{
              margin: 0, fontFamily: 'Fredoka One', fontSize: 20,
              color: t.fg, lineHeight: 1.15, letterSpacing: '-0.01em',
            }}>Sessie pauzeren?</h2>
          </div>

          <p style={{
            margin: 0, fontSize: 13.5, color: t.fgDim,
            lineHeight: 1.6, fontWeight: 500,
          }}>
            Je hebt 6 van 12 kaarten gedaan. Je voortgang blijft bewaard — Pulse onthoudt waar je gebleven was.
          </p>

          <div style={{
            display: 'flex', gap: 10, justifyContent: 'flex-end',
            paddingTop: 6, flexWrap: 'wrap',
          }}>
            <BtnGhost t={t} icon="log-out">Pauzeren en stoppen</BtnGhost>
            <BtnPrimary t={t} icon="play">Doorgaan</BtnPrimary>
          </div>
        </div>
      </div>
    </LerenPage>
  );
}
