/* ============================================================
   Phone screen components — interactive overlays on Seedream images
   Each screen uses the Seedream image as background and adds
   real HTML interactive controls on top.
   ============================================================ */

const { useState, useEffect, useRef, useCallback } = React;

// ─────────────────────────────────────────
// Utility: preference option data
// ─────────────────────────────────────────
const PREFERENCE_QUESTIONS = [
  {
    key: 'household',
    question: 'Who are you finding a home for?',
    subtitle: 'Tell us about your household so we can find the right home for your family.',
    options: [
      { value: 'single', label: 'Just me', icon: 'single' },
      { value: 'couple', label: 'A couple', icon: 'couple' },
      { value: 'family', label: 'A growing family', icon: 'family' },
      { value: 'multi-gen', label: 'A multi-generation family', icon: 'multigen' },
    ],
  },
  {
    key: 'lifestage',
    question: 'Which stage of life best describes you?',
    subtitle: 'Your life stage shapes the kind of home that fits best.',
    options: [
      { value: 'just-started', label: 'Just starting out', icon: 'sprout' },
      { value: 'growing', label: 'Growing with kids', icon: 'kids' },
      { value: 'nesting', label: 'Settled and nesting', icon: 'nest' },
      { value: 'empty-nest', label: 'Empty nesters', icon: 'bird' },
    ],
  },
  {
    key: 'priority',
    question: 'What matters most in your daily life?',
    subtitle: 'Pick the one that would make the biggest difference.',
    options: [
      { value: 'green-space', label: 'Green space & nature', icon: 'leaf' },
      { value: 'privacy', label: 'Privacy & quiet', icon: 'shield' },
      { value: 'entertaining', label: 'Hosting & entertaining', icon: 'glass' },
      { value: 'proximity', label: 'Close to amenities', icon: 'pin' },
    ],
  },
  {
    key: 'spaceStyle',
    question: 'What\'s your ideal home feeling?',
    subtitle: 'The mood you want to walk into every day.',
    options: [
      { value: 'bright-open', label: 'Bright and open', icon: 'sun' },
      { value: 'cozy-traditional', label: 'Warm and cozy', icon: 'candle' },
      { value: 'modern-minimal', label: 'Sleek and modern', icon: 'cube' },
      { value: 'outdoor-focused', label: 'Indoor-outdoor flow', icon: 'door' },
    ],
  },
  {
    key: 'communityVibe',
    question: 'What kind of community feels like home?',
    subtitle: 'The neighborhood matters as much as the house.',
    options: [
      { value: 'walkable-family', label: 'Walkable & family-friendly', icon: 'walk' },
      { value: 'quiet-suburban', label: 'Quiet suburban feel', icon: 'house' },
      { value: 'vibrant-urban', label: 'Vibrant and connected', icon: 'city' },
      { value: 'nature-retreat', label: 'Nature retreat', icon: 'mountain' },
    ],
  },
];

