// components/hero.jsx — four hero variants
// 1. cycle  — Live Sedona day/night cycle
// 2. twilight — Static parallax twilight scene
// 3. starmap — Constellation art focus
// 4. reticle — Telescope eyepiece reticle

// ── Shared Sedona skyline (rear horizon range) ────────────
function RedRocksFar({ opacity = 1, color = '#3a1a14' }) {
  return (
    <svg viewBox="0 0 1440 240" preserveAspectRatio="none"
         style={{ position: 'absolute', left: 0, right: 0, bottom: 0, width: '100%', height: '24vh', opacity }}>
      <path fill={color}
        d="M0,240 L0,170 L60,140 L130,165 L220,110 L290,135 L380,100 L460,130 L520,90 L600,135
           L680,80 L760,115 L840,70 L920,120 L1000,95 L1080,135 L1170,90 L1250,125 L1340,100
           L1440,140 L1440,240 Z" />
    </svg>
  );
}

// Foreground spires — recognizable Sedona / Cathedral Rock-ish silhouette
function RedRocksNear({ color = '#2a0f0a' }) {
  return (
    <svg viewBox="0 0 1440 360" preserveAspectRatio="none"
         style={{ position: 'absolute', left: 0, right: 0, bottom: 0, width: '100%', height: '32vh' }}>
      <path fill={color}
        d="M0,360 L0,260 L80,250 L140,220 L180,235 L220,180
           L260,160 L290,140 L310,130 L335,140 L355,165 L370,150 L395,155 L420,200 L445,210
           L470,205 L490,180 L510,170 L530,175 L555,225 L585,235 L620,240
           L660,200 L700,170 L735,150 L765,158 L795,200 L820,230
           L860,240 L920,260 L985,225 L1040,210 L1095,235
           L1145,210 L1195,200 L1245,225 L1295,250 L1340,265 L1390,260 L1440,275
           L1440,360 Z" />
    </svg>
  );
}

// Tiny Saguaro/desert plants along the foreground edge
function DesertEdge({ color = '#1a0806' }) {
  return (
    <svg viewBox="0 0 1440 80" preserveAspectRatio="none"
         style={{ position: 'absolute', left: 0, right: 0, bottom: 0, width: '100%', height: '70px' }}>
      <path fill={color} d="M0,80 L0,40 L1440,55 L1440,80 Z" />
      {/* A few scrubby tufts */}
      <g fill={color}>
        <path d="M180,50 q4,-12 8,0 z" />
        <path d="M340,45 q5,-15 10,0 z" />
        <path d="M560,52 q6,-18 12,0 z" />
        <path d="M820,48 q5,-14 10,0 z" />
        <path d="M1080,50 q4,-12 8,0 z" />
        <path d="M1240,46 q6,-16 12,0 z" />
      </g>
    </svg>
  );
}

// Star field as positioned divs (more performant than many SVG circles)
function StarField({ stars, opacity = 1 }) {
  return (
    <div style={{ position: 'absolute', inset: 0, opacity, pointerEvents: 'none' }}>
      {stars.map((s, i) => (
        <div key={i} className="star" style={{
          left: s.x + '%',
          top: s.y + '%',
          width: s.size + 'px',
          height: s.size + 'px',
          '--dur': s.dur + 's',
          '--star-max': s.max,
          '--star-min': s.min,
          animationDelay: s.delay + 's',
          boxShadow: s.size > 1.6 ? `0 0 ${s.size * 2}px rgba(248,244,232,0.7)` : undefined,
        }} />
      ))}
    </div>
  );
}

// Sun or moon disc
function CelestialBody({ kind, x, y, hidden }) {
  const isMoon = kind === 'moon';
  const size = isMoon ? 62 : 96;
  if (hidden) return null;
  return (
    <div style={{
      position: 'absolute',
      left: x + '%',
      top: y * 100 + '%',
      width: size, height: size,
      borderRadius: '50%',
      background: isMoon ? '#F4E4B0' : 'radial-gradient(circle at 40% 35%, #fff9d6, #f5b94a 65%, #d97243)',
      boxShadow: isMoon
        ? '0 0 80px 16px rgba(244,228,176,0.35), inset -10px -8px 24px rgba(0,0,0,0.18)'
        : '0 0 140px 30px rgba(245,185,74,0.45)',
      transform: 'translate(-50%, -50%)',
      transition: 'all 1.2s cubic-bezier(0.4,0,0.2,1)',
    }} />
  );
}

