// site/stillness.jsx — Home page. Bone-dominant editorial layout, plum accents,
// line-art glyphs throughout. Final copy per page-copy.md, condensed ~20%.
// Headlines use simple declaratives — no "not X, it's Y" parallels.

const { useState: useStateS, useEffect: useEffectS, useRef: useRefS } = React;

function Stillness({ tweaks }) {
  return (
    <div style={{
      background: "var(--bone-200)",
      color: "var(--metis-deep-indigo)",
      minHeight: "100vh",
      paddingTop: 72
    }}>
      <StillnessHero />
      <InsightQuote />
      <AIWFeature />
      <TheWork />
      <HowWeWork />
      <ClosingCTA />
    </div>);

}

// ── Glyph library — abstract organic line art used as imagery
const GLYPHS = {
  // single eye / open perception
  eye:
  <svg viewBox="0 0 120 80" width="100%" style={{ maxWidth: 200, display: "block" }}>
      <path d="M10 40 Q 60 5 110 40 Q 60 75 10 40 Z" fill="none" stroke="currentColor" strokeWidth="1.1" />
      <circle cx="60" cy="40" r="14" fill="none" stroke="currentColor" strokeWidth="1.1" />
      <circle cx="60" cy="40" r="5" fill="currentColor" />
    </svg>,

  // concentric ripples — recognize
  ripples:
  <svg viewBox="0 0 120 120" width="100%" style={{ maxWidth: 160 }}>
      <circle cx="60" cy="60" r="6" fill="currentColor" />
      <circle cx="60" cy="60" r="20" fill="none" stroke="currentColor" strokeWidth="1.2" />
      <circle cx="60" cy="60" r="38" fill="none" stroke="currentColor" strokeWidth="1" opacity="0.6" />
      <circle cx="60" cy="60" r="56" fill="none" stroke="currentColor" strokeWidth="0.8" opacity="0.35" strokeDasharray="2 4" />
    </svg>,

  // sieve / filter — discern
  sieve:
  <svg viewBox="0 0 120 120" width="100%" style={{ maxWidth: 160 }}>
      <path d="M20 30 L 100 30 L 80 62 L 80 100 L 40 100 L 40 62 Z" fill="none" stroke="currentColor" strokeWidth="1.2" />
      <line x1="20" y1="30" x2="100" y2="30" stroke="currentColor" strokeWidth="0.8" strokeDasharray="3 3" />
      <circle cx="50" cy="46" r="2" fill="currentColor" />
      <circle cx="70" cy="50" r="2" fill="currentColor" />
      <circle cx="60" cy="38" r="2" fill="currentColor" />
    </svg>,

  // lever / fulcrum — recalibrate
  lever:
  <svg viewBox="0 0 120 120" width="100%" style={{ maxWidth: 160 }}>
      <line x1="20" y1="80" x2="100" y2="40" stroke="currentColor" strokeWidth="1.4" />
      <path d="M55 65 L 65 65 L 60 95 Z" fill="currentColor" />
      <line x1="40" y1="95" x2="80" y2="95" stroke="currentColor" strokeWidth="1" />
      <circle cx="20" cy="80" r="3.5" fill="currentColor" />
      <circle cx="100" cy="40" r="3.5" fill="currentColor" />
    </svg>,

  // network — team / culture
  network:
  <svg viewBox="0 0 120 120" width="100%" style={{ maxWidth: 160 }}>
      {[[28, 38], [92, 30], [60, 68], [36, 94], [94, 86]].map(([x, y], i) =>
    <circle key={i} cx={x} cy={y} r="3.5" fill="currentColor" />
    )}
      <path d="M28 38 L 60 68 L 92 30 M 36 94 L 60 68 L 94 86" stroke="currentColor" strokeWidth="0.9" fill="none" opacity="0.6" />
    </svg>,

  // archway / threshold — organizations
  archway:
  <svg viewBox="0 0 120 120" width="100%" style={{ maxWidth: 160 }}>
      <path d="M20 100 L 20 50 Q 60 10 100 50 L 100 100" fill="none" stroke="currentColor" strokeWidth="1.2" />
      <line x1="20" y1="100" x2="100" y2="100" stroke="currentColor" strokeWidth="1.2" />
      <line x1="35" y1="100" x2="35" y2="62" stroke="currentColor" strokeWidth="0.7" opacity="0.55" />
      <line x1="60" y1="100" x2="60" y2="48" stroke="currentColor" strokeWidth="0.7" opacity="0.55" />
      <line x1="85" y1="100" x2="85" y2="62" stroke="currentColor" strokeWidth="0.7" opacity="0.55" />
    </svg>,

  // ascending steps — leadership
  steps:
  <svg viewBox="0 0 120 120" width="100%" style={{ maxWidth: 160 }}>
      <path d="M15 100 L 35 100 L 35 80 L 55 80 L 55 60 L 75 60 L 75 40 L 100 40" fill="none" stroke="currentColor" strokeWidth="1.2" />
      <circle cx="100" cy="40" r="4" fill="currentColor" />
      <line x1="15" y1="105" x2="100" y2="105" stroke="currentColor" strokeWidth="0.5" opacity="0.4" strokeDasharray="2 3" />
    </svg>,

  // crescent — individual / inner
  crescent:
  <svg viewBox="0 0 120 120" width="100%" style={{ maxWidth: 160 }}>
      <circle cx="60" cy="60" r="42" fill="none" stroke="currentColor" strokeWidth="1.2" />
      <path d="M60 18 A 42 42 0 0 1 60 102 A 30 30 0 0 0 60 18 Z" fill="currentColor" opacity="0.85" />
    </svg>,

  // infinity / sustained — retainer / ongoing
  loop:
  <svg viewBox="0 0 160 100" width="100%" style={{ maxWidth: 200 }}>
      <path d="M40 50 C 40 20 80 20 80 50 C 80 80 120 80 120 50 C 120 20 80 20 80 50 C 80 80 40 80 40 50 Z"
    fill="none" stroke="currentColor" strokeWidth="1.4" />
    </svg>,

  // arc with arrow — direction / approach
  arc:
  <svg viewBox="0 0 120 80" width="100%" style={{ maxWidth: 200 }}>
      <path d="M10 70 Q 60 5 110 70" fill="none" stroke="currentColor" strokeWidth="1.2" />
      <path d="M100 60 L 110 70 L 100 80" fill="none" stroke="currentColor" strokeWidth="1.2" />
      <circle cx="10" cy="70" r="3" fill="currentColor" />
    </svg>

};

