// Hi-fi science direction — editorial/swiss, data-forward
// Theme-aware palette via CSS custom properties.

const SCI_BRAND_VARIANT =
  typeof document !== "undefined"
    ? (document.documentElement.getAttribute("data-brand-variant") || "classic")
    : "classic";
const SCI_IS_SENSEI   = SCI_BRAND_VARIANT === "sensei";
const SCI_IS_WANDERER = SCI_BRAND_VARIANT === "wanderer";
const SCI_IS_AMARA    = SCI_BRAND_VARIANT === "amara";
const SCI_COPY_AMARA = {
  brandName: "Amara",
  navMethod: "How It Works",
  navInstruments: "The Atlas",
  navSample: "Love & Union",
  navPricing: "Pricing",
  heroKicker: "§ 01 · A reading across worlds",
  heroTitle:
    "Eight traditions read\nyour life. One atlas,\nwritten by hand.",
  heroBody:
    "Give us your birth date, time, and place — plus a few minutes for a personality quiz. We run your data through Western astrology, Vedic Jyotish, Chinese Ba Zi, Numerology, Astrocartography, Human Design, Tarot birth cards, and the Mayan Tzolk'in. Where multiple traditions say the same thing about you, that becomes a chapter in your atlas. You get a personalized report — PDF and audio — delivered within 7 days.",
  heroPrimaryCta: "Your Atlas · $79",
  heroSecondaryCta: "Love & Union · $39",
  disclaimer:
    "For self-reflection only. Not medical, legal, or mental-health advice. Pay once, keep your reading forever — no subscription required.",
  footerTagline: "8 TRADITIONS · 38 READINGS · WRITTEN BY HAND",
};
const SCI_COPY_V2 = {
  brandName: "Amara",
  navMethod: "Method",
  navInstruments: "Archetypes",
  navSample: "Instant Downloads",
  navPricing: "Full Reading",
  heroKicker: "§ 01 · Reading",
  heroTitle:
    "Read the signs.\nProtect your peace.",
  heroBody:
    "Thirteen traditions — astrology, Human Design, Big Five, Enneagram, Gene Keys, I Ching — each reading you on their own. We show you what they all agree on. That's the part no single reading could ever tell you.",
  heroPrimaryCta: "Start Free",
  heroSecondaryCta: "Instant Download",
  disclaimer:
    "Guidance for reflection only. Not medical, legal, or mental-health advice.",
  footerTagline: "DISCIPLINE. RHYTHM. CLARITY.",
};
const SCI_COPY_CLASSIC = {
  brandName: "Amara",
  navMethod: "How It Works",
  navInstruments: (SCI_IS_AMARA ? "The Atlas" : "Twelve Ways In"),
  navSample: "Sample report",
  navPricing: "Pricing",
  heroKicker: "§ 01 · Thesis",
  heroTitle: "You've read yourself in pieces. Here's all of you at once.",
  heroBody:
    "Thirteen traditions — astrology, Human Design, Big Five, Enneagram, Gene Keys, I Ching — each reading you on their own. We show you what they all agree on. That's the part no single reading could ever tell you.",
  heroPrimaryCta: "Read My Chart",
  heroSecondaryCta: "Start Free",
  disclaimer:
    "Not another app. Not another daily horoscope. An 8,000-word letter about your mind, your work, your relationships, your karmic lines, and your blind spots — written when every chart in your life finally tells the same story.",
  footerTagline: "THE ANCIENTS READ THE STARS. WE READ YOU.",
};
const SCI_COPY_V3 = {
  brandName: "Amara",
  navMethod: "How It Works",
  navInstruments: "World Systems",
  navSample: "Instant Downloads",
  navPricing: "Full Reading",
  heroKicker: "§ 01 · The Global Reading",
  heroTitle:
    "Every culture studied\nthe human soul.\nHere's what they found.",
  heroBody:
    "Thirteen traditions — Western astrology, Vedic, Human Design, Big Five, Enneagram, I Ching, Mayan, and more — each reading you on their own. We show you what they all agree on. That's the part no single tradition could ever tell you.",
  heroPrimaryCta: "Start Free",
  heroSecondaryCta: "Instant Download",
  disclaimer:
    "Guidance for reflection only. Not medical, legal, or mental-health advice.",
  footerTagline: "EVERY CULTURE STUDIED YOU. WE SYNTHESIZED WHAT THEY FOUND.",
};
const SCI_COPY = SCI_IS_AMARA ? SCI_COPY_AMARA : SCI_IS_SENSEI ? SCI_COPY_V2 : SCI_IS_WANDERER ? SCI_COPY_V3 : SCI_COPY_CLASSIC;
const SCI_THEME_V2 = {
  paper: "#ffffff",
  ink: "#0a0a0a",
  ink2: "#2a2a2a",
  ink3: "#6b6b6b",
  tint: "#f2f2f0",
  tint2: "#f7f7f6",
  rule: "#0a0a0a",
  border: "#0a0a0a",
  accent: "#b8202a",
  accentDeep: "#7a1a1f",
  display: '"Shippori Mincho","Noto Serif JP","Hiragino Mincho ProN","Yu Mincho",serif',
  body: '"Noto Sans JP","Inter",system-ui,sans-serif',
  mono: '"JetBrains Mono","IBM Plex Mono",monospace',
};

if (typeof document !== "undefined") {
  document.documentElement.dataset.brandVariant = SCI_BRAND_VARIANT;
}
if (typeof window !== "undefined") {
  window.TAMASHI_VARIANT = SCI_BRAND_VARIANT;
  window.SCI_IS_AMARA   = SCI_IS_AMARA;
  window.SCI_IS_SENSEI  = SCI_IS_SENSEI;
  window.SCI_IS_WANDERER= SCI_IS_WANDERER;
  window.SCI_COPY       = SCI_COPY;
}

// V2-only: inject Shippori Mincho font (never loads on V1 / classic)
if (SCI_IS_SENSEI && typeof document !== "undefined" && !document.getElementById("sci-shippori-font")) {
  const link = document.createElement("link");
  link.id = "sci-shippori-font";
  link.href = "https://fonts.googleapis.com/css2?family=Shippori+Mincho:wght@400;500;600;700&display=swap";
  link.rel = "stylesheet";
  document.head.appendChild(link);
}

// V3-only: inject Cormorant Garamond — old-world scholarly, no single culture
if (SCI_IS_WANDERER && typeof document !== "undefined" && !document.getElementById("sci-cormorant-font")) {
  const link = document.createElement("link");
  link.id = "sci-cormorant-font";
  link.href = "https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400;1,500&family=Inter:wght@300;400;500&display=swap";
  link.rel = "stylesheet";
  document.head.appendChild(link);
}

const SCI = {
  paper:   "var(--sci-paper)",
  ink:     "var(--sci-ink)",
  ink2:    "var(--sci-ink2)",
  ink3:    "var(--sci-ink3)",
  tint:    "var(--sci-tint)",
  tint2:   "var(--sci-tint2)",
  rule:    "var(--sci-rule)",
  border:  "var(--sci-border)",
  orange:  "var(--sci-orange)",
  forest:  "var(--sci-forest)",
  sand:    "var(--sci-sand)",
  display: SCI_IS_SENSEI
    ? '"Shippori Mincho","Noto Serif JP","Hiragino Mincho ProN","Yu Mincho",serif'
    : SCI_IS_WANDERER
    ? '"Cormorant Garamond","Palatino Linotype","Book Antiqua",Palatino,serif'
    : '"Cormorant Garamond","GT Sectra",Canela,serif',
  body:    SCI_IS_SENSEI
    ? '"Noto Sans JP","Inter",system-ui,sans-serif'
    : '"Inter",system-ui,sans-serif',
  mono:    '"JetBrains Mono","IBM Plex Mono",monospace',
};

// —— Theme engine ——————————————————————————————
const SCI_THEME_KEY = "tamashi-theme";
const SCI_THEMES = ["system", "light", "dark"];

function sciGetEffective(pref) {
  if (pref === "light") return "light";
  if (pref === "dark")  return "dark";
  return (typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches)
    ? "dark" : "light";
}
function sciApplyTheme(pref) {
  if (typeof document === "undefined") return;
  document.documentElement.dataset.sciTheme = sciGetEffective(pref);
}
// init on load (before first paint)
if (typeof localStorage !== "undefined") {
  sciApplyTheme(localStorage.getItem(SCI_THEME_KEY) || "system");
}

if (
  typeof document !== "undefined" &&
  !document.getElementById("sci-live-styles")
) {
  const style = document.createElement("style");
  style.id = "sci-live-styles";
  style.textContent = [
    ":root,[data-sci-theme='light']{" +
      "--sci-paper:#f3efe4;--sci-ink:#111111;--sci-ink2:#3a3a36;--sci-ink3:#6e6a60;" +
      "--sci-tint:#e4dfcf;--sci-tint2:#eae4d2;--sci-rule:#1c1c1c;" +
      "--sci-orange:#c65a2a;--sci-forest:#2b4a3a;--sci-sand:#bfa76a;" +
      "--sci-orange-rgb:198,90,42;" +
      "--sci-paper-rgb:243,239,228;--sci-ink-rgb:17,17,17;--sci-border:#1c1c1c;" +
    "}",
    "[data-sci-theme='dark']{" +
      "--sci-paper:#1a1714;--sci-ink:#ede8db;--sci-ink2:#afa99c;--sci-ink3:#706a5e;" +
      "--sci-tint:#252119;--sci-tint2:#201d18;--sci-rule:#e0dbd0;" +
      "--sci-orange:#d4673a;--sci-forest:#3a6050;--sci-sand:#c9965a;" +
      "--sci-orange-rgb:212,103,58;" +
      "--sci-paper-rgb:26,23,20;--sci-ink-rgb:237,232,219;--sci-border:#3a3530;" +
    "}",
    // —— Amara palette — Woven Linen + Midnight Indigo + Desert Rose + Earth Ochre + Sage Green
    //    From the Amara Brand Guide. Maps to existing CSS variable names so the
    //    rest of the template renders unchanged. The "orange" slot is now Desert Rose. ——
    ":root[data-brand-variant='amara'],[data-brand-variant='amara'][data-sci-theme='light']{" +
      "--sci-paper:#f5f0e6;--sci-ink:#191970;--sci-ink2:#3d3560;--sci-ink3:#7a6f8a;" +
      "--sci-tint:#ebe4d4;--sci-tint2:#f0eadc;--sci-rule:#191970;" +
      "--sci-orange:#cd5c5c;--sci-forest:#8fbc8f;--sci-sand:#b8860b;" +
      "--sci-orange-rgb:205,92,92;" +
      "--sci-paper-rgb:245,240,230;--sci-ink-rgb:25,25,112;--sci-border:#191970;" +
      "--sci-indigo:#191970;--sci-ochre:#b8860b;--sci-rose:#cd5c5c;--sci-linen:#f5f0e6;--sci-sage:#8fbc8f;" +
    "}",
    "[data-brand-variant='amara'][data-sci-theme='dark']{" +
      "--sci-paper:#0f0d2c;--sci-ink:#f5f0e6;--sci-ink2:#cdc7d6;--sci-ink3:#8a82a0;" +
      "--sci-tint:#1a1740;--sci-tint2:#15122e;--sci-rule:#dcd5c4;" +
      "--sci-orange:#e07878;--sci-forest:#a8d4a8;--sci-sand:#d4a82e;" +
      "--sci-orange-rgb:224,120,120;" +
      "--sci-paper-rgb:15,13,44;--sci-ink-rgb:245,240,230;--sci-border:#3a3760;" +
      "--sci-indigo:#3a3a90;--sci-ochre:#d4a82e;--sci-rose:#e07878;--sci-linen:#f5f0e6;--sci-sage:#a8d4a8;" +
    "}",
    // —— Sensei V2 palette (ONLY these override defaults on /sensei) ——
    ":root[data-brand-variant='sensei'],[data-brand-variant='sensei'][data-sci-theme='light']{" +
      "--sci-paper:#ffffff;--sci-ink:#0a0a0a;--sci-ink2:#2a2a2a;--sci-ink3:#6b6b6b;" +
      "--sci-tint:#f2f2f0;--sci-tint2:#f7f7f6;--sci-rule:#0a0a0a;" +
      "--sci-orange:#b8202a;--sci-forest:#1a1a1a;--sci-sand:#f2f2f0;" +
      "--sci-orange-rgb:184,32,42;" +
      "--sci-paper-rgb:255,255,255;--sci-ink-rgb:10,10,10;--sci-border:#0a0a0a;" +
    "}",
    "[data-brand-variant='sensei'][data-sci-theme='dark']{" +
      "--sci-paper:#0a0a0a;--sci-ink:#f5f4f2;--sci-ink2:#d2cfcb;--sci-ink3:#9f9a96;" +
      "--sci-tint:#191818;--sci-tint2:#121112;--sci-rule:#e9e8e5;" +
      "--sci-orange:#d11a2a;--sci-forest:#c9c7c3;--sci-sand:#b5aca1;" +
      "--sci-orange-rgb:209,26,42;" +
      "--sci-paper-rgb:10,10,10;--sci-ink-rgb:245,244,242;--sci-border:#3a3530;" +
    "}",
    // —— Wanderer V3 palette — global synthesis: midnight + aged gold + warm parchment ——
    ":root[data-brand-variant='wanderer'],[data-brand-variant='wanderer'][data-sci-theme='light']{" +
      "--sci-paper:#f5f0e8;--sci-ink:#1a1520;--sci-ink2:#3d3548;--sci-ink3:#7a6e8a;" +
      "--sci-tint:#ede7d9;--sci-tint2:#f0ebe0;--sci-rule:#1a1520;" +
      "--sci-orange:#c9a84c;--sci-forest:#3a7a8f;--sci-sand:#5c4a8a;" +
      "--sci-orange-rgb:201,168,76;" +
      "--sci-paper-rgb:245,240,232;--sci-ink-rgb:26,21,32;--sci-border:#1a1520;" +
    "}",
    "[data-brand-variant='wanderer'][data-sci-theme='dark']{" +
      "--sci-paper:#0d0b1e;--sci-ink:#e8e4d8;--sci-ink2:#b8b0c8;--sci-ink3:#7a7088;" +
      "--sci-tint:#151225;--sci-tint2:#110f1e;--sci-rule:#e8e4d8;" +
      "--sci-orange:#c9a84c;--sci-forest:#3a7a8f;--sci-sand:#7b5ea7;" +
      "--sci-orange-rgb:201,168,76;" +
      "--sci-paper-rgb:13,11,30;--sci-ink-rgb:232,228,216;--sci-border:#3a3050;" +
    "}",
    // — body background follows theme —
    "body{background:var(--sci-paper);color:var(--sci-ink);transition:background .25s ease,color .25s ease}",
    // —— keyframes ——
    "@keyframes sci-marquee{0%{transform:translateX(0)}100%{transform:translateX(-50%)}}",
    "@keyframes sci-float{0%,100%{transform:translateY(0)}50%{transform:translateY(-5px)}}",
    "@keyframes sci-spin-slow{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}",
    "@keyframes sci-spin-rev{0%{transform:rotate(0deg)}100%{transform:rotate(-360deg)}}",
    "@keyframes sci-pulse-ring{0%,100%{r:22}50%{r:23.5}}",
    "@keyframes sci-card-in{0%{transform:translateY(14px)}100%{transform:translateY(0)}}",
    "@keyframes sci-grow{0%{transform:scaleX(0)}100%{transform:scaleX(1)}}",
    "@keyframes sci-shimmer{0%{transform:translateX(-120%)}100%{transform:translateX(200%)}}",
    "@keyframes sci-pulse{0%,100%{opacity:1}50%{opacity:.6}}",
    "@keyframes sci-draw{0%{stroke-dashoffset:140}100%{stroke-dashoffset:0}}",
    "@keyframes sci-dash{0%{stroke-dashoffset:0}100%{stroke-dashoffset:-16}}",
    "@keyframes sci-fade-up{0%{opacity:.001;transform:translateY(10px)}100%{opacity:1;transform:translateY(0)}}",
    "@keyframes sci-bar-breathe{0%,100%{transform:scaleX(1)}50%{transform:scaleX(0.45)}}",
    "@keyframes sci-col-wave{0%,100%{transform:scaleY(1)}50%{transform:scaleY(0.12)}}",
    "@keyframes sci-ping{0%,100%{transform:scale(1);opacity:1}7%{transform:scale(2.8);opacity:0.6}15%,100%{transform:scale(1);opacity:1}}",
    "@keyframes sci-signal{0%,100%{stroke-opacity:0.2;stroke-width:1}50%{stroke-opacity:1;stroke-width:2}}",
    "@keyframes sci-num-appear{0%,100%{opacity:0.08}12%,20%{opacity:1}}",
    "@keyframes sci-carto-draw{0%{stroke-dashoffset:52}100%{stroke-dashoffset:0}}",
    "@keyframes sci-iching-flip{0%,100%{opacity:1}40%,60%{opacity:0.1}}",
    "@keyframes sci-genes-glow{0%,100%{opacity:0}12%{opacity:1}}",
    "@keyframes sci-heartbeat{0%{transform:scale(1)}6%{transform:scale(1.18)}12%{transform:scale(1)}18%{transform:scale(1.08)}24%,100%{transform:scale(1)}}",
    "@keyframes sci-breathe{0%,100%{transform:scale(1)}50%{transform:scale(1.7)}}",
    "@keyframes sci-taiji{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}",
    "@keyframes sci-yin-ping{0%,100%{r:2;opacity:0.4}50%{r:3.5;opacity:1}}",
    "@keyframes sci-yang-ping{0%,100%{r:3.5;opacity:1}50%{r:2;opacity:0.4}}",
    "@keyframes sci-pulse-fade{0%,100%{opacity:0.55}50%{opacity:1}}",
    "@keyframes sci-marquee-amara{0%{transform:translateX(0)}100%{transform:translateX(-50%)}}",
    /* Amara accent strip + Sage Green secondary highlight */
    "[data-brand-variant='amara'] .amara-announcement{background:#b8860b;color:#f5f0e6;padding:10px 24px;text-align:center;font-family:" + "'JetBrains Mono','IBM Plex Mono',monospace;font-size:11px;letter-spacing:2px;text-transform:uppercase;border-bottom:1px solid #191970;overflow:hidden;white-space:nowrap}",
    "[data-brand-variant='amara'] .amara-announcement-track{display:inline-block;animation:sci-marquee-amara 38s linear infinite}",
    "[data-brand-variant='amara'] .amara-announcement-track > span{padding:0 28px}",
    "[data-brand-variant='amara'] .amara-announcement-track > span > em{color:#f5f0e6;font-style:normal;border-bottom:1px solid #f5f0e6}",
    ".sci-marquee{overflow:hidden;position:relative}",
    ".sci-marquee-track{display:flex;align-items:center;gap:44px;width:max-content;animation:sci-marquee 26s linear infinite;will-change:transform}",
    ".sci-card-hover{transition:transform .24s ease,box-shadow .24s ease}",
    ".sci-card-hover:hover{transform:translateY(-3px);box-shadow:0 8px 18px rgba(0,0,0,.08)}",
    ".sci-btn{transition:transform .14s ease,box-shadow .18s ease,opacity .18s ease}",
    ".sci-btn:hover{transform:translateY(-1px)}",
    ".sci-btn:active{transform:translateY(0)}",
    ".sci-btn:focus-visible{outline:2px solid var(--sci-ink);outline-offset:2px}",
    ".sci-link-btn{border:none;background:none;padding:0;text-align:left;cursor:pointer;color:inherit}",
    ".sci-link-btn:hover{text-decoration:underline}",
    ".sci-link-btn:focus-visible{outline:2px solid var(--sci-ink);outline-offset:2px}",
    '[data-sci-motion="1"]{will-change:transform}',
    ".sci-reveal{animation:sci-fade-up .55s cubic-bezier(.18,.84,.34,1) both}",
    ".sci-sparkline-line{stroke-dasharray:140;stroke-dashoffset:140;animation:sci-draw 1.8s ease forwards}",
    '@media (prefers-reduced-motion: reduce){.sci-marquee-track,.sci-card-hover,.sci-reveal,.sci-sparkline-line,[data-sci-motion="1"]{animation:none!important;transition:none!important}}',
  ].join("\n");
  document.head.appendChild(style);
}

