/* App entry — wires sections, handles Tweaks panel */
const { useState: useStateApp, useEffect: useEffectApp } = React;

const SKILLS = ["playing piano", "fashion design", "writing stories", "drawing", "daydreaming"];

const STORIES = [
{
  title: "Photostat",
  genre: "Sci-Fi · Short Story",
  blurb: "In a world where everyone is learning to adapt with technology, a young author named Henry starts to surrender his writing skills to an advanced robot (Meta 5.0) which can perform both manual labour and simple tasks. He starts to realize that everything is faster, easier, and cheaper because of Meta 5.0. Will this new change in lifestyle actually provide him any good?",
  cover: "assets/photostat-cover.png",
  coverType: "img",
  link: "https://www.wattpad.com/story/407424246-photostat-a-short-story",
  length: "~12 min read"
},
{
  title: "Breaking Point",
  genre: "Fantasy · Thriller",
  blurb: "An angel sets off to earth to protect her designated human God has chosen for her. She starts to understand real-world interactions and adapt to everyday life on earth. However earth is a place where you can find both the good and the bad. One day, on her way to going home, she sees something very terrible happening. Will she be able to help? If not how will the consequences of human action unfold?",
  cover: "assets/breaking-point-cover.png",
  coverType: "img",
  link: "https://www.wattpad.com/story/402969344-breaking-point",
  length: "~20 min read"
},
{
  title: "The Disassembly Drones",
  genre: "Action · Adventure",
  blurb: "Uzi has lived behind doors her whole life, hiding from the drones built to kill her. Rebellious by nature, and gifted with invention, she creates a railgun designed to protect her from harm. She realizes she's done living in a cowardly system—a system which encourages her to stay quiet. So she decides to set out on a journey to take on the very robots designed to exterminate her. Will she be able to take down the robots or is she bait left to die?",
  cover: "assets/drones-cover.png",
  coverType: "img",
  link: "https://www.wattpad.com/story/363013662-the-disassembly-drones-a-short-murder-drones",
  length: "~8 min read"
}];


const FEATURED = {
  ...STORIES[0]
};

const THEMES = [
{ id: "light", label: "Light" },
{ id: "dark", label: "Dark" },
{ id: "blueprint", label: "Blueprint" }];


const ACCENTS = [
{ id: "purple", label: "Electric Purple", hex: "#7C3AED", hex2: "#E54B9B", hex3: "#2BA89B" },
{ id: "magenta", label: "Hot Magenta", hex: "#E54B9B", hex2: "#F4A261", hex3: "#7C3AED" },
{ id: "teal", label: "Mint Teal", hex: "#2BA89B", hex2: "#5BB4F0", hex3: "#7C3AED" },
{ id: "orange", label: "Sun Orange", hex: "#F4A261", hex2: "#E54B9B", hex3: "#2BA89B" }];


const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
  "theme": "blueprint",
  "accent": "purple",
  "motion": true,
  "stickerWobble": true
} /*EDITMODE-END*/;

