// SS1 — Measurement Active (Exam Mode), Dark Mode
// Full-bleed camera screen with hero count + exam badge.

function CountdownRing({ progress = 0.7, label = '00:18' }) {
  // 18s remaining of 60s = elapsed 42/60 = 0.7 of ring filled
  const size = 140;
  const stroke = 8;
  const r = (size - stroke) / 2;
  const c = 2 * Math.PI * r;
  return (
    <div style={{
      width: size, height: size, position: 'relative',
      display: 'flex', alignItems: 'center', justifyContent: 'center',
    }}>
      <svg width={size} height={size} style={{ position: 'absolute', inset: 0, transform: 'rotate(-90deg)' }}>
        <circle cx={size / 2} cy={size / 2} r={r}
          stroke="rgba(255,255,255,0.22)" strokeWidth={stroke} fill="none" />
        <circle cx={size / 2} cy={size / 2} r={r}
          stroke="#FFFFFF" strokeWidth={stroke} fill="none"
          strokeDasharray={c} strokeDashoffset={c * (1 - progress)}
          strokeLinecap="round" />
      </svg>
      <span style={{
        color: '#FFFFFF', fontSize: 30, fontWeight: 500,
        fontFamily: RC.fontMono, fontVariantNumeric: 'tabular-nums',
        textShadow: '0 2px 6px rgba(0,0,0,0.5)',
      }}>{label}</span>
    </div>
  );
}

function GlassPill({ children, fontSize = 38, fontWeight = 600, opacity = 0.96, extraStyle = {} }) {
  return (
    <div style={{
      display: 'inline-flex', alignItems: 'center', gap: 14,
      padding: '20px 32px',
      borderRadius: 9999,
      background: 'rgba(0,0,0,0.32)',
      backdropFilter: 'blur(20px) saturate(180%)',
      WebkitBackdropFilter: 'blur(20px) saturate(180%)',
      border: '1.5px solid rgba(255,255,255,0.18)',
      color: `rgba(255,255,255,${opacity})`,
      fontSize, fontWeight,
      fontFamily: RC.fontSans,
      whiteSpace: 'nowrap',
      ...extraStyle,
    }}>{children}</div>
  );
}

function GraduationCap({ size = 36, color = '#FFFFFF' }) {
  // Simple mortarboard glyph: trapezoid top + tassel
  return (
    <svg width={size} height={size * 0.85} viewBox="0 0 24 20" fill="none">
      <path d="M12 3 L23 7 L12 11 L1 7 Z" fill={color}/>
      <path d="M4 9 L4 14 C4 15.5 7.5 17 12 17 C16.5 17 20 15.5 20 14 L20 9"
        stroke={color} strokeWidth="1.6" fill="none" strokeLinecap="round" strokeLinejoin="round"/>
      <line x1="22" y1="7.5" x2="22" y2="13" stroke={color} strokeWidth="1.4" strokeLinecap="round"/>
      <circle cx="22" cy="14" r="1.2" fill={color}/>
    </svg>
  );
}

