// v5 — About as a faceted hexagonal compass
// Adapted from v2's CredentialsSection — one practitioner, six lenses.

const V5_FACETS = [
{
  id: "strategist",
  roman: "I",
  label: "Strategist",
  discipline: "Brand · category · positioning",
  tagline: "Helping unfamiliar ideas find their language.",
  body: "The work often starts before the category is clear. A team can describe what they are building, but not what world it lives in. I help shape the positioning, audience model, narrative architecture, and operating logic that let the rest of the work compound instead of scatter.",
  evidence: [
  { t: "Marianne's Olive Oil · brand & website", s: "Recent", pip: "pip-green" },
  { t: "RVRS · venture shaping · brand platform", s: "Recent", pip: "pip-green" },
  { t: "Schwazze · multi-banner growth system", s: "2024–26", pip: "pip-steel" },
  { t: "Native Roots · CMO · 50+ product launches", s: "2017–20", pip: "pip-steel" }]

},
{
  id: "builder",
  roman: "II",
  label: "Builder",
  discipline: "Product · interface · AI",
  tagline: "Design as a thinking instrument. AI as the new tool.",
  body: "Twenty years of product and experience design, now consolidated around AI-native workflows. From early concept to shipped surface, the practice produces interfaces, prototypes, product systems, and buildable artifacts using Claude, OpenAI, and MCP exploration as part of the design instrument, not as a side track.",
  evidence: [
  { t: "Apple Music · rapid prototyping", s: "2015", pip: "pip-steel" },
  { t: "Adobe Marketing Cloud · 3 patents", s: "2012–14", pip: "pip-copper" },
  { t: "Airbnb Trips · design sprints", s: "2016", pip: "pip-steel" },
  { t: "AI-Native HMI Foundry · Claude → Ignition", s: "Active", pip: "pip-green" }]

},
{
  id: "educator",
  roman: "III",
  label: "Educator",
  discipline: "CU Boulder · adjunct",
  tagline: "The classroom is where the method gets sharper.",
  body: "Adjunct Professor of Design at the University of Colorado since 2017. I teach human-centered design, product development, business strategy, and creative process. Frameworks that survive a room of graduate students tend to survive client work too.",
  evidence: [
  { t: "Adjunct Faculty · CU Boulder", s: "2017–now", pip: "pip-green" },
  { t: "Advanced Tools · graduate", s: "Active", pip: "pip-green" },
  { t: "Design Leadership · graduate", s: "Inactive", pip: "pip-steel" },
  { t: "Startup Design · graduate", s: "Inactive", pip: "pip-steel" }]

},
{
  id: "author",
  roman: "IV",
  label: "Author",
  discipline: "Writing · Kendall Hunt",
  tagline: "Writing forces the method to become clear.",
  body: "Two books published with Kendall Hunt in 2024. Story (by) Design and The Futures of Brand translate design, story, and brand strategy into frameworks students and teams can use. The books are the practice's working memory: written and designed to be used in the order a designer actually meets the problem.",
  evidence: [
  { t: "Story (by) Design · Kendall Hunt", s: "2024", pip: "pip-copper" },
  { t: "The Futures of Brand · Kendall Hunt", s: "2024", pip: "pip-copper" },
  { t: "Frameworks in active use · CU classroom", s: "Ongoing", pip: "pip-green" },
  { t: "Reusable models · client engagements", s: "Ongoing", pip: "pip-green" }]

},
{
  id: "founder",
  roman: "V",
  label: "Founder",
  discipline: "Portal · Stay Gold · practice",
  tagline: "A studio engine behind the practice.",
  body: "Founded Portal in 2013 as the studio layer of the practice: senior creative talent, real-time research, human-centered design, and lean development. Co-founded Stay Gold in 2020. Portal lets the work expand beyond a single operator without losing the through-line.",
  evidence: [
  { t: "Portal · founder · studio engine", s: "2013–now", pip: "pip-green" },
  { t: "Stay Gold · co-founder · studio", s: "2020–24", pip: "pip-steel" },
  { t: "Independent design practice", s: "Active", pip: "pip-green" },
  { t: "Senior creative network", s: "Network", pip: "pip-green" }]

},
{
  id: "translator",
  roman: "VI",
  label: "Translator",
  discipline: "Emerging · regulated",
  tagline: "Making new categories make sense.",
  body: "The through-line across everything: working at the moment when an idea is not yet obvious. Psychedelics, cannabis, functional mushrooms, AI-native product, SCADA/HMI, clean energy. The job is to make the unfamiliar legible, desirable, usable, teachable, buildable, and trusted.",
  evidence: [
  { t: "Psychedelic Science · brand + social", s: "Recent", pip: "pip-green" },
  { t: "Spor · regulated CPG · microdose", s: "Recent", pip: "pip-green" },
  { t: "Cultivation SCADA/HMI · regulated industrial", s: "Lab", pip: "pip-copper" },
  { t: "Grid Flexibility Command Twin · clean energy", s: "Lab", pip: "pip-copper" }]

}];