// ── Hero
function StillnessHero() {
  // Tie a couple of effects to scroll progress through the hero
  const heroRef = useRefS(null);
  const p = useScrollProgress(heroRef);
  const isMobile = useIsMobile();

  return (
    <section ref={heroRef} style={{
      minHeight: "auto",
      padding: "6vh 0 4vh",
      position: "relative",
      display: "flex",
      flexDirection: "column",
      justifyContent: "center",
      overflow: "hidden"
    }}>
      {/* ambient glyphs — parallax + subtle rotation, scroll-driven.
               Pulled up off the bottom so the InsightQuote section starts inside
               the first viewport. */}
      <AmbientGlyph
        position={{ top: "8%", left: "6%" }}
        size={150}
        color="var(--metis-charred-plum)"
        opacity={0.13}
        parallax={-40}
        rotate={32}>
        
        {GLYPHS.ripples}
      </AmbientGlyph>
      <AmbientGlyph
        position={{ top: "18%", right: "4%" }}
        size={200}
        color="var(--metis-deep-indigo)"
        opacity={0.13}
        parallax={60}
        rotate={-12}>

        {GLYPHS.arc}
      </AmbientGlyph>
      <AmbientGlyph
        position={{ top: "38%", left: "44%" }}
        size={84}
        color="var(--metis-charred-plum)"
        opacity={0.10}
        parallax={-22}
        rotate={120}>
        
        {GLYPHS.crescent}
      </AmbientGlyph>

      <div style={{
        maxWidth: 1240, margin: "0 auto", padding: isMobile ? "0 24px" : "0 64px",
        width: "100%", position: "relative", boxSizing: "border-box"
      }}>
        {/* Headline + Logo — aligned vertical centerline + matched heights */}
        <div style={{
          display: "flex",
          alignItems: "center",
          gap: "clamp(20px, 3vw, 48px)",
          flexWrap: "nowrap"
        }}>
          <h1 style={{
            fontFamily: "var(--font-sans)",
            fontWeight: 700,
            fontSize: isMobile ? "clamp(44px, 13vw, 72px)" : "clamp(56px, 8.4vw, 124px)",
            lineHeight: 0.96,
            letterSpacing: "-0.035em",
            margin: 0,
            color: "var(--metis-deep-indigo)",
            whiteSpace: isMobile ? "normal" : "nowrap"
          }}>
            Wisdom <span style={{ fontFamily: "var(--font-display)", fontStyle: "italic", fontWeight: 400, color: "var(--metis-charred-plum)" }}>at</span> Work.
          </h1>

          {/* Logo sized to match headline cap-height; wings flutter; whole mark
                       gives a hair of scroll-tied lift so it feels paired with the type */}
          <HeroLogo progress={p} />
        </div>

        <div style={{
          marginTop: 28,
          fontFamily: "var(--font-display)",
          fontStyle: "italic",
          fontSize: isMobile ? 22 : 28,
          lineHeight: 1.3,
          fontWeight: 400,
          color: "var(--slate-700)",
          maxWidth: 620
        }}>
          Guided by Insight. Grounded in Humanity.
        </div>

        <p style={{ marginTop: 22, maxWidth: 520, fontSize: isMobile ? 16 : 17, lineHeight: 1.6, fontWeight: 300, color: "var(--slate-700)" }}>
          We help organizations think and feel better through psychologically informed leadership and culture development.
        </p>

        <div style={{ marginTop: 32, display: "flex", gap: 16, alignItems: "center", flexWrap: "wrap" }}>
          <CalendlyButton>Book a strategy session</CalendlyButton>
          <a href="approach.html" style={{
            fontSize: 13,
            fontWeight: 500,
            letterSpacing: "0.18em",
            textTransform: "uppercase",
            color: "var(--slate-700)",
            border: 0,
            textDecoration: "none",
            padding: "12px 4px"
          }}>
            Explore the approach &nbsp;↓
          </a>
        </div>
      </div>
    </section>);

}

// ── HeroLogo — sized to track the headline's cap-height. Uses the same
// pattern of two masked copies of the indigo mark so the wings flutter while
// the figure stays still. Optional gentle scroll-tied tilt.
function HeroLogo({ progress = 0 }) {
  const isMobile = useIsMobile();
  // logo height ≈ headline glyph height. Headline uses 8.4vw / clamp 56–124.
  // The visible mark inside the PNG occupies ~92% of the square, so we size
  // a touch larger than the cap-height to feel optically matched.
  const size = isMobile ? "clamp(60px, 18vw, 84px)" : "clamp(96px, 10.5vw, 160px)";
  const tilt = (window.METIS_GLYPHS_ANIM ? 1 : 1) * (progress - 0.5) * 6; // ±3°
  return (
    <div
      aria-hidden="true"
      data-metis-hero-logo
      style={{
        width: size, height: size, position: "relative", flexShrink: 0,
        transform: `rotate(${tilt.toFixed(2)}deg)`,
        transition: "transform 120ms linear"
      }}>
      
      <img
        src={window.metisAsset('logoIndigo')}
        alt=""
        draggable="false"
        style={{
          position: "absolute", inset: 0, width: "100%", height: "100%", objectFit: "contain",
          WebkitMaskImage: "linear-gradient(to right, black 0 62%, transparent 72% 100%)",
          maskImage: "linear-gradient(to right, black 0 62%, transparent 72% 100%)",
          userSelect: "none", pointerEvents: "none"
        }} />
      
      <div aria-hidden="true" style={{
        position: "absolute", inset: 0,
        backgroundImage: `url(${window.metisAsset('logoIndigo')})`,
        backgroundSize: "contain",
        backgroundRepeat: "no-repeat",
        backgroundPosition: "center",
        WebkitMaskImage: "linear-gradient(to right, transparent 0 62%, black 72% 100%)",
        maskImage: "linear-gradient(to right, transparent 0 62%, black 72% 100%)",
        transformOrigin: "62% 50%",
        animation: "metisFlutter 3.4s ease-in-out infinite"
      }} />
    </div>);

}