function App() {
  const [tweaks, setTweak] = window.useTweaks(TWEAK_DEFAULTS);

  // Apply theme + accent vars to <body>
  useEffectApp(() => {
    document.body.dataset.theme = tweaks.theme;
    const a = ACCENTS.find((x) => x.id === tweaks.accent) || ACCENTS[0];
    document.body.style.setProperty("--accent", a.hex);
    document.body.style.setProperty("--accent-2", a.hex2);
    document.body.style.setProperty("--accent-3", a.hex3);
    document.body.classList.toggle("no-motion", !tweaks.motion);
  }, [tweaks.theme, tweaks.accent, tweaks.motion]);

  return (
    <React.Fragment>
      <Background />
      <div className="shell">
        <nav className="nav">
          <span className="nav-mark"><span className="dot"></span><em style={{ fontStyle: 'italic', color: 'var(--accent)' }}>.</em></span>
          <div className="nav-links">
            <a href="#about">About</a>
            <a href="#work">Stories</a>
            <a href="#tools">Tools</a>
          </div>
        </nav>

        <Hero skills={SKILLS} featured={FEATURED} />
        <About />
        <Stories stories={STORIES} />
        <Converter />

        <section className="section" style={{ paddingTop: 20 }}>
          <div className="section-head" style={{ marginBottom: 18, color: "rgb(0, 200, 255)" }}>
            <h2 className="section-title">Pick a Vibe <em>

</em>.</h2>
            <div className="section-meta">
              <span className="num">03</span>
              <span>change the mood</span>
            </div>
          </div>
          <div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(170px, 1fr))",
            gap: 14
          }}>
            {THEMES.map((t) => {
              const active = tweaks.theme === t.id;
              return (
                <button
                  key={t.id}
                  onClick={() => setTweak("theme", t.id)}
                  style={{
                    padding: "22px 20px",
                    border: "1.5px solid var(--line)",
                    borderRadius: "20px",
                    background: "var(--paper)",
                    color: "var(--ink)",
                    cursor: "pointer",
                    textAlign: "left",
                    boxShadow: active ? "var(--shadow-card-hover)" : "var(--shadow-card)",
                    transform: active ? "translate(-2px, -3px)" : "none",
                    transition: "transform .25s, box-shadow .25s",
                    font: "inherit",
                    display: "flex",
                    alignItems: "center",
                    gap: 16
                  }}>
                  <span className={`theme-chip ${t.id}`} style={{ width: 44, height: 44, pointerEvents: "none", flexShrink: 0 }}></span>
                  <div>
                    <div style={{ fontFamily: "'Instrument Serif', serif", fontSize: 26, lineHeight: 1, marginBottom: 4 }}>{t.label}</div>
                    <div style={{ fontFamily: "'JetBrains Mono', monospace", fontSize: 10, letterSpacing: ".18em", textTransform: "uppercase", color: "var(--ink-soft)" }}>
                      {active ? "✓ active" : "tap to apply"}
                    </div>
                  </div>
                </button>);

            })}
          </div>
        </section>

        <footer className="foot">
          <div>© 2026 Noora Rokni · Built by hand <span className="heart">♥</span></div>
          <div>// crafted with html · css · javascript</div>
        </footer>
      </div>

      <window.TweaksPanel title="Tweaks">
        <window.TweakSection label="Theme" />
        <div style={{ padding: "4px 14px 12px" }}>
          <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr 1fr", gap: "6px" }}>
            {THEMES.map((t) =>
            <button
              key={t.id}
              onClick={() => setTweak("theme", t.id)}
              style={{
                padding: "10px 6px",
                borderRadius: "10px",
                border: tweaks.theme === t.id ? "1.5px solid #5BB4F0" : "1px solid rgba(255,255,255,0.15)",
                background: tweaks.theme === t.id ? "rgba(91,180,240,0.18)" : "transparent",
                color: "inherit",
                font: "inherit",
                fontSize: "12px",
                fontWeight: 500,
                cursor: "pointer",
                display: "flex",
                flexDirection: "column",
                alignItems: "center",
                gap: "6px"
              }}>
              <span className={`theme-chip ${t.id}`} style={{ width: 22, height: 22, pointerEvents: "none" }}></span>
              {t.label}
            </button>
            )}
          </div>
        </div>
        <window.TweakSection label="Accent" />
        <window.TweakSelect
          label="Color"
          value={tweaks.accent}
          options={ACCENTS.map((a) => a.id)}
          onChange={(v) => setTweak("accent", v)} />
        
        <window.TweakSection label="Motion" />
        <window.TweakToggle
          label="Background drift"
          value={tweaks.motion}
          onChange={(v) => setTweak("motion", v)} />
        
      </window.TweaksPanel>
    </React.Fragment>);

}

ReactDOM.createRoot(document.getElementById("root")).render(<App />);