const V5Facet = () => {
  const [active, setActive] = useState(0);
  const [paused, setPaused] = useState(false);
  const wheelRef = useRef(null);

  useEffect(() => {
    if (paused) return;
    const id = setInterval(() => setActive((a) => (a + 1) % V5_FACETS.length), 6500);
    return () => clearInterval(id);
  }, [paused]);

  useEffect(() => {
    const el = wheelRef.current;if (!el) return;
    const io = new IntersectionObserver(([e]) => {
      if (!e.isIntersecting) setPaused(true);
    }, { threshold: 0.05 });
    io.observe(el);
    return () => io.disconnect();
  }, []);

  const pick = (i) => {setPaused(true);setActive(i);};

  const R = 200;
  const labelR = 300;
  const angleFor = (i) => -90 + i * 60;
  const rad = (a) => a * Math.PI / 180;
  const ptFor = (i, r = R) => {
    const a = rad(angleFor(i));
    return [Math.cos(a) * r, Math.sin(a) * r];
  };
  const hexPts = V5_FACETS.map((_, i) => ptFor(i).join(",")).join(" ");
  const activeFacet = V5_FACETS[active];
  const activeAngle = angleFor(active);

  return (
    <section id="about" className="v5-facet-section" data-screen-label="About · Six lenses">
      <div className="v4-container">
        <div className="v5-facet-head">
          <div className="v5-facet-head-left">
            <div className="v5-facet-section-eyebrow">
              <span className="v5-facet-section-eyebrow-rule"></span>
              <span className="v5-facet-section-eyebrow-num">03</span>
              <span>About · meet the practitioner</span>
            </div>
            <h2 className="v5-facet-headline" data-cursor="↻ Rotate the wheel">
              <span className="emph" style={{ color: "rgb(14, 15, 14)" }}>One practice.</span> <span className="emph" style={{ fontFamily: "\"Instrument Serif\"" }}>Six lenses.</span>
            </h2>
          </div>
          <div className="v5-facet-intro">
            <FadeIn delay={200}>
              <p style={{ fontSize: "19px", width: "415px" }}>Independent design director, founder, author, and educator. Based in Boulder. Twenty years of practice across software, advertising, regulated CPG, cannabis, psychedelics, AI, and education.</p>
              <p className="v5-facet-intro-sub">Different work, same instrument.<br /><span className="emph">The lens changes. The practice holds.</span></p>
            </FadeIn>
          </div>
        </div>

        <div className="v5-facet-layout" ref={wheelRef}>
          {/* Wheel */}
          <div className="v5-facet-wheel">
            <div className="v5-facet-wheel-meta">
              <span className="mono">Lens</span>
              <span className="v5-facet-wheel-counter">{activeFacet.roman} <span>/ VI</span></span>
            </div>

            <svg viewBox="-300 -300 600 600" className="v5-facet-wheel-svg" aria-hidden="true">
              <defs>
                <radialGradient id="v5-facet-glow" cx="0.5" cy="0.5" r="0.5">
                  <stop offset="0%" stopColor="var(--v4-accent)" stopOpacity="0.22" />
                  <stop offset="55%" stopColor="var(--v4-accent)" stopOpacity="0.06" />
                  <stop offset="100%" stopColor="var(--v4-accent)" stopOpacity="0" />
                </radialGradient>
              </defs>

              {/* Glow behind active vertex */}
              <circle r="130"
              cx={ptFor(active, R)[0]}
              cy={ptFor(active, R)[1]}
              fill="url(#v5-facet-glow)"
              style={{ transition: "cx 0.9s var(--ease-soft, ease), cy 0.9s var(--ease-soft, ease)" }} />
              

              {/* Concentric guide rings */}
              <circle r="92" fill="none" stroke="var(--v4-line-soft)" strokeWidth="0.6" strokeDasharray="1 4" />
              <circle r="150" fill="none" stroke="var(--v4-line-soft)" strokeWidth="0.6" strokeDasharray="1 4" />

              {/* Outer hex frame */}
              <polygon points={hexPts} fill="none" stroke="var(--v4-line)" strokeWidth="0.8" />

              {/* Spokes */}
              {V5_FACETS.map((_, i) => {
                const [x, y] = ptFor(i);
                const on = i === active;
                return (
                  <line key={i} x1="0" y1="0" x2={x} y2={y}
                  stroke={on ? "var(--v4-accent)" : "var(--v4-line)"}
                  strokeWidth={on ? 1.2 : 0.5}
                  style={{ transition: "stroke 0.5s ease, stroke-width 0.5s ease" }} />);


              })}

              {/* Tick marks at midpoints */}
              {V5_FACETS.map((_, i) => {
                const a = rad(angleFor(i) + 30);
                const x1 = Math.cos(a) * 175,y1 = Math.sin(a) * 175;
                const x2 = Math.cos(a) * 188,y2 = Math.sin(a) * 188;
                return <line key={`t${i}`} x1={x1} y1={y1} x2={x2} y2={y2} stroke="var(--v4-mute)" strokeWidth="0.5" />;
              })}

              {/* Vertex dots */}
              {V5_FACETS.map((_, i) => {
                const [x, y] = ptFor(i);
                const on = i === active;
                return (
                  <g key={`v${i}`}>
                    {on && <circle cx={x} cy={y} r="14" fill="none" stroke="var(--v4-accent)" strokeWidth="0.7" opacity="0.55" className="v5-facet-vertex-halo" />}
                    <circle cx={x} cy={y} r={on ? 6.5 : 3.5} fill={on ? "var(--v4-accent)" : "var(--v4-mute)"}
                    style={{ transition: "r 0.4s ease, fill 0.4s ease" }} />
                    
                  </g>);

              })}

              {/* Rotating pointer arc */}
              <g style={{ transform: `rotate(${activeAngle + 90}deg)`, transformOrigin: "0 0", transition: "transform 0.85s cubic-bezier(.4,1.3,.5,1)" }}>
                <path d="M -16 -195 A 195 195 0 0 1 16 -195" fill="none" stroke="var(--v4-accent)" strokeWidth="1.4" strokeLinecap="round" />
                <line x1="0" y1="-178" x2="0" y2="-205" stroke="var(--v4-accent)" strokeWidth="1" />
              </g>
            </svg>

            {/* Portrait at center */}
            <div className="v5-facet-portrait" aria-label="Chris Znerold">
              <img src={typeof window !== "undefined" && window.__resources && window.__resources.chris || "src/assets/chris.png"} alt="Chris Znerold" />
              <div className="v5-facet-portrait-ring"></div>
            </div>

            {/* Facet labels */}
            {V5_FACETS.map((f, i) => {
              const [lx, ly] = ptFor(i, labelR);
              const on = i === active;
              let anchor = "center";
              if (lx > 30) anchor = "left";else
              if (lx < -30) anchor = "right";
              return (
                <button
                  key={f.id}
                  type="button"
                  onClick={() => pick(i)}
                  onMouseEnter={() => pick(i)}
                  className={`v5-facet-label ${on ? "is-active" : ""}`}
                  data-anchor={anchor}
                  style={{
                    left: `calc(50% + ${lx}px)`,
                    top: `calc(50% + ${ly}px)`
                  }}>
                  
                  <span className="v5-facet-label-roman mono">{f.roman}</span>
                  <span className="v5-facet-label-name">{f.label}</span>
                  <span className="v5-facet-label-disc">{f.discipline}</span>
                </button>);

            })}
          </div>

          {/* Detail panel */}
          <div className="v5-facet-detail">
            <div className="v5-facet-detail-head">
              <span className="mono v5-facet-detail-roman">Lens {activeFacet.roman}</span>
              <div className="v5-facet-detail-progress">
                {V5_FACETS.map((_, i) =>
                <button key={i} type="button" onClick={() => pick(i)}
                className={`v5-facet-tick ${i === active ? "is-active" : ""}`}
                aria-label={`Show lens ${i + 1}`} />

                )}
              </div>
            </div>

            <div key={activeFacet.id} className="v5-facet-detail-body">
              <h3 className="v5-facet-detail-title">{activeFacet.label}</h3>
              <p className="v5-facet-detail-tagline">{activeFacet.tagline}</p>
              <p className="v5-facet-detail-body-copy">{activeFacet.body}</p>

              <div className="v5-facet-evidence">
                <ul>
                  {activeFacet.evidence.map((it, j) =>
                  <li key={j} className="v5-facet-evidence-item">
                      <span className={`v5-facet-evidence-pip v5-facet-pip-${it.pip.replace("pip-", "")}`}></span>
                      <span className="v5-facet-evidence-text">{it.t}</span>
                      <span className="mono v5-facet-evidence-status">{it.s}</span>
                    </li>
                  )}
                </ul>
              </div>
            </div>

            <div className="v5-facet-detail-foot">
              <span className="mono">{String(active + 1).padStart(2, "0")} / 06</span>
              <button type="button" className="mono v5-facet-next" onClick={() => pick((active + 1) % V5_FACETS.length)}>
                Next lens →
              </button>
            </div>
          </div>
        </div>
      </div>
    </section>);

};

Object.assign(window, { V5Facet, V5_FACETS });