// —— Theme toggle component ———————————————————
function SciThemeToggle() {
  const [pref, setPref] = React.useState(
    () => (typeof localStorage !== "undefined" ? localStorage.getItem(SCI_THEME_KEY) || "system" : "system")
  );
  React.useEffect(() => {
    if (pref !== "system") return;
    const mq = window.matchMedia("(prefers-color-scheme: dark)");
    const handler = () => sciApplyTheme("system");
    mq.addEventListener("change", handler);
    return () => mq.removeEventListener("change", handler);
  }, [pref]);
  const cycle = () => {
    const next = SCI_THEMES[(SCI_THEMES.indexOf(pref) + 1) % SCI_THEMES.length];
    setPref(next);
    localStorage.setItem(SCI_THEME_KEY, next);
    sciApplyTheme(next);
  };
  const icons = { system: "◑", light: "○", dark: "●" };
  const labels = { system: "System", light: "Light", dark: "Dark" };
  return (
    <button
      type="button"
      onClick={cycle}
      title={`Theme: ${labels[pref]} — click to cycle`}
      style={{
        display: "inline-flex",
        alignItems: "center",
        gap: 5,
        border: `1px solid ${SCI.border}`,
        background: "transparent",
        color: SCI.ink,
        fontFamily: SCI.mono,
        fontSize: 10,
        letterSpacing: 0.5,
        padding: "4px 10px",
        cursor: "pointer",
        textTransform: "uppercase",
        transition: "opacity .15s ease",
        flexShrink: 0,
      }}
    >
      <span style={{ fontSize: 12, lineHeight: 1 }}>{icons[pref]}</span>
      {labels[pref]}
    </button>
  );
}

// —— tiny UI atoms ————————————————————————————
function Rule({ style, v }) {
  return (
    <div
      style={{
        background: SCI.rule,
        width: v ? 1 : "100%",
        height: v ? "100%" : 1,
        ...style,
      }}
    />
  );
}
function MonoLabel({ children, style, size = 10 }) {
  return (
    <span
      style={{
        fontFamily: SCI.mono,
        fontSize: size,
        letterSpacing: 1,
        textTransform: "uppercase",
        color: SCI.ink2,
        ...style,
      }}
    >
      {children}
    </span>
  );
}
function SciBtn({
  children,
  primary,
  style,
  w,
  size = "md",
  icon,
  onClick,
  disabled,
  type = "button",
  title,
}) {
  const sizes = {
    sm: { h: 34, fs: 12, px: 14 },
    md: { h: 44, fs: 13, px: 20 },
    lg: { h: 52, fs: 14, px: 26 },
  };
  const s = sizes[size];
  return (
    <button
      className="sci-btn"
      type={type}
      onClick={onClick}
      disabled={disabled}
      title={title}
      style={{
        display: "inline-flex",
        alignItems: "center",
        justifyContent: "center",
        gap: 8,
        height: s.h,
        padding: `0 ${s.px}px`,
        width: w,
        background: primary ? SCI.ink : "transparent",
        color: primary ? SCI.paper : SCI.ink,
        border: `1px solid ${SCI.border}`,
        fontFamily: SCI.body,
        fontSize: s.fs,
        fontWeight: 500,
        cursor: disabled ? "not-allowed" : "pointer",
        opacity: disabled ? 0.55 : 1,
        outline: "none",
        appearance: "none",
        ...style,
      }}
    >
      {children}
      {icon && <span style={{ fontFamily: SCI.mono }}>{icon}</span>}
    </button>
  );
}
function Pill({ children, dark, style }) {
  return (
    <span
      style={{
        display: "inline-flex",
        alignItems: "center",
        gap: 6,
        padding: "4px 10px",
        border: `1px solid ${SCI.border}`,
        background: dark ? SCI.ink : "transparent",
        color: dark ? SCI.paper : SCI.ink,
        fontFamily: SCI.mono,
        fontSize: 10,
        letterSpacing: 0.5,
        textTransform: "uppercase",
        ...style,
      }}
    >
      {children}
    </span>
  );
}

// —— Big Five horizontal bars ————————————————
function BigFiveBars({ values, animated = true }) {
  const traits = [
    { l: "Openness", s: "O", v: values[0] },
    { l: "Conscientiousness", s: "C", v: values[1] },
    { l: "Extraversion", s: "E", v: values[2] },
    { l: "Agreeableness", s: "A", v: values[3] },
    { l: "Neuroticism", s: "N", v: values[4] },
  ];
  return (
    <div style={{ fontFamily: SCI.body }}>
      {traits.map((t, i) => (
        <div
          key={i}
          style={{
            display: "grid",
            gridTemplateColumns: "28px 1fr 44px",
            alignItems: "center",
            gap: 10,
            padding: "7px 0",
            borderBottom: i < 4 ? `1px solid ${SCI.tint}` : "none",
          }}
        >
          <div style={{ fontFamily: SCI.mono, fontSize: 11, fontWeight: 500 }}>
            {t.s}
          </div>
          <div
            style={{
              position: "relative",
              height: 10,
              background: SCI.tint,
              overflow: "hidden",
            }}
          >
            <div
              style={{
                position: "absolute",
                left: 0,
                top: 0,
                bottom: 0,
                width: `${t.v}%`,
                background: i === 0 ? SCI.orange : SCI.ink,
                transformOrigin: "left center",
                animation: animated ? "sci-grow 1s ease both" : "none",
                animationDelay: animated ? `${i * 70}ms` : "0ms",
              }}
            />
            {animated && (
              <div
                style={{
                  position: "absolute",
                  inset: 0,
                  width: "34%",
                  background:
                    "linear-gradient(90deg, transparent, rgba(var(--sci-paper-rgb),0.4), transparent)",
                  animation: "sci-shimmer 2.3s ease-in-out infinite",
                  animationDelay: `${i * 90}ms`,
                }}
              />
            )}
            {/* percentile ticks */}
            {[25, 50, 75].map((p) => (
              <div
                key={p}
                style={{
                  position: "absolute",
                  left: `${p}%`,
                  top: -3,
                  bottom: -3,
                  width: 1,
                  background: SCI.paper,
                }}
              />
            ))}
          </div>
          <div
            style={{ fontFamily: SCI.mono, fontSize: 11, textAlign: "right" }}
          >
            {t.v}
            <span style={{ color: SCI.ink3 }}>%</span>
          </div>
        </div>
      ))}
    </div>
  );
}

// —— MBTI cognitive stack ———————————————————
function MBTIStack({ animated = true }) {
  const fns = [
    { fn: "Ni", pos: "Dominant", w: 96 },
    { fn: "Te", pos: "Auxiliary", w: 74 },
    { fn: "Fi", pos: "Tertiary", w: 48 },
    { fn: "Se", pos: "Inferior", w: 28 },
  ];
  return (
    <div>
      {fns.map((f, i) => (
        <div
          key={i}
          style={{
            display: "grid",
            gridTemplateColumns: "48px 90px 1fr",
            alignItems: "center",
            gap: 10,
            padding: "6px 0",
            borderBottom: i < 3 ? `1px solid ${SCI.tint}` : "none",
          }}
        >
          <div
            style={{
              fontFamily: SCI.display,
              fontSize: 22,
              lineHeight: 1,
              color: i === 0 ? SCI.orange : SCI.ink,
            }}
          >
            {f.fn}
          </div>
          <div
            style={{
              fontFamily: SCI.mono,
              fontSize: 9,
              color: SCI.ink3,
              textTransform: "uppercase",
              letterSpacing: 0.5,
            }}
          >
            {f.pos}
          </div>
          <div
            style={{
              height: 6,
              background: SCI.tint,
              position: "relative",
              overflow: "hidden",
            }}
          >
            <div
              style={{
                position: "absolute",
                left: 0,
                top: 0,
                bottom: 0,
                width: `${f.w}%`,
                background: i === 0 ? SCI.orange : SCI.ink,
                transformOrigin: "left center",
                animation: animated ? "sci-grow 1s ease both" : "none",
                animationDelay: animated ? `${i * 100}ms` : "0ms",
              }}
            />
          </div>
        </div>
      ))}
    </div>
  );
}

// —— Enneagram radar (9-pointed) ———————————————
function EnneaRadar({ values, animated = true }) {
  // values: array of 9 numbers 0..1, index 0 = type 1 at top
  const cx = 100,
    cy = 100,
    R = 78;
  const pts = values.map((v, i) => {
    const a = -Math.PI / 2 + (i * 2 * Math.PI) / 9;
    return [cx + Math.cos(a) * R * v, cy + Math.sin(a) * R * v];
  });
  const poly = pts.map((p) => p.join(",")).join(" ");
  const axes = values.map((_, i) => {
    const a = -Math.PI / 2 + (i * 2 * Math.PI) / 9;
    return [cx + Math.cos(a) * R, cy + Math.sin(a) * R];
  });
  return (
    <svg viewBox="0 0 200 200" style={{ width: "100%", height: "100%" }}>
      {[0.25, 0.5, 0.75, 1].map((r, i) => (
        <polygon
          key={i}
          fill="none"
          stroke={SCI.ink3}
          strokeWidth="0.8"
          points={values
            .map((_, j) => {
              const a = -Math.PI / 2 + (j * 2 * Math.PI) / 9;
              return `${cx + Math.cos(a) * R * r},${cy + Math.sin(a) * R * r}`;
            })
            .join(" ")}
        />
      ))}
      {axes.map(([x, y], i) => (
        <line
          key={i}
          x1={cx}
          y1={cy}
          x2={x}
          y2={y}
          stroke={SCI.ink3}
          strokeWidth="0.8"
        />
      ))}
      <polygon
        points={poly}
        fill={SCI.orange}
        fillOpacity="0.18"
        stroke={SCI.orange}
        strokeWidth="1.4"
        style={
          animated ? { animation: "sci-pulse 3s ease-in-out infinite" } : null
        }
      />
      {pts.map(([x, y], i) => (
        <g key={i}>
          <circle
            cx={x}
            cy={y}
            r={i === 7 ? 4 : 2.4}
            fill={i === 7 ? SCI.orange : SCI.paper}
          />
          {(() => {
            const a = -Math.PI / 2 + (i * 2 * Math.PI) / 9;
            const lx = cx + Math.cos(a) * (R + 12);
            const ly = cy + Math.sin(a) * (R + 12);
            return (
              <text
                x={lx}
                y={ly}
                fontFamily={SCI.mono}
                fontSize="9"
                fill={i === 7 ? SCI.orange : SCI.ink3}
                textAnchor="middle"
                dominantBaseline="middle"
                fontWeight={i === 7 ? 600 : 400}
              >
                {i + 1}
              </text>
            );
          })()}
        </g>
      ))}
    </svg>
  );
}

// —— Sparkline trend ————————————————————————
function Sparkline({ data, color = SCI.ink, height = 34, animated = true }) {
  const max = Math.max(...data),
    min = Math.min(...data);
  const pts = data
    .map((v, i) => {
      const x = (i / (data.length - 1)) * 100;
      const y = 100 - ((v - min) / (max - min || 1)) * 100;
      return `${x},${y}`;
    })
    .join(" ");
  return (
    <svg
      viewBox="0 0 100 100"
      preserveAspectRatio="none"
      style={{ width: "100%", height }}
    >
      <polyline
        className={animated ? "sci-sparkline-line" : undefined}
        fill="none"
        stroke={color}
        strokeWidth="2"
        vectorEffect="non-scaling-stroke"
        points={pts}
      />
    </svg>
  );
}

// —— Correlation heat strip ——————————————————
function HeatStrip({ cells = 12, animated = true }) {
  const vals = [0.2, 0.8, 0.5, 0.9, 0.3, 0.6, 0.7, 0.2, 0.95, 0.4, 0.55, 0.75];
  return (
    <div
      style={{
        display: "grid",
        gridTemplateColumns: `repeat(${cells},1fr)`,
        gap: 2,
      }}
    >
      {Array.from({ length: cells }).map((_, i) => (
        <div
          key={i}
          style={{
            aspectRatio: "1/1",
            background: `rgba(var(--sci-orange-rgb),${vals[i % vals.length]})`,
            border: `1px solid ${SCI.paper}`,
            animation: animated
              ? `sci-pulse 2.4s ease-in-out ${i * 70}ms infinite`
              : "none",
          }}
        />
      ))}
    </div>
  );
}

// —— Header / Nav ———————————————————————————
function SciNav({
  compact,
  onBegin,
  onInstantDownload,
  onSignIn,
  onSignUp,
  onNavigateSection,
  onNavigatePage,
  activeSection = "Methodology",
  user,
}) {
  const navItems = [
    { label: SCI_COPY.navMethod, sectionId: "section-methodology" },
    { label: SCI_COPY.navInstruments, sectionId: "section-instruments" },
    SCI_IS_SENSEI
      ? { label: SCI_COPY.navSample, route: "/scrolls" }
      : { label: SCI_COPY.navSample, sectionId: "section-sample" },
    { label: SCI_COPY.navPricing, sectionId: "section-pricing" },
  ];
  return (
    <div
      style={{
        display: "flex",
        alignItems: "stretch",
        height: compact ? 56 : 64,
        borderBottom: `1px solid ${SCI.border}`,
        background: SCI.paper,
      }}
    >
      <div
        style={{
          padding: "0 28px",
          display: "flex",
          alignItems: "center",
          borderRight: `1px solid ${SCI.border}`,
          gap: 10,
        }}
      >
        {/* 魂 hanko seal */}
        <div
          style={{
            width: 26,
            height: 26,
            border: `1.5px solid ${SCI.border}`,
            display: "flex",
            alignItems: "center",
            justifyContent: "center",
            flexShrink: 0,
          }}
        >
          <span
            style={{
              fontFamily: "serif",
              fontSize: 15,
              lineHeight: 1,
              color: SCI.orange,
              userSelect: "none",
            }}
          >
            {SCI_IS_AMARA ? "·" : "魂"}
          </span>
        </div>
        <div
          style={{
            fontFamily: SCI.display,
            fontSize: 22,
            letterSpacing: -0.3,
            fontWeight: 500,
          }}
        >
          {SCI_COPY.brandName}
        </div>
      </div>
      <div
        style={{
          flex: 1,
          display: "flex",
          alignItems: "center",
          padding: "0 28px",
          gap: 32,
          fontSize: 13,
        }}
      >
        {navItems.map((item) => (
          <button
            key={item.label}
            type="button"
            onClick={() => {
              if (item.sectionId && onNavigateSection)
                onNavigateSection(item.sectionId, item.label);
              if (item.route && onNavigatePage) onNavigatePage(item.route);
            }}
            style={{
              color: activeSection === item.label ? SCI.ink : SCI.ink2,
              border: "none",
              borderBottom:
                activeSection === item.label
                  ? `1.5px solid ${SCI.border}`
                  : "none",
              padding: "4px 0",
              background: "none",
              cursor: "pointer",
              fontFamily: SCI.body,
              fontSize: 13,
            }}
          >
            {item.label}
          </button>
        ))}
      </div>
      <div
        style={{
          padding: "0 16px",
          display: "flex",
          alignItems: "center",
          borderLeft: `1px solid ${SCI.border}`,
        }}
      >
        <SciThemeToggle />
      </div>
      <div
        style={{
          borderLeft: `1px solid ${SCI.border}`,
          padding: "0 18px",
          display: "flex",
          alignItems: "center",
          gap: 10,
        }}
      >
        {user ? (
          <button
            type="button"
            onClick={onSignIn}
            style={{
              fontSize: 12,
              border: "none",
              background: "none",
              padding: 0,
              margin: 0,
              cursor: "pointer",
              color: SCI.ink2,
              fontFamily: SCI.mono,
              letterSpacing: 0.5,
              textTransform: "uppercase",
            }}
          >
            My account
          </button>
        ) : (
          <button
            type="button"
            onClick={onSignIn}
            style={{
              fontSize: 12,
              border: "none",
              background: "none",
              padding: 0,
              margin: 0,
              cursor: "pointer",
              color: SCI.ink2,
              fontFamily: SCI.body,
            }}
          >
            Log In
          </button>
        )}
        {!user && (
          <SciBtn size="sm" onClick={onSignUp || onBegin} style={{ marginLeft: 2 }}>
            Create Account
          </SciBtn>
        )}
        <SciBtn primary size="sm" icon="→" onClick={onBegin}>
          {SCI_IS_SENSEI ? "Start Free" : user ? "My Reading" : "Start Free"}
        </SciBtn>
      </div>
    </div>
  );
}