// ─────────────────────────────────────────
// Icon components for preference options
// ─────────────────────────────────────────
function PrefIcon({ type }) {
  const icons = {
    single: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <circle cx="12" cy="7" r="3.5"/>
        <path d="M5 21c0-3.5 3-6 7-6s7 2.5 7 6"/>
      </svg>
    ),
    couple: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <circle cx="8" cy="7" r="2.8"/>
        <circle cx="16" cy="7" r="2.8"/>
        <path d="M3 20c0-3 2.5-5 5-5s5 2 5 5"/>
        <path d="M11 20c0-3 2.5-5 5-5s5 2 5 5"/>
      </svg>
    ),
    family: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <circle cx="12" cy="5" r="2.5"/>
        <circle cx="6" cy="9" r="2"/>
        <circle cx="18" cy="9" r="2"/>
        <path d="M4 20c0-2.5 1.5-4.5 4-4.5s4 2 4 4.5"/>
        <path d="M12 20c0-2.5 1.5-4.5 4-4.5s4 2 4 4.5"/>
      </svg>
    ),
    multigen: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <circle cx="6" cy="6" r="2.2"/>
        <circle cx="12" cy="5" r="2.5"/>
        <circle cx="18" cy="6" r="2.2"/>
        <path d="M3 19c0-2 1.5-3.5 3.5-3.5S10 17 10 19"/>
        <path d="M7 19c0-2.5 2-4.5 5-4.5s5 2 5 4.5"/>
        <path d="M14 19c0-2 1.5-3.5 3.5-3.5S21 17 21 19"/>
      </svg>
    ),
    sprout: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <path d="M12 20V10"/>
        <path d="M12 10C12 6 9 5 7 5c0 3 1 5 5 5z"/>
        <path d="M12 13c0-3 3-4 5-4 0 3-2 5-5 5z"/>
      </svg>
    ),
    kids: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <circle cx="12" cy="6" r="3"/>
        <path d="M8 14v5"/>
        <path d="M16 14v5"/>
        <path d="M6 10c1-1 3-1.5 6-1.5s5 .5 6 1.5"/>
        <path d="M7 20h10"/>
      </svg>
    ),
    nest: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <path d="M3 18c3-4 6-6 9-6s6 2 9 6"/>
        <ellipse cx="12" cy="18" rx="9" ry="2.5"/>
        <circle cx="10" cy="16" r="1.2" fill="currentColor"/>
        <circle cx="14" cy="16.5" r="1" fill="currentColor"/>
      </svg>
    ),
    bird: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <path d="M16 7a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"/>
        <path d="M16 7c-2 2-5 3-8 3H3l2-5h3"/>
        <path d="M16 7l-2 4"/>
        <path d="M9 16c3-1 5-3 7-6"/>
      </svg>
    ),
    leaf: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <path d="M20 4C10 4 4 10 4 20c10 0 16-6 16-16z"/>
        <path d="M4 20L14 10"/>
      </svg>
    ),
    shield: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <path d="M12 2l8 3v6c0 5-3.5 8.5-8 10-4.5-1.5-8-5-8-10V5l8-3z"/>
      </svg>
    ),
    glass: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <path d="M8 21h8"/>
        <path d="M12 17v4"/>
        <path d="M7 4h10l-1.5 9h-7L7 4z"/>
        <path d="M8 4c0 2 2 3 4 3s4-1 4-3"/>
      </svg>
    ),
    pin: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <circle cx="12" cy="10" r="3.5"/>
        <path d="M12 22s7-7 7-12a7 7 0 0 0-14 0c0 5 7 12 7 12z"/>
      </svg>
    ),
    sun: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <circle cx="12" cy="12" r="4"/>
        <path d="M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6l1.4 1.4M17 17l1.4 1.4M5.6 18.4L7 17M17 7l1.4-1.4"/>
      </svg>
    ),
    candle: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <path d="M12 2c1 2 2 3 2 5a2 2 0 1 1-4 0c0-2 1-3 2-5z"/>
        <rect x="8" y="10" width="8" height="11" rx="1.5"/>
        <path d="M8 15h8"/>
      </svg>
    ),
    cube: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <path d="M12 3l8 4v10l-8 4-8-4V7l8-4z"/>
        <path d="M12 3v18M4 7l8 4 8-4"/>
      </svg>
    ),
    door: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <rect x="4" y="3" width="16" height="19" rx="1"/>
        <circle cx="15" cy="13" r="1" fill="currentColor"/>
        <path d="M4 8h16"/>
      </svg>
    ),
    walk: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <circle cx="13" cy="5" r="2"/>
        <path d="M8 21l2-6 3-2 1 4"/>
        <path d="M14 11l2 4 3 1"/>
        <path d="M7 14l-2 1"/>
      </svg>
    ),
    house: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <path d="M3 11l9-7 9 7"/>
        <path d="M5 10v10h14V10"/>
        <path d="M10 20v-6h4v6"/>
      </svg>
    ),
    city: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <rect x="3" y="10" width="5" height="11"/>
        <rect x="10" y="5" width="5" height="16"/>
        <rect x="17" y="8" width="4" height="13"/>
        <rect x="5" y="12" width="1.5" height="1.5" fill="currentColor"/>
        <rect x="12" y="7" width="1.5" height="1.5" fill="currentColor"/>
        <rect x="12" y="11" width="1.5" height="1.5" fill="currentColor"/>
      </svg>
    ),
    mountain: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
        <path d="M3 20l5-9 4 6 3-4 6 7H3z"/>
        <path d="M10 11l2-3 1 1"/>
      </svg>
    ),
  };
  return (
    <div style={{ width: 22, height: 22, flexShrink: 0 }}>
      {icons[type] || icons.single}
    </div>
  );
}

