// tweaks-melindas.jsx — Font pair switcher (handcrafted alternatives)
const { useEffect: uE_tm } = React;

const MELINDAS_TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
  "fontPair": "editorial",
  "heroAccent": "peach"
}/*EDITMODE-END*/;

const FONT_PAIRS = [
  { id: "editorial", label: "Editorial", display: "Newsreader", body: "Manrope",
    note: "Soft italics, smoother body. Authentic + warm." },
  { id: "heritage", label: "Heritage", display: "EB Garamond", body: "Plus Jakarta Sans",
    note: "Classic patisserie. Slender italics." },
  { id: "original", label: "Original", display: "Source Serif 4", body: "Nunito",
    note: "The first pass." },
];

const HERO_ACCENTS = [
  { id: "peach", label: "Peach (B)", note: "Same serif, bigger weight, peach color. Punchy." },
  { id: "underline", label: "Underline (C)", note: "Same color, curved underline like the logo flourish." },
  { id: "plain", label: "Plain", note: "No accent. Lets meaning carry it." },
];

function MelindasTweaks() {
  const [t, setTweak] = useTweaks(MELINDAS_TWEAK_DEFAULTS);

  // Apply the selected pair + hero accent to <html> so styles.css picks it up
  uE_tm(() => {
    document.documentElement.setAttribute("data-fontpair", t.fontPair || "editorial");
    document.documentElement.setAttribute("data-hero-accent", t.heroAccent || "peach");
  }, [t.fontPair, t.heroAccent]);

  return (
    <TweaksPanel title="Tweaks">
      <TweakSection label='Hero "isn\u2019t." treatment' />
      <div style={{ display: "flex", flexDirection: "column", gap: 6, marginBottom: 4 }}>
        {HERO_ACCENTS.map((a) => {
          const active = (t.heroAccent || "peach") === a.id;
          return (
            <button key={a.id} onClick={() => setTweak('heroAccent', a.id)}
              style={{
                textAlign: "left", padding: "8px 12px", borderRadius: 10,
                border: active ? "1.5px solid #1AADBA" : "1px solid rgba(100,65,35,0.14)",
                background: active ? "rgba(26,173,186,0.08)" : "rgba(255,253,249,0.5)",
                cursor: "pointer", display: "flex", flexDirection: "column", gap: 2,
                transition: "all 180ms cubic-bezier(0.16,1,0.3,1)", width: "100%"
              }}>
              <span style={{ fontFamily: "var(--display)", fontWeight: 600, fontSize: 14, color: "#2C1A0E" }}>{a.label}</span>
              <span style={{ fontFamily: "var(--body)", fontSize: 11.5, color: "#6B4A35", lineHeight: 1.5 }}>{a.note}</span>
            </button>
          );
        })}
      </div>
      <TweakSection label="Type pair" />
      <div style={{ display: "flex", flexDirection: "column", gap: 8 }}>
        {FONT_PAIRS.map((p) => {
          const active = (t.fontPair || "editorial") === p.id;
          return (
            <button key={p.id}
              onClick={() => setTweak('fontPair', p.id)}
              style={{
                textAlign: "left",
                padding: "10px 12px",
                borderRadius: 10,
                border: active ? "1.5px solid #1AADBA" : "1px solid rgba(100,65,35,0.14)",
                background: active ? "rgba(26,173,186,0.08)" : "rgba(255,253,249,0.5)",
                cursor: "pointer",
                display: "flex", flexDirection: "column", gap: 5,
                transition: "all 180ms cubic-bezier(0.16,1,0.3,1)",
                width: "100%"
              }}>
              <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline", gap: 8 }}>
                <span style={{ fontFamily: `"${p.display}", Georgia, serif`, fontSize: 18, fontWeight: 600, color: "#2C1A0E", letterSpacing: "-0.01em" }}>
                  Melinda's <em style={{ fontWeight: 400, fontStyle: "italic" }}>bakery</em>
                </span>
                <span style={{ fontFamily: `"${p.body}", system-ui`, fontSize: 10, fontWeight: 600, color: "#6B4A35", textTransform: "uppercase", letterSpacing: "0.12em" }}>
                  {p.label}
                </span>
              </div>
              <div style={{ fontFamily: `"${p.body}", system-ui`, fontSize: 11.5, color: "#6B4A35", lineHeight: 1.5 }}>
                {p.note}
              </div>
              <div style={{ fontFamily: `"${p.body}", system-ui`, fontSize: 10, color: "#9C7D67", letterSpacing: "0.04em" }}>
                {p.display} · {p.body}
              </div>
            </button>
          );
        })}
      </div>
    </TweaksPanel>
  );
}

window.MelindasTweaks = MelindasTweaks;