// —— Animated metric strip ———————————————————
function MetricStrip() {
  const metrics = [
    { k: "Confidence", target: 0.91, fmt: (v) => v.toFixed(2), sub: "cross-system agreement" },
    { k: "Convergent", target: 7, fmt: (v) => `${Math.round(v)} / 10`, sub: "readings aligned" },
    { k: "Shadow", target: null, display: "Type 1", sub: "growth direction" },
    { k: "Stress", target: null, display: "→ 5", sub: "integration path" },
  ];
  const [vals, setVals] = React.useState([0, 0, null, null]);
  const [started, setStarted] = React.useState(false);
  const ref = React.useRef(null);

  React.useEffect(() => {
    if (!ref.current) return;
    const obs = new IntersectionObserver(
      ([entry]) => { if (entry.isIntersecting && !started) setStarted(true); },
      { threshold: 0.3 }
    );
    obs.observe(ref.current);
    return () => obs.disconnect();
  }, [started]);

  React.useEffect(() => {
    if (!started) return;
    const duration = 1400;
    const start = performance.now();
    function tick(now) {
      const t = Math.min((now - start) / duration, 1);
      const ease = 1 - Math.pow(1 - t, 3);
      setVals([0.91 * ease, 7 * ease, null, null]);
      if (t < 1) requestAnimationFrame(tick);
    }
    requestAnimationFrame(tick);
  }, [started]);

  return (
    <div
      ref={ref}
      style={{
        borderTop: `1px solid ${SCI.border}`,
        display: "grid",
        gridTemplateColumns: "repeat(4, 1fr)",
      }}
    >
      {metrics.map((m, i) => {
        const display = m.target !== null ? m.fmt(vals[i] || 0) : m.display;
        const pct = m.target !== null ? (vals[i] || 0) / m.target : 1;
        return (
          <div
            key={i}
            style={{
              padding: "12px 16px",
              borderRight: i < 3 ? `1px solid ${SCI.tint}` : "none",
              position: "relative",
              overflow: "hidden",
            }}
          >
            <div
              style={{
                position: "absolute",
                bottom: 0,
                left: 0,
                height: 2,
                width: `${pct * 100}%`,
                background: SCI.orange,
                transition: "width 0.05s linear",
              }}
            />
            <MonoLabel size={9}>{m.k}</MonoLabel>
            <div
              style={{
                fontFamily: SCI.display,
                fontSize: 22,
                lineHeight: 1.1,
                margin: "2px 0",
              }}
            >
              {display}
            </div>
            <div
              style={{ fontFamily: SCI.mono, fontSize: 9, color: SCI.ink3 }}
            >
              {m.sub}
            </div>
          </div>
        );
      })}
    </div>
  );
}

// —— SECTION: Hero ——————————————————————————
function SciHero({
  onBegin,
  onInstantDownload,
  dobValue = "",
  onDobChange,
  onEnterDob,
}) {
  const [sampleTab, setSampleTab] = React.useState("enneagram");
  return (
    <div style={{ borderBottom: `1px solid ${SCI.border}` }}>
      {/* top meta strip */}
      <div
        style={{
          display: "flex",
          justifyContent: "space-between",
          padding: "8px 28px",
          fontFamily: SCI.mono,
          fontSize: 10,
          color: SCI.ink2,
          borderBottom: `1px solid ${SCI.tint}`,
        }}
      >
        <span>{SCI_IS_AMARA ? "AMARA · ATLASES" : (SCI_IS_SENSEI ? "魂 · AMARA · GUIDANCE" : "魂 · AMARA · SOUL")}</span>
        <span>EST. 2026 · N = 184,212 READINGS · {SCI_COPY.brandName}</span>
        <span>{(() => { const d = new Date(); const mo = ["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"][d.getMonth()]; return `${String(d.getDate()).padStart(2,"0")}.${mo}.${d.getFullYear()}`; })()}</span>
      </div>

      <div
        id="section-home"
        style={{
          display: "grid",
          gridTemplateColumns: "1.15fr 1fr",
          minHeight: 560,
        }}
      >
        {/* Left: headline */}
        <div
          style={{
            padding: "56px 56px 40px",
            borderRight: `1px solid ${SCI.border}`,
            display: "flex",
            flexDirection: "column",
            justifyContent: "space-between",
          }}
        >
          <div>
            <MonoLabel>{SCI_COPY.heroKicker}</MonoLabel>
            <h1
              style={{
                fontFamily: SCI.display,
                fontWeight: 500,
                fontSize: 88,
                lineHeight: 0.92,
                letterSpacing: -1.5,
                margin: "18px 0 0",
                whiteSpace: SCI_IS_SENSEI ? "pre-line" : "normal",
              }}
            >
              {SCI_COPY.heroTitle}
            </h1>
            <div
              style={{
                maxWidth: 460,
                marginTop: 22,
                fontSize: 16,
                lineHeight: 1.55,
                color: SCI.ink2,
              }}
            >
              {SCI_COPY.heroBody}
            </div>
          </div>

          <div style={{ marginTop: 32 }}>
            <div
              style={{
                display: "flex",
                alignItems: "center",
                gap: 14,
                marginBottom: 14,
              }}
            >
              <div
                style={{
                  flex: 1,
                  maxWidth: 360,
                  height: 52,
                  border: `1px solid ${SCI.border}`,
                  display: "flex",
                  alignItems: "center",
                  padding: "0 16px",
                  background: SCI.paper,
                }}
              >
                <MonoLabel style={{ marginRight: 12 }}>DOB</MonoLabel>
                <input
                  value={dobValue}
                  onChange={(e) => onDobChange && onDobChange(e.target.value)}
                  onKeyDown={(e) => {
                    if (e.key === "Enter" && onEnterDob) onEnterDob();
                  }}
                  placeholder="Your Birthday · MM / DD / YYYY"
                  style={{
                    border: "none",
                    background: "none",
                    outline: "none",
                    flex: 1,
                    fontFamily: SCI.mono,
                    fontSize: 14,
                    color: SCI.ink,
                  }}
                />
                <button
                  type="button"
                  onClick={onEnterDob || onBegin}
                  style={{
                    color: SCI.ink3,
                    fontFamily: SCI.mono,
                    fontSize: 11,
                    border: "none",
                    background: "none",
                    padding: 0,
                    cursor: "pointer",
                  }}
                >
                  ↵
                </button>
              </div>
              <SciBtn
                primary
                size="lg"
                icon="→"
                onClick={onBegin}
                style={{ background: SCI.orange, borderColor: SCI.orange }}
              >
                {SCI_COPY.heroPrimaryCta}
              </SciBtn>
              {SCI_IS_SENSEI ? (
                <SciBtn size="lg" onClick={onInstantDownload || onBegin}>
                  {SCI_COPY.heroSecondaryCta}
                </SciBtn>
              ) : null}
            </div>
            <div
              style={{
                display: "flex",
                gap: 18,
                fontFamily: SCI.mono,
                fontSize: 10,
                color: SCI.ink3,
                letterSpacing: 0.5,
              }}
            >
              <span>— FREE PREVIEW</span>
              <span>— NO SIGNUP</span>
              <span>— {SCI_IS_AMARA ? "$129" : "$49"} ONCE · YOURS FOREVER</span>
            </div>
            <div
              style={{
                marginTop: 10,
                fontFamily: SCI.mono,
                fontSize: 10,
                color: SCI.ink3,
                letterSpacing: 0.3,
              }}
            >
              {SCI_COPY.disclaimer}
            </div>
          </div>
        </div>

        {/* Right: live data panel */}
        <div
          style={{
            padding: 0,
            display: "grid",
            gridTemplateRows: "auto 1fr auto",
          }}
        >
          {/* Top strip */}
          <div
            style={{
              padding: "14px 24px",
              borderBottom: `1px solid ${SCI.border}`,
              display: "flex",
              justifyContent: "space-between",
              alignItems: "center",
            }}
          >
            <MonoLabel>Live: sample subject · J.D. · ♀ · 1994</MonoLabel>
            <div style={{ display: "flex", gap: 6 }}>
              {[
                { key: "bigfive", label: "Big Five" },
                { key: "mbti", label: "MBTI" },
                { key: "enneagram", label: "Enneagram" },
              ].map((t) => (
                <button
                  key={t.key}
                  onClick={() => setSampleTab(t.key)}
                  style={{
                    padding: "4px 12px",
                    border: `1px solid ${SCI.border}`,
                    background: sampleTab === t.key ? SCI.ink : "transparent",
                    color: sampleTab === t.key ? SCI.paper : SCI.ink,
                    fontFamily: SCI.mono,
                    fontSize: 10,
                    letterSpacing: 0.8,
                    textTransform: "uppercase",
                    cursor: "pointer",
                  }}
                >
                  {t.label}
                </button>
              ))}
            </div>
          </div>

          {/* Main viz — tab-switched */}
          <div style={{ flex: 1, minHeight: 0 }}>
            {sampleTab === "enneagram" && (
              <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", height: "100%" }}>
                <div style={{ padding: 24, borderRight: `1px solid ${SCI.tint}`, display: "flex", flexDirection: "column" }}>
                  <MonoLabel style={{ marginBottom: 6 }}>Enneagram profile</MonoLabel>
                  <div style={{ fontFamily: SCI.display, fontSize: 36, lineHeight: 1, margin: "2px 0 4px" }}>
                    Type 8<span style={{ color: SCI.orange }}>.</span>
                  </div>
                  <div style={{ fontFamily: SCI.mono, fontSize: 10, color: SCI.ink3, marginBottom: 10 }}>
                    8w7 · Sp/Sx · Triad: Gut
                  </div>
                  <div style={{ flex: 1, minHeight: 0 }}>
                    <EnneaRadar values={[0.42, 0.38, 0.48, 0.55, 0.62, 0.58, 0.72, 0.95, 0.61]} />
                  </div>
                </div>
                <div style={{ padding: 24, display: "flex", flexDirection: "column" }}>
                  <MonoLabel style={{ marginBottom: 8 }}>Big Five · percentile</MonoLabel>
                  <BigFiveBars values={[88, 72, 41, 63, 22]} />
                  <div style={{ marginTop: 14 }}>
                    <MonoLabel style={{ marginBottom: 6 }}>MBTI cognitive stack</MonoLabel>
                    <MBTIStack />
                  </div>
                </div>
              </div>
            )}
            {sampleTab === "bigfive" && (
              <div style={{ padding: 24 }}>
                <MonoLabel style={{ marginBottom: 12 }}>Big Five (OCEAN) · percentile scores</MonoLabel>
                <div style={{ fontFamily: SCI.display, fontSize: 28, lineHeight: 1, margin: "4px 0 16px" }}>
                  High <span style={{ color: SCI.orange }}>O</span> · High <span style={{ color: SCI.orange }}>C</span>
                </div>
                <BigFiveBars values={[88, 72, 41, 63, 22]} animated />
                <div style={{ marginTop: 20, display: "grid", gridTemplateColumns: "1fr 1fr", gap: 10 }}>
                  {[
                    { trait: "Openness", pct: 88, note: "Highly creative, curious, intellectually driven" },
                    { trait: "Conscientiousness", pct: 72, note: "Organized and goal-directed" },
                    { trait: "Extraversion", pct: 41, note: "Moderate — selective social energy" },
                    { trait: "Agreeableness", pct: 63, note: "Warm but direct" },
                    { trait: "Neuroticism", pct: 22, note: "Emotionally stable under pressure" },
                  ].map((r) => (
                    <div key={r.trait} style={{ padding: "10px 12px", border: `1px solid ${SCI.tint}`, fontSize: 11, lineHeight: 1.5 }}>
                      <span style={{ fontFamily: SCI.mono, fontSize: 9, display: "block", color: SCI.ink3, textTransform: "uppercase", letterSpacing: 0.8 }}>{r.trait} · {r.pct}th pct</span>
                      {r.note}
                    </div>
                  ))}
                </div>
              </div>
            )}
            {sampleTab === "mbti" && (
              <div style={{ padding: 24 }}>
                <MonoLabel style={{ marginBottom: 12 }}>MBTI cognitive stack</MonoLabel>
                <div style={{ fontFamily: SCI.display, fontSize: 36, lineHeight: 1, margin: "4px 0 4px" }}>
                  INTJ<span style={{ color: SCI.orange }}>.</span>
                </div>
                <div style={{ fontFamily: SCI.mono, fontSize: 10, color: SCI.ink3, marginBottom: 18 }}>
                  Ni · Te · Fi · Se · The Architect
                </div>
                <MBTIStack animated />
                <div style={{ marginTop: 20, display: "grid", gridTemplateColumns: "1fr 1fr", gap: 10 }}>
                  {[
                    { fn: "Ni", label: "Introverted Intuition", role: "Dominant", note: "Long-range pattern recognition; sees the inevitable outcome." },
                    { fn: "Te", label: "Extraverted Thinking", role: "Auxiliary", note: "Externalizes structure; builds efficient, logical systems." },
                    { fn: "Fi", label: "Introverted Feeling", role: "Tertiary", note: "Deep personal values; quiet moral compass." },
                    { fn: "Se", label: "Extraverted Sensing", role: "Inferior", note: "Present-moment data; often underdeveloped." },
                  ].map((r) => (
                    <div key={r.fn} style={{ padding: "10px 12px", border: `1px solid ${SCI.tint}`, fontSize: 11, lineHeight: 1.5 }}>
                      <span style={{ fontFamily: SCI.mono, fontSize: 9, display: "block", color: SCI.orange, textTransform: "uppercase", letterSpacing: 0.8, marginBottom: 2 }}>{r.fn} · {r.role}</span>
                      <span style={{ fontFamily: SCI.mono, fontSize: 9, display: "block", color: SCI.ink3, marginBottom: 4 }}>{r.label}</span>
                      {r.note}
                    </div>
                  ))}
                </div>
              </div>
            )}
          </div>

          {/* Bottom metric strip — animated on mount */}
          <MetricStrip />
        </div>
      </div>
    </div>
  );
}

// —— SECTION: Credibility strip —————————————
function SciLogoStrip() {
  const logos = [
    { n: "WIRED", f: SCI.display, s: 22 },
    { n: "The Atlantic", f: SCI.display, s: 20, italic: true },
    { n: "NYT", f: SCI.display, s: 26, bold: true },
    { n: "Nautilus", f: SCI.body, s: 20 },
    { n: "VOX", f: SCI.body, s: 24, bold: true },
    { n: "Scientific American", f: SCI.display, s: 16 },
  ];
  const loop = [...logos, ...logos];
  return (
    <div
      style={{
        padding: "26px 28px",
        borderBottom: `1px solid ${SCI.border}`,
        display: "flex",
        alignItems: "center",
        gap: 48,
      }}
    >
      <MonoLabel size={10} style={{ whiteSpace: "nowrap" }}>
        As featured in —
      </MonoLabel>
      <div className="sci-marquee" style={{ flex: 1, opacity: 0.85 }}>
        <div className="sci-marquee-track">
          {loop.map((l, i) => (
            <span
              key={i}
              style={{
                fontFamily: l.f,
                fontSize: l.s,
                color: SCI.ink,
                fontWeight: l.bold ? 700 : 400,
                fontStyle: l.italic ? "italic" : "normal",
                letterSpacing: l.f === SCI.body ? "0.12em" : "-0.01em",
                whiteSpace: "nowrap",
              }}
            >
              {l.n}
            </span>
          ))}
        </div>
      </div>
    </div>
  );
}

function SciInstantDownloads({ onInstantDownload }) {
  const products = [
    {
      title: "Daily Archetype Forecast",
      format: "PDF + Mobile Cards",
      desc: "A ready-to-use daily guidance deck with no onboarding required — guidance for every day.",
      price: "$19",
    },
    {
      title: "30-Day Ritual Calendar",
      format: "Print + Wallpaper",
      desc: "A done-for-you monthly rhythm system for focus, recovery, and momentum.",
      price: "$24",
    },
    {
      title: "Relationship Energy",
      format: "Quick Reference PDF",
      desc: "Fast read on attachment patterns, conflict rhythm, and repair language.",
      price: "$17",
    },
  ];
  return (
    <div
      id="section-downloads"
      style={{ borderBottom: `1px solid ${SCI.border}`, background: SCI.tint2 }}
    >
      <div style={{ padding: "48px 56px 18px" }}>
        <MonoLabel>§ 02 · Instant Downloads</MonoLabel>
        <h2
          style={{
            fontFamily: SCI.display,
            fontSize: 52,
            lineHeight: 0.95,
            margin: "10px 0 0",
            letterSpacing: -0.7,
            fontWeight: 500,
          }}
        >
          Download now. Use today.
        </h2>
      </div>
      <div
        style={{
          display: "grid",
          gridTemplateColumns: "repeat(3, minmax(0,1fr))",
          gap: 0,
          borderTop: `1px solid ${SCI.border}`,
        }}
      >
        {products.map((product, index) => (
          <div
            key={product.title}
            style={{
              padding: "24px 22px",
              borderRight: index < 2 ? `1px solid ${SCI.border}` : "none",
              background: SCI.paper,
            }}
          >
            <MonoLabel size={9}>{product.format}</MonoLabel>
            <div
              style={{
                marginTop: 8,
                fontFamily: SCI.display,
                fontSize: 30,
                lineHeight: 1.05,
                letterSpacing: -0.3,
              }}
            >
              {product.title}
            </div>
            <div style={{ marginTop: 10, fontSize: 14, lineHeight: 1.5, color: SCI.ink2 }}>
              {product.desc}
            </div>
            <div
              style={{
                marginTop: 16,
                display: "flex",
                justifyContent: "space-between",
                alignItems: "center",
              }}
            >
              <span style={{ fontFamily: SCI.display, fontSize: 32 }}>{product.price}</span>
              <SciBtn primary size="sm" icon="→" onClick={onInstantDownload}>
                Buy now
              </SciBtn>
            </div>
          </div>
        ))}
      </div>
      <div
        style={{
          padding: "14px 56px",
          borderTop: `1px solid ${SCI.border}`,
          fontFamily: SCI.mono,
          fontSize: 10,
          color: SCI.ink3,
          letterSpacing: 0.5,
        }}
      >
        Guidance Not Medical: all products are reflective tools and educational material.
      </div>
    </div>
  );
}