// ─────────────────────────────────────────
// Screen 01: Discover
// ─────────────────────────────────────────
function DiscoverScreen() {
  const { dispatch } = useApp();

  const handleStart = () => {
    dispatch({ type: 'NEXT_STEP' });
  };

  const handleExplore = () => {
    // Jump directly to match step
    dispatch({ type: 'SET_STEP', step: 2 });
  };

  return (
    <div style={{
      position: 'absolute', inset: 0,
      display: 'flex', flexDirection: 'column',
      zIndex: 1,
    }}>
      {/* Top: ambient visual from background image (top 40% with fade) */}
      <div style={{
        position: 'absolute', top: 0, left: 0, right: 0,
        height: '42%',
        pointerEvents: 'none',
      }} />
      {/* Solid bottom panel — hides baked-in image text, provides clean
          surface for native HTML copy so nothing double-renders */}
      <div style={{
        position: 'absolute', left: 0, right: 0, bottom: 0,
        height: '62%',
        background: 'linear-gradient(to top, #0B2E24 0%, #0B2E24 70%, rgba(11,46,36,0.92) 88%, rgba(11,46,36,0) 100%)',
        pointerEvents: 'none',
      }} />

      {/* Content — all text lives here, fully on the solid panel */}
      <div style={{
        position: 'relative', zIndex: 2,
        flex: 1,
        display: 'flex',
        flexDirection: 'column',
        justifyContent: 'flex-end',
        padding: '0 24px 36px',
      }}>
        <div style={{ marginBottom: 'auto', paddingTop: 100 }}>
          <div style={{
            display: 'inline-flex', alignItems: 'center', gap: 6,
            padding: '5px 12px',
            background: 'rgba(201, 169, 98, 0.15)',
            border: '1px solid rgba(201, 169, 98, 0.3)',
            borderRadius: 100,
            color: '#C9A962',
            fontSize: 11.5,
            fontWeight: 500,
            marginBottom: 14,
            letterSpacing: '0.02em',
          }}>
            <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" width="12" height="12">
              <path d="M12 3l2 5 5 2-5 2-2 5-2-5-5-2 5-2 2-5z"/>
            </svg>
            AI-Powered Home Match
          </div>
        </div>

        <div style={{
          fontFamily: "'Fraunces', serif",
          fontSize: 42,
          fontWeight: 500,
          lineHeight: 1.05,
          letterSpacing: '-0.03em',
          color: '#F5EFE0',
          marginBottom: 14,
        }}>
          Find the home where <span style={{ color: '#C9A962', fontStyle: 'italic', fontWeight: 400 }}>your life fits</span>.
        </div>
        <p style={{
          fontSize: 15.5, lineHeight: 1.55,
          color: 'rgba(245, 239, 224, 0.75)',
          maxWidth: 320,
          marginBottom: 28,
        }}>
          Tell us how you want to live. We'll match you with homes and communities that fit your lifestyle — then show you what a day in your future home could look like.
        </p>

        <button
          onClick={handleStart}
          style={{
            width: '100%',
            display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8,
            padding: '16px 28px',
            background: '#C9A962',
            border: 'none',
            borderRadius: 100,
            color: '#0B2E24',
            fontSize: 16.5,
            fontWeight: 600,
            cursor: 'pointer',
            transition: 'all 0.2s ease',
            marginBottom: 12,
          }}
          onMouseEnter={(e) => {
            e.currentTarget.style.background = '#E0C98E';
            e.currentTarget.style.transform = 'translateY(-1px)';
          }}
          onMouseLeave={(e) => {
            e.currentTarget.style.background = '#C9A962';
            e.currentTarget.style.transform = 'translateY(0)';
          }}
        >
          <svg viewBox="0 0 24 24" fill="currentColor" width="18" height="18">
            <polygon points="8,5 19,12 8,19"/>
          </svg>
          Start My Match
        </button>
        <button
          onClick={handleExplore}
          style={{
            width: '100%',
            padding: '15px 28px',
            background: 'transparent',
            border: '1.5px solid rgba(245, 239, 224, 0.25)',
            borderRadius: 100,
            color: '#F5EFE0',
            fontSize: 16,
            fontWeight: 400,
            cursor: 'pointer',
            transition: 'all 0.2s ease',
          }}
          onMouseEnter={(e) => {
            e.currentTarget.style.borderColor = 'rgba(245, 239, 224, 0.5)';
            e.currentTarget.style.background = 'rgba(245, 239, 224, 0.06)';
          }}
          onMouseLeave={(e) => {
            e.currentTarget.style.borderColor = 'rgba(245, 239, 224, 0.25)';
            e.currentTarget.style.background = 'transparent';
          }}
        >
          Explore Homes
        </button>

        <div style={{ marginTop: 24, textAlign: 'center' }}>
          <p style={{
            fontSize: 12.5, color: 'rgba(245, 239, 224, 0.5)',
          }}>
            Free demo · No real data stored
          </p>
        </div>
      </div>
    </div>
  );
}