// ─────────────────────────────────────────────────────────
//  Hero 1 — Day/Night Cycle (live)
// ─────────────────────────────────────────────────────────

const HERO_STARS = makeStars(110, 11);

function HeroCycle({ hour, phase, onBook, go }) {
  const grad = SKY_GRADIENTS[phase];
  const gradStops = grad.map((c, i) => `${c} ${(i / (grad.length - 1)) * 100}%`).join(', ');
  const isDark = phase === 'night' || phase === 'twilight' || phase === 'dawn';
  const starOpacity = phase === 'night' ? 1 : phase === 'twilight' ? 0.55 : phase === 'dawn' ? 0.2 : 0;
  const sunY = getSunY(hour);
  const moonY = getMoonY(hour);
  const sunX = 12 + ((hour - 6) / 12) * 76;
  const moonX = 88 - (((hour > 18 ? hour - 18 : hour + 6) / 12) * 76);
  const moon = getMoonPhase();

  return (
    <section style={{
      position: 'relative',
      minHeight: '92vh',
      overflow: 'hidden',
      background: `linear-gradient(180deg, ${gradStops})`,
      color: 'var(--c-star)',
      transition: 'background 1.5s ease',
    }}>
      {/* Stars */}
      <StarField stars={HERO_STARS} opacity={starOpacity} />

      {/* Sun & moon */}
      <CelestialBody kind="sun" x={sunX} y={sunY} hidden={hour < 6 || hour > 18.5} />
      <CelestialBody kind="moon" x={moonX} y={moonY} hidden={hour > 5 && hour < 18} />

      {/* Atmospheric haze near horizon when sunset */}
      {(phase === 'sunset' || phase === 'twilight') && (
        <div style={{
          position: 'absolute', left: 0, right: 0, bottom: '32vh', height: '20vh',
          background: 'linear-gradient(180deg, transparent, rgba(217,114,67,0.32))',
          pointerEvents: 'none',
        }} />
      )}

      {/* Red rock layers */}
      <RedRocksFar opacity={isDark ? 0.85 : 1} color={isDark ? '#1a0a08' : '#5a2a1c'} />
      <RedRocksNear color={isDark ? '#0a0405' : '#3a1410'} />
      <DesertEdge color="#06030a" />

      {/* Content */}
      <div style={{ position: 'relative', zIndex: 5 }}>
        <div className="wrap" style={{ paddingTop: 'clamp(56px, 9vw, 130px)', paddingBottom: 'clamp(56px, 9vw, 130px)' }}>
          <div style={{ maxWidth: 880 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 28 }}>
              <span className="tag tag--dot" style={{
                background: 'rgba(248,244,232,0.08)',
                borderColor: 'rgba(248,244,232,0.18)',
                color: 'rgba(248,244,232,0.85)',
                backdropFilter: 'blur(6px)',
              }}>
                <span style={{ color: phase === 'night' ? '#9be09b' : phase === 'sunset' ? '#f5b94a' : '#9be09b' }}>●</span>
                {phase === 'night' ? 'Open tonight' : phase === 'sunset' ? 'Gates open in 45 min' : 'Booking nightly'}
              </span>
              <span style={{ fontFamily: 'var(--f-ui)', fontSize: 12, color: 'rgba(248,244,232,0.6)', letterSpacing: '0.04em' }}>
                Sedona, Arizona · {Math.floor(hour)}:{String(Math.floor((hour % 1) * 60)).padStart(2, '0')} local
              </span>
            </div>

            <h1 className="display" style={{
              fontSize: 'clamp(54px, 8.4vw, 120px)',
              margin: '0 0 28px',
              maxWidth: 1000,
            }}>
              The red rocks fade.<br/>
              The <em>universe</em> turns on.
            </h1>

            <p className="lead" style={{ maxWidth: 580, color: 'rgba(248,244,232,0.82)', marginBottom: 36 }}>
              A small-group, guide-led stargazing experience beneath one of Arizona's
              most protected dark skies. Telescopes. Constellations. Saturn's rings when
              conditions allow.
            </p>

            <div style={{ display: 'flex', gap: 12, flexWrap: 'wrap', alignItems: 'center' }}>
              <button className="btn btn--moon" onClick={onBook}>
                Book a Star Show <IconArrow size={16} />
              </button>
              <button className="btn btn--ghost-night" onClick={() => go('sky')}>
                See what's visible tonight
              </button>
            </div>

            <div style={{
              marginTop: 56,
              display: 'flex',
              gap: 28,
              flexWrap: 'wrap',
              fontFamily: 'var(--f-ui)',
              fontSize: 13,
              color: 'rgba(248,244,232,0.7)',
            }}>
              <TrustItem label="Small groups" sub="Max 10 guests" />
              <Divider />
              <TrustItem label="Real telescopes" sub="Celestron 8″ &amp; 11″" />
              <Divider />
              <TrustItem label="Dark Sky community" sub="Since 2014" />
              <Divider />
              <TrustItem label="Family friendly" sub="Ages 5+" />
            </div>
          </div>
        </div>
      </div>

      {/* Bottom-right tonight card */}
      <TonightCardFloating moon={moon} phase={phase} go={go} />
    </section>
  );
}