// —— SECTION: Methodology (3 steps) —————————
function SciMethod() {
  const steps = [
    {
      n: "01",
      title: "Tell Us About You",
      kicker: "Your birthday, your name, your place",
      body: "Your birth date, time, and city. Then a short personality read — the same kind psychologists use, not a quiz. Takes about twenty minutes.",
      meta: [
        ["Questions", "120"],
        ["Time", "~20 min"],
        ["Accuracy", "IRT-scaled"],
      ],
    },
    {
      n: "02",
      title: (SCI_IS_AMARA ? "The Atlas" : "Twelve Ways In"),
      kicker: "The ancient and the modern",
      body: "Each of the eight traditions reads you on its own. Then we find where they all say the same thing. That's where it gets interesting.",
      meta: [
        ["Systems", "10"],
        ["Cross-checks", "48"],
        ["Agreement score", "0–1.0"],
      ],
    },
    {
      n: "03",
      title: "You Get Your Chart",
      kicker: "Written for you, not about you",
      body: "Not bullet points. Not a horoscope. A long read — your personality, your career, your energy, your edges — written like a letter from someone who knows you.",
      meta: [
        ["Sections", "12"],
        ["Length", "~8,000 words"],
        ["Audio", "38 min"],
      ],
    },
  ];
  return (
    <div
      id="section-methodology"
      style={{ borderBottom: `1px solid ${SCI.border}` }}
    >
      <div
        style={{
          padding: "56px 56px 24px",
          display: "grid",
          gridTemplateColumns: "1fr 2fr",
          alignItems: "end",
          gap: 40,
        }}
      >
        <div>
          <MonoLabel>§ 02 · Method</MonoLabel>
          <h2
            style={{
              fontFamily: SCI.display,
              fontSize: 54,
              lineHeight: 0.95,
              margin: "10px 0 0",
              letterSpacing: -0.8,
              fontWeight: 500,
            }}
          >
            How it{" "}
            <span style={{ fontStyle: "italic" }}>works.</span>
          </h2>
        </div>
        <div
          style={{
            fontSize: 15,
            lineHeight: 1.6,
            color: SCI.ink2,
            maxWidth: 560,
          }}
        >
          No single system tells the whole story. Astrology knows your sky. Psychology knows your patterns. Together, they get close — and where they agree on you is where it gets interesting.
        </div>
      </div>
      <div
        style={{
          display: "grid",
          gridTemplateColumns: "repeat(3,1fr)",
          borderTop: `1px solid ${SCI.border}`,
        }}
      >
        {steps.map((s, i) => (
          <div
            key={i}
            className="sci-card-hover"
            style={{
              padding: "32px 28px 36px",
              borderRight: i < 2 ? `1px solid ${SCI.border}` : "none",
            }}
          >
            <div
              style={{
                display: "flex",
                justifyContent: "space-between",
                alignItems: "baseline",
                marginBottom: 16,
              }}
            >
              <div
                style={{
                  fontFamily: SCI.display,
                  fontSize: 52,
                  lineHeight: 1,
                  color: i === 1 ? SCI.orange : SCI.ink,
                }}
              >
                {s.n}
              </div>
              <MonoLabel>{s.kicker}</MonoLabel>
            </div>
            <div
              style={{
                fontFamily: SCI.display,
                fontSize: 26,
                lineHeight: 1.1,
                margin: "0 0 10px",
              }}
            >
              {s.title}
            </div>
            <div
              style={{
                fontSize: 14,
                lineHeight: 1.55,
                color: SCI.ink2,
                marginBottom: 20,
              }}
            >
              {s.body}
            </div>
            <div style={{ borderTop: `1px solid ${SCI.tint}` }}>
              {s.meta.map(([k, v], j) => (
                <div
                  key={j}
                  style={{
                    display: "flex",
                    justifyContent: "space-between",
                    padding: "8px 0",
                    borderBottom: `1px solid ${SCI.tint}`,
                    fontFamily: SCI.mono,
                    fontSize: 11,
                  }}
                >
                  <span
                    style={{
                      color: SCI.ink3,
                      textTransform: "uppercase",
                      letterSpacing: 0.5,
                      fontSize: 10,
                    }}
                  >
                    {k}
                  </span>
                  <span>{v}</span>
                </div>
              ))}
            </div>
          </div>
        ))}
      </div>
    </div>
  );
}

// —— SECTION: Instruments grid ——————————————
function InstrumentIcon({ kind }) {
  const s = { width: "100%", aspectRatio: "1/1" };

  /* ── BIG FIVE — bars breathe independently, each a different rhythm ── */
  if (kind === "bigfive") {
    const widths = [0.88, 0.72, 0.41, 0.63, 0.22];
    const durations = [2.1, 2.7, 3.3, 2.4, 3.8];
    const delays = [0, 0.6, 1.3, 0.3, 1.8];
    return (
      <svg viewBox="0 0 60 60" style={s}>
        {[0, 1, 2, 3, 4].map((i) => (
          <g key={i}>
            <rect x="8" y={8 + i * 9} width="44" height="5" fill={SCI.tint} rx="1" />
            <rect
              x="8" y={8 + i * 9}
              width={44 * widths[i]} height="5" rx="1"
              fill={i === 2 ? SCI.orange : SCI.ink}
              style={{
                animation: `sci-bar-breathe ${durations[i]}s ease-in-out ${delays[i]}s infinite`,
                transformBox: "fill-box",
                transformOrigin: "left center",
              }}
            />
          </g>
        ))}
      </svg>
    );
  }

  /* ── MBTI — 4 columns fill up from the bottom in a rolling wave ── */
  if (kind === "mbti") {
    const letters = ["I", "N", "T", "J"];
    const heights = [38, 28, 34, 20];
    return (
      <svg viewBox="0 0 60 60" style={s}>
        {letters.map((c, i) => {
          const x = 6 + i * 13;
          const h = heights[i];
          return (
            <g key={i}>
              <rect x={x} y="8" width="10" height="44" fill={SCI.tint} rx="1" />
              <rect
                x={x} y={52 - h} width="10" height={h} rx="1"
                fill={i === 1 ? SCI.orange : SCI.ink}
                style={{
                  animation: `sci-col-wave 3s ease-in-out ${i * 0.55}s infinite`,
                  transformBox: "fill-box",
                  transformOrigin: "center bottom",
                }}
              />
              <text x={x + 5} y="57" fontFamily={SCI.mono} fontSize="7" textAnchor="middle" fill={SCI.ink3}>{c}</text>
            </g>
          );
        })}
      </svg>
    );
  }

  /* ── ENNEAGRAM — 9 points ping clockwise in sequence ── */
  if (kind === "ennea") {
    const pts = Array.from({ length: 9 }, (_, i) => {
      const a = -Math.PI / 2 + (i * 2 * Math.PI) / 9;
      return { x: 30 + Math.cos(a) * 21, y: 30 + Math.sin(a) * 21, a };
    });
    /* inner enneagram lines: triangle 0-3-6 and hexagon 1-2-4-5-7-8 */
    const tri = [0, 3, 6].map(i => pts[i]);
    const hex = [1, 2, 4, 5, 7, 8].map(i => pts[i]);
    return (
      <svg viewBox="0 0 60 60" style={s}>
        <circle cx="30" cy="30" r="21" fill="none" stroke={SCI.ink} strokeWidth="0.8" />
        <polygon
          points={tri.map(p => `${p.x},${p.y}`).join(" ")}
          fill="none" stroke={SCI.ink2} strokeWidth="0.6"
        />
        <polygon
          points={hex.map(p => `${p.x},${p.y}`).join(" ")}
          fill="none" stroke={SCI.ink2} strokeWidth="0.6"
        />
        {pts.map((p, i) => (
          <circle
            key={i} cx={p.x} cy={p.y}
            r={i === 8 ? 3 : 2}
            fill={i === 8 ? SCI.orange : SCI.ink}
            style={{
              animation: `sci-ping 4.5s ease-in-out ${i * 0.5}s infinite`,
              transformBox: "fill-box",
              transformOrigin: "center",
            }}
          />
        ))}
      </svg>
    );
  }

  /* ── HUMAN DESIGN — energy pulses down through the body-graph channels ── */
  if (kind === "hd") {
    const nodes = [[30,10],[30,28],[30,46],[14,28],[46,28]];
    const lines = [
      [0,1],[1,2],[1,3],[1,4],
    ];
    return (
      <svg viewBox="0 0 60 60" style={s}>
        {lines.map(([a, b], i) => (
          <line
            key={i}
            x1={nodes[a][0]} y1={nodes[a][1]}
            x2={nodes[b][0]} y2={nodes[b][1]}
            stroke={SCI.ink} strokeWidth="1.5"
            style={{ animation: `sci-signal 3s ease-in-out ${i * 0.7}s infinite` }}
          />
        ))}
        {nodes.map(([cx, cy], i) => (
          <circle
            key={i} cx={cx} cy={cy} r="5"
            fill={i === 0 ? SCI.orange : i % 2 === 0 ? SCI.ink : "none"}
            stroke={SCI.ink} strokeWidth="1"
            style={{ animation: `sci-pulse ${2.2 + i * 0.3}s ease-in-out ${i * 0.4}s infinite` }}
          />
        ))}
      </svg>
    );
  }

  /* ── WESTERN ASTROLOGY — three planets orbit at different speeds ── */
  if (kind === "astro") {
    const planets = [
      { r: 21, speed: "20s", size: 2.2, color: SCI.orange, phase: 0 },
      { r: 15, speed: "13s", size: 1.6, color: SCI.ink, phase: 2.1 },
      { r: 9,  speed: "7s",  size: 1.2, color: SCI.ink2, phase: 4.4 },
    ];
    return (
      <svg viewBox="0 0 60 60" style={s} overflow="hidden">
        {/* Zodiac wheel: outer ring with 12 tick marks */}
        <circle cx="30" cy="30" r="21" fill="none" stroke={SCI.ink} strokeWidth="0.8"
          style={{ animation: "sci-spin-slow 80s linear infinite", transformOrigin: "30px 30px" }}
        />
        {Array.from({ length: 12 }, (_, i) => {
          const a = (i * Math.PI) / 6;
          return (
            <line key={i}
              x1={30 + Math.cos(a) * 17} y1={30 + Math.sin(a) * 17}
              x2={30 + Math.cos(a) * 21} y2={30 + Math.sin(a) * 21}
              stroke={SCI.ink} strokeWidth="0.6"
            />
          );
        })}
        {/* Orbital rings */}
        {planets.map((p, i) => (
          <circle key={`ring-${i}`} cx="30" cy="30" r={p.r}
            fill="none" stroke={SCI.border} strokeWidth="0.4" strokeDasharray="1 3"
          />
        ))}
        {/* Orbiting planet dots */}
        {planets.map((p, i) => (
          <circle
            key={`planet-${i}`}
            cx={30 + p.r} cy="30" r={p.size}
            fill={p.color}
            style={{
              animation: `sci-spin-${i % 2 === 0 ? "slow" : "rev"} ${p.speed} linear infinite`,
              transformOrigin: "30px 30px",
              animationDelay: `${-p.phase}s`,
            }}
          />
        ))}
        <circle cx="30" cy="30" r="2" fill={SCI.ink} />
      </svg>
    );
  }

  /* ── NUMEROLOGY — satellite master numbers appear in sequence like a sum ── */
  if (kind === "num") {
    const satellites = [
      { x: 10, y: 18, n: "3",  delay: 0 },
      { x: 48, y: 18, n: "11", delay: 1.4 },
      { x: 10, y: 52, n: "22", delay: 2.8 },
      { x: 48, y: 52, n: "7",  delay: 4.2 },
    ];
    return (
      <svg viewBox="0 0 60 60" style={s}>
        <text x="30" y="41" fontFamily={SCI.display} fontSize="36" textAnchor="middle" fill={SCI.ink}
          style={{ animation: "sci-pulse 5.6s ease-in-out infinite" }}>7</text>
        {satellites.map((sat, i) => (
          <text key={i} x={sat.x} y={sat.y}
            fontFamily={SCI.mono} fontSize="8" textAnchor="middle"
            fill={i === 1 ? SCI.orange : SCI.ink2}
            style={{ animation: `sci-num-appear 5.6s ease-in-out ${sat.delay}s infinite` }}
          >{sat.n}</text>
        ))}
        {/* connecting lines */}
        {[[10,18],[48,18],[10,50],[48,50]].map(([x,y], i) => (
          <line key={i} x1="30" y1="35" x2={x} y2={y}
            stroke={SCI.border} strokeWidth="0.4" strokeDasharray="2 2"
            style={{ animation: `sci-num-appear 5.6s ease-in-out ${satellites[i].delay}s infinite` }}
          />
        ))}
      </svg>
    );
  }

  /* ── ASTROCARTOGRAPHY — meridian line draws itself over the map ── */
  if (kind === "carto") {
    return (
      <svg viewBox="0 0 60 60" style={s}>
        {/* latitude curves */}
        {[22, 30, 38].map((cy, i) => (
          <path key={i}
            d={`M8,${cy} Q22,${cy - 5 + i * 3} 36,${cy} T58,${cy + 2}`}
            fill="none" stroke={SCI.ink2} strokeWidth="0.6"
          />
        ))}
        {/* ghost meridian */}
        <line x1="38" y1="6" x2="35" y2="54" stroke={SCI.border} strokeWidth="0.8" strokeDasharray="2 3" />
        {/* animated orange meridian draws itself */}
        <line
          x1="20" y1="6" x2="23" y2="54"
          stroke={SCI.orange} strokeWidth="1.2"
          strokeDasharray="52" strokeDashoffset="52"
          style={{ animation: "sci-carto-draw 2.4s ease-in-out infinite alternate" }}
        />
        {/* location pin pulsing */}
        <circle cx="22" cy="30" r="2.5" fill={SCI.orange}
          style={{ animation: "sci-breathe 2.4s ease-in-out infinite", transformBox: "fill-box", transformOrigin: "center" }}
        />
      </svg>
    );
  }

  /* ── I CHING — lines flip between broken and solid like coin tosses ── */
  if (kind === "iching") {
    /* two hexagrams: original + transformed */
    const brokenA = [true, false, true, false, false, true];
    const brokenB = [false, true, false, true, true, false];
    return (
      <svg viewBox="0 0 60 60" style={s}>
        {[0, 1, 2, 3, 4, 5].map((i) => {
          const y = 9 + i * 7;
          const delay = i * 0.45;
          return (
            <g key={i}>
              {/* state A */}
              <g style={{ animation: `sci-iching-flip 5.4s ease-in-out ${delay}s infinite` }}>
                {brokenA[i] ? (
                  <>
                    <rect x="8" y={y} width="18" height="3" fill={SCI.ink} rx="0.5" />
                    <rect x="34" y={y} width="18" height="3" fill={SCI.ink} rx="0.5" />
                  </>
                ) : (
                  <rect x="8" y={y} width="44" height="3" fill={SCI.ink} rx="0.5" />
                )}
              </g>
              {/* state B (inverted opacity) */}
              <g style={{ animation: `sci-iching-flip 5.4s ease-in-out ${delay + 2.7}s infinite` }}>
                {brokenB[i] ? (
                  <>
                    <rect x="8" y={y} width="18" height="3" fill={SCI.orange} rx="0.5" />
                    <rect x="34" y={y} width="18" height="3" fill={SCI.orange} rx="0.5" />
                  </>
                ) : (
                  <rect x="8" y={y} width="44" height="3" fill={SCI.orange} rx="0.5" />
                )}
              </g>
            </g>
          );
        })}
      </svg>
    );
  }

  /* ── GENE KEYS — 8 squares orbit; the light travels between them ── */
  if (kind === "genes") {
    return (
      <svg viewBox="0 0 60 60" style={s} overflow="hidden">
        <g style={{ animation: "sci-spin-slow 22s linear infinite", transformOrigin: "30px 30px" }}>
          {Array.from({ length: 8 }, (_, i) => {
            const cx = 30 + Math.cos((i * Math.PI) / 4) * 14 - 4;
            const cy = 30 + Math.sin((i * Math.PI) / 4) * 14 - 4;
            return (
              <g key={i} transform={`translate(${cx},${cy})`}>
                <rect width="8" height="8" fill="none" stroke={SCI.ink} strokeWidth="0.8" rx="0.5" />
                <rect width="8" height="8" fill={SCI.orange} rx="0.5"
                  style={{ animation: `sci-genes-glow 8s ease-in-out ${i * 1}s infinite` }}
                />
              </g>
            );
          })}
          <circle cx="30" cy="30" r="3.5" fill={SCI.ink} />
          <circle cx="30" cy="30" r="1.5" fill={SCI.paper} />
        </g>
      </svg>
    );
  }

  /* ── CHINESE ASTROLOGY — yin-yang spins; dots pulse opposite-phase ── */
  if (kind === "chinese") {
    return (
      <svg viewBox="0 0 60 60" style={s}>
        <g style={{ animation: "sci-taiji 16s linear infinite", transformOrigin: "30px 30px" }}>
          <circle cx="30" cy="30" r="22" fill="none" stroke={SCI.ink} strokeWidth="0.8" />
          <path d="M30,8 A22,22 0 0,1 30,52 A11,11 0 0,1 30,30 A11,11 0 0,0 30,8" fill={SCI.ink} />
          <circle cx="30" cy="19" r="2" fill={SCI.paper}
            style={{ animation: "sci-yin-ping 3s ease-in-out infinite" }}
          />
          <circle cx="30" cy="41" r="2" fill={SCI.ink}
            style={{ animation: "sci-yang-ping 3s ease-in-out infinite" }}
          />
        </g>
      </svg>
    );
  }

  /* ── LIFE PATH — number beats like a heart; wave path undulates ── */
  if (kind === "lifepath") {
    return (
      <svg viewBox="0 0 60 60" style={s}>
        <text x="30" y="41" fontFamily={SCI.display} fontSize="42" textAnchor="middle"
          fill={SCI.orange} fontStyle="italic"
          style={{ animation: "sci-heartbeat 2.8s ease-in-out infinite", transformBox: "fill-box", transformOrigin: "center" }}
        >3</text>
        <line x1="6" y1="52" x2="54" y2="52" stroke={SCI.border} strokeWidth="0.8" />
        <path d="M6,52 Q14,46 22,52 T38,52 T54,52" fill="none" stroke={SCI.ink2} strokeWidth="0.8"
          style={{ animation: "sci-dash 1.4s linear infinite" }}
          strokeDasharray="4 4"
        />
      </svg>
    );
  }

  /* ── VEDIC ASTROLOGY — outer square rotates, inner counter-rotates, center breathes ── */
  if (kind === "vedic") {
    return (
      <svg viewBox="0 0 60 60" style={s} overflow="hidden">
        {/* outer square rotates */}
        <g style={{ animation: "sci-spin-slow 28s linear infinite", transformOrigin: "30px 30px" }}>
          <rect x="11" y="11" width="38" height="38" fill="none" stroke={SCI.ink} strokeWidth="0.8" rx="1" />
          <line x1="11" y1="11" x2="30" y2="30" stroke={SCI.ink2} strokeWidth="0.5" />
          <line x1="49" y1="11" x2="30" y2="30" stroke={SCI.ink2} strokeWidth="0.5" />
          <line x1="49" y1="49" x2="30" y2="30" stroke={SCI.ink2} strokeWidth="0.5" />
          <line x1="11" y1="49" x2="30" y2="30" stroke={SCI.ink2} strokeWidth="0.5" />
        </g>
        {/* inner square counter-rotates */}
        <g style={{ animation: "sci-spin-rev 18s linear infinite", transformOrigin: "30px 30px" }}>
          <rect x="20" y="20" width="20" height="20" fill="none" stroke={SCI.ink} strokeWidth="0.8" rx="1" />
        </g>
        {/* center dot breathes */}
        <circle cx="30" cy="30" r="3" fill="none" stroke={SCI.orange} strokeWidth="1"
          style={{ animation: "sci-breathe 3s ease-in-out infinite", transformBox: "fill-box", transformOrigin: "center" }}
        />
        <circle cx="30" cy="30" r="1.5" fill={SCI.orange} />
      </svg>
    );
  }

  // ── Amara-only icons (added for the 7 traditions the original 12 didn't cover) ──
  if (kind === "egpt") {
    return (
      <svg viewBox="0 0 60 60" style={s} overflow="hidden">
        {/* Egyptian decans — horizontal stripes with one accent (the "ascendant face") */}
        {[14, 22, 30, 38, 46].map((y, i) => (
          <rect key={i} x="10" y={y} width="40" height="2.4" fill={i === 2 ? SCI.orange : SCI.ink} rx="0.5"
            style={{ animation: `sci-pulse-fade 4s ease-in-out infinite ${i * 0.15}s` }} />
        ))}
        <circle cx="30" cy="30" r="2" fill={SCI.orange}
          style={{ animation: "sci-breathe 3s ease-in-out infinite", transformBox: "fill-box", transformOrigin: "center" }} />
      </svg>
    );
  }
  if (kind === "ifa") {
    return (
      <svg viewBox="0 0 60 60" style={s} overflow="hidden">
        {/* Yoruba Ifá — 8 cowrie shells in 2 rows of 4 */}
        {Array.from({ length: 8 }).map((_, i) => {
          const x = 12 + (i % 4) * 12;
          const y = 18 + Math.floor(i / 4) * 16;
          const open = [1, 3, 4, 6].includes(i);
          return (
            <ellipse key={i} cx={x + 4} cy={y + 4} rx="3.4" ry="2.4"
              fill={open ? "none" : SCI.ink} stroke={SCI.ink} strokeWidth="0.8"
              style={{ animation: `sci-pulse-fade 5s ease-in-out infinite ${i * 0.12}s` }} />
          );
        })}
        <circle cx="50" cy="50" r="2" fill={SCI.orange} />
      </svg>
    );
  }
  if (kind === "maya") {
    return (
      <svg viewBox="0 0 60 60" style={s} overflow="hidden">
        {/* Mayan Tzolkin — bar/dot numerals */}
        <rect x="14" y="16" width="32" height="3" fill={SCI.ink} />
        <rect x="14" y="24" width="32" height="3" fill={SCI.ink} />
        {[0, 1, 2].map(i => (
          <circle key={i} cx={20 + i * 10} cy="36" r="2.6" fill={i === 1 ? SCI.orange : SCI.ink}
            style={i === 1 ? { animation: "sci-breathe 3s ease-in-out infinite", transformBox: "fill-box", transformOrigin: "center" } : undefined} />
        ))}
        <rect x="14" y="44" width="32" height="3" fill={SCI.ink} />
      </svg>
    );
  }
  if (kind === "tibet") {
    return (
      <svg viewBox="0 0 60 60" style={s} overflow="hidden">
        {/* Tibetan elemental — five concentric rings (earth, water, fire, wind, space) */}
        {[
          { y: 50, r: 18, c: SCI.ink },
          { y: 42, r: 14, c: SCI.ink },
          { y: 34, r: 11, c: SCI.orange },
          { y: 26, r: 8, c: SCI.ink },
          { y: 18, r: 5, c: SCI.ink },
        ].map((e, i) => (
          <circle key={i} cx="30" cy={e.y} r={e.r} fill="none" stroke={e.c}
            strokeWidth={i === 2 ? 1.4 : 0.8}
            style={{ animation: `sci-pulse-fade 5s ease-in-out infinite ${i * 0.15}s` }} />
        ))}
      </svg>
    );
  }
  if (kind === "norse") {
    return (
      <svg viewBox="0 0 60 60" style={s} overflow="hidden">
        {/* Norse runes — three Elder Futhark glyphs in a 3-rune cast */}
        <g stroke={SCI.ink} strokeWidth="1.4" fill="none">
          {/* Fehu */}
          <line x1="14" y1="14" x2="14" y2="46" />
          <line x1="14" y1="20" x2="22" y2="16" />
          <line x1="14" y1="28" x2="22" y2="24" />
          {/* Ansuz (centre — accent) */}
          <line x1="30" y1="14" x2="30" y2="46" stroke={SCI.orange}
            style={{ animation: "sci-breathe 3s ease-in-out infinite", transformBox: "fill-box", transformOrigin: "center" }} />
          <line x1="30" y1="22" x2="38" y2="18" stroke={SCI.orange} />
          <line x1="30" y1="30" x2="38" y2="26" stroke={SCI.orange} />
          {/* Laguz */}
          <line x1="46" y1="14" x2="46" y2="46" />
          <line x1="46" y1="38" x2="54" y2="42" />
        </g>
      </svg>
    );
  }
  if (kind === "celt") {
    return (
      <svg viewBox="0 0 60 60" style={s} overflow="hidden">
        {/* Celtic ogham — vertical staff with ticks */}
        <line x1="30" y1="8" x2="30" y2="52" stroke={SCI.ink} strokeWidth="1.2" />
        {[14, 20, 26, 32, 38, 44].map((y, i) => {
          const left = i % 2 === 0;
          return (
            <line key={i} x1={left ? 16 : 30} y1={y} x2={left ? 30 : 44} y2={y}
              stroke={i === 2 ? SCI.orange : SCI.ink} strokeWidth="1"
              style={{ animation: `sci-pulse-fade 4s ease-in-out infinite ${i * 0.12}s` }} />
          );
        })}
      </svg>
    );
  }
  if (kind === "wheel") {
    return (
      <svg viewBox="0 0 60 60" style={s} overflow="hidden">
        {/* Native medicine wheel — four-quadrant circle */}
        <circle cx="30" cy="30" r="22" fill="none" stroke={SCI.ink} strokeWidth="1.2" />
        <line x1="30" y1="8"  x2="30" y2="52" stroke={SCI.ink} strokeWidth="0.8" />
        <line x1="8"  y1="30" x2="52" y2="30" stroke={SCI.ink} strokeWidth="0.8" />
        {/* East quadrant gets the accent (Amara: where you face) */}
        <path d="M 30 8 A 22 22 0 0 1 52 30 L 30 30 Z" fill={SCI.orange} fillOpacity="0.18" stroke={SCI.orange} strokeWidth="0.8"
          style={{ animation: "sci-pulse-fade 4s ease-in-out infinite" }} />
        <circle cx="30" cy="30" r="1.8" fill={SCI.orange} />
      </svg>
    );
  }

  return null;
}