// ── AmbientGlyph — absolutely positioned organic glyph that responds to
// scroll: vertical parallax + optional rotation. Reads the global
// `data-glyph-mode` attribute to allow tweak-driven toggling.
function AmbientGlyph({ children, position, size = 160, color = "currentColor", opacity = 0.12, parallax = 30, rotate = 0 }) {
  const ref = useRefS(null);
  const [t, setT] = useStateS({ y: 0, r: 0, mode: "scroll" });
  useEffectS(() => {
    let raf = 0;
    const compute = () => {
      const mode = document.body.getAttribute("data-glyph-mode") || "scroll";
      if (!ref.current) return;
      if (mode === "static") {
        setT((s) => s.y === 0 && s.r === 0 && s.mode === "static" ? s : { y: 0, r: 0, mode: "static" });
        return;
      }
      if (mode === "breathe") {
        // continuous, no scroll dependency
        const ms = performance.now();
        const phase = ms / 4200 % 1;
        const r = Math.sin(phase * Math.PI * 2) * (rotate * 0.4);
        setT((s) => s.mode === "breathe" && s.y === 0 && Math.abs(s.r - r) < 0.01 ? s : { y: 0, r, mode });
        return;
      }
      // scroll-responsive
      const rect = ref.current.getBoundingClientRect();
      const vh = window.innerHeight;
      const center = rect.top + rect.height / 2;
      const norm = 1 - center / vh; // ~0 when at bottom of viewport, ~1 at top
      const y = norm * parallax, r = norm * rotate;
      // Only re-render when the value actually moved (i.e. the user is scrolling).
      setT((s) => s.mode === mode && Math.abs(s.y - y) < 0.01 && Math.abs(s.r - r) < 0.01 ? s : { y, r, mode });
    };
    const tick = () => {compute();raf = requestAnimationFrame(tick);};
    raf = requestAnimationFrame(tick);
    return () => cancelAnimationFrame(raf);
  }, [parallax, rotate]);

  return (
    <div ref={ref} style={{
      position: "absolute",
      ...position,
      width: size,
      color,
      opacity,
      pointerEvents: "none",
      transform: `translate3d(0, ${t.y.toFixed(2)}px, 0) rotate(${t.r.toFixed(2)}deg)`,
      willChange: "transform"
    }}>
      {children}
    </div>);

}

// ── Insight quote — single-line marquee that scrolls left→right, repeating
function InsightQuote() {
  const isMobile = useIsMobile();
  const Quote = () =>
  <span className="metis-marquee__item" style={{
    fontFamily: "var(--font-display)",
    fontStyle: "italic",
    fontWeight: 400,
    fontSize: isMobile ? "clamp(24px, 8vw, 34px)" : "clamp(34px, 4.4vw, 56px)",
    lineHeight: 1.1,
    color: "var(--metis-deep-indigo)"
  }}>
      Change rarely fails for lack of strategy. It fails when&nbsp;<span style={{ color: "var(--metis-charred-plum)" }}>insight</span>&nbsp;is missing.
      <span aria-hidden="true" style={{
      display: "inline-block",
      width: isMobile ? 8 : 10,
      height: isMobile ? 8 : 10,
      margin: isMobile ? "0 28px" : "0 48px",
      transform: "rotate(45deg)",
      background: "var(--metis-charred-plum)",
      flexShrink: 0,
      verticalAlign: "middle"
    }} />
    </span>;

  // Two identical halves so the -50%→0 slide loops seamlessly.
  const half = [0, 1, 2].map((i) => <Quote key={i} />);
  return (
    <section style={{
      padding: isMobile ? "4vh 0 6vh" : "5vh 0 8vh",
      position: "relative",
      minHeight: "32vh",
      display: "flex",
      flexDirection: "column",
      justifyContent: "center"
    }}>
      <div className="metis-marquee" aria-label="Change rarely fails for lack of strategy. It fails when insight is missing.">
        <div className="metis-marquee__track">
          {half}
          {half.map((q, i) => <Quote key={`b${i}`} />)}
        </div>
      </div>
      <div style={{
        marginTop: isMobile ? 24 : 36,
        textAlign: "center",
        fontSize: 11,
        letterSpacing: "0.24em",
        textTransform: "uppercase",
        color: "var(--slate-600)",
        fontWeight: 500
      }}>
        The Metis Principle
      </div>
    </section>);

}

