// Our Process — five-step pipeline walking from Trace through Frame.
// This is the centerpiece. Numbered, indexed, the rooms in order they're entered.

const PROCESS_STEPS = [
  {
    n: "01",
    phase: "Intake",
    sub: "JustATrace",
    color: "var(--jh-trace)",
    headline: "The trace of history.",
    body: "Clients provide archival and reference-based elements — photographs, film negatives, on-set plates, written reference. Provenance matters. The more the source can tell us, the less we have to invent.",
    deliverables: ["Archival ingest", "Reference catalog", "Source provenance"],
  },
  {
    n: "02",
    phase: "Generate",
    sub: "JustAPrompt",
    color: "var(--jh-prompt)",
    headline: "Brought to modern film.",
    body: "Using the latest generative tools we extend, restore, and reframe — modeled, conditioned, and corrected against the source. Every step is a fixable file. We bring it forward without losing what makes it specific.",
    deliverables: ["Model selection · LoRA train", "Conditioning · controlnet pass", "Intermediate EXR"],
  },
  {
    n: "03",
    phase: "Build",
    sub: "JustAScene",
    color: "var(--jh-scene)",
    headline: "Immersion of actor and audience.",
    body: "We build the world the shot belongs in — set extension, environment, atmospherics, depth. The actor stands somewhere real to them. The audience reads it without thinking. That's the test.",
    deliverables: ["Camera-matched geometry", "Light direction · atmospherics", "Set dressing pass"],
  },
  {
    n: "04",
    phase: "Integrate",
    sub: "JustAComp",
    color: "var(--jh-comp)",
    headline: "Put it all together.",
    body: "Compositing is where the seams disappear. Plate, generative element, environment, archival recovery — they leave us as a single shot. Edges, light, atmospherics, the boring 70% that makes the work invisible.",
    deliverables: ["Edge · spill · roto", "Light & atmospherics", "Color-managed EXR"],
  },
  {
    n: "05",
    phase: "Finish",
    sub: "JustAFrame",
    color: "var(--jh-frame)",
    headline: "Human hands and skill.",
    body: "Editorial, grade, titles, deliverables. A final pass with eyes that have been on the project from intake. We hand back masters to your spec — DCP, IMF, ProRes — and the project leaves the house finished.",
    deliverables: ["Conform · grade · DI", "Title & motion graphics", "Mastering to spec"],
  },
];