function TrustItem({ label, sub }) {
  return (
    <div>
      <div style={{ fontWeight: 600, color: 'rgba(248,244,232,0.95)' }}>{label}</div>
      <div style={{ opacity: 0.7, fontSize: 12 }}>{sub}</div>
    </div>
  );
}
function Divider() {
  return <div style={{ width: 1, height: 24, background: 'rgba(248,244,232,0.18)', alignSelf: 'center' }} />;
}

function TonightCardFloating({ moon, phase, go }) {
  return (
    <div className="hero-tonight-floating" style={{
      position: 'absolute',
      right: 'clamp(20px, 4vw, 56px)',
      bottom: 'clamp(20px, 4vw, 56px)',
      width: 280,
      padding: 20,
      borderRadius: 18,
      background: 'rgba(7,17,31,0.55)',
      backdropFilter: 'blur(20px) saturate(140%)',
      border: '1px solid rgba(248,244,232,0.16)',
      color: 'var(--c-star)',
      zIndex: 6,
    }}>
      <div className="eyebrow on-night" style={{ marginBottom: 14 }}>Tonight in Sedona</div>
      <div style={{ display: 'flex', alignItems: 'center', gap: 14, marginBottom: 14 }}>
        <MoonGlyph fraction={moon.fraction} size={48} />
        <div>
          <div style={{ fontFamily: 'var(--f-display)', fontSize: 22, lineHeight: 1.1 }}>{moon.name}</div>
          <div style={{ fontFamily: 'var(--f-ui)', fontSize: 12, opacity: 0.7 }}>{moon.illum}% illuminated</div>
        </div>
      </div>
      <div style={{ fontFamily: 'var(--f-body)', fontSize: 14, color: 'rgba(248,244,232,0.82)', marginBottom: 14, fontStyle: 'italic' }}>
        {moon.illum < 30
          ? 'Excellent night for Milky Way & deep-sky targets.'
          : moon.illum > 80
          ? "Bright moon. Best for lunar craters & planets."
          : 'Mixed sky — planets and brighter clusters shine.'}
      </div>
      <a onClick={() => go('sky')} style={{
        fontFamily: 'var(--f-ui)', fontSize: 12, fontWeight: 600,
        letterSpacing: '0.06em', textTransform: 'uppercase', display: 'inline-flex',
        alignItems: 'center', gap: 6, color: 'var(--c-moon)',
        cursor: 'pointer',
      }}>
        See tonight's targets <IconArrow size={12} />
      </a>
    </div>
  );
}