// ── AIW Featured marquee — dark indigo callout, plum accents
function AIWFeature() {
  const isMobile = useIsMobile();
  const questions = [
  "Where is your operational drag? Which processes cost the most in time, errors, and fatigue.",
  "Are you AI-ready? Whether your data is structured and secure enough to power intelligent agents.",
  "What is the efficiency dividend? How much human capacity can you unlock.",
  "How do you govern the machines? The rules of engagement for AI-human teams."];

  const stats = [
  { n: "40–60%", l: "Cycle-time reduction in data-heavy functions" },
  { n: "3×", l: "Faster decision making" },
  { n: "10–14", l: "Weeks · typical audit timeline" }];


  return (
    <section id="aiw" style={{ padding: isMobile ? "0 16px" : "0 64px" }}>
      <Reveal>
        <div data-fx-card style={{
          background: "var(--metis-deep-indigo)",
          color: "var(--bone-200)",
          borderRadius: 18,
          padding: isMobile ? "40px 24px 36px" : "72px 72px 56px",
          position: "relative",
          overflow: "hidden"
        }}>
          {/* ambient line art — scroll-responsive */}
          <AmbientGlyph position={{ right: -40, top: -20 }} size={320} color="var(--plum-300)" opacity={0.10} parallax={50} rotate={45}>
            {GLYPHS.network}
          </AmbientGlyph>
          <AmbientGlyph position={{ left: -30, bottom: -40 }} size={180} color="var(--plum-300)" opacity={0.10} parallax={-30} rotate={-20}>
            {GLYPHS.loop}
          </AmbientGlyph>

          <div style={{ position: "relative" }}>
            <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "1.5fr 1fr", gap: isMobile ? 24 : 64, alignItems: isMobile ? "start" : "end", marginBottom: isMobile ? 36 : 56 }}>
              <div>
                <div style={{ display: "inline-flex", alignItems: "center", gap: 8, padding: "5px 12px", borderRadius: 999, border: "1px solid rgba(192,164,181,0.30)", color: "var(--plum-300)", fontSize: 10, fontWeight: 500, letterSpacing: "0.2em", textTransform: "uppercase" }}>
                  <span style={{ width: 5, height: 5, borderRadius: 999, background: "var(--plum-300)" }} />
                  Now Featured
                </div>
                <h2 style={{
                  fontFamily: "var(--font-sans)",
                  fontSize: "clamp(36px, 5vw, 56px)",
                  fontWeight: 500,
                  lineHeight: 1.05,
                  letterSpacing: "-0.02em",
                  margin: "20px 0 0",
                  color: "var(--bone-200)",
                  textWrap: "balance"
                }}>
                  AI in your workflow,<br />without the hype.
                </h2>
              </div>
              <p style={{ fontSize: 15, lineHeight: 1.65, color: "var(--slate-300)", fontWeight: 300, margin: 0, maxWidth: 380 }}>
                The AI Workflow Integration Audit is built for C-suite leaders who want measurable operational gains. We treat AI as a digital workforce, not a software toy.
              </p>
            </div>

            <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "repeat(4, 1fr)", gap: isMobile ? 0 : 24, marginBottom: isMobile ? 36 : 56 }}>
              {questions.map((q, i) =>
              <div key={i} style={{ padding: "20px 0", borderTop: "1px solid rgba(246,244,242,0.16)" }}>
                  <div style={{ fontFamily: "var(--font-mono)", fontSize: 11, color: "var(--plum-300)", letterSpacing: "0.08em", marginBottom: 14 }}>
                    {String(i + 1).padStart(2, "0")}
                  </div>
                  <div style={{ fontSize: 15, lineHeight: 1.5, fontWeight: 400, color: "var(--bone-200)" }}>
                    {q}
                  </div>
                </div>
              )}
            </div>

            <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr 1fr" : "repeat(3, 1fr) auto", gap: isMobile ? 24 : 32, alignItems: isMobile ? "start" : "end", paddingTop: 32, borderTop: "1px solid rgba(246,244,242,0.12)" }}>
              {stats.map((s) =>
              <div key={s.n}>
                  <div style={{ fontFamily: "var(--font-sans)", fontSize: 44, fontWeight: 300, letterSpacing: "-0.025em", color: "var(--plum-300)", lineHeight: 1 }}>{s.n}</div>
                  <div style={{ marginTop: 10, fontSize: 12, color: "var(--slate-300)", letterSpacing: "0.04em", lineHeight: 1.5, maxWidth: 220 }}>{s.l}</div>
                </div>
              )}
              <CalendlyButton to={window.METIS.LINKS.aiwForm} style={{ gridColumn: isMobile ? "1 / -1" : "auto", justifySelf: "start", marginTop: isMobile ? 8 : 0 }}>Start the AIW audit</CalendlyButton>
            </div>
          </div>
        </div>
      </Reveal>
    </section>);

}

