// Hero — full-bleed reel well, quote anchored bottom-left.
// `videoSrc` is a hook for the user to drop in their hero loop later.

const Hero = ({ videoSrc }) => {
  const videoRef = React.useRef(null);
  const [loaded, setLoaded] = React.useState(false);

  return (
    <section
      id="top"
      data-screen-label="Hero"
      style={{
        position: "relative",
        height: "100vh",
        minHeight: 720,
        width: "100%",
        overflow: "hidden",
        borderBottom: "1px solid var(--jh-rule)",
      }}
    >
      {/* Reel well — video if supplied, otherwise placeholder plate */}
      <div style={{
        position: "absolute",
        inset: 0,
        background: "var(--jh-bg-sunken)",
      }}>
        {/* Always render the placeholder underneath so there's never a black flash
            while the video buffers. The video sits on top, fades in when ready. */}
        <PlaceholderPlate />
        {videoSrc && (
          <video
            ref={videoRef}
            src={videoSrc}
            autoPlay muted loop playsInline preload="auto"
            onLoadedData={() => setLoaded(true)}
            onCanPlay={() => setLoaded(true)}
            style={{
              position: "absolute",
              inset: 0,
              width: "100%", height: "100%",
              objectFit: "cover",
              filter: "brightness(0.55) saturate(0.85) contrast(1.08)",
              opacity: loaded ? 1 : 0,
              transition: "opacity 600ms cubic-bezier(0.2,0,0.1,1)",
            }}
          />
        )}
        {/* warm vignette so type stays legible */}
        <div style={{
          position: "absolute", inset: 0,
          background: "linear-gradient(180deg, rgba(14,12,10,0.55) 0%, rgba(14,12,10,0.15) 35%, rgba(14,12,10,0.85) 100%)",
          pointerEvents: "none",
        }} />
        {/* hairline frame */}
        <div style={{
          position: "absolute",
          inset: "88px var(--jh-gutter) 64px",
          border: "1px solid rgba(237,230,216,0.08)",
          pointerEvents: "none",
        }} />
      </div>

      {/* Top-right metadata: timecode + status */}
      <div style={{
        position: "absolute",
        top: 96, right: "calc(var(--jh-gutter) + 16px)",
        display: "flex", flexDirection: "column", alignItems: "flex-end", gap: 8,
        zIndex: 2,
      }}>
        <span style={{
          fontFamily: "var(--jh-font-mono)",
          fontSize: 10,
          letterSpacing: "0.22em",
          textTransform: "uppercase",
          color: "var(--jh-amber)",
        }}>SELECTED · 2026 · LOOP</span>
        <span style={{
          fontFamily: "var(--jh-font-mono)",
          fontSize: 10,
          letterSpacing: "0.22em",
          textTransform: "uppercase",
          color: "var(--jh-fg-3)",
        }}>00:00:00:00 · {loaded ? "PLAYING" : "STANDBY"}</span>
      </div>

      {/* Eyebrow upper-center */}
      <div style={{
        position: "absolute",
        top: 112,
        left: "50%",
        transform: "translateX(-50%)",
        display: "flex", alignItems: "center", gap: 12,
        zIndex: 2,
      }}>
        <span style={{ width: 24, height: 1, background: "var(--jh-amber)" }} />
        <span style={{
          fontFamily: "var(--jh-font-mono)",
          fontSize: 11,
          letterSpacing: "0.32em",
          textTransform: "uppercase",
          color: "var(--jh-fg-2)",
        }}>A house with many rooms</span>
        <span style={{ width: 24, height: 1, background: "var(--jh-amber)" }} />
      </div>

      {/* Big bold quote, bottom-left */}
      <div style={{
        position: "absolute",
        left: "var(--jh-gutter)",
        bottom: 96,
        right: "var(--jh-gutter)",
        zIndex: 2,
        display: "flex",
        alignItems: "flex-end",
        justifyContent: "space-between",
        gap: 64,
      }}>
        <blockquote style={{
          margin: 0,
          maxWidth: "18ch",
          position: "relative",
        }}>
          <span style={{
            position: "absolute",
            left: -28, top: -24,
            fontFamily: "var(--jh-font-display)",
            fontWeight: 900,
            fontSize: 120,
            lineHeight: 1,
            color: "var(--jh-amber)",
            opacity: 0.45,
            userSelect: "none",
          }}>“</span>
          <p style={{
            fontFamily: "var(--jh-font-display)",
            fontWeight: 900,
            fontSize: "clamp(56px, 8vw, 128px)",
            lineHeight: 0.92,
            letterSpacing: "-0.025em",
            textTransform: "uppercase",
            color: "var(--jh-fg)",
            margin: 0,
            maxWidth: "100%",
          }}>
            Full-service.<br />
            <span style={{ color: "var(--jh-fg-2)" }}>No </span>pretense.
          </p>
          <footer style={{
            marginTop: 24,
            display: "flex", alignItems: "center", gap: 12,
          }}>
            <span style={{ width: 32, height: 1, background: "var(--jh-fg-3)" }} />
            <span style={{
              fontFamily: "var(--jh-font-mono)",
              fontSize: 11,
              letterSpacing: "0.18em",
              textTransform: "uppercase",
              color: "var(--jh-fg-2)",
            }}>Five rooms · One house</span>
          </footer>
        </blockquote>

        {/* Right-side caption — credibility line */}
        <div style={{
          display: "flex", flexDirection: "column", alignItems: "flex-end", gap: 12,
          paddingBottom: 12,
          maxWidth: 320,
          textAlign: "right",
        }}>
          <Badge tone="available">Booking 2026 Q3</Badge>
          <p style={{
            fontFamily: "var(--jh-font-serif)",
            fontStyle: "italic",
            fontSize: 14,
            lineHeight: 1.5,
            color: "var(--jh-fg-2)",
            margin: 0,
          }}>Indie film, documentary, small-to-mid game, AI video. We work best with productions that already know what they need.</p>
        </div>
      </div>

      {/* bottom-left scroll hint */}
      <div style={{
        position: "absolute",
        bottom: 24,
        left: "var(--jh-gutter)",
        fontFamily: "var(--jh-font-mono)",
        fontSize: 10,
        letterSpacing: "0.32em",
        textTransform: "uppercase",
        color: "var(--jh-fg-3)",
        zIndex: 2,
      }}>
        SCROLL ↓
      </div>
    </section>
  );
};
window.Hero = Hero;