// ─────────────────────────────────────────
// Screen 02: Preferences
// ─────────────────────────────────────────
function PreferencesScreen() {
  const { state, dispatch } = useApp();
  const [qIndex, setQIndex] = useState(0);
  const questions = PREFERENCE_QUESTIONS;

  const currentQ = questions[qIndex];
  const currentVal = state.preferences[currentQ.key];
  const progress = ((qIndex + 1) / questions.length) * 100;

  const handleSelect = (value) => {
    dispatch({ type: 'SET_PREFERENCE', key: currentQ.key, value });
  };

  const handleNext = () => {
    if (qIndex < questions.length - 1) {
      setQIndex(qIndex + 1);
    } else {
      dispatch({ type: 'NEXT_STEP' });
    }
  };

  const handlePrev = () => {
    if (qIndex > 0) {
      setQIndex(qIndex - 1);
    } else {
      dispatch({ type: 'PREV_STEP' });
    }
  };

  const canContinue = currentVal !== null;

  return (
    <div style={{
      position: 'absolute', inset: 0,
      zIndex: 1,
      display: 'flex',
      flexDirection: 'column',
    }}>
      {/* Image header band — top photography fades into solid dark below
          (the baked-in image copy is fully covered by the solid panel) */}
      <div style={{
        height: 160,
        flexShrink: 0,
        position: 'relative',
      }}>
        <div style={{
          position: 'absolute',
          left: 0, right: 0, bottom: 0,
          height: '70%',
          background: 'linear-gradient(to bottom, rgba(11,46,36,0) 0%, #0B2E24 100%)',
        }} />
      </div>

      {/* Progress bar */}
      <div style={{
        position: 'absolute', top: 70, left: 24, right: 24,
        zIndex: 5,
        display: 'flex', alignItems: 'center', gap: 12,
      }}>
        <button
          onClick={handlePrev}
          style={{
            width: 32, height: 32, borderRadius: '50%',
            background: 'rgba(245, 239, 224, 0.15)',
            backdropFilter: 'blur(10px)',
            border: 'none',
            color: '#F5EFE0',
            cursor: 'pointer',
            display: 'flex', alignItems: 'center', justifyContent: 'center',
            transition: 'all 0.2s ease',
          }}
          onMouseEnter={(e) => { e.currentTarget.style.background = 'rgba(245, 239, 224, 0.25)'; }}
          onMouseLeave={(e) => { e.currentTarget.style.background = 'rgba(245, 239, 224, 0.15)'; }}
        >
          <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" width="16" height="16">
            <polyline points="15 18 9 12 15 6"/>
          </svg>
        </button>
        <div style={{ flex: 1, height: 3, background: 'rgba(245, 239, 224, 0.2)', borderRadius: 2, overflow: 'hidden' }}>
          <div style={{
            height: '100%',
            width: `${progress}%`,
            background: 'linear-gradient(90deg, #C9A962, #E0C98E)',
            borderRadius: 2,
            transition: 'width 0.4s ease',
          }} />
        </div>
        <span style={{ fontSize: 12, color: 'rgba(245, 239, 224, 0.7)', minWidth: 32, textAlign: 'right' }}>
          {qIndex + 1}/{questions.length}
        </span>
      </div>

      {/* Question card — sits fully on solid background, no ghost text */}
      <div style={{
        flex: 1,
        margin: '0 20px',
        background: 'rgba(245, 239, 224, 0.04)',
        border: '1px solid rgba(245, 239, 224, 0.08)',
        borderRadius: 28,
        padding: '24px 22px 26px',
        display: 'flex',
        flexDirection: 'column',
        position: 'relative',
        top: -10,
      }}>
        <div style={{
          fontFamily: "'Fraunces', serif",
          fontSize: 12,
          color: '#C9A962',
          letterSpacing: '0.08em',
          textTransform: 'uppercase',
          marginBottom: 8,
        }}>
          {questions[qIndex].key === 'household' ? 'Step 1 of 5' :
           questions[qIndex].key === 'lifestage' ? 'Step 2 of 5' :
           questions[qIndex].key === 'priority' ? 'Step 3 of 5' :
           questions[qIndex].key === 'spaceStyle' ? 'Step 4 of 5' : 'Step 5 of 5'}
        </div>

        <h2 style={{
          fontFamily: "'Fraunces', serif",
          fontSize: 30,
          fontWeight: 500,
          lineHeight: 1.15,
          letterSpacing: '-0.02em',
          color: '#F5EFE0',
          marginBottom: 10,
        }}>
          {currentQ.question}
        </h2>

        <p style={{
          fontSize: 14,
          lineHeight: 1.5,
          color: 'rgba(245, 239, 224, 0.7)',
          marginBottom: 24,
        }}>
          {currentQ.subtitle}
        </p>

        {/* Options */}
        <div style={{ flex: 1, display: 'flex', flexDirection: 'column', gap: 10, overflowY: 'auto' }}>
          {currentQ.options.map((opt) => {
            const selected = currentVal === opt.value;
            return (
              <button
                key={opt.value}
                onClick={() => handleSelect(opt.value)}
                style={{
                  display: 'flex',
                  alignItems: 'center',
                  gap: 14,
                  padding: '16px 18px',
                  background: selected ? 'rgba(201, 169, 98, 0.12)' : 'rgba(245, 239, 224, 0.04)',
                  border: `1.5px solid ${selected ? 'rgba(201, 169, 98, 0.6)' : 'rgba(245, 239, 224, 0.15)'}`,
                  borderRadius: 16,
                  color: selected ? '#F5EFE0' : 'rgba(245, 239, 224, 0.85)',
                  fontSize: 16,
                  fontWeight: selected ? 500 : 400,
                  cursor: 'pointer',
                  transition: 'all 0.2s ease',
                  textAlign: 'left',
                  width: '100%',
                }}
                onMouseEnter={(e) => {
                  if (!selected) {
                    e.currentTarget.style.background = 'rgba(245, 239, 224, 0.08)';
                    e.currentTarget.style.borderColor = 'rgba(245, 239, 224, 0.25)';
                  }
                }}
                onMouseLeave={(e) => {
                  if (!selected) {
                    e.currentTarget.style.background = 'rgba(245, 239, 224, 0.04)';
                    e.currentTarget.style.borderColor = 'rgba(245, 239, 224, 0.15)';
                  }
                }}
              >
                <div style={{
                  width: 40, height: 40,
                  borderRadius: 12,
                  background: selected ? 'rgba(201, 169, 98, 0.2)' : 'rgba(245, 239, 224, 0.08)',
                  color: selected ? '#C9A962' : 'rgba(245, 239, 224, 0.6)',
                  display: 'flex', alignItems: 'center', justifyContent: 'center',
                  flexShrink: 0,
                  transition: 'all 0.2s ease',
                }}>
                  <PrefIcon type={opt.icon} />
                </div>
                <span style={{ flex: 1 }}>{opt.label}</span>
                {selected && (
                  <div style={{
                    width: 22, height: 22, borderRadius: '50%',
                    background: '#C9A962',
                    color: '#0B2E24',
                    display: 'flex', alignItems: 'center', justifyContent: 'center',
                    flexShrink: 0,
                  }}>
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round" width="12" height="12">
                      <polyline points="20 6 9 17 4 12"/>
                    </svg>
                  </div>
                )}
              </button>
            );
          })}
        </div>

        {/* Continue button */}
        <button
          onClick={handleNext}
          disabled={!canContinue}
          style={{
            marginTop: 20,
            height: 52,
            borderRadius: 100,
            background: canContinue ? '#F5EFE0' : 'rgba(245, 239, 224, 0.1)',
            color: canContinue ? '#0B2E24' : 'rgba(245, 239, 224, 0.3)',
            fontSize: 17,
            fontWeight: 600,
            cursor: canContinue ? 'pointer' : 'not-allowed',
            border: 'none',
            display: 'flex',
            alignItems: 'center',
            justifyContent: 'center',
            gap: 8,
            transition: 'all 0.2s ease',
          }}
          onMouseEnter={(e) => {
            if (canContinue) {
              e.currentTarget.style.background = '#fff';
              e.currentTarget.style.transform = 'translateY(-1px)';
            }
          }}
          onMouseLeave={(e) => {
            e.currentTarget.style.transform = 'translateY(0)';
            if (canContinue) e.currentTarget.style.background = '#F5EFE0';
          }}
        >
          {qIndex < questions.length - 1 ? 'Continue' : 'See my matches'}
          <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" width="18" height="18">
            <line x1="5" y1="12" x2="19" y2="12"/>
            <polyline points="12 5 19 12 12 19"/>
          </svg>
        </button>
      </div>
    </div>
  );
}

// Expose
window.DiscoverScreen = DiscoverScreen;
window.PreferencesScreen = PreferencesScreen;
window.PREFERENCE_QUESTIONS = PREFERENCE_QUESTIONS;
window.PrefIcon = PrefIcon;