// ── The Work — 3-pane interactive overview. Bone aesthetic, plum accents.
//   Left rail: 3 lines (Organizations / Individuals / AI Workflow)
//   Center:    list of offerings for the selected line, click to expand
//   Right:     short field-note fragments
function TheWork() {
  const lines = {
    org: {
      label: "For Organizations",
      sub: "Companies, teams, leaders.",
      glyph: GLYPHS.archway,
      items: [
      { name: "Audit Portfolio", short: "Seven diagnostics across culture, leadership, performance, change, and AI." },
      { name: "Leadership Development Programs", short: "Custom academies for resilient, high-performing leaders." },
      { name: "Retainer Advisory", short: "Sustained partnership for organizations in motion." },
      { name: "Workshops & Keynotes", short: "Psychology translated into actionable strategy." }]

    },
    ind: {
      label: "For Individuals",
      sub: "Executives, founders, professionals.",
      glyph: GLYPHS.crescent,
      items: [
      { name: "Executive Coaching", short: "Evidence-based 1:1 coaching for leaders ready to lead with authenticity." },
      { name: "Group Coaching", short: "Small cohorts of 6\u20138. Peer learning paired with expert facilitation." },
      { name: "Leadership Intensives", short: "One- or two-day immersions for rapid clarity." },
      { name: "Psychological Strategy Sessions", short: "90 minutes of targeted guidance on mindset, communication, or leadership." }]

    },
    ai: {
      label: "AI Workflow Integration",
      sub: "Most requested. Built for C-suite leaders.",
      glyph: GLYPHS.network,
      items: [
      { name: "Operational Drag Heatmap", short: "Where human capacity is trapped in low-leverage loops." },
      { name: "ROI-Ranked Roadmap", short: "Quick wins separated from long-term plays." },
      { name: "Human\u2013AI Governance Framework", short: "The rules of engagement for AI-human teams." },
      { name: "10\u201312 Week Integration Blueprint", short: "The path from one pilot to operational scale." }]

    }
  };
  const [tab, setTab] = useStateS("org");
  const [open, setOpen] = useStateS(0);
  const isMobile = useIsMobile();
  const fragments = [
  "We partner with leaders to surface the patterns shaping their people and performance.",
  "We work the problem until your team can run it without us.",
  "Insight is the start. Implementation is the work."];

  const active = lines[tab];

  return (
    <section style={{ padding: isMobile ? "9vh 24px 6vh" : "14vh 64px 8vh" }}>
      <div style={{ maxWidth: 1240, margin: "0 auto" }}>
        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "1fr 1.4fr", gap: isMobile ? 24 : 80, marginBottom: isMobile ? 40 : 64, alignItems: "end" }}>
          <Reveal>
            <Eyebrow>The work</Eyebrow>
            <h2 style={{ fontFamily: "var(--font-sans)", fontSize: "clamp(40px, 5vw, 60px)", fontWeight: 300, lineHeight: 1.0, letterSpacing: "-0.025em", margin: "16px 0 0", color: "var(--metis-deep-indigo)", textWrap: "balance" }}>
              A diagnostic <span style={{ fontFamily: "var(--font-display)", fontStyle: "italic", fontWeight: 400, color: "var(--metis-charred-plum)" }}>architecture</span> for the modern enterprise.
            </h2>
          </Reveal>
          <Reveal delay={120}>
            <p style={{ lineHeight: 1.65, fontWeight: 300, color: "var(--slate-700)", margin: 0, maxWidth: 480, fontSize: "17px" }}>
              Enterprise-grade audits, leadership development at every level, and individual coaching for the leaders who carry it.
            </p>
          </Reveal>
        </div>

        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "260px 1fr 240px", gap: isMobile ? 36 : 56, alignItems: "start" }}>
          {/* Left rail */}
          <div style={{ borderTop: "1px solid var(--border-soft)" }}>
            {Object.entries(lines).map(([k, v]) => {
              const isActive = tab === k;
              return (
                <button key={k}
                onClick={() => {setTab(k);setOpen(0);}}
                style={{
                  appearance: "none", border: 0, borderBottom: "1px solid var(--border-soft)",
                  background: "transparent", textAlign: "left",
                  padding: "18px 16px 18px 0", width: "100%", cursor: "pointer",
                  color: isActive ? "var(--metis-deep-indigo)" : "var(--slate-600)",
                  position: "relative",
                  transition: "color 200ms var(--ease-out)"
                }}>
                  <span style={{
                    position: "absolute", left: -1, top: 18, bottom: 18, width: 2,
                    background: isActive ? "var(--metis-charred-plum)" : "transparent",
                    transition: "background 200ms var(--ease-out)"
                  }} />
                  <div style={{ display: "flex", alignItems: "center", gap: 12 }}>
                    <div style={{ width: 28, height: 28, color: isActive ? "var(--metis-charred-plum)" : "var(--slate-500)", flexShrink: 0 }}>
                      {v.glyph}
                    </div>
                    <div>
                      <div style={{ fontFamily: "var(--font-sans)", fontSize: 15, fontWeight: isActive ? 500 : 400, letterSpacing: "-0.005em", lineHeight: 1.2 }}>
                        {v.label}
                      </div>
                      <div style={{ marginTop: 4, fontFamily: "var(--font-display)", fontStyle: "italic", fontSize: 12, color: "var(--slate-600)", lineHeight: 1.35 }}>
                        {v.sub}
                      </div>
                    </div>
                  </div>
                </button>);

            })}
          </div>

          {/* Center detail */}
          <div style={{ minHeight: 380 }}>
            <div style={{ animation: "metisFadeUp 360ms var(--ease-out) both" }} key={tab}>
              <div style={{ paddingBottom: 28, marginBottom: 4 }}>
                <div style={{ fontFamily: "var(--font-mono)", fontSize: 11, letterSpacing: "0.08em", color: "var(--slate-600)" }}>
                  {active.items.length} offerings
                </div>
              </div>
              {active.items.map((s, i) => {
                const isOpen = open === i;
                return (
                  <div key={s.name} style={{ borderTop: "1px solid var(--border-soft)", borderBottom: i === active.items.length - 1 ? "1px solid var(--border-soft)" : "none" }}>
                    <button onClick={() => setOpen(isOpen ? -1 : i)}
                    style={{
                      display: "flex", justifyContent: "space-between", alignItems: "baseline", gap: 24,
                      width: "100%", padding: "22px 0", background: "transparent", border: 0,
                      cursor: "pointer", textAlign: "left", fontFamily: "var(--font-sans)"
                    }}>
                      <span style={{ fontSize: 22, fontWeight: 400, letterSpacing: "-0.01em", color: "var(--metis-deep-indigo)" }}>{s.name}</span>
                      <span style={{
                        width: 16, height: 16, flexShrink: 0, position: "relative",
                        transform: isOpen ? "rotate(45deg)" : "rotate(0)",
                        transition: "transform 240ms var(--ease-out)",
                        color: "var(--metis-charred-plum)"
                      }}>
                        <span style={{ position: "absolute", top: "50%", left: 0, right: 0, height: 1, background: "currentColor" }} />
                        <span style={{ position: "absolute", left: "50%", top: 0, bottom: 0, width: 1, background: "currentColor" }} />
                      </span>
                    </button>
                    <div style={{ maxHeight: isOpen ? 200 : 0, overflow: "hidden", transition: "max-height 400ms var(--ease-out)" }}>
                      <div style={{ paddingBottom: 22, fontSize: 15, lineHeight: 1.65, fontWeight: 300, color: "var(--slate-700)", maxWidth: 560 }}>
                        <p style={{ margin: "0 0 16px" }}>{s.short}</p>
                        <a href="services.html" style={{
                          fontSize: 12, letterSpacing: "0.18em", textTransform: "uppercase", fontWeight: 500,
                          color: "var(--metis-charred-plum)", textDecoration: "none", borderBottom: "1px solid currentColor",
                          paddingBottom: 1
                        }}>Inquire · read more &nbsp;→</a>
                      </div>
                    </div>
                  </div>);

              })}
            </div>
          </div>

          {/* Margin notes */}
          <div>
            <div style={{ fontSize: 10, letterSpacing: "0.2em", textTransform: "uppercase", color: "var(--metis-charred-plum)", fontWeight: 500, marginBottom: 18 }}>
              From the field
            </div>
            <div style={{ display: "flex", flexDirection: "column", gap: 28 }}>
              {fragments.map((f, i) =>
              <div key={i} style={{
                fontFamily: "var(--font-display)",
                fontStyle: "italic",
                fontSize: 15,
                lineHeight: 1.45,
                color: "var(--slate-700)",
                fontWeight: 400,
                paddingLeft: 14,
                borderLeft: "1px solid rgba(76,46,69,0.30)"
              }}>
                  {f}
                </div>
              )}
            </div>
          </div>
        </div>

        <div style={{ marginTop: 56, textAlign: "center" }}>
          <a href="services.html" style={{
            fontSize: 13,
            fontWeight: 500,
            letterSpacing: "0.18em",
            textTransform: "uppercase",
            color: "var(--metis-charred-plum)",
            textDecoration: "none",
            border: 0,
            borderBottom: "1px solid currentColor",
            paddingBottom: 2
          }}>
            View full service menu &nbsp;→
          </a>
        </div>
      </div>
    </section>);

}