// Moon glyph SVG showing illumination
function MoonGlyph({ fraction, size = 32 }) {
  // fraction 0..1 across synodic month
  const r = size / 2 - 1;
  const cx = size / 2, cy = size / 2;
  // Compute the visible (lit) part
  // Use ellipse terminator
  const phaseAngle = fraction * 2 * Math.PI;
  const cosPhase = Math.cos(phaseAngle);
  return (
    <svg width={size} height={size} viewBox={`0 0 ${size} ${size}`}>
      <defs>
        <clipPath id={`moonClip-${size}`}>
          <circle cx={cx} cy={cy} r={r} />
        </clipPath>
      </defs>
      <circle cx={cx} cy={cy} r={r} fill="#1a2238" />
      {/* Lit portion */}
      <g clipPath={`url(#moonClip-${size})`}>
        {fraction < 0.5 ? (
          // Waxing: right side lit
          <>
            <rect x={cx} y={0} width={cx} height={size} fill="#F4D27A" />
            <ellipse cx={cx} cy={cy} rx={Math.abs(cosPhase) * r} ry={r}
                     fill={fraction < 0.25 ? '#1a2238' : '#F4D27A'} />
          </>
        ) : (
          <>
            <rect x={0} y={0} width={cx} height={size} fill="#F4D27A" />
            <ellipse cx={cx} cy={cy} rx={Math.abs(cosPhase) * r} ry={r}
                     fill={fraction > 0.75 ? '#1a2238' : '#F4D27A'} />
          </>
        )}
      </g>
      <circle cx={cx} cy={cy} r={r} fill="none" stroke="rgba(248,244,232,0.25)" />
    </svg>
  );
}

// ─────────────────────────────────────────────────────────
//  Hero 2 — Static parallax twilight
// ─────────────────────────────────────────────────────────

const TWILIGHT_STARS = makeStars(160, 22);