function SciInstruments() {
  const [filter, setFilter] = React.useState("all");
  const [revealed, setRevealed] = React.useState(false);
  const gridRef = React.useRef(null);

  React.useEffect(() => {
    if (!gridRef.current) return;
    const obs = new IntersectionObserver(
      ([e]) => { if (e.isIntersecting) { setRevealed(true); obs.disconnect(); } },
      { threshold: 0.1 }
    );
    obs.observe(gridRef.current);
    return () => obs.disconnect();
  }, []);

  const FILTERS = [
    { label: (SCI_IS_AMARA ? "All 8" : "All 12"), value: "all" },
    { label: "Psychometric", value: "Psychometric" },
    { label: "Typological", value: "Typological" },
    { label: "Synthetic", value: "Synthetic" },
    { label: "Archetypal", value: "Archetypal" },
  ];

  const items = SCI_IS_AMARA ? [
    { n: "Modern psychology",   k: "bigfive",  cat: "Empirical",   note: "Big Five · MBTI · Enneagram",         learn: "The traits at the 90th percentile, and what they cost you",   status: "3 readings" },
    { n: "Western astrology",   k: "astro",    cat: "Archetypal",  note: "Natal · houses · transits",            learn: "What your rising says about how strangers read you",         status: "5 readings" },
    { n: "Vedic Jyotish",       k: "vedic",    cat: "Archetypal",  note: "Dasha · nakshatra · D-charts",         learn: "The karmic line and the gift on its other side",             status: "5 readings" },
    { n: "Chinese systems",     k: "chinese",  cat: "Calendrical", note: "Four pillars · zodiac · I Ching",      learn: "How you operate in groups and under pressure",                status: "4 readings" },
    { n: "Mayan Tzolkin",       k: "maya",     cat: "Calendrical", note: "Day-sign · galactic tone",             learn: "The 260-day rhythm your life keeps falling into",            status: "3 readings" },
    { n: "Tibetan elemental",   k: "tibet",    cat: "Esoteric",    note: "Element · animal · life-force",        learn: "Where wind, fire, water, or earth doubles in you",            status: "3 readings" },
    { n: "Celtic tree",         k: "celt",     cat: "Lunar",       note: "Ogham · lunar tree calendar",          learn: "The tree of your birth-moon and what it shelters",            status: "3 readings" },
    { n: "Norse runes",         k: "norse",    cat: "Oracular",    note: "Elder Futhark · 3-rune cast",          learn: "The cast that keeps coming up for the question you carry",   status: "3 readings" },
    { n: "Egyptian decans",     k: "egpt",     cat: "Calendrical", note: "36 decans · ascendant face",           learn: "The face that rules the ten degrees of your rising",         status: "2 readings" },
    { n: "Yoruba Ifá",          k: "ifa",      cat: "Oral",        note: "Odu · 256 paths",                       learn: "The Odu that names your road and its proverb",               status: "3 readings" },
    { n: "Native medicine wheel", k: "wheel",  cat: "Oral",        note: "Direction · element · animal",         learn: "The direction you face and the totem that walks it",         status: "2 readings" },
    { n: "Kabbalah",            k: "kabb",     cat: "Esoteric",    note: "Tree of life · sephirot",              learn: "The sephira your year is teaching you to receive",           status: "1 reading"  },
    { n: "European folk",       k: "folk",     cat: "Oracular",    note: "Hex · birth-flower · saint",           learn: "The folk-saint and flower of the day you arrived",           status: "1 reading"  },
  ] : [
    {
      n: "Big Five (OCEAN)",
      k: "bigfive",
      cat: "Psychometric",
      note: "who you become under pressure",
      learn: "The 2 traits you're in the 90th percentile on — and what they cost you",
      status: "Primary",
    },
    {
      n: "MBTI / 16-Type",
      k: "mbti",
      cat: "Typological",
      note: "how your mind moves",
      learn: "Why certain kinds of work drain you and others don't",
      status: "Primary",
    },
    {
      n: "Enneagram",
      k: "ennea",
      cat: "Typological",
      note: "the fear that shapes you",
      learn: "The pattern you repeat in every relationship",
      status: "Primary",
    },
    {
      n: "Life Path",
      k: "lifepath",
      cat: "Archetypal",
      note: "the number you walk",
      learn: "The tension between what you're built for and what you keep choosing",
      status: "Primary",
    },
    {
      n: "Human Design",
      k: "hd",
      cat: "Synthetic",
      note: "the energy you're meant to run",
      learn: "Whether you're built to initiate — or wait and respond",
      status: "Included",
    },
    {
      n: "Numerology",
      k: "num",
      cat: "Archetypal",
      note: "the patterns in your name and date",
      learn: "The number that keeps showing up in how your life moves",
      status: "Included",
    },
    {
      n: "Western Astrology",
      k: "astro",
      cat: "Archetypal",
      note: "the sky you were born under",
      learn: "What your rising says about how strangers read you",
      status: "Included",
    },
    {
      n: "Vedic Astrology",
      k: "vedic",
      cat: "Archetypal",
      note: "the karma you carried in",
      learn: "The wound that keeps opening, and the gift on the other side of it",
      status: "Included",
    },
    {
      n: "Astrocartography",
      k: "carto",
      cat: "Archetypal",
      note: "where on earth you bloom",
      learn: "The city or region where your energy actually works with you",
      status: "Included",
    },
    {
      n: "Gene Keys",
      k: "genes",
      cat: "Archetypal",
      note: "the gift hiding in your shadow",
      learn: "What you keep calling a flaw that is actually your edge",
      status: "Included",
    },
    {
      n: "I Ching",
      k: "iching",
      cat: "Archetypal",
      note: "an old answer for a new question",
      learn: "The hexagram that describes where you are right now",
      status: "Included",
    },
    {
      n: "Chinese Astrology",
      k: "chinese",
      cat: "Archetypal",
      note: "the animal year that still moves you",
      learn: "Why you operate the way you do in groups and under pressure",
      status: "Included",
    },
  ];

  return (
    <div
      id="section-instruments"
      style={{ borderBottom: `1px solid ${SCI.border}`, background: SCI.paper }}
    >
      <div
        style={{
          padding: "56px 56px 18px",
          display: "flex",
          justifyContent: "space-between",
          alignItems: "end",
        }}
      >
        <div>
          <MonoLabel>§ 04 · {SCI_IS_AMARA ? "The Atlas" : "Twelve Ways In"}</MonoLabel>
          <h2
            style={{
              fontFamily: SCI.display,
              fontSize: 48,
              lineHeight: 0.95,
              margin: "10px 0 0",
              letterSpacing: -0.6,
              fontWeight: 500,
            }}
          >
            8 traditions, ~38 readings.<span style={{ color: SCI.orange }}> One answer.</span>
          </h2>
          <p style={{ marginTop: 16, fontSize: 15, color: SCI.ink2, lineHeight: 1.6, maxWidth: 520 }}>
            Each of these reads you on its own. The report only highlights what 7+ of them agree on. That's your signal. Everything else is noise.
          </p>
        </div>
        <div style={{ display: "flex", gap: 8 }}>
          {FILTERS.map((f) => (
            <button
              key={f.value}
              type="button"
              onClick={() => setFilter(f.value)}
              style={{
                display: "inline-flex",
                alignItems: "center",
                gap: 6,
                padding: "4px 10px",
                border: `1px solid ${SCI.border}`,
                background: filter === f.value ? SCI.ink : "transparent",
                color: filter === f.value ? SCI.paper : SCI.ink,
                fontFamily: SCI.mono,
                fontSize: 10,
                letterSpacing: 0.5,
                textTransform: "uppercase",
                cursor: "pointer",
                transition: "background 0.18s ease, color 0.18s ease",
              }}
            >
              {f.label}
            </button>
          ))}
        </div>
      </div>
      <div
        ref={gridRef}
        style={{
          display: "grid",
          gridTemplateColumns: "repeat(6,1fr)",
          borderTop: `1px solid ${SCI.border}`,
        }}
      >
        {items.map((it, i) => {
          const visible = filter === "all" || it.cat === filter;
          return (
            <div
              key={i}
              className="sci-card-hover"
              style={{
                padding: "22px 20px 20px",
                borderRight: i % 6 < 5 ? `1px solid ${SCI.border}` : "none",
                borderBottom: i < 6 ? `1px solid ${SCI.border}` : "none",
                display: "flex",
                flexDirection: "column",
                gap: 14,
                minHeight: 220,
                background: SCI.paper,
                opacity: !revealed ? 0 : visible ? 1 : 0.2,
                pointerEvents: visible ? "auto" : "none",
                transition: "opacity 0.25s ease, transform 0.25s ease",
                transform: !revealed ? "translateY(14px)" : "translateY(0)",
                animationDelay: revealed ? `${i * 60}ms` : "0ms",
              }}
            >
              <div
                style={{
                  display: "flex",
                  justifyContent: "space-between",
                  alignItems: "center",
                }}
              >
                <MonoLabel size={9}>
                  № {String(i + 1).padStart(2, "0")}
                </MonoLabel>
                <MonoLabel
                  size={9}
                  style={{ color: i === 0 ? SCI.orange : SCI.ink3 }}
                >
                  {it.status}
                </MonoLabel>
              </div>
              <div style={{ display: "flex", justifyContent: "center", overflow: "hidden" }}>
                <div style={{ width: "58%" }}>
                  <InstrumentIcon kind={it.k} />
                </div>
              </div>
              <div>
                <div
                  style={{
                    fontFamily: SCI.display,
                    fontSize: 20,
                    lineHeight: 1.1,
                    marginBottom: 4,
                  }}
                >
                  {it.n}
                </div>
                <MonoLabel size={9} style={{ color: SCI.ink3 }}>
                  {it.cat}
                </MonoLabel>
                <div
                  style={{
                    fontSize: 12,
                    color: SCI.ink2,
                    marginTop: 6,
                    lineHeight: 1.4,
                  }}
                >
                  {it.note}
                </div>
                {it.learn && (
                  <div
                    style={{
                      fontSize: 11,
                      color: SCI.ink3,
                      marginTop: 8,
                      paddingTop: 8,
                      borderTop: `1px solid ${SCI.border}`,
                      lineHeight: 1.45,
                      fontStyle: "italic",
                    }}
                  >
                    {it.learn}
                  </div>
                )}
              </div>
            </div>
          );
        })}
      </div>
    </div>
  );
}