// ── What We Do — 4 cards with line glyphs
function WhatWeDo() {
  const cards = [
  { tag: "Organizational", title: "Audit Portfolio", body: "Seven enterprise diagnostics across culture, leadership, performance, and change. Available standalone or as a full suite.", glyph: GLYPHS.archway },
  { tag: "Leadership", title: "Development Programs", body: "Custom academies that cultivate emotionally intelligent, resilient, high-performing leaders.", glyph: GLYPHS.steps },
  { tag: "Ongoing", title: "Retainer Advisory", body: "Sustained leadership and culture partnership for organizations in motion.", glyph: GLYPHS.loop },
  { tag: "Individual", title: "Executive Coaching", body: "Personalized, evidence-based coaching for leaders ready to deepen self-awareness.", glyph: GLYPHS.crescent }];

  return (
    <section style={{ padding: "14vh 64px 8vh" }}>
      <div style={{ maxWidth: 1240, margin: "0 auto" }}>
        <div style={{ display: "grid", gridTemplateColumns: "1fr 1.4fr", gap: 80, marginBottom: 64, alignItems: "end" }}>
          <Reveal>
            <Eyebrow>What we do</Eyebrow>
            <h2 style={{ fontFamily: "var(--font-sans)", fontSize: "clamp(40px, 5vw, 60px)", fontWeight: 300, lineHeight: 1.0, letterSpacing: "-0.025em", margin: "16px 0 0", color: "var(--metis-deep-indigo)", textWrap: "balance" }}>
              A diagnostic <span style={{ fontFamily: "var(--font-display)", fontStyle: "italic", fontWeight: 400, color: "var(--metis-charred-plum)" }}>architecture</span> for the modern enterprise.
            </h2>
          </Reveal>
          <Reveal delay={120}>
            <p style={{ fontSize: 17, lineHeight: 1.65, fontWeight: 300, color: "var(--slate-700)", margin: 0, maxWidth: 480 }}>
              Enterprise-grade audits, leadership development at every level, and individual coaching for the leaders who carry it.
            </p>
          </Reveal>
        </div>

        <div style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 16 }}>
          {cards.map((c, i) =>
          <Reveal key={c.tag} delay={i * 80} y={20}>
              <a href="services.html" style={{
              display: "block",
              background: "var(--bone-100)",
              border: "1px solid var(--border-soft)",
              borderRadius: 14,
              padding: "32px 28px",
              textDecoration: "none",
              color: "inherit",
              height: "100%",
              boxSizing: "border-box",
              transition: "all 280ms var(--ease-out)"
            }}
            onMouseEnter={(e) => {
              e.currentTarget.style.transform = "translateY(-3px)";
              e.currentTarget.style.borderColor = "rgba(76,46,69,0.25)";
              e.currentTarget.style.boxShadow = "0 18px 36px rgba(28,30,63,0.08)";
            }}
            onMouseLeave={(e) => {
              e.currentTarget.style.transform = "translateY(0)";
              e.currentTarget.style.borderColor = "var(--border-soft)";
              e.currentTarget.style.boxShadow = "none";
            }}>
                <div style={{ height: 80, color: "var(--metis-charred-plum)", marginBottom: 28, display: "flex", alignItems: "center" }}>
                  {c.glyph}
                </div>
                <div style={{ fontSize: 10, letterSpacing: "0.2em", textTransform: "uppercase", color: "var(--slate-600)", fontWeight: 500, marginBottom: 10 }}>
                  {c.tag}
                </div>
                <h3 style={{ fontFamily: "var(--font-sans)", fontSize: 22, fontWeight: 500, letterSpacing: "-0.01em", lineHeight: 1.15, margin: "0 0 14px", color: "var(--metis-deep-indigo)" }}>
                  {c.title}
                </h3>
                <p style={{ fontSize: 13.5, lineHeight: 1.6, fontWeight: 300, color: "var(--slate-700)", margin: 0 }}>
                  {c.body}
                </p>
              </a>
            </Reveal>
          )}
        </div>

        <div style={{ marginTop: 48, textAlign: "center" }}>
          <a href="services.html" style={{
            fontSize: 13,
            fontWeight: 500,
            letterSpacing: "0.18em",
            textTransform: "uppercase",
            color: "var(--metis-charred-plum)",
            textDecoration: "none",
            border: 0,
            borderBottom: "1px solid currentColor",
            paddingBottom: 2
          }}>
            View full service menu &nbsp;→
          </a>
        </div>
      </div>
    </section>);

}