function HeroTwilight({ onBook, go }) {
  const moon = getMoonPhase();
  return (
    <section style={{
      position: 'relative',
      minHeight: '94vh',
      overflow: 'hidden',
      background: 'linear-gradient(180deg, #07111F 0%, #182A46 35%, #3a2046 60%, #9b3a4b 82%, #d97243 100%)',
      color: 'var(--c-star)',
    }}>
      <StarField stars={TWILIGHT_STARS} opacity={1} />

      {/* Crescent moon */}
      <div style={{ position: 'absolute', top: '14%', right: '14%' }}>
        <MoonGlyph fraction={moon.fraction} size={86} />
      </div>

      {/* Constellation arc, Orion */}
      <svg viewBox="0 0 600 400" style={{
        position: 'absolute', top: '20%', left: '8%', width: 360, opacity: 0.6,
      }}>
        <g className="constellation-line">
          <line x1="80" y1="80" x2="220" y2="120" />
          <line x1="220" y1="120" x2="280" y2="200" />
          <line x1="280" y1="200" x2="240" y2="280" />
          <line x1="240" y1="280" x2="160" y2="320" />
          <line x1="160" y1="320" x2="100" y2="240" />
          <line x1="100" y1="240" x2="80" y2="80" />
          <line x1="220" y1="120" x2="320" y2="100" />
          <line x1="280" y1="200" x2="380" y2="220" />
        </g>
        <g className="constellation-dot">
          {[[80,80,3],[220,120,4],[280,200,3.5],[240,280,3],[160,320,3.5],[100,240,2.5],[320,100,2.5],[380,220,3]].map(([x,y,r],i) => (
            <circle key={i} cx={x} cy={y} r={r} />
          ))}
        </g>
      </svg>

      {/* Layered rocks - 3 layers for parallax feel */}
      <svg viewBox="0 0 1440 200" preserveAspectRatio="none"
           style={{ position: 'absolute', left: 0, right: 0, bottom: '28vh', width: '100%', height: '18vh', opacity: 0.7 }}>
        <path fill="#2a1428" d="M0,200 L0,110 L120,90 L240,120 L360,80 L480,110 L600,70 L720,100 L840,80 L960,120 L1080,90 L1200,110 L1320,80 L1440,100 L1440,200 Z" />
      </svg>
      <RedRocksFar color="#1a0a14" opacity={1} />
      <RedRocksNear color="#0a0408" />
      <DesertEdge color="#04020a" />

      <div style={{ position: 'relative', zIndex: 5 }}>
        <div className="wrap" style={{ paddingTop: 'clamp(80px, 12vw, 180px)' }}>
          <div style={{ maxWidth: 880 }}>
            <div className="eyebrow on-night" style={{ marginBottom: 28 }}>
              ◦ Tonight · Waxing Crescent · Excellent dark sky
            </div>
            <h1 className="display" style={{
              fontSize: 'clamp(58px, 8.6vw, 128px)',
              margin: '0 0 32px',
            }}>
              A quiet night<br/>
              under a <em>very big</em> sky.
            </h1>
            <p className="lead" style={{ maxWidth: 540, color: 'rgba(248,244,232,0.82)', marginBottom: 40 }}>
              After sunset, Sedona becomes something else. The canyon walls turn to silhouette,
              the desert cools, and the stars begin to appear. We bring the telescopes and the
              stories. You bring curiosity.
            </p>
            <div style={{ display: 'flex', gap: 12, flexWrap: 'wrap' }}>
              <button className="btn btn--moon" onClick={onBook}>
                Reserve a telescope <IconArrow size={16} />
              </button>
              <button className="btn btn--ghost-night" onClick={() => go('sky')}>
                Tonight's sky
              </button>
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────
//  Hero 3 — Star map / constellation focus
// ─────────────────────────────────────────────────────────

const STARMAP_STARS = makeStars(200, 33);

function HeroStarMap({ onBook, go }) {
  return (
    <section style={{
      position: 'relative',
      minHeight: '94vh',
      overflow: 'hidden',
      background: 'radial-gradient(ellipse at 70% 40%, #1a2745, #07111f 70%)',
      color: 'var(--c-star)',
    }}>
      <StarField stars={STARMAP_STARS} opacity={1} />

      {/* Big constellation art - Scorpius-like */}
      <svg viewBox="0 0 800 800" style={{
        position: 'absolute',
        right: '-5%',
        top: '50%',
        transform: 'translateY(-50%)',
        width: 'min(85vh, 800px)',
        height: 'min(85vh, 800px)',
        opacity: 0.85,
      }}>
        <defs>
          <radialGradient id="halo">
            <stop offset="0%" stopColor="rgba(244,210,122,0.5)" />
            <stop offset="100%" stopColor="rgba(244,210,122,0)" />
          </radialGradient>
        </defs>
        {/* Concentric reticle rings */}
        <circle cx="400" cy="400" r="380" stroke="rgba(248,244,232,0.05)" fill="none" />
        <circle cx="400" cy="400" r="280" stroke="rgba(248,244,232,0.08)" fill="none" />
        <circle cx="400" cy="400" r="180" stroke="rgba(248,244,232,0.12)" fill="none" />
        {/* Constellation lines */}
        <g stroke="rgba(248,244,232,0.5)" strokeWidth="0.8" fill="none">
          <path d="M180,180 L260,240 L320,300 L380,360 L420,420 L450,500 L420,580 L350,620 L260,600 L200,540 L180,460 L240,500" />
          <path d="M420,420 L500,400 L580,420 L640,460" />
          <path d="M320,300 L380,260 L450,250" />
        </g>
        {/* Major stars */}
        {[
          [180,180,4,'Antares'],[260,240,3,'σ Sco'],[320,300,3.5,'δ Sco'],[380,360,3,'π Sco'],
          [420,420,5,'Antares'],[450,500,3.5,'ε Sco'],[420,580,3,'μ Sco'],[350,620,3.5,'ζ Sco'],
          [260,600,4,'λ Sco'],[200,540,3,''],[180,460,3,''],[240,500,2.5,''],
          [500,400,3,''],[580,420,3.5,''],[640,460,4,'Shaula'],[380,260,2.5,''],[450,250,3,''],
        ].map(([x,y,r,name], i) => (
          <g key={i}>
            <circle cx={x} cy={y} r={r * 2} fill="url(#halo)" />
            <circle cx={x} cy={y} r={r} fill="#F8F4E8" />
            {name && <text x={x + 12} y={y - 6} fill="rgba(248,244,232,0.5)"
                           style={{ font: '300 11px var(--f-ui)', letterSpacing: '0.06em' }}>{name}</text>}
          </g>
        ))}
        {/* Center crosshair */}
        <g stroke="rgba(248,244,232,0.15)" strokeWidth="0.5">
          <line x1="0" y1="400" x2="800" y2="400" />
          <line x1="400" y1="0" x2="400" y2="800" />
        </g>
        <text x="400" y="40" textAnchor="middle" fill="rgba(248,244,232,0.45)"
              style={{ font: '500 11px var(--f-ui)', letterSpacing: '0.32em' }}>SCORPIUS · JUNE SKY</text>
      </svg>

      {/* Subtle silhouette */}
      <RedRocksNear color="#040308" />

      <div style={{ position: 'relative', zIndex: 5 }}>
        <div className="wrap" style={{ paddingTop: 'clamp(100px, 15vw, 200px)' }}>
          <div style={{ maxWidth: 640 }}>
            <div className="eyebrow on-night" style={{ marginBottom: 32 }}>
              ⊕ N 34°51′ · W 111°45′ · Elev 4,500ft
            </div>
            <h1 className="display" style={{
              fontSize: 'clamp(56px, 8.2vw, 116px)',
              margin: '0 0 32px',
            }}>
              Learn the sky<br/>
              the <em>old way</em>.
            </h1>
            <p className="lead" style={{ maxWidth: 480, color: 'rgba(248,244,232,0.82)', marginBottom: 40 }}>
              Your guide names every star you see, traces the constellations that named
              the seasons, and points a real telescope at the things in between.
            </p>
            <div style={{ display: 'flex', gap: 12, flexWrap: 'wrap' }}>
              <button className="btn btn--moon" onClick={onBook}>
                Book a Star Show <IconArrow size={16} />
              </button>
              <button className="btn btn--ghost-night" onClick={() => go('sky')}>
                What's visible this season
              </button>
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────
//  Hero 4 — Telescope reticle (eyepiece view)
// ─────────────────────────────────────────────────────────

const RETICLE_STARS = makeStars(80, 44);

function HeroReticle({ onBook, go }) {
  return (
    <section style={{
      position: 'relative',
      minHeight: '94vh',
      overflow: 'hidden',
      background: '#07111F',
      color: 'var(--c-star)',
    }}>
      <StarField stars={RETICLE_STARS} opacity={0.6} />

      {/* The eyepiece — large circular vignette on the right */}
      <div style={{
        position: 'absolute',
        right: '-12vw',
        top: '50%',
        transform: 'translateY(-50%)',
        width: 'min(95vh, 1000px)',
        height: 'min(95vh, 1000px)',
        borderRadius: '50%',
        background: 'radial-gradient(circle, #1a2745 0%, #0d1a30 50%, #07111f 78%, transparent 80%)',
        boxShadow: 'inset 0 0 60px 20px rgba(0,0,0,0.7), 0 0 80px rgba(244,210,122,0.04)',
        border: '1px solid rgba(248,244,232,0.08)',
      }}>
        {/* A "Saturn" inside the eyepiece */}
        <svg viewBox="0 0 600 600" style={{
          position: 'absolute', inset: 0, width: '100%', height: '100%',
        }}>
          {/* Crosshair */}
          <g stroke="rgba(244,210,122,0.35)" strokeWidth="0.6">
            <line x1="0" y1="300" x2="600" y2="300" strokeDasharray="2,4" />
            <line x1="300" y1="0" x2="300" y2="600" strokeDasharray="2,4" />
          </g>
          {/* Tick marks */}
          <g stroke="rgba(244,210,122,0.6)" strokeWidth="1">
            {[0,30,60,90,120,150,180,210,240,270,300,330].map(deg => {
              const rad = (deg * Math.PI) / 180;
              const x1 = 300 + Math.cos(rad) * 260;
              const y1 = 300 + Math.sin(rad) * 260;
              const x2 = 300 + Math.cos(rad) * 275;
              const y2 = 300 + Math.sin(rad) * 275;
              return <line key={deg} x1={x1} y1={y1} x2={x2} y2={y2} />;
            })}
          </g>
          <circle cx="300" cy="300" r="275" fill="none" stroke="rgba(244,210,122,0.25)" />
          <circle cx="300" cy="300" r="180" fill="none" stroke="rgba(244,210,122,0.15)" />
          {/* Saturn */}
          <g transform="translate(300 280)">
            <ellipse cx="0" cy="8" rx="85" ry="14" fill="none" stroke="#d6b878" strokeWidth="2" opacity="0.7" />
            <ellipse cx="0" cy="8" rx="85" ry="14" fill="none" stroke="#8a7544" strokeWidth="0.5" opacity="0.9" transform="rotate(-12)" />
            <circle cx="0" cy="0" r="34" fill="#e6c98a" />
            <ellipse cx="0" cy="-6" rx="34" ry="6" fill="#f0d49b" opacity="0.7" />
            <ellipse cx="0" cy="8" rx="34" ry="5" fill="#a88a4c" opacity="0.4" />
            {/* Ring front */}
            <path d="M -85,8 A 85,14 0 0 0 85,8" fill="none" stroke="#e6c98a" strokeWidth="2.2" />
          </g>
          {/* Labels */}
          <text x="300" y="500" textAnchor="middle" fill="rgba(244,210,122,0.7)"
                style={{ font: '600 11px var(--f-ui)', letterSpacing: '0.32em' }}>
            SATURN · 1.27 BILLION KM
          </text>
          <text x="300" y="120" textAnchor="middle" fill="rgba(244,210,122,0.4)"
                style={{ font: '500 9px var(--f-mono)', letterSpacing: '0.16em' }}>
            8″ SCT · 196× · 12mm EYEPIECE
          </text>
        </svg>
      </div>

      {/* Skyline subtle */}
      <RedRocksNear color="#02010a" />

      <div style={{ position: 'relative', zIndex: 5 }}>
        <div className="wrap" style={{ paddingTop: 'clamp(80px, 12vw, 170px)' }}>
          <div style={{ maxWidth: 620 }}>
            <div className="eyebrow on-night" style={{ marginBottom: 28 }}>
              + Live through the eyepiece
            </div>
            <h1 className="display" style={{
              fontSize: 'clamp(58px, 8.4vw, 122px)',
              margin: '0 0 32px',
            }}>
              That's <em>actually</em><br/>
              Saturn.
            </h1>
            <p className="lead" style={{ maxWidth: 520, color: 'rgba(248,244,232,0.82)', marginBottom: 40 }}>
              Not a photo. Not a screen. The real planet — its rings, its moons —
              one billion miles away, focused into your eye by an 8-inch telescope
              we point for you.
            </p>
            <div style={{ display: 'flex', gap: 12, flexWrap: 'wrap' }}>
              <button className="btn btn--moon" onClick={onBook}>
                Book a Star Show <IconArrow size={16} />
              </button>
              <button className="btn btn--ghost-night" onClick={() => go('sky')}>
                What you'll see tonight
              </button>
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────
//  Router
// ─────────────────────────────────────────────────────────

function Hero({ variant, hour, phase, onBook, go }) {
  if (variant === 'twilight') return <HeroTwilight onBook={onBook} go={go} />;
  if (variant === 'starmap')  return <HeroStarMap onBook={onBook} go={go} />;
  if (variant === 'reticle')  return <HeroReticle onBook={onBook} go={go} />;
  return <HeroCycle hour={hour} phase={phase} onBook={onBook} go={go} />;
}

Object.assign(window, { Hero, HeroCycle, HeroTwilight, HeroStarMap, HeroReticle, MoonGlyph, StarField, RedRocksNear, RedRocksFar, DesertEdge });