// —— SECTION: Sample report / convergence ——————
function SciSample({ onReadSample }) {
  return (
    <div
      id="section-sample"
      style={{ borderBottom: `1px solid ${SCI.border}`, background: SCI.tint2 }}
    >
      <div
        style={{
          padding: "48px 56px 24px",
          display: "grid",
          gridTemplateColumns: "1fr 1fr",
          gap: 40,
          alignItems: "end",
        }}
      >
        <div>
          <MonoLabel>§ 02 · Sample output</MonoLabel>
          <h2
            style={{
              fontFamily: SCI.display,
              fontSize: 48,
              lineHeight: 0.95,
              margin: "10px 0 0",
              letterSpacing: -0.6,
              fontWeight: 500,
            }}
          >
            A peek at what's
            <br />
            waiting for you.
          </h2>
        </div>
        <div style={{ fontSize: 14, lineHeight: 1.55, color: SCI.ink2 }}>
          When eight different traditions look at the same person and point to the same things — that's not coincidence. That's you.
        </div>
      </div>

      <div
        style={{
          display: "grid",
          gridTemplateColumns: "1.15fr 1fr",
          borderTop: `1px solid ${SCI.border}`,
        }}
      >
        {/* LEFT — convergence matrix */}
        <div
          style={{ padding: "32px 40px", borderRight: `1px solid ${SCI.border}` }}
        >
          <div
            style={{
              display: "flex",
              justifyContent: "space-between",
              alignItems: "baseline",
              marginBottom: 14,
            }}
          >
            <MonoLabel>Convergence matrix · sample subject</MonoLabel>
            <MonoLabel size={9} style={{ color: SCI.ink3 }}>
              Agreement scale 0.0 – 1.0
            </MonoLabel>
          </div>
          <ConvergenceMatrix />
          <div
            style={{
              marginTop: 18,
              display: "flex",
              gap: 16,
              alignItems: "center",
              fontFamily: SCI.mono,
              fontSize: 10,
              color: SCI.ink2,
            }}
          >
            <span>Legend:</span>
            {[0.2, 0.45, 0.7, 0.9].map((v) => (
              <span
                key={v}
                style={{ display: "inline-flex", alignItems: "center", gap: 4 }}
              >
                <span
                  style={{
                    width: 14,
                    height: 14,
                    background: `rgba(var(--sci-orange-rgb),${v})`,
                    border: `1px solid ${SCI.border}`,
                  }}
                />
                {v.toFixed(1)}
              </span>
            ))}
          </div>
        </div>

        {/* RIGHT — excerpt card */}
        <div
          style={{
            padding: "32px 40px",
            background: SCI.paper,
            display: "flex",
            flexDirection: "column",
          }}
        >
          <div
            style={{
              display: "flex",
              justifyContent: "space-between",
              alignItems: "center",
              marginBottom: 10,
            }}
          >
            <MonoLabel>Excerpt · §7 · Work & vocation</MonoLabel>
            <MonoLabel size={9} style={{ color: SCI.ink3 }}>
              7 of 12 readings agree
            </MonoLabel>
          </div>
          <div
            style={{
              fontFamily: SCI.display,
              fontSize: 28,
              lineHeight: 1.15,
              margin: "6px 0 10px",
              letterSpacing: -0.2,
            }}
          >
            A builder who resents being managed.
          </div>
          <div style={{ fontSize: 14, lineHeight: 1.6, color: SCI.ink2 }}>
            Your Big Five profile (high Openness, low Agreeableness) and
            Enneagram 8 both describe someone who trusts their own calibration
            over hierarchy. MBTI Ni-Te confirms it: you orient by internal
            model, not instruction.{" "}
            <span style={{ background: "rgba(var(--sci-orange-rgb),0.18)" }}>
              Three archetypal readings independently flag leadership
              lines — a convergence our engine rates <strong>0.91</strong>
            </span>
            .
          </div>
          <div style={{ fontSize: 14, lineHeight: 1.6, color: SCI.ink2, marginTop: 12 }}>
            The pattern holds across time. Your astrology chart places Saturn in
            the 10th house — the house of authority and public life. Your Gene
            Key 63 shadow is doubt, its gift is inquiry. Together they describe
            someone who questions the structure before they'll build inside it.
            That's not resistance. That's discernment. The chart sees the
            difference.
          </div>
          <div
            style={{
              marginTop: "auto",
              paddingTop: 22,
              display: "flex",
              justifyContent: "space-between",
              alignItems: "end",
            }}
          >
            <div>
              <MonoLabel size={9} style={{ color: SCI.ink3 }}>
                Trend · this trait over last 3 reports
              </MonoLabel>
              <div style={{ width: 180, marginTop: 4 }}>
                <Sparkline
                  data={[0.62, 0.68, 0.71, 0.74, 0.79, 0.83, 0.88, 0.91]}
                  color={SCI.orange}
                  height={40}
                />
              </div>
            </div>
            <SciBtn icon="→" onClick={onReadSample}>
              Read full report
            </SciBtn>
          </div>
        </div>
      </div>
    </div>
  );
}

function ConvergenceMatrix() {
  const axes = [
    "Big 5",
    "MBTI",
    "Enn",
    "HD",
    "Astro",
    "Num",
    "Carto",
    "IChing",
    "Genes",
    "Chin",
  ];
  // deterministic-ish sample values
  const cells = axes.map((_, i) =>
    axes.map((_, j) => {
      if (i === j) return 1;
      const seed = ((i * 7 + j * 3) % 10) / 10;
      return Math.min(0.95, 0.22 + seed * 0.75);
    }),
  );
  return (
    <div>
      {/* header row */}
      <div
        style={{
          display: "grid",
          gridTemplateColumns: `72px repeat(${axes.length}, 1fr)`,
          gap: 0,
        }}
      >
        <div />
        {axes.map((a, i) => (
          <div
            key={i}
            style={{
              fontFamily: SCI.mono,
              fontSize: 9,
              color: SCI.ink2,
              textAlign: "center",
              padding: "4px 0",
              letterSpacing: 0.5,
            }}
          >
            {a}
          </div>
        ))}
      </div>
      {cells.map((row, i) => (
        <div
          key={i}
          style={{
            display: "grid",
            gridTemplateColumns: `72px repeat(${axes.length}, 1fr)`,
            gap: 0,
            alignItems: "stretch",
          }}
        >
          <div
            style={{
              fontFamily: SCI.mono,
              fontSize: 10,
              color: SCI.ink2,
              padding: "0 8px",
              display: "flex",
              alignItems: "center",
              justifyContent: "flex-end",
              letterSpacing: 0.3,
            }}
          >
            {axes[i]}
          </div>
          {row.map((v, j) => (
            <div
              key={j}
              style={{
                aspectRatio: "1/1",
                background:
                  i === j ? SCI.ink : `rgba(var(--sci-orange-rgb),${v.toFixed(2)})`,
                border: `1px solid ${SCI.paper}`,
                display: "flex",
                alignItems: "center",
                justifyContent: "center",
                fontFamily: SCI.mono,
                fontSize: 8,
                color: v > 0.55 || i === j ? SCI.paper : SCI.ink2,
                animation:
                  i === j
                    ? "none"
                    : `sci-pulse 2.8s ease-in-out ${((i + j) % 7) * 90}ms infinite`,
              }}
            >
              {i === j ? "—" : v.toFixed(2).replace("0.", ".")}
            </div>
          ))}
        </div>
      ))}
    </div>
  );
}

// —— SECTION: Pricing ——————————————————————
function SciPricing({ onSelectTier }) {
  const tiers = SCI_IS_AMARA ? [
    {
      t: "The Daily Sign",
      jp: null,
      key: "daily_sign",
      p: "$19",
      per: "per month",
      kicker: "Morning reading",
      body: "A daily horoscope, tarot card, and rune pull — three readings delivered to your inbox every morning. Rotates through traditions. Pause anytime, cancel in a click.",
      features: [
        "Daily horoscope · personalized",
        "Daily tarot card draw",
        "Daily rune pull",
        "Sent at 06:30 local",
        "Cancel anytime",
      ],
      cta: "Begin Daily Sign",
      dark: false,
    },
    {
      t: "Love & Union",
      jp: null,
      key: "love_union",
      p: "$39",
      per: "once",
      kicker: "Relationship reading",
      body: "Two charts, one reading. Synastry, composite chart, love languages, compatibility score, and relationship timing — for you and someone you care about.",
      features: [
        "Synastry chart · two people",
        "Composite midpoint chart",
        "Love language analysis",
        "Compatibility score",
        "Relationship timing forecast",
        "PDF + audio",
      ],
      cta: "Begin Love & Union",
      dark: false,
    },
    {
      t: "The Atlas",
      jp: null,
      key: "atlas",
      p: "$79",
      per: "once · keep forever",
      kicker: "Full birth reading",
      body: "Eight traditions read against your specific life: Western astrology, Vedic Jyotish, Chinese Ba Zi, Numerology, Astrocartography, Human Design, Tarot birth cards, and the Mayan Tzolk'in. A convergence atlas where the traditions agree.",
      features: [
        "8 traditions · ~38 readings",
        "Convergence matrix · 8 × 8",
        "8 chapters · ~8,000 words",
        "Audio · 38 minutes · my voice",
        "Lifetime PDF + free updates",
        "Chat with your atlas",
      ],
      cta: "Begin Atlas",
      dark: true,
      recommended: true,
    },
    {
      t: "The Whole World",
      jp: null,
      key: "whole_world",
      p: "$129",
      per: "once · lifetime access",
      kicker: "Everything bundle",
      body: "The Atlas + Love & Union + Wellness + Career + Year of personalized horoscopes. Every reading we offer, against your life, in one purchase.",
      features: [
        "Everything in The Atlas",
        "Love & Union · 2-person reading",
        "Wellness score + moon calendar",
        "Career + vocational analysis",
        "Year of daily horoscopes",
        "Lifetime access · all future updates",
      ],
      cta: "Get Whole World",
      dark: false,
    },
  ] : [
    {
      t: SCI_IS_SENSEI ? "Shoden" : "Starter Reading",
      jp: SCI_IS_SENSEI ? "初伝" : null,
      key: "Glimpse",
      p: "$0",
      per: "forever",
      kicker: SCI_IS_SENSEI ? "Free preview · First transmission" : "Your starter read",
      body: SCI_IS_SENSEI
        ? "Big Five and MBTI. The first door. Enough to know this is real. No time limit."
        : "Big Five and MBTI. Enough to feel this is real. No time limit.",
      features: [
        "Big Five Summary",
        "MBTI Type",
        "Share Link",
      ],
      cta: SCI_IS_SENSEI ? "Enter Shoden" : "Start Free",
      dark: false,
    },
    {
      t: SCI_IS_SENSEI ? "Chuden" : "Full Reading",
      jp: SCI_IS_SENSEI ? "中伝" : null,
      key: "Becoming",
      p: "$49",
      per: SCI_IS_SENSEI ? "傳承 — once, lifetime" : "once",
      kicker: SCI_IS_SENSEI ? "The 8,000-word blueprint · Middle transmission" : "The full chart",
      body: SCI_IS_SENSEI
        ? "All twelve readings. 8,000-word personalized report. 38-min narrated audio. Pay once, keep forever. No subscription — this is the whole transmission."
        : "All twelve readings. 8,000-word report. 38-min narrated audio. Pay once, keep it forever. No subscription, no upsell — this is the whole thing.",
      features: [
        SCI_IS_AMARA ? "All 8 traditions · ~38 readings" : "All 12 Readings",
        "Long-form Report",
        "Audio (38 Min)",
        "Export PDF",
        SCI_IS_SENSEI ? "Relationship Add-on (En)" : "Relationship Read Add-on",
        "Chat With Your Chart",
      ],
      cta: SCI_IS_SENSEI ? "Receive Chuden" : "Get Full Reading",
      dark: true,
      recommended: true,
    },
  ];
  return (
    <div
      id="section-pricing"
      style={{ borderBottom: `1px solid ${SCI.border}`, background: SCI.paper }}
    >
      <div
        style={{
          padding: "48px 56px 18px",
          display: "flex",
          justifyContent: "space-between",
          alignItems: "end",
        }}
      >
        <div>
          <MonoLabel>§ 05 · Pricing</MonoLabel>
          <h2
            style={{
              fontFamily: SCI.display,
              fontSize: 48,
              lineHeight: 0.95,
              margin: "10px 0 0",
              letterSpacing: -0.6,
              fontWeight: 500,
            }}
          >
            Choose your <span style={{ fontStyle: "italic" }}>chapter.</span>
          </h2>
        </div>
        <MonoLabel size={10} style={{ color: SCI.ink3 }}>
          Prices in USD · tax at checkout
        </MonoLabel>
      </div>
      <div
        style={{
          display: "grid",
          gridTemplateColumns: SCI_IS_AMARA ? "repeat(4,1fr)" : "repeat(2,1fr)",
          borderTop: `1px solid ${SCI.border}`,
        }}
      >
        {tiers.map((t, i) => (
          <div
            key={i}
            className="sci-card-hover"
            style={{
              padding: "30px 56px 32px",
              borderRight: i < 2 ? `1px solid ${SCI.border}` : "none",
              background: t.dark ? SCI.ink : SCI.paper,
              color: t.dark ? SCI.paper : SCI.ink,
              position: "relative",
              display: "flex",
              flexDirection: "column",
            }}
          >
            {t.recommended && (
              <div
                style={{
                  position: "absolute",
                  top: -1,
                  right: -1,
                  background: SCI.orange,
                  color: SCI.paper,
                  fontFamily: SCI.mono,
                  fontSize: 9,
                  letterSpacing: 0.8,
                  textTransform: "uppercase",
                  padding: "5px 12px",
                  border: `1px solid ${SCI.border}`,
                }}
              >
                Most chosen
              </div>
            )}
            <div
              style={{
                display: "flex",
                justifyContent: "space-between",
                alignItems: "baseline",
                marginBottom: 10,
              }}
            >
              <span
                style={{
                  fontFamily: SCI.mono,
                  fontSize: 11,
                  letterSpacing: 1,
                  textTransform: "uppercase",
                  opacity: 0.7,
                }}
              >
                Tier {String(i + 1).padStart(2, "0")}
              </span>
              <span
                style={{
                  fontFamily: SCI.mono,
                  fontSize: 10,
                  opacity: 0.6,
                  letterSpacing: 0.5,
                }}
              >
                {t.kicker}
              </span>
            </div>
            <div
              style={{
                fontFamily: SCI.display,
                fontSize: 38,
                lineHeight: 1,
                margin: "6px 0 2px",
              }}
            >
              {t.jp ? (
                <span style={{ display: "block" }}>
                  <span style={{ fontFamily: SCI.display, fontSize: 38, lineHeight: 1, margin: "6px 0 2px", display: "block" }}>{t.t}</span>
                  <span style={{ fontFamily: SCI.display, fontSize: 18, lineHeight: 1.2, opacity: 0.5, display: "block", marginTop: 2 }}>{t.jp}</span>
                </span>
              ) : t.t}
            </div>
            <div
              style={{
                display: "flex",
                alignItems: "baseline",
                gap: 6,
                margin: "14px 0 4px",
              }}
            >
              <span
                style={{
                  fontFamily: SCI.display,
                  fontSize: 64,
                  lineHeight: 0.9,
                  letterSpacing: -1.5,
                }}
              >
                {t.p}
              </span>
              <span
                style={{ fontFamily: SCI.mono, fontSize: 11, opacity: 0.7 }}
              >
                / {t.per}
              </span>
            </div>
            <div
              style={{
                fontSize: 14,
                lineHeight: 1.5,
                opacity: 0.85,
                margin: "14px 0 18px",
                maxWidth: 320,
              }}
            >
              {t.body}
            </div>
            <div
              style={{
                borderTop: `1px solid ${t.dark ? "rgba(var(--sci-paper-rgb),0.2)" : SCI.tint}`,
              }}
            >
              {t.features.map((f, j) => (
                <div
                  key={j}
                  style={{
                    display: "flex",
                    gap: 10,
                    padding: "9px 0",
                    borderBottom: `1px solid ${t.dark ? "rgba(var(--sci-paper-rgb),0.15)" : SCI.tint}`,
                    fontSize: 13,
                  }}
                >
                  <span
                    style={{
                      fontFamily: SCI.mono,
                      fontSize: 11,
                      opacity: 0.5,
                      width: 22,
                    }}
                  >
                    {String(j + 1).padStart(2, "0")}
                  </span>
                  {f}
                </div>
              ))}
            </div>
            <div style={{ marginTop: "auto", paddingTop: 22 }}>
              <SciBtn
                w="100%"
                size="lg"
                icon="→"
                primary={!t.dark}
                onClick={() => onSelectTier && onSelectTier(t.key)}
                style={
                  t.dark
                    ? {
                        background: SCI.paper,
                        color: SCI.ink,
                        border: `1px solid ${SCI.paper}`,
                      }
                    : {}
                }
              >
                {t.cta}
              </SciBtn>
            </div>
          </div>
        ))}
      </div>
    </div>
  );
}