// ── MovementGlyph — renders the proper SVG for each "movement" verb and
// animates the meaningful internal element (not the whole frame):
//   recognize   — concentric ripples expand outward
//   discern     — 3 dots drop into the sieve
//   recalibrate — the scale bar tilts around the fulcrum; the fulcrum
//                 and base stay still
// `p` is a 0..1 progression: scroll (default), continuous breathe, or 0 static.
function MovementGlyph({ kind }) {
  const ref = useRefS(null);
  const [s, setS] = useStateS({ p: 0, mode: "scroll" });
  useEffectS(() => {
    let raf = 0;
    const tick = () => {
      const mode = document.body.getAttribute("data-glyph-mode") || "scroll";
      if (!ref.current) {raf = requestAnimationFrame(tick);return;}
      if (mode === "static") {
        setS((prev) => prev.p === 1 && prev.mode === "static" ? prev : { p: 1, mode: "static" });
      } else if (mode === "breathe") {
        const phase = performance.now() / 3600 % 1;
        const p = 0.5 + 0.5 * Math.sin(phase * Math.PI * 2);
        setS((prev) => prev.mode === "breathe" && Math.abs(prev.p - p) < 0.005 ? prev : { p, mode });
      } else {
        const rect = ref.current.getBoundingClientRect();
        const vh = window.innerHeight;
        // 0 when glyph enters from bottom, 1 when it leaves top
        const passed = (vh - rect.top) / (vh + rect.height);
        const p = Math.max(0, Math.min(1, passed));
        // Only re-render when progress actually changed (user is scrolling).
        setS((prev) => prev.mode === mode && Math.abs(prev.p - p) < 0.005 ? prev : { p, mode });
      }
      raf = requestAnimationFrame(tick);
    };
    raf = requestAnimationFrame(tick);
    return () => cancelAnimationFrame(raf);
  }, []);

  const inner =
  kind === "recognize" ? <RipplesGlyph progress={s.p} /> :
  kind === "discern" ? <SieveGlyph progress={s.p} /> :
  kind === "recalibrate" ? <LeverGlyph progress={s.p} /> :
  null;

  return <div ref={ref} style={{ width: "100%", height: "100%" }}>{inner}</div>;
}

// ── RipplesGlyph — rings pulse outward; opacity wave makes each ring "fire"
// in sequence as `progress` advances.
function RipplesGlyph({ progress = 0 }) {
  // ease so the pulse breathes rather than scrubs
  const e = (k) => k < 0.5 ? 2 * k * k : 1 - Math.pow(-2 * k + 2, 2) / 2;
  const wave = e(progress);
  const rings = [
  { base: 20, amp: 6, baseOp: 1.0, phase: 0.0 },
  { base: 38, amp: 10, baseOp: 0.6, phase: 0.18 },
  { base: 56, amp: 14, baseOp: 0.35, phase: 0.36 }];

  return (
    <svg viewBox="0 0 120 120" width="100%" style={{ maxWidth: 160 }}>
      <circle cx="60" cy="60" r={6 + wave * 1.4} fill="currentColor" />
      {rings.map((r, i) => {
        const local = Math.max(0, Math.min(1, wave - r.phase));
        const radius = r.base + local * r.amp;
        const op = r.baseOp * (0.35 + 0.65 * local);
        return (
          <circle key={i}
          cx="60" cy="60"
          r={radius.toFixed(2)}
          fill="none"
          stroke="currentColor"
          strokeWidth={i === 2 ? 0.8 : i === 1 ? 1 : 1.2}
          opacity={op.toFixed(2)}
          strokeDasharray={i === 2 ? "2 4" : undefined} />);

      })}
    </svg>);
}

// ── SieveGlyph — 3 dots drop from above the sieve mouth, accelerating, then
// settle at their resting positions inside the bowl. The sieve frame itself
// stays still.
function SieveGlyph({ progress = 0 }) {
  // Settled (resting) positions, matching the original sieve composition
  const dots = [
  { cx: 50, settledY: 46, startY: -6, delay: 0.00 },
  { cx: 70, settledY: 50, startY: -10, delay: 0.18 },
  { cx: 60, settledY: 38, startY: -14, delay: 0.36 }];

  // ease-in (accel) on the way down — feels like gravity
  const eIn = (k) => k * k;
  return (
    <svg viewBox="0 0 120 120" width="100%" style={{ maxWidth: 160 }}>
      {/* sieve frame — static */}
      <path d="M20 30 L 100 30 L 80 62 L 80 100 L 40 100 L 40 62 Z"
      fill="none" stroke="currentColor" strokeWidth="1.2" />
      <line x1="20" y1="30" x2="100" y2="30"
      stroke="currentColor" strokeWidth="0.8" strokeDasharray="3 3" />
      {/* dots — animated drop */}
      {dots.map((d, i) => {
        const span = 1 - d.delay - 0.05;
        const local = Math.max(0, Math.min(1, (progress - d.delay) / span));
        const cy = d.startY + (d.settledY - d.startY) * eIn(local);
        const op = local < 0.05 ? local / 0.05 : 1;
        return <circle key={i} cx={d.cx} cy={cy.toFixed(2)} r="2" fill="currentColor" opacity={op.toFixed(2)} />;
      })}
    </svg>);
}

// ── LeverGlyph — only the scale bar (and its end caps) rotate; the fulcrum
// triangle and base stay anchored. Pivot is the apex of the fulcrum, ≈ (60, 65).
function LeverGlyph({ progress = 0 }) {
  // ±18° rocking around the fulcrum
  const tilt = (progress - 0.5) * 36;
  return (
    <svg viewBox="0 0 120 120" width="100%" style={{ maxWidth: 160 }}>
      {/* Static base */}
      <line x1="40" y1="95" x2="80" y2="95" stroke="currentColor" strokeWidth="1" />
      {/* Static fulcrum */}
      <path d="M55 65 L 65 65 L 60 95 Z" fill="currentColor" />
      {/* The scale bar (with end caps) rotates around the fulcrum apex */}
      <g transform={`rotate(${tilt.toFixed(2)} 60 65)`}>
        <line x1="20" y1="80" x2="100" y2="40" stroke="currentColor" strokeWidth="1.4" />
        <circle cx="20" cy="80" r="3.5" fill="currentColor" />
        <circle cx="100" cy="40" r="3.5" fill="currentColor" />
      </g>
    </svg>);
}

// ── BlinkingEye — replaces the rotating eye glyph; lids close briefly on a
// 6s cycle. Used in the closing CTA ambient pair.
function BlinkingEye() {
  return (
    <svg viewBox="0 0 120 80" width="100%" style={{ maxWidth: 200, display: "block" }}>
      <g style={{
        transformBox: "fill-box",
        transformOrigin: "center",
        animation: "metisBlink 6s ease-in-out infinite"
      }}>
        <path d="M10 40 Q 60 5 110 40 Q 60 75 10 40 Z" fill="none" stroke="currentColor" strokeWidth="1.1" />
        <circle cx="60" cy="40" r="14" fill="none" stroke="currentColor" strokeWidth="1.1" />
        <circle cx="60" cy="40" r="5" fill="currentColor" />
      </g>
    </svg>);
}