const ProcessSection = () => {
  const [active, setActive] = React.useState(0);
  return (
    <SectionWrap id="process" label="Our Process">
      <SectionHeader
        index="03"
        eyebrow="Our Process"
        title={<>Five rooms.<br />In order.</>}
        meta="START → FINISH"
      />

      {/* Pipeline track — five-column header */}
      <div style={{
        display: "grid",
        gridTemplateColumns: `repeat(${PROCESS_STEPS.length}, 1fr)`,
        gap: 0,
        borderTop: "1px solid var(--jh-rule-strong)",
        borderBottom: "1px solid var(--jh-rule-strong)",
        marginBottom: 0,
      }}>
        {PROCESS_STEPS.map((s, i) => {
          const isActive = active === i;
          return (
            <button
              key={i}
              onClick={() => setActive(i)}
              onMouseEnter={() => setActive(i)}
              style={{
                cursor: "pointer",
                appearance: "none",
                background: isActive ? "var(--jh-bg-stage)" : "transparent",
                border: "none",
                borderRight: i < PROCESS_STEPS.length - 1 ? "1px solid var(--jh-rule)" : "none",
                padding: "28px 24px 24px",
                textAlign: "left",
                display: "flex",
                flexDirection: "column",
                gap: 12,
                position: "relative",
                transition: "background 180ms cubic-bezier(0.2,0,0.1,1)",
                color: "var(--jh-fg)",
                fontFamily: "inherit",
              }}
            >
              {/* indicator bar — top edge, accent color when active */}
              <span style={{
                position: "absolute",
                top: -1, left: 0, right: 0,
                height: 2,
                background: isActive ? s.color : "transparent",
                transition: "background 180ms cubic-bezier(0.2,0,0.1,1)",
              }} />
              <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline" }}>
                <span style={{
                  fontFamily: "var(--jh-font-mono)",
                  fontSize: 10,
                  letterSpacing: "0.32em",
                  textTransform: "uppercase",
                  color: isActive ? s.color : "var(--jh-fg-3)",
                }}>STEP {s.n}</span>
                <span style={{
                  fontFamily: "var(--jh-font-mono)",
                  fontSize: 10,
                  letterSpacing: "0.22em",
                  color: "var(--jh-fg-4)",
                }}>{i + 1}/5</span>
              </div>
              <span style={{
                fontFamily: "var(--jh-font-display)",
                fontWeight: 800,
                fontSize: 28,
                textTransform: "uppercase",
                letterSpacing: "-0.005em",
                color: isActive ? "var(--jh-fg)" : "var(--jh-fg-2)",
                lineHeight: 1,
              }}>{s.phase}</span>
              <span style={{
                fontFamily: "var(--jh-font-mono)",
                fontSize: 11,
                letterSpacing: "0.18em",
                textTransform: "uppercase",
                color: isActive ? s.color : "var(--jh-fg-3)",
                transition: "color 180ms cubic-bezier(0.2,0,0.1,1)",
              }}>{s.sub}</span>
            </button>
          );
        })}
      </div>

      {/* Active step detail */}
      <div style={{
        display: "grid",
        gridTemplateColumns: "1fr 1.2fr",
        gap: 64,
        padding: "64px 0 32px",
        borderBottom: "1px solid var(--jh-rule)",
      }}>
        {/* Left: number + sub-brand wordmark */}
        <div style={{ display: "flex", flexDirection: "column", gap: 24 }}>
          <span style={{
            fontFamily: "var(--jh-font-mono)",
            fontSize: 11,
            letterSpacing: "0.32em",
            textTransform: "uppercase",
            color: PROCESS_STEPS[active].color,
          }}>STEP {PROCESS_STEPS[active].n} · {PROCESS_STEPS[active].phase}</span>
          <Wordmark
            noun={PROCESS_STEPS[active].sub.replace("JustA", "")}
            size={88}
            color={PROCESS_STEPS[active].color}
            stacked
          />
          <ul style={{
            listStyle: "none",
            padding: 0,
            margin: "16px 0 0",
            display: "flex", flexDirection: "column", gap: 0,
            borderTop: "1px solid var(--jh-rule)",
          }}>
            {PROCESS_STEPS[active].deliverables.map((d, i) => (
              <li key={i} style={{
                padding: "12px 0",
                borderBottom: "1px solid var(--jh-rule)",
                display: "flex",
                gap: 12,
                fontFamily: "var(--jh-font-mono)",
                fontSize: 12,
                letterSpacing: "0.12em",
                textTransform: "uppercase",
                color: "var(--jh-fg-2)",
              }}>
                <span style={{ color: PROCESS_STEPS[active].color }}>—</span>
                {d}
              </li>
            ))}
          </ul>
        </div>

        {/* Right: headline + body */}
        <div style={{ display: "flex", flexDirection: "column", gap: 24 }}>
          <h3 style={{
            fontFamily: "var(--jh-font-display)",
            fontWeight: 900,
            fontSize: "clamp(40px, 5vw, 72px)",
            textTransform: "uppercase",
            letterSpacing: "-0.02em",
            lineHeight: 0.95,
            margin: 0,
            color: "var(--jh-fg)",
            maxWidth: "16ch",
          }}>{PROCESS_STEPS[active].headline}</h3>
          <p style={{
            fontFamily: "var(--jh-font-serif)",
            fontSize: 18,
            lineHeight: 1.55,
            color: "var(--jh-fg-2)",
            margin: 0,
            maxWidth: "62ch",
          }}>{PROCESS_STEPS[active].body}</p>
          <div style={{ marginTop: 16, display: "flex", alignItems: "center", gap: 16 }}>
            <span style={{ width: 32, height: 1, background: PROCESS_STEPS[active].color }} />
            <span style={{
              fontFamily: "var(--jh-font-mono)",
              fontSize: 10,
              letterSpacing: "0.32em",
              textTransform: "uppercase",
              color: "var(--jh-fg-3)",
            }}>HOVER OR CLICK ANY STEP TO READ</span>
          </div>
        </div>
      </div>

      {/* Linear flow ribbon — visualizes the pipeline as files move through */}
      <div style={{
        padding: "32px 0 0",
        display: "flex",
        alignItems: "center",
        gap: 12,
        flexWrap: "wrap",
      }}>
        <span style={{
          fontFamily: "var(--jh-font-mono)",
          fontSize: 10,
          letterSpacing: "0.32em",
          textTransform: "uppercase",
          color: "var(--jh-fg-3)",
        }}>FLOW</span>
        {PROCESS_STEPS.map((s, i) => (
          <React.Fragment key={i}>
            <span style={{
              fontFamily: "var(--jh-font-mono)",
              fontSize: 11,
              letterSpacing: "0.18em",
              textTransform: "uppercase",
              color: active === i ? s.color : "var(--jh-fg-2)",
              transition: "color 180ms cubic-bezier(0.2,0,0.1,1)",
            }}>{s.sub}</span>
            {i < PROCESS_STEPS.length - 1 && (
              <span style={{
                fontFamily: "var(--jh-font-mono)",
                fontSize: 11,
                color: "var(--jh-fg-4)",
              }}>→</span>
            )}
          </React.Fragment>
        ))}
        <span style={{
          marginLeft: "auto",
          fontFamily: "var(--jh-font-serif)",
          fontStyle: "italic",
          fontSize: 14,
          color: "var(--jh-fg-3)",
        }}>One house. One pipeline. One pass.</span>
      </div>
    </SectionWrap>
  );
};
window.ProcessSection = ProcessSection;