// —— SECTION: Testimonials / stats —————————
function SciTestimonials() {
  return (
    <div style={{ borderBottom: `1px solid ${SCI.border}` }}>
      <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr" }}>
        {/* Left: stats */}
        <div
          style={{ padding: "48px 56px", borderRight: `1px solid ${SCI.border}` }}
        >
          <MonoLabel>§ 06 · Adoption</MonoLabel>
          <div
            style={{
              display: "grid",
              gridTemplateColumns: "1fr 1fr",
              gap: 0,
              marginTop: 24,
              borderTop: `1px solid ${SCI.border}`,
            }}
          >
            {[
              { k: "Charts read", v: "184,212", s: "since Q2·2024" },
              { k: "Full charts issued", v: "92,408", s: "blueprint tier" },
              { k: "Average length", v: "8,214w", s: "per chart" },
              { k: "Still here · 90d", v: "71%", s: "inner circle" },
            ].map((m, i) => (
              <div
                key={i}
                style={{
                  padding: "22px 20px",
                  borderRight: i % 2 === 0 ? `1px solid ${SCI.border}` : "none",
                  borderBottom: i < 2 ? `1px solid ${SCI.border}` : "none",
                }}
              >
                <MonoLabel size={9}>{m.k}</MonoLabel>
                <div
                  style={{
                    fontFamily: SCI.display,
                    fontSize: 42,
                    lineHeight: 1,
                    margin: "8px 0 4px",
                    letterSpacing: -0.5,
                  }}
                >
                  {m.v}
                </div>
                <MonoLabel size={9} style={{ color: SCI.ink3 }}>
                  {m.s}
                </MonoLabel>
              </div>
            ))}
          </div>
          <div style={{ marginTop: 28 }}>
            <MonoLabel>Weekly charts · 2026</MonoLabel>
            <div style={{ marginTop: 10 }}>
              <Sparkline
                data={[
                  22, 28, 31, 29, 34, 40, 38, 44, 49, 52, 58, 61, 63, 68, 71,
                  74, 78, 82,
                ]}
                height={56}
              />
            </div>
          </div>
        </div>

        {/* Right: editorial pullquote */}
        <div
          style={{
            padding: "48px 56px",
            background: SCI.ink,
            color: SCI.paper,
          }}
        >
          <MonoLabel style={{ color: "rgba(var(--sci-paper-rgb),0.5)" }}>
            Subject № 41,208
          </MonoLabel>
          <blockquote
            style={{
              fontFamily: SCI.display,
              fontSize: 36,
              lineHeight: 1.15,
              letterSpacing: -0.3,
              margin: "18px 0 24px",
              maxWidth: 520,
            }}
          >
            {'\u201c'}It's the first time a reading told me something I didn't already know{" "}
            <span style={{ color: SCI.orange, fontStyle: "italic" }}>and</span>{" "}
            that turned out to be true.{'\u201d'}
          </blockquote>
          <div
            style={{
              display: "flex",
              alignItems: "center",
              gap: 14,
              fontFamily: SCI.mono,
              fontSize: 11,
              letterSpacing: 0.5,
              color: "rgba(var(--sci-paper-rgb),0.7)",
            }}
          >
            <div
              style={{
                width: 36,
                height: 36,
                borderRadius: 20,
                background: "rgba(var(--sci-paper-rgb),0.1)",
                border: "1px solid rgba(var(--sci-paper-rgb),0.3)",
                display: "flex",
                alignItems: "center",
                justifyContent: "center",
                fontFamily: SCI.mono,
                fontSize: 11,
                color: "rgba(var(--sci-paper-rgb),0.7)",
                letterSpacing: 0.5,
              }}
            >MW</div>
            <div>
              <div>M. WALCOTT</div>
              <div style={{ fontSize: 10, opacity: 0.6 }}>
                researcher · BERLIN · BLUEPRINT TIER
              </div>
            </div>
          </div>
          <div
            style={{
              marginTop: 36,
              paddingTop: 20,
              borderTop: "1px solid rgba(var(--sci-paper-rgb),0.15)",
              display: "grid",
              gridTemplateColumns: "1fr 1fr",
              gap: 16,
            }}
          >
            {[
              ['\u201cBetter than three years of therapy, honestly.\u201d', "— R.K."],
              ['\u201cI\u2019ve never seen myself this clearly on a page.\u201d', "— A.M."],
            ].map(([q, a], i) => (
              <div
                key={i}
                style={{
                  fontSize: 13,
                  lineHeight: 1.5,
                  color: "rgba(var(--sci-paper-rgb),0.85)",
                }}
              >
                {q}
                <div
                  style={{
                    fontFamily: SCI.mono,
                    fontSize: 10,
                    opacity: 0.55,
                    marginTop: 4,
                  }}
                >
                  {a}
                </div>
              </div>
            ))}
          </div>
        </div>
      </div>
    </div>
  );
}

// —— SECTION: FAQ (editorial) ————————————————
function SciFAQ() {
  const qs = [
    [
      "Is this astrology or psychology?",
      "Both, honestly. The psychology (Big Five, MBTI, Enneagram) carries actual statistical weight. The astrology is real too — just a different kind of real. We show you where they agree on you. That's the whole point.",
    ],
    [
      "Does my birth time really matter?",
      "For two of the ten readings — your Rising sign and your Human Design type — birth time shifts the result significantly. Down to the minute matters. If you don't have it, we'll tell you exactly what's affected and what isn't. You won't be left with gaps, just honest context.",
    ],
    [
      "How long does it take?",
      "About twenty minutes to enter your details and answer the questions. The chart itself generates in under two minutes. Most people say they lose an hour reading it.",
    ],
    [
      "Is this a subscription?",
      "No. Full Reading is a one-time purchase of $49. You pay once, you keep it forever. No recurring charges, no hidden fees, no cancellation needed.",
    ],
    [
      "Is my data private?",
      "Yes. Your birth data and answers are never sold, never shared, and deleted the moment you ask. One button, under Settings.",
    ],
  ];
  const [openIndex, setOpenIndex] = React.useState(0);
  return (
    <div
      style={{ borderBottom: `1px solid ${SCI.border}`, background: SCI.paper }}
    >
      <div style={{ padding: "48px 56px 8px" }}>
        <MonoLabel>§ 07 · Frequently asked</MonoLabel>
        <h2
          style={{
            fontFamily: SCI.display,
            fontSize: 48,
            lineHeight: 0.95,
            margin: "10px 0 24px",
            letterSpacing: -0.6,
            fontWeight: 500,
          }}
        >
          What people ask before they begin.
        </h2>
      </div>
      <div style={{ borderTop: `1px solid ${SCI.border}` }}>
        {qs.map(([q, a], i) => {
          const open = openIndex === i;
          return (
            <button
              key={i}
              type="button"
              className="sci-link-btn"
              onClick={() => setOpenIndex((prev) => (prev === i ? -1 : i))}
              aria-expanded={open}
              style={{
                width: "100%",
                display: "grid",
                gridTemplateColumns: "80px 1fr 1.4fr 60px",
                borderBottom: `1px solid ${SCI.border}`,
                padding: "22px 56px",
                gap: 24,
                background: open ? SCI.tint2 : SCI.paper,
              }}
            >
              <div
                style={{
                  fontFamily: SCI.mono,
                  fontSize: 11,
                  color: SCI.ink3,
                  letterSpacing: 0.5,
                }}
              >
                № {String(i + 1).padStart(2, "0")}
              </div>
              <div
                style={{
                  fontFamily: SCI.display,
                  fontSize: 24,
                  lineHeight: 1.15,
                  letterSpacing: -0.2,
                }}
              >
                {q}
              </div>
              <div
                style={{
                  fontSize: 14,
                  lineHeight: 1.55,
                  color: SCI.ink2,
                  maxHeight: open ? 220 : 0,
                  overflow: "hidden",
                  opacity: open ? 1 : 0,
                  transition: "max-height .24s ease, opacity .2s ease",
                  textAlign: "left",
                }}
              >
                {a}
              </div>
              <div
                style={{
                  fontFamily: SCI.display,
                  fontSize: 26,
                  textAlign: "right",
                  color: SCI.ink,
                }}
              >
                {open ? "−" : "+"}
              </div>
            </button>
          );
        })}
      </div>
    </div>
  );
}

// —— SECTION: CTA + Footer ————————————————
function SciCTA({ onBegin, dobValue = "", onDobChange, onEnterDob }) {
  return (
    <div
      style={{
        background: SCI.ink,
        color: SCI.paper,
        padding: "72px 56px 56px",
        borderBottom: `1px solid ${SCI.border}`,
      }}
    >
      <div
        style={{
          display: "grid",
          gridTemplateColumns: "1fr 1fr",
          gap: 40,
          alignItems: "center",
        }}
      >
        <div>
          <MonoLabel style={{ color: "rgba(var(--sci-paper-rgb),0.5)" }}>
            → Begin
          </MonoLabel>
          <h2
            style={{
              fontFamily: SCI.display,
              fontSize: 72,
              lineHeight: 0.95,
              margin: "14px 0 0",
              letterSpacing: -1.2,
              fontWeight: 500,
            }}
          >
            Twenty minutes.
            <br />
            <span style={{ fontStyle: "italic", color: SCI.orange }}>
              {SCI_IS_SENSEI ? "Or skip to instant downloads." : "A lifetime of reference."}
            </span>
          </h2>
        </div>
        <div>
          <div style={{ display: "flex", gap: 12, marginBottom: 20 }}>
            <div
              style={{
                flex: 1,
                height: 56,
                border: "1px solid rgba(var(--sci-paper-rgb),0.4)",
                display: "flex",
                alignItems: "center",
                padding: "0 16px",
                background: "rgba(var(--sci-paper-rgb),0.04)",
              }}
            >
              <MonoLabel
                style={{ color: "rgba(var(--sci-paper-rgb),0.5)", marginRight: 14 }}
              >
                DOB
              </MonoLabel>
              <input
                value={dobValue}
                onChange={(e) => onDobChange && onDobChange(e.target.value)}
                onKeyDown={(e) => {
                  if (e.key === "Enter" && onEnterDob) onEnterDob();
                }}
                placeholder="Your Birthday · MM / DD / YYYY"
                style={{
                  flex: 1,
                  background: "none",
                  border: "none",
                  outline: "none",
                  color: SCI.paper,
                  fontFamily: SCI.mono,
                  fontSize: 14,
                }}
              />
            </div>
            <SciBtn
              size="lg"
              icon="→"
              onClick={onEnterDob || onBegin}
              style={{
                background: SCI.paper,
                color: SCI.ink,
                border: `1px solid ${SCI.paper}`,
              }}
            >
              {SCI_IS_SENSEI ? "Get Full Personal Reading" : "Begin"}
            </SciBtn>
          </div>
          <div
            style={{
              fontFamily: SCI.mono,
              fontSize: 10,
              letterSpacing: 0.5,
              color: "rgba(var(--sci-paper-rgb),0.6)",
            }}
          >
            FREE PREVIEW · NO SIGNUP · {SCI_IS_AMARA ? "$129" : "$49"} ONCE FOR THE FULL REPORT
          </div>
        </div>
      </div>
    </div>
  );
}

function SciFooter({ onNavigatePage, onNavigateSection }) {
  const cols = SCI_IS_SENSEI ? [
    {
      h: "Product",
      items: [
        { label: SCI_COPY.navMethod, sectionId: "section-methodology" },
        { label: SCI_COPY.navInstruments, sectionId: "section-instruments" },
        { label: SCI_COPY.navSample, route: "/scrolls" },
        { label: SCI_COPY.navPricing, sectionId: "section-pricing" },
        { label: "Research", route: "/research" },
      ],
    },
    {
      h: "Company",
      items: [
        { label: "About", route: "/about" },
        { label: "Contact", route: "/contact" },
      ],
    },
    {
      h: "Legal",
      items: [
        { label: "Privacy", route: "/privacy" },
        { label: "Terms", route: "/terms" },
        { label: "Data deletion", route: "/data-deletion" },
      ],
    },
  ] : [
    {
      h: "Product",
      items: [
        { label: SCI_COPY.navMethod, sectionId: "section-methodology" },
        { label: SCI_COPY.navInstruments, sectionId: "section-instruments" },
        { label: SCI_COPY.navSample, sectionId: "section-sample" },
        { label: SCI_COPY.navPricing, sectionId: "section-pricing" },
        { label: "Research", route: "/research" },
      ],
    },
    {
      h: "Company",
      items: [
        { label: "About", route: "/about" },
        { label: "Press", route: "/press" },
        { label: "Careers", route: "/careers" },
        { label: "Contact", route: "/contact" },
      ],
    },
    {
      h: "Legal",
      items: [
        { label: "Privacy", route: "/privacy" },
        { label: "Terms", route: "/terms" },
        { label: "Data deletion", route: "/data-deletion" },
        { label: "Cookies", route: "/cookies" },
      ],
    },
    {
      h: "Follow",
      items: [
        { label: "Newsletter", route: "/newsletter" },
        { label: "Substack", route: "/substack" },
        { label: "RSS", route: "/rss" },
      ],
    },
  ];
  return (
    <div style={{ padding: "40px 56px 28px", background: SCI.paper }}>
      <div
        style={{
          display: "grid",
          gridTemplateColumns: SCI_IS_SENSEI ? "1.4fr repeat(3, 1fr)" : "1.4fr repeat(4, 1fr)",
          gap: 40,
          paddingBottom: 28,
          borderBottom: `1px solid ${SCI.border}`,
        }}
      >
        <div>
          <div
            style={{
              fontFamily: SCI.display,
              fontSize: 36,
              lineHeight: 1,
              letterSpacing: -0.5,
            }}
          >
            {SCI_COPY.brandName}<span style={{ color: SCI.orange }}>.</span>
            <span style={{ fontFamily: "serif", fontSize: 28, color: SCI.orange, marginLeft: 12, opacity: 0.9, fontWeight: 400 }}>{SCI_IS_AMARA ? "" : "魂"}</span>
          </div>
          <div
            style={{
              fontFamily: SCI.mono,
              fontSize: 10,
              color: SCI.ink3,
              marginTop: 6,
              letterSpacing: 0.5,
            }}
          >
            {SCI_IS_AMARA ? "" : "魂 · "}{SCI_COPY.footerTagline} · 2026
          </div>
          <div
            style={{
              fontSize: 13,
              lineHeight: 1.55,
              color: SCI.ink2,
              marginTop: 20,
              maxWidth: 280,
            }}
          >
            Twelve ways of reading a soul. Ancient, modern, and everything in between — treated with the
            statistical weight each of them actually earns.
          </div>
        </div>
        {cols.map((c, i) => (
          <div key={i}>
            <MonoLabel>{c.h}</MonoLabel>
            <div
              style={{
                marginTop: 14,
                display: "flex",
                flexDirection: "column",
                gap: 8,
              }}
            >
              {c.items.map((it, j) => (
                <button
                  key={j}
                  type="button"
                  className="sci-link-btn"
                  onClick={() => {
                    if (it.sectionId && onNavigateSection)
                      onNavigateSection(it.sectionId, it.label);
                    if (it.route && onNavigatePage) onNavigatePage(it.route);
                  }}
                  style={{ fontSize: 13, color: SCI.ink2 }}
                >
                  {it.label}
                </button>
              ))}
            </div>
          </div>
        ))}
      </div>
      <div
        style={{
          paddingTop: 16,
          display: "flex",
          justifyContent: "space-between",
          fontFamily: SCI.mono,
          fontSize: 10,
          color: SCI.ink3,
          letterSpacing: 0.5,
        }}
      >
        <span>© 2026 {SCI_COPY.brandName}{SCI_IS_AMARA ? " · ALL RIGHTS RESERVED" : " 魂 · ALL RIGHTS RESERVED"}</span>
        <span>{SCI_COPY.footerTagline}</span>
        <span>{SCI_IS_AMARA ? "FIG. END" : "魂 / END"}</span>
      </div>
    </div>
  );
}

// ——— Composite desktop page ————————————————
function HomeScienceHiFiDesktop({
  onBegin,
  onInstantDownload,
  onSignIn,
  onSignUp,
  onNavigateSection,
  onNavigatePage,
  activeSection,
  dobValue,
  onDobChange,
  onEnterDob,
  onReadSample,
  onSelectTier,
  user,
}) {
  return (
    <div
      style={{
        width: 1400,
        background: SCI.paper,
        color: SCI.ink,
        fontFamily: SCI.body,
        overflow: "hidden",
        border: `1px solid ${SCI.border}`,
      }}
    >
      {SCI_IS_AMARA && (
        <div className="amara-announcement">
          <div className="amara-announcement-track">
            <span>One soul · A thousand traditions · <em>Your universal truth</em></span>
            <span>8 traditions · ~38 readings · <em>$79 once · yours forever</em></span>
            <span>Free preview · No signup · <em>Read it before you pay</em></span>
            <span>Hand-synthesized by Amara · <em>Delivered in 7 days</em></span>
            <span>One soul · A thousand traditions · <em>Your universal truth</em></span>
            <span>8 traditions · ~38 readings · <em>$79 once · yours forever</em></span>
            <span>Free preview · No signup · <em>Read it before you pay</em></span>
            <span>Hand-synthesized by Amara · <em>Delivered in 7 days</em></span>
          </div>
        </div>
      )}
      <SciNav
        onBegin={onBegin}
        onInstantDownload={onInstantDownload}
        onSignIn={onSignIn}
        onSignUp={onSignUp}
        onNavigateSection={onNavigateSection}
        onNavigatePage={onNavigatePage}
        activeSection={activeSection}
        user={user}
      />
      <SciHero
        onBegin={onBegin}
        onInstantDownload={onInstantDownload}
        dobValue={dobValue}
        onDobChange={onDobChange}
        onEnterDob={onEnterDob}
      />
      <SciLogoStrip />
      {SCI_IS_SENSEI ? <SciInstantDownloads onInstantDownload={onInstantDownload} /> : null}
      <SciSample onReadSample={onReadSample} />
      <SciMethod />
      <SciInstruments />
      <SciPricing onSelectTier={onSelectTier} />
      <div style={{ height: 4, background: SCI.orange }} />
      <SciTestimonials />
      <SciFAQ />
      <SciCTA
        onBegin={onBegin}
        dobValue={dobValue}
        onDobChange={onDobChange}
        onEnterDob={onEnterDob}
      />
      <SciFooter
        onNavigatePage={onNavigatePage}
        onNavigateSection={onNavigateSection}
      />
    </div>
  );
}