// ── How We Work — Recognize / Discern / Recalibrate
function HowWeWork() {
  const movements = [
  {
    n: "01",
    verb: "Recognize",
    tag: "See what's overlooked",
    body: "We surface the patterns shaping people and performance. The ones too close to see.",
    kind: "recognize"
  },
  {
    n: "02",
    verb: "Discern",
    tag: "Separate signal from noise",
    body: "Behavioral science and validated assessments turn lived experience into decision-ready intelligence.",
    kind: "discern"
  },
  {
    n: "03",
    verb: "Recalibrate",
    tag: "Move the right levers",
    body: "We stay through implementation. Insight becomes the structural and behavioral changes that hold.",
    kind: "recalibrate"
  }];

  const isMobile = useIsMobile();
  return (
    <section style={{ padding: isMobile ? "7vh 24px 9vh" : "10vh 64px 14vh", background: "var(--bone-100)", borderTop: "1px solid var(--border-soft)", borderBottom: "1px solid var(--border-soft)" }}>
      <div style={{ maxWidth: 1240, margin: "0 auto" }}>
        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "1fr 1.4fr", gap: isMobile ? 24 : 80, marginBottom: isMobile ? 48 : 80, alignItems: "end" }}>
          <Reveal>
            <Eyebrow>How we work</Eyebrow>
            <h2 style={{ fontFamily: "var(--font-sans)", fontSize: "clamp(40px, 5vw, 60px)", fontWeight: 300, lineHeight: 1.0, letterSpacing: "-0.025em", margin: "16px 0 0", color: "var(--metis-deep-indigo)" }}>
              <span style={{ fontFamily: "var(--font-display)", fontStyle: "italic", fontWeight: 400, color: "var(--metis-charred-plum)" }}>Recognize.</span>{" "}
              <span style={{ fontFamily: "var(--font-display)", fontStyle: "italic", fontWeight: 400, color: "var(--metis-charred-plum)" }}>Discern.</span>{" "}
              <span style={{ fontFamily: "var(--font-display)", fontStyle: "italic", fontWeight: 400, color: "var(--metis-charred-plum)" }}>Recalibrate.</span>
            </h2>
          </Reveal>
          <Reveal delay={120}>
            <p style={{ fontSize: 17, lineHeight: 1.65, fontWeight: 300, color: "var(--slate-700)", margin: 0, maxWidth: 460 }}>
              Three movements shape every engagement. A one-time audit or a multi-year partnership runs through all three.
            </p>
          </Reveal>
        </div>

        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "repeat(3, 1fr)", gap: isMobile ? 40 : 48 }}>
          {movements.map((m, i) =>
          <Reveal key={m.n} delay={i * 120} y={24}>
              <div>
                <div style={{ height: 110, color: "var(--metis-deep-indigo)", marginBottom: 28, display: "flex", alignItems: "flex-end" }}>
                  <MovementGlyph kind={m.kind} />
                </div>
                <h3 style={{
                fontFamily: m.verb === "Discern" ? '"Libre Franklin"' : "var(--font-display)",
                fontStyle: "italic",
                fontWeight: 400,
                fontSize: 44,
                lineHeight: 1,
                letterSpacing: "-0.015em",
                color: "var(--metis-charred-plum)",
                margin: "0 0 16px"
              }}>{m.verb}</h3>
                <div style={{ fontSize: 17, fontWeight: 500, color: "var(--metis-deep-indigo)", marginBottom: 14, letterSpacing: "-0.005em" }}>
                  {m.tag}
                </div>
                <p style={{ fontSize: 14, lineHeight: 1.6, fontWeight: 300, color: "var(--slate-700)", margin: 0, maxWidth: 360 }}>
                  {m.body}
                </p>
              </div>
            </Reveal>
          )}
        </div>
      </div>
    </section>);

}

// ── Closing
function ClosingCTA() {
  const isMobile = useIsMobile();
  return (
    <section style={{ padding: isMobile ? "11vh 24px" : "16vh 64px", textAlign: "center", background: "var(--bone-200)", position: "relative", overflow: "hidden" }}>
      <AmbientGlyph position={{ right: "8%", bottom: "20%" }} size={220} color="var(--metis-deep-indigo)" opacity={0.10} parallax={70} rotate={0}>
        <BlinkingEye />
      </AmbientGlyph>
      <Reveal>
        <div style={{ position: "relative", maxWidth: 920, margin: "0 auto" }}>
          <Eyebrow>Begin</Eyebrow>
          <h2 style={{
            fontFamily: "var(--font-sans)",
            fontSize: "clamp(44px, 6.5vw, 88px)",
            fontWeight: 300,
            lineHeight: 1.0,
            letterSpacing: "-0.03em",
            color: "var(--metis-deep-indigo)",
            margin: "20px 0 32px",
            textWrap: "balance"
          }}>
            Ready to see your organization <span style={{ fontFamily: "var(--font-display)", fontStyle: "italic", fontWeight: 400, color: "var(--metis-charred-plum)" }}>clearly</span>?
          </h2>
          <p style={{ fontSize: 17, lineHeight: 1.6, fontWeight: 300, color: "var(--slate-700)", maxWidth: 560, margin: "0 auto 40px" }}>
            Start with a free 30-minute discovery call or step into the AI Workflow audit.
          </p>
          <div style={{ display: "flex", gap: 16, justifyContent: "center", flexWrap: "wrap" }}>
            <CalendlyButton>Book a strategy session</CalendlyButton>
            <a href="services.html" className="m-btn m-btn--secondary">
              Explore the audits
              <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" style={{ marginLeft: 10 }}>
                <line x1="5" y1="12" x2="19" y2="12" />
                <polyline points="13 6 19 12 13 18" />
              </svg>
            </a>
          </div>
        </div>
      </Reveal>
    </section>);

}

window.Stillness = Stillness;
window.METIS_GLYPHS = GLYPHS;