/* global React, ReactDOM, TweaksPanel, TweakSection, TweakRadio, useTweaks */
const { useEffect } = React;

const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
  "mood": "nude",
  "pace": "editorial",
  "motion": "living"
}/*EDITMODE-END*/;

function TweaksApp() {
  const [tweaks, setTweak] = useTweaks(TWEAK_DEFAULTS);

  // Apply tweaks to <html> as data attributes — CSS does the rest.
  useEffect(() => {
    const html = document.documentElement;
    html.setAttribute("data-mood", tweaks.mood);
    html.setAttribute("data-pace", tweaks.pace);
    html.setAttribute("data-motion", tweaks.motion);
  }, [tweaks.mood, tweaks.pace, tweaks.motion]);

  return (
    <TweaksPanel title="Tweaks">
      <TweakSection
        title="Atmosfera"
        description="Reinterpreta a paleta inteira. Champagne aprofunda os dourados; Noir vira a página em modo editorial escuro."
      >
        <TweakRadio
          value={tweaks.mood}
          onChange={(v) => setTweak("mood", v)}
          options={[
            { value: "nude",      label: "Nude" },
            { value: "champagne", label: "Champagne" },
            { value: "noir",      label: "Noir" },
          ]}
        />
      </TweakSection>

      <TweakSection
        title="Ritmo"
        description="Densidade vertical e proporção das imagens. Cinema = respiro grande, fotos verticais. Compacto = tudo mais próximo."
      >
        <TweakRadio
          value={tweaks.pace}
          onChange={(v) => setTweak("pace", v)}
          options={[
            { value: "compact",   label: "Compacto" },
            { value: "editorial", label: "Editorial" },
            { value: "cinematic", label: "Cinema" },
          ]}
        />
      </TweakSection>

      <TweakSection
        title="Movimento"
        description="Quanta vida a página tem. Vivo = floats, Ken Burns, shimmer. Calmo = só os reveals. Off = totalmente estático."
      >
        <TweakRadio
          value={tweaks.motion}
          onChange={(v) => setTweak("motion", v)}
          options={[
            { value: "off",    label: "Off" },
            { value: "calm",   label: "Calmo" },
            { value: "living", label: "Vivo" },
          ]}
        />
      </TweakSection>
    </TweaksPanel>
  );
}

const tweaksMount = document.createElement("div");
tweaksMount.id = "tweaks-root";
document.body.appendChild(tweaksMount);
ReactDOM.createRoot(tweaksMount).render(<TweaksApp />);