// ——— Mobile version ————————————————
function HomeScienceHiFiMobile({
  onBegin,
  onInstantDownload,
  onSignIn,
  onSignUp,
  dobValue = "",
  onDobChange,
  onEnterDob,
  onNavigatePage,
  user,
}) {
  const faq = [
    [
      "Is this science or divination?",
      "Both, honestly. The psychology (Big Five, MBTI, Enneagram) has real statistical weight. The astrology is real too — just a different kind of real. We show you where they agree on you.",
    ],
    [
      "What does the assessment cover?",
      "Big Five, MBTI, Enneagram, and birth-data-driven archetypal systems, combined into one convergence report.",
    ],
    [
      "Can I delete my data?",
      "Yes. Data deletion remains available and is handled from account settings and support workflows.",
    ],
  ];
  const [openFaq, setOpenFaq] = React.useState(0);

  return (
    <div
      style={{
        width: 390,
        background: SCI.paper,
        color: SCI.ink,
        fontFamily: SCI.body,
        border: `1px solid ${SCI.border}`,
        overflow: "hidden",
      }}
    >
      {/* nav */}
      <div
        style={{
          height: 52,
          borderBottom: `1px solid ${SCI.border}`,
          display: "flex",
          alignItems: "center",
          padding: "0 18px",
          justifyContent: "space-between",
        }}
      >
        <div style={{ display: "flex", alignItems: "center", gap: 8 }}>
          <div
            style={{
              width: 22,
              height: 22,
              border: `1.5px solid ${SCI.border}`,
              display: "flex",
              alignItems: "center",
              justifyContent: "center",
              flexShrink: 0,
            }}
          >
            <span style={{ fontFamily: "serif", fontSize: 13, lineHeight: 1, color: SCI.orange, userSelect: "none" }}>{SCI_IS_AMARA ? "" : "魂"}</span>
          </div>
          <div style={{ fontFamily: SCI.display, fontSize: 20 }}>{SCI_COPY.brandName}</div>
        </div>
        <div style={{ display: "flex", alignItems: "center", gap: 8 }}>
          {!user && (
            <button
              type="button"
              onClick={onSignIn}
              style={{
                border: "none",
                background: "none",
                padding: 0,
                margin: 0,
                cursor: "pointer",
                color: SCI.ink2,
                fontFamily: SCI.body,
                fontSize: 12,
              }}
            >
              Log In
            </button>
          )}
          <SciBtn size="sm" primary icon="→" onClick={onSignUp || onBegin}>
            {user ? "Full Reading" : "Start Free"}
          </SciBtn>
        </div>
      </div>

      {/* meta */}
      <div
        style={{
          padding: "6px 18px",
          fontFamily: SCI.mono,
          fontSize: 9,
          color: SCI.ink2,
          borderBottom: `1px solid ${SCI.tint}`,
          display: "flex",
          justifyContent: "space-between",
        }}
      >
        <span>FIG. 01</span>
        <span>N = 184,212</span>
      </div>

      {/* hero */}
      <div
        style={{
          padding: "32px 20px 28px",
          borderBottom: `1px solid ${SCI.border}`,
        }}
      >
        <MonoLabel>{SCI_COPY.heroKicker}</MonoLabel>
        <h1
          style={{
            fontFamily: SCI.display,
            fontSize: 52,
            lineHeight: 0.92,
            letterSpacing: -0.8,
            fontWeight: 500,
            margin: "12px 0 14px",
            whiteSpace: SCI_IS_SENSEI ? "pre-line" : "normal",
          }}
        >
          {SCI_COPY.heroTitle}
        </h1>
        <div
          style={{
            fontSize: 15,
            lineHeight: 1.55,
            color: SCI.ink2,
            marginBottom: 22,
          }}
        >
          {SCI_COPY.heroBody}
        </div>
        <div
          style={{
            height: 52,
            border: `1px solid ${SCI.border}`,
            display: "flex",
            alignItems: "center",
            padding: "0 14px",
            marginBottom: 10,
          }}
        >
          <MonoLabel style={{ marginRight: 10 }}>DOB</MonoLabel>
          <input
            value={dobValue}
            onChange={(e) => onDobChange && onDobChange(e.target.value)}
            onKeyDown={(e) => {
              if (e.key === "Enter" && onEnterDob) onEnterDob();
            }}
            placeholder="MM / DD / YYYY"
            style={{
              border: "none",
              background: "none",
              outline: "none",
              flex: 1,
              fontFamily: SCI.mono,
              fontSize: 13,
              color: SCI.ink,
            }}
          />
        </div>
        <SciBtn
          primary
          size="lg"
          w="100%"
          icon="→"
          onClick={onEnterDob || onBegin}
          style={{ background: SCI.orange, borderColor: SCI.orange }}
        >
          {SCI_COPY.heroPrimaryCta}
        </SciBtn>
        {SCI_IS_SENSEI ? (
          <SciBtn
            size="lg"
            w="100%"
            onClick={onInstantDownload || onBegin}
            style={{ marginTop: 8 }}
          >
            {SCI_COPY.heroSecondaryCta}
          </SciBtn>
        ) : null}
      </div>

      {SCI_IS_SENSEI ? (
        <div
          style={{
            padding: "24px 20px",
            borderBottom: `1px solid ${SCI.border}`,
            background: SCI.tint2,
          }}
        >
          <MonoLabel>§ 02 · Instant Downloads</MonoLabel>
          <div style={{ marginTop: 10, display: "grid", gap: 10 }}>
            {[
              "Daily Archetype Forecast · PDF + cards · $19",
              "30-Day Ritual Calendar · print + wallpaper · $24",
              "Relationship Energy · quick reference · $17",
            ].map((line) => (
              <div
                key={line}
                style={{
                  padding: "12px 12px",
                  border: `1px solid ${SCI.border}`,
                  background: SCI.paper,
                  fontSize: 13,
                  lineHeight: 1.4,
                }}
              >
                {line}
              </div>
            ))}
          </div>
          <SciBtn
            primary
            size="lg"
            w="100%"
            icon="→"
            onClick={onInstantDownload || onBegin}
            style={{ marginTop: 10 }}
          >
            Instant Download
          </SciBtn>
        </div>
      ) : null}

      {/* live viz */}
      <div
        style={{ padding: "22px 20px", borderBottom: `1px solid ${SCI.border}` }}
      >
        <div
          style={{
            display: "flex",
            justifyContent: "space-between",
            alignItems: "center",
            marginBottom: 12,
          }}
        >
          <MonoLabel>Live sample · J.D.</MonoLabel>
          <Pill dark>Enneagram</Pill>
        </div>
        <div
          style={{
            fontFamily: SCI.display,
            fontSize: 30,
            lineHeight: 1,
            margin: "4px 0 10px",
          }}
        >
          Type 8<span style={{ color: SCI.orange }}>.</span>
        </div>
        <div
          style={{ aspectRatio: "1/1", maxWidth: 280, margin: "0 auto 16px" }}
        >
          <EnneaRadar
            values={[0.42, 0.38, 0.48, 0.55, 0.62, 0.58, 0.72, 0.95, 0.61]}
          />
        </div>
        <MonoLabel style={{ marginBottom: 6 }}>Big Five</MonoLabel>
        <BigFiveBars values={[88, 72, 41, 63, 22]} />
      </div>

      {/* logo strip */}
      <div
        style={{
          padding: "18px 20px",
          borderBottom: `1px solid ${SCI.border}`,
          overflow: "hidden",
        }}
      >
        <MonoLabel style={{ marginBottom: 10 }}>As featured in —</MonoLabel>
        <div
          style={{
            display: "flex",
            gap: 18,
            fontFamily: SCI.display,
            fontSize: 18,
            flexWrap: "wrap",
            color: SCI.ink,
          }}
        >
          <span>WIRED</span>
          <span style={{ fontStyle: "italic" }}>The Atlantic</span>
          <span style={{ fontWeight: 700 }}>NYT</span>
          <span>Nautilus</span>
        </div>
      </div>

      {/* method */}
      <div
        style={{ padding: "28px 20px", borderBottom: `1px solid ${SCI.border}` }}
      >
        <MonoLabel>§ 02 · Method</MonoLabel>
        <h2
          style={{
            fontFamily: SCI.display,
            fontSize: 34,
            lineHeight: 1,
            margin: "10px 0 18px",
            letterSpacing: -0.5,
            fontWeight: 500,
          }}
        >
          How it <span style={{ fontStyle: "italic" }}>works.</span>
        </h2>
        {["Tell Us About You", (SCI_IS_AMARA ? "The Atlas" : "Twelve Ways In"), "You Get Your Chart"].map((t, i) => (
          <div
            key={i}
            style={{ padding: "14px 0", borderTop: `1px solid ${SCI.tint}` }}
          >
            <div
              style={{
                display: "flex",
                justifyContent: "space-between",
                alignItems: "baseline",
              }}
            >
              <span
                style={{ fontFamily: SCI.mono, fontSize: 11, color: SCI.ink3 }}
              >
                0{i + 1}
              </span>
              <MonoLabel size={9}>
                {["~20 min", "12 readings", "yours forever"][i]}
              </MonoLabel>
            </div>
            <div
              style={{ fontFamily: SCI.display, fontSize: 22, marginTop: 4 }}
            >
              {t}
            </div>
          </div>
        ))}
      </div>

      {/* instruments */}
      <div
        style={{ padding: "28px 20px", borderBottom: `1px solid ${SCI.border}` }}
      >
        <MonoLabel>§ 03 · Instruments</MonoLabel>
        <h2
          style={{
            fontFamily: SCI.display,
            fontSize: 32,
            margin: "8px 0 14px",
            letterSpacing: -0.4,
            fontWeight: 500,
          }}
        >
          Ten<span style={{ color: SCI.orange }}>.</span>
        </h2>
        <div
          style={{
            display: "grid",
            gridTemplateColumns: "repeat(2,1fr)",
            gap: 0,
            border: `1px solid ${SCI.border}`,
          }}
        >
          {[
            ["Big Five", "bigfive"],
            ["MBTI", "mbti"],
            ["Enneagram", "ennea"],
            ["Human Design", "hd"],
            ["Astrology", "astro"],
            ["Numerology", "num"],
            ["Astrocarto.", "carto"],
            ["I Ching", "iching"],
            ["Gene Keys", "genes"],
            ["Chinese", "chinese"],
          ].map(([n, k], i) => (
            <div
              key={i}
              style={{
                padding: "14px 12px",
                borderRight: i % 2 === 0 ? `1px solid ${SCI.border}` : "none",
                borderBottom: i < 8 ? `1px solid ${SCI.border}` : "none",
                display: "flex",
                alignItems: "center",
                gap: 10,
              }}
            >
              <div style={{ width: 34, flexShrink: 0 }}>
                <InstrumentIcon kind={k} />
              </div>
              <div style={{ fontSize: 12, fontWeight: 500 }}>{n}</div>
            </div>
          ))}
        </div>
      </div>

      {/* sample quote */}
      <div
        style={{
          padding: "28px 20px",
          borderBottom: `1px solid ${SCI.border}`,
          background: SCI.tint2,
        }}
      >
        <MonoLabel>§ 04 · Sample</MonoLabel>
        <div
          style={{
            fontFamily: SCI.display,
            fontSize: 26,
            lineHeight: 1.1,
            margin: "10px 0 12px",
          }}
        >
          A builder who resents being managed.
        </div>
        <div style={{ fontSize: 13, lineHeight: 1.55, color: SCI.ink2 }}>
          Big Five (high O, low A) + Enneagram 8 + MBTI Ni-Te all describe the
          same person. Convergence: <strong>0.91</strong>.
        </div>
      </div>

      {/* pricing */}
      <div
        style={{ padding: "28px 20px", borderBottom: `1px solid ${SCI.border}` }}
      >
        <MonoLabel>§ 05 · Pricing</MonoLabel>
        <h2
          style={{
            fontFamily: SCI.display,
            fontSize: 32,
            margin: "8px 0 14px",
            letterSpacing: -0.4,
            fontWeight: 500,
          }}
        >
          Choose your <span style={{ fontStyle: "italic" }}>chapter.</span>
        </h2>
        {[
          { t: "Starter Reading", p: "$0", per: "forever" },
          { t: "Full Reading", p: "$49", per: "once", dark: true, badge: "Most Chosen" },
        ].map((t, i) => (
          <div
            key={i}
            style={{
              padding: "16px 14px",
              marginBottom: 10,
              background: t.dark ? SCI.ink : SCI.paper,
              color: t.dark ? SCI.paper : SCI.ink,
              border: `1px solid ${SCI.border}`,
              position: "relative",
            }}
          >
            {t.badge && (
              <div style={{
                position: "absolute", top: -1, right: -1,
                background: SCI.orange, color: SCI.paper,
                fontFamily: SCI.mono, fontSize: 9, letterSpacing: 0.8,
                textTransform: "uppercase", padding: "4px 10px",
              }}>{t.badge}</div>
            )}
            <div
              style={{
                display: "flex",
                justifyContent: "space-between",
                alignItems: "baseline",
              }}
            >
              <div style={{ fontFamily: SCI.display, fontSize: 22 }}>{t.t}</div>
              <div>
                <span
                  style={{
                    fontFamily: SCI.display,
                    fontSize: 28,
                    letterSpacing: -0.5,
                  }}
                >
                  {t.p}
                </span>
                <span
                  style={{
                    fontFamily: SCI.mono,
                    fontSize: 10,
                    marginLeft: 4,
                    opacity: 0.7,
                  }}
                >
                  / {t.per}
                </span>
              </div>
            </div>
          </div>
        ))}
      </div>

      {/* testimonial */}
      <div
        style={{ padding: "28px 20px", background: SCI.ink, color: SCI.paper }}
      >
        <MonoLabel style={{ color: "rgba(var(--sci-paper-rgb),0.5)" }}>
          Subject № 41,208
        </MonoLabel>
        <blockquote
          style={{
            fontFamily: SCI.display,
            fontSize: 22,
            lineHeight: 1.2,
            margin: "12px 0 14px",
          }}
        >
          {'\u201c'}The first reading that told me something I didn't know{" "}
          <span style={{ color: SCI.orange, fontStyle: "italic" }}>and</span>{" "}
          that turned out to be true.{'\u201d'}
        </blockquote>
        <div style={{ fontFamily: SCI.mono, fontSize: 10, opacity: 0.6 }}>
          — M. WALCOTT · BERLIN
        </div>
      </div>

      {/* mobile FAQ accordion */}
      <div
        style={{
          padding: "24px 20px",
          borderTop: `1px solid ${SCI.border}`,
          borderBottom: `1px solid ${SCI.border}`,
        }}
      >
        <MonoLabel>§ 06 · FAQ</MonoLabel>
        <div style={{ marginTop: 10, borderTop: `1px solid ${SCI.border}` }}>
          {faq.map(([q, a], i) => {
            const open = openFaq === i;
            return (
              <button
                key={i}
                type="button"
                className="sci-link-btn"
                onClick={() => setOpenFaq((prev) => (prev === i ? -1 : i))}
                aria-expanded={open}
                style={{
                  width: "100%",
                  borderBottom: `1px solid ${SCI.border}`,
                  padding: "12px 0",
                  textAlign: "left",
                }}
              >
                <div
                  style={{
                    display: "flex",
                    justifyContent: "space-between",
                    alignItems: "baseline",
                    gap: 12,
                  }}
                >
                  <div
                    style={{
                      fontFamily: SCI.display,
                      fontSize: 22,
                      lineHeight: 1.1,
                    }}
                  >
                    {q}
                  </div>
                  <div style={{ fontFamily: SCI.display, fontSize: 22 }}>
                    {open ? "−" : "+"}
                  </div>
                </div>
                <div
                  style={{
                    marginTop: 6,
                    fontSize: 13,
                    lineHeight: 1.55,
                    color: SCI.ink2,
                    maxHeight: open ? 120 : 0,
                    overflow: "hidden",
                    opacity: open ? 1 : 0,
                    transition: "max-height .24s ease, opacity .2s ease",
                  }}
                >
                  {a}
                </div>
              </button>
            );
          })}
        </div>
      </div>

      {/* CTA */}
      <div
        style={{
          padding: "32px 20px",
          background: SCI.ink,
          color: SCI.paper,
          borderTop: "1px solid rgba(var(--sci-paper-rgb),0.15)",
        }}
      >
        <h2
          style={{
            fontFamily: SCI.display,
            fontSize: 36,
            lineHeight: 0.95,
            margin: "0 0 16px",
            letterSpacing: -0.6,
            fontWeight: 500,
          }}
        >
          Twenty minutes.{" "}
          <span style={{ fontStyle: "italic", color: SCI.orange }}>
            A lifetime of reference.
          </span>
        </h2>
        <SciBtn
          w="100%"
          size="lg"
          icon="→"
          onClick={onBegin}
          style={{
            background: SCI.paper,
            color: SCI.ink,
            border: `1px solid ${SCI.paper}`,
          }}
        >
          Begin assessment
        </SciBtn>
      </div>

      {/* footer */}
      <div
        style={{
          padding: "20px",
          background: SCI.paper,
          fontFamily: SCI.mono,
          fontSize: 10,
          color: SCI.ink3,
          display: "flex",
          justifyContent: "space-between",
        }}
      >
        <button
          type="button"
          className="sci-link-btn"
          onClick={() => onNavigatePage && onNavigatePage("/privacy")}
          style={{ fontFamily: SCI.mono, fontSize: 10, color: SCI.ink3 }}
        >
          Privacy
        </button>
        <span>© 2026 {SCI_COPY.brandName}</span>
        <button
          type="button"
          className="sci-link-btn"
          onClick={() => onNavigatePage && onNavigatePage("/terms")}
          style={{ fontFamily: SCI.mono, fontSize: 10, color: SCI.ink3 }}
        >
          Terms
        </button>
      </div>
    </div>
  );
}

// —— Shared input field primitive used by extras ————————
function FieldDesktop({ label, value, mono, placeholder }) {
  return (
    <div style={{ border: `1px solid ${SCI.border}`, background: SCI.paper }}>
      <div style={{ padding: "8px 14px 2px" }}>
        <span
          style={{
            fontFamily: SCI.mono,
            fontSize: 9,
            letterSpacing: 1,
            textTransform: "uppercase",
            color: SCI.ink3,
          }}
        >
          {label}
        </span>
      </div>
      <div
        style={{
          padding: "0 14px 12px",
          fontFamily: mono ? SCI.mono : SCI.body,
          fontSize: 14,
          color: value ? SCI.ink : SCI.ink3,
        }}
      >
        {value || placeholder || "—"}
      </div>
    </div>
  );
}

Object.assign(window, {
  SCI,
  SCI_COPY,
  SCI_COPY_V2,
  SCI_THEME_V2,
  SCI_IS_SENSEI,
  MonoLabel,
  Pill,
  SciBtn,
  Rule,
  BigFiveBars,
  EnneaRadar,
  MBTIStack,
  Sparkline,
  HeatStrip,
  FieldDesktop,
  SciNav,
  SciFooter,
  SciHero,
  SciThemeToggle,
  HomeScienceHiFiDesktop,
  HomeScienceHiFiMobile,
});