// PlaceholderPlate — a quiet, layered well that reads as "video goes here"
// without being noisy. Uses the brand palette only.
const PlaceholderPlate = () => (
  <div style={{
    position: "absolute", inset: 0,
    background: "var(--jh-bg-sunken)",
    overflow: "hidden",
  }}>
    {/* horizontal scan bands — references film/CRT without being decorative */}
    <div style={{
      position: "absolute", inset: 0,
      backgroundImage: "repeating-linear-gradient(0deg, rgba(184,137,58,0.03) 0px, rgba(184,137,58,0.03) 1px, transparent 1px, transparent 4px)",
    }} />
    {/* large soft block */}
    <div style={{
      position: "absolute",
      left: "10%", top: "20%",
      width: "55%", height: "55%",
      background: "radial-gradient(ellipse at 30% 40%, rgba(184,137,58,0.18), transparent 70%)",
      filter: "blur(40px)",
    }} />
    <div style={{
      position: "absolute",
      right: "5%", bottom: "10%",
      width: "45%", height: "45%",
      background: "radial-gradient(ellipse at 60% 50%, rgba(107,124,136,0.12), transparent 70%)",
      filter: "blur(60px)",
    }} />
    {/* placeholder label, dead-center, very small */}
    <div style={{
      position: "absolute",
      left: "50%", top: "50%",
      transform: "translate(-50%, -50%)",
      display: "flex", flexDirection: "column", alignItems: "center", gap: 6,
      pointerEvents: "none",
    }}>
      <span style={{
        fontFamily: "var(--jh-font-mono)",
        fontSize: 10,
        letterSpacing: "0.4em",
        textTransform: "uppercase",
        color: "rgba(237,230,216,0.18)",
      }}>BACKGROUND · DROP-IN</span>
    </div>
  </div>
);
window.PlaceholderPlate = PlaceholderPlate;