function SS1ActiveExam() {
  return (
    <ScreenshotShell
      dark={true}
      headline="摄像头自动计数"
      subline="实时对照中考评分，不只是计数器"
      caption="摄像头识别 · 数据本地处理 · 不上传云端"
    >
      {/* Zone B contents — 1290 × 1734 camera screen */}
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* Blurred neutral indoor placeholder — soft muted radials */}
        <div style={{
          position: 'absolute', inset: -40,
          background:
            'radial-gradient(ellipse at 30% 20%, #4a5568 0%, transparent 55%),' +
            'radial-gradient(ellipse at 80% 35%, #5d6b7a 0%, transparent 50%),' +
            'radial-gradient(ellipse at 50% 90%, #2d3748 0%, transparent 60%),' +
            'radial-gradient(ellipse at 15% 70%, #6b7280 0%, transparent 45%),' +
            'linear-gradient(180deg, #3b4252 0%, #2a323d 100%)',
          filter: 'blur(30px) saturate(0.6)',
        }} />
        {/* Skipping silhouette — custom asset, mask-fill white at 0.18 opacity */}
        <div style={{
          position: 'absolute',
          left: '50%', top: '55%',
          transform: 'translate(-50%, -50%)',
          width: 1290 * 0.55, height: 1734 * 0.55,
          WebkitMaskImage: 'url("../assets/skipping.png")',
          maskImage: 'url("../assets/skipping.png")',
          WebkitMaskSize: 'contain',
          maskSize: 'contain',
          WebkitMaskRepeat: 'no-repeat',
          maskRepeat: 'no-repeat',
          WebkitMaskPosition: 'center',
          maskPosition: 'center',
          background: 'rgba(255,255,255,0.18)',
          pointerEvents: 'none',
        }} />

        {/* Top scrim */}
        <div style={{
          position: 'absolute', top: 0, left: 0, right: 0, height: 420,
          background: 'linear-gradient(180deg, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0) 100%)',
        }} />
        {/* Bottom scrim */}
        <div style={{
          position: 'absolute', bottom: 0, left: 0, right: 0, height: 660,
          background: 'linear-gradient(0deg, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0) 100%)',
        }} />

        {/* Status bar — embedded into Zone B since camera is full-bleed */}
        <StatusBar dark={true} />

        {/* Top-left countdown ring */}
        <div style={{ position: 'absolute', top: 200, left: 60 }}>
          <CountdownRing progress={0.7} label="00:18" />
        </div>

        {/* Top-right cluster: ModeMenu pill + Province chip stacked, right-aligned */}
        <div style={{
          position: 'absolute', top: 200, right: 60,
          display: 'flex', flexDirection: 'column', alignItems: 'flex-end', gap: 18,
        }}>
          <GlassPill fontSize={42} fontWeight={600} opacity={0.96}>
            <GraduationCap size={36} color="#FFFFFF" />
            <span>中考模式</span>
            <span style={{ fontSize: 32, opacity: 0.85, marginLeft: -4 }}>⌄</span>
          </GlassPill>
          <GlassPill fontSize={32} fontWeight={500} opacity={0.92}
            extraStyle={{ padding: '16px 28px' }}>
            <span>北京 · 初三 · 男</span>
            <span style={{ fontSize: 26, opacity: 0.7 }}>⌄</span>
          </GlassPill>
        </div>

        {/* Hero count "127" — vertically centered in remaining space */}
        <div style={{
          position: 'absolute',
          left: 0, right: 0, top: '50%',
          transform: 'translateY(-50%)',
          display: 'flex', flexDirection: 'column', alignItems: 'center',
          gap: 28,
        }}>
          <div style={{
            fontFamily: RC.fontRounded,
            fontWeight: 200,
            fontSize: 380,
            lineHeight: 0.95,
            color: '#FFFFFF',
            fontVariantNumeric: 'tabular-nums',
            letterSpacing: -8,
            textShadow: '0 6px 24px rgba(0,0,0,0.45), 0 2px 6px rgba(0,0,0,0.35)',
          }}>127</div>
          {/* ExamScoreBadge — examMid SOLID 0.85 fill + white text */}
          <div style={{
            display: 'inline-flex', alignItems: 'center',
            padding: '20px 36px',
            borderRadius: 9999,
            background: 'rgba(16,185,129,0.92)', // examMid dark @ 0.85+
            color: '#FFFFFF',
            fontSize: 42, fontWeight: 600,
            fontFamily: RC.fontSans,
            boxShadow: '0 4px 14px rgba(0,0,0,0.25)',
            letterSpacing: -0.2,
          }}>
            ≈ 中考 17 分 / 满分 20
          </div>
        </div>

        {/* Bottom strip — three white items with drop shadow */}
        <div style={{
          position: 'absolute', bottom: 100, left: 0, right: 0,
          display: 'flex', justifyContent: 'center', alignItems: 'center', gap: 50,
          color: '#FFFFFF', fontSize: 36, fontWeight: 500,
          fontFamily: RC.fontSans,
          textShadow: '0 2px 8px rgba(0,0,0,0.6)',
        }}>
          <span style={{ fontVariantNumeric: 'tabular-nums' }}>127 个/分</span>
          <span style={{ opacity: 0.5, fontSize: 28 }}>·</span>
          <span style={{ opacity: 0.85 }}>长按暂停</span>
          <span style={{ opacity: 0.5, fontSize: 28 }}>·</span>
          <span style={{ fontVariantNumeric: 'tabular-nums' }}>≈ 23 kcal</span>
        </div>
      </div>
    </ScreenshotShell>
  );
}

window.SS1ActiveExam = SS1ActiveExam;
