// ──────────────────────────────────────────────────────────────────
// Takedown — design canvas composition.
// All variants live as artboards on a single DesignCanvas.
// ──────────────────────────────────────────────────────────────────

// Tweak-aware splash that loops indefinitely for showcase.
const SplashShowcase = () => {
  const [taglineShown, setTaglineShown] = React.useState(false);
  const [wordmarkShown, setWordmarkShown] = React.useState(false);
  const [tick, setTick] = React.useState(0);
  React.useEffect(() => {
    // 4 transitions @ 2.6s + 3s TAP THE T hold + 0.75s wordmark delay + 1s
    // tagline delay + 0.5s fade + ~5s hold = ~24s cycle.
    const id = setInterval(() => {
      setTaglineShown(false);
      setWordmarkShown(false);
      setTick((t) => t + 1);
    }, 24000);
    return () => clearInterval(id);
  }, []);
  // When cube lands on T-monogram: wordmark fades in 0.75s after, tagline
  // 1.25s after the wordmark (so 2s after settle).
  const onSettled = React.useCallback(() => {
    setTimeout(() => setWordmarkShown(true), 750);
    setTimeout(() => setTaglineShown(true), 2000);
  }, []);
  return (
    <div style={{ position: "absolute", inset: 0, background: "#000", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center" }}>
      <SplashCube key={tick} size={140} onSettled={onSettled} />
      {/* TAKEDOWN wordmark below cube, fades in 0.5s after settle. */}
      <div
        style={{
          marginTop: 36,
          width: 216,
          display: "flex",
          justifyContent: "center",
          alignItems: "center",
          opacity: wordmarkShown ? 1 : 0,
          transform: wordmarkShown ? "translateY(0)" : "translateY(6px)",
          transition: "opacity 500ms ease-out, transform 500ms ease-out",
        }}
      >
        <img src="assets/tkdn-wordmark-tight.png" alt="TAKEDOWN" style={{ width: "100%", objectFit: "contain" }} />
      </div>
      <div
        style={{
          position: "absolute",
          bottom: 60,
          left: 0,
          right: 0,
          display: "flex",
          justifyContent: "center",
          padding: "0 32px",
          color: "rgba(255,255,255,0.55)",
          opacity: taglineShown ? 1 : 0,
          transform: taglineShown ? "translateY(0)" : "translateY(6px)",
          transition: "opacity 500ms ease-out, transform 500ms ease-out",
        }}
      >
        <span
          style={{
            fontFamily: '"Avenir Next", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif',
            fontWeight: 700,
            fontStyle: "italic",
            fontSize: 14,
            letterSpacing: "0.04em",
            textTransform: "uppercase",
          }}
        >
          COMBAT SPORT LIVES HERE.
        </span>
      </div>
    </div>
  );
};

// Cube-exploded reference card: shows each face of the 5-pose sequence.
const CubeFacesCard = () => {
  return (
    <div className="tkdn tkdn-dark" style={{ width: 760, background: "var(--bg-primary)", color: "var(--text-primary)", padding: 32, borderRadius: 8 }}>
      <Overline style={{ color: "var(--accent)" }}>SPLASH CUBE · 5 FACES · 4 TURNS</Overline>
      <div className="t-h2" style={{ marginTop: 8 }}>The brand opener.</div>
      <p className="t-body-lg" style={{ color: "var(--text-secondary)", maxWidth: 540, marginTop: 8 }}>
        Black ground, white cube tumbles through 5 poses before settling on the T-monogram. Each step is a pure single-axis roll (no in-between matrix slerp). The BACK face does double-duty - it shows TKDN at the start, then swaps to TAP THE T while hidden during the LEFT → TOP turn.
      </p>

      <div style={{ display: "grid", gridTemplateColumns: "repeat(5, 1fr)", gap: 12, marginTop: 24 }}>
        {[
          {
            label: "01 · TKDN  (start)",
            sub: "BACK face · rotateY(180)",
            el: (
              <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gridTemplateRows: "1fr 1fr", gap: 0, width: "76%", height: "76%" }}>
                {["T","K","D","N"].map((c) => (
                  <div key={c} style={{ display: "flex", alignItems: "center", justifyContent: "center", overflow: "hidden" }}>
                    <WordmarkLetter letter={c} size={32} color="#fff" />
                  </div>
                ))}
              </div>
            ),
          },
          {
            label: "02 · BUILT FOR PROS",
            sub: "LEFT face · ← left",
            el: <CardLabel text="BUILT FOR PROS" />,
            corner: "tr",
          },
          {
            label: "03 · PRESENT AND FUTURE",
            sub: "TOP face · ↓ down",
            el: <CardLabel text="PRESENT AND FUTURE" />,
            corner: "br",
          },
          {
            label: "04 · TAP THE T",
            sub: "BACK face (swap) · → right",
            el: <CardLabel text="TAP THE T" />,
            corner: "tl",
          },
          {
            label: "05 · T-MONOGRAM  (settle)",
            sub: "RIGHT face · ↓ down",
            el: <img src="assets/tkdn-t.png" alt="" style={{ width: "78%", height: "78%", objectFit: "contain" }} />,
          },
        ].map((f) => (
          <div key={f.label}>
            <div style={{ position: "relative", aspectRatio: 1, background: "#0D0808", border: "1px solid rgba(255,255,255,0.18)", display: "flex", alignItems: "center", justifyContent: "center", padding: 8 }}>
              {f.el}
              {f.corner && (
                <>
                  <div style={{ position: "absolute", width: 16, height: 2, background: "var(--accent, #F04B24)", ...({ tl: { top: 8, left: 8 }, tr: { top: 8, right: 8 }, bl: { bottom: 8, left: 8 }, br: { bottom: 8, right: 8 } }[f.corner]) }} />
                  <div style={{ position: "absolute", width: 2, height: 16, background: "var(--accent, #F04B24)", ...({ tl: { top: 8, left: 8 }, tr: { top: 8, right: 8 }, bl: { bottom: 8, left: 8 }, br: { bottom: 8, right: 8 } }[f.corner]) }} />
                </>
              )}
            </div>
            <Overline style={{ color: "var(--text-tertiary)", marginTop: 8 }}>{f.label}</Overline>
            <div className="t-caption-lg" style={{ color: "var(--text-tertiary)", marginTop: 2 }}>{f.sub}</div>
          </div>
        ))}
      </div>

      <Hairline style={{ margin: "24px 0" }} />

      <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr 1fr 1fr", gap: 16 }}>
        <div>
          <Overline style={{ color: "var(--text-secondary)" }}>CADENCE</Overline>
          <div className="t-body" style={{ color: "var(--text-secondary)", marginTop: 6 }}>2.6s per turn (cubic-bezier .4/0/.2/1). All faces hold the same duration before the next flip.</div>
        </div>
        <div>
          <Overline style={{ color: "var(--text-secondary)" }}>SETTLE</Overline>
          <div className="t-body" style={{ color: "var(--text-secondary)", marginTop: 6 }}>After T-monogram lands, wordmark fades in at +750ms, tagline at +2000ms.</div>
        </div>
        <div>
          <Overline style={{ color: "var(--text-secondary)" }}>EDGE MARKS</Overline>
          <div className="t-body" style={{ color: "var(--text-secondary)", marginTop: 6 }}>Accent right-angle on 3 of 5 faces. TAP THE T's corner sits on the edge it just rotated off (top — shared with PRESENT AND FUTURE).</div>
        </div>
        <div>
          <Overline style={{ color: "var(--text-secondary)" }}>HOLD</Overline>
          <div className="t-body" style={{ color: "var(--text-secondary)", marginTop: 6 }}>Final pose holds ~5s before the showcase restarts the cycle.</div>
        </div>
      </div>
    </div>
  );
};

// Tiny helper for the card's word labels — Avenir Next italic bold to match
// the cube's CubeLabel without pulling in the splash module.
const CardLabel = ({ text }) => (
  <div style={{
    width: "84%",
    color: "#fff",
    fontFamily: '"Avenir Next", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif',
    fontWeight: 700,
    fontStyle: "italic",
    fontSize: 10,
    letterSpacing: "0.03em",
    textTransform: "uppercase",
    lineHeight: 1.1,
    textAlign: "center",
    textWrap: "balance",
  }}>{text}</div>
);

// Notes header for canvas sections
const SectionIntro = ({ code, title, body }) => (
  <div style={{ width: 480, padding: "12px 0", fontFamily: "Figtree, sans-serif" }}>
    <Overline style={{ color: "#c96442" }}>{code}</Overline>
    <div className="t-h2" style={{ marginTop: 6, color: "#1f1a16" }}>{title}</div>
    <p className="t-body-lg" style={{ marginTop: 10, color: "#5a4a3a", maxWidth: 460 }}>{body}</p>
  </div>
);

// Build the design canvas
const TakedownCanvas = () => {
  const [seed, setSeed] = React.useState(0); // forces re-render on tweak changes
  return (
    <DesignCanvas>
      <DCSection
        id="splash"
        title="01 · Brand opener"
        subtitle="Splash cube animation - black ground, white cube, orange-red signature face. TKDN letters baked in."
      >
        <DCArtboard id="splash-dark" label="A · Splash · live" width={430} height={884}>
          <Phone dark>
            <SplashShowcase />
          </Phone>
        </DCArtboard>
        <DCArtboard id="splash-faces" label="B · 6 faces, exploded" width={820} height={620}>
          <CubeFacesCard />
        </DCArtboard>
      </DCSection>

      <DCSection
        id="welcome"
        title="02 · Welcome · first impression"
        subtitle="Bold, terse, mat-ready. Two directions - Classic (full-bleed photo) and Editorial (split-grid with cube)."
      >
        <DCArtboard id="welcome-dark" label="A · Classic · dark" width={430} height={884}>
          <Phone dark>
            <WelcomeScreen onStart={() => {}} onSignIn={() => {}} />
          </Phone>
        </DCArtboard>
        <DCArtboard id="welcome-light" label="A · Classic · light" width={430} height={884}>
          <Phone dark={false}>
            <WelcomeScreen onStart={() => {}} onSignIn={() => {}} />
          </Phone>
        </DCArtboard>
        <DCArtboard id="welcome-bold-dark" label="B · Editorial · dark" width={430} height={884}>
          <Phone dark>
            <WelcomeScreenBold onStart={() => {}} onSignIn={() => {}} />
          </Phone>
        </DCArtboard>
        <DCArtboard id="welcome-bold-light" label="B · Editorial · light" width={430} height={884}>
          <Phone dark={false}>
            <WelcomeScreenBold onStart={() => {}} onSignIn={() => {}} />
          </Phone>
        </DCArtboard>
      </DCSection>

      <DCSection
        id="auth-flow"
        title="03 · Sign-in flow · interactive"
        subtitle="Tap through Welcome → Sign up / Sign in → Onboarding → Role. Same prototype, dark and light."
      >
        <DCArtboard id="auth-interactive-dark" label="A · Tap-through · dark" width={430} height={884}>
          <AuthFlowPrototype dark />
        </DCArtboard>
        <DCArtboard id="auth-interactive-light" label="B · Tap-through · light" width={430} height={884}>
          <AuthFlowPrototype dark={false} />
        </DCArtboard>
        <DCArtboard id="login-static" label="C · Login · dark" width={430} height={884}>
          <Phone dark>
            <LoginScreen onBack={() => {}} onLogin={() => {}} onForgot={() => {}} onSignup={() => {}} />
          </Phone>
        </DCArtboard>
        <DCArtboard id="signup-static" label="D · Sign-up · dark" width={430} height={884}>
          <Phone dark>
            <SignUpOptionsScreen onBack={() => {}} onEmail={() => {}} onSignIn={() => {}} />
          </Phone>
        </DCArtboard>
      </DCSection>

      <DCSection
        id="onboarding-static"
        title="04 · Onboarding · 3 steps + role"
        subtitle="One profile → Build your kit → Pro platform → Pick your role. All four screens side-by-side."
      >
        {[0, 1, 2].map((i) => (
          <DCArtboard key={i} id={`onb-${i}`} label={`Step 0${i + 1}`} width={430} height={884}>
            <Phone dark>
              <OnboardingScreen step={i} onNext={() => {}} onBack={() => {}} onSkip={() => {}} />
            </Phone>
          </DCArtboard>
        ))}
        <DCArtboard id="role" label="04 · Role select" width={430} height={884}>
          <Phone dark>
            <RoleSelectionScreen onBack={() => {}} onContinue={() => {}} />
          </Phone>
        </DCArtboard>
      </DCSection>

      <DCSection
        id="home"
        title="05 · Home feed"
        subtitle="Engagement loop. Status strip + Current build hero + Mat feed cards. Module-coded edge stripes color each item."
      >
        <DCArtboard id="home-dark" label="A · Classic · dark" width={430} height={884}>
          <Phone dark>
            <HomeFeedScreen />
          </Phone>
        </DCArtboard>
        <DCArtboard id="home-light" label="A · Classic · light" width={430} height={884}>
          <Phone dark={false}>
            <HomeFeedScreen />
          </Phone>
        </DCArtboard>
        <DCArtboard id="home-bold-dark" label="B · Editorial · dark" width={430} height={884}>
          <Phone dark>
            <HomeFeedScreenBold />
          </Phone>
        </DCArtboard>
      </DCSection>

      <DCSection
        id="builder"
        title="06 · Designer · the custom gear product"
        subtitle="Interactive: tap a zone, swap a color, expand the drawer. Two compositions - sheet drawer (A) and floating rails (B)."
      >
        <DCArtboard id="builder-interactive" label="A · Drawer · interactive" width={430} height={884}>
          <BuilderFlowPrototype dark />
        </DCArtboard>
        <DCArtboard id="design-intent" label="A1 · Design intent · AI seed" width={430} height={884}>
          <Phone dark><DesignIntentScreen onClose={() => {}} onContinue={() => {}} onSkip={() => {}} /></Phone>
        </DCArtboard>
        <DCArtboard id="builder-bold" label="B · Floating rails" width={430} height={884}>
          <Phone dark>
            <BuilderCanvasScreenBold />
          </Phone>
        </DCArtboard>
        <DCArtboard id="builder-review" label="C · Review · spec sheet" width={430} height={884}>
          <Phone dark>
            <BuilderReviewScreen onBack={() => {}} onSubmit={() => {}} />
          </Phone>
        </DCArtboard>
      </DCSection>

      <DCSection
        id="profile"
        title="07 · Profile + Settings · interactive theme toggle"
        subtitle="Tap the gear, switch dark/light/system. CTA tone (Mono vs Accent) is also tweakable here for live comparison."
      >
        <DCArtboard id="profile-interactive-dark" label="A · Dark default · live toggle" width={430} height={884}>
          <ProfileFlowPrototype initialMode="dark" initialCta="mono" />
        </DCArtboard>
        <DCArtboard id="profile-interactive-light" label="B · Light default · live toggle" width={430} height={884}>
          <ProfileFlowPrototype initialMode="light" initialCta="accent" />
        </DCArtboard>
      </DCSection>

      <DCSection
        id="empty"
        title="08 · Empty states"
        subtitle="Tactical metaphors - wireframe singlet, empty ruler, all-clear status grid, blank record card. No generic illustrations."
      >
        <DCArtboard id="empty-saved" label="A · Saved drafts" width={430} height={884}>
          <Phone dark>
            <EmptySavedDesigns onAction={() => {}} />
          </Phone>
        </DCArtboard>
        <DCArtboard id="empty-orders" label="B · Order history" width={430} height={884}>
          <Phone dark>
            <EmptyOrderHistory onAction={() => {}} />
          </Phone>
        </DCArtboard>
        <DCArtboard id="empty-notif" label="C · Notifications" width={430} height={884}>
          <Phone dark>
            <EmptyNotifications onAction={() => {}} />
          </Phone>
        </DCArtboard>
        <DCArtboard id="empty-matches" label="D · Match record" width={430} height={884}>
          <Phone dark>
            <EmptyMatchHistory onAction={() => {}} />
          </Phone>
        </DCArtboard>
      </DCSection>

      <DCSection
        id="module-color"
        title="09 · Module color usage · spec"
        subtitle="5 navigational tints: Wrestler · Designer · Gear · Scout · Room. Where they live, what they signal, what they never do."
      >
        <DCArtboard id="module-spec" label="Spec card" width={780} height={760}>
          <ModuleColorSpec />
        </DCArtboard>
      </DCSection>

      <DCSection
        id="system"
        title="10 · System reference"
        subtitle="Colors, type, radii, spacing, buttons at a glance. Verify nothing strays off-system."
      >
        <DCArtboard id="system-ref" label="Reference" width={780} height={880}>
          <SystemReferenceCard />
        </DCArtboard>
      </DCSection>
      <DCSection
        id="phase1-auth"
        title="11 · Phase 1 · Auth additions"
        subtitle="Forgot password + Interests picker. Complete the pre-auth flow."
      >
        <DCArtboard id="forgot-password" label="AUTH-3 · Forgot password" width={430} height={884}>
          <Phone dark><ForgotPasswordScreen /></Phone>
        </DCArtboard>
        <DCArtboard id="interests" label="AUTH-5 · Interests" width={430} height={884}>
          <Phone dark><InterestsScreen /></Phone>
        </DCArtboard>
      </DCSection>

      <DCSection
        id="phase1-home"
        title="12 · Phase 1 · Home expansions"
        subtitle="Notifications, gym detail, explore, search, post composer, parent dashboard."
      >
        <DCArtboard id="notifications" label="HOME-2 · Notifications" width={430} height={884}>
          <Phone dark><NotificationsScreen /></Phone>
        </DCArtboard>
        <DCArtboard id="gym-detail" label="HOME-3 · Gym detail" width={430} height={884}>
          <Phone dark><GymDetailScreen /></Phone>
        </DCArtboard>
        <DCArtboard id="explore" label="HOME-4 · Explore" width={430} height={884}>
          <Phone dark><ExploreScreen /></Phone>
        </DCArtboard>
        <DCArtboard id="search-results" label="HOME-5 · Search results" width={430} height={884}>
          <Phone dark><SearchResultsScreen /></Phone>
        </DCArtboard>
        <DCArtboard id="create-post" label="HOME-6 · Create post" width={430} height={884}>
          <Phone dark><CreatePostScreen /></Phone>
        </DCArtboard>
        <DCArtboard id="parent-dash" label="HOME-7 · Parent dashboard" width={430} height={884}>
          <Phone dark><ParentDashboardScreen /></Phone>
        </DCArtboard>
      </DCSection>

      <DCSection
        id="phase1-profile"
        title="13 · Phase 1 · Profile additions"
        subtitle="Edit profile, order history, wallet, notification preferences."
      >
        <DCArtboard id="edit-profile" label="PRO-2 · Edit profile" width={430} height={884}>
          <Phone dark><EditProfileScreen /></Phone>
        </DCArtboard>
        <DCArtboard id="order-history" label="PRO-4 · Order history" width={430} height={884}>
          <Phone dark><OrderHistoryScreen /></Phone>
        </DCArtboard>
        <DCArtboard id="wallet" label="PRO-6 · Wallet" width={430} height={884}>
          <Phone dark><WalletScreen /></Phone>
        </DCArtboard>
        <DCArtboard id="notif-prefs" label="PRO-7 · Notification prefs" width={430} height={884}>
          <Phone dark><NotifPrefsScreen /></Phone>
        </DCArtboard>
      </DCSection>

      <DCSection
        id="phase1-builder"
        title="14 · Phase 1 · Designer additions"
        subtitle="Product config - fabric, size, fit."
      >
        <DCArtboard id="product-config" label="BLD-3 · Product config" width={430} height={884}>
          <Phone dark><ProductConfigScreen /></Phone>
        </DCArtboard>
      </DCSection>

      <DCSection
        id="phase1-gymhq"
        title="15 · Phase 1 · Gym HQ Member"
        subtitle="Member dashboard, check-in & schedule, progress tracker."
      >
        <DCArtboard id="member-dash" label="GHM-1 · Member dashboard" width={430} height={884}>
          <Phone dark><MemberDashboardScreen /></Phone>
        </DCArtboard>
        <DCArtboard id="checkin" label="GHM-2 · Check-in" width={430} height={884}>
          <Phone dark><CheckinScreen /></Phone>
        </DCArtboard>
        <DCArtboard id="progress" label="GHM-3 · Progress tracker" width={430} height={884}>
          <Phone dark><ProgressTrackerScreen /></Phone>
        </DCArtboard>
      </DCSection>

      <DCSection id="phase2-events" title="16 · Phase 2 · Events" subtitle="Browse + detail with corner-marked hero and schedule strip.">
        <DCArtboard id="events-browse" label="EVT-1 · Events browse" width={430} height={884}><Phone dark><EventsBrowseScreen /></Phone></DCArtboard>
        <DCArtboard id="event-detail" label="EVT-2 · Event detail" width={430} height={884}><Phone dark><EventDetailScreen /></Phone></DCArtboard>
      </DCSection>

      <DCSection id="phase2-msg-social" title="17 · Phase 2 · Messaging + Social" subtitle="Inbox + open social feed.">
        <DCArtboard id="messages" label="MSG-1 · Messages" width={430} height={884}><Phone dark><MessagesScreen /></Phone></DCArtboard>
        <DCArtboard id="social-feed" label="SOC-1 · Social feed" width={430} height={884}><Phone dark><SocialFeedScreen /></Phone></DCArtboard>
      </DCSection>

      <DCSection id="phase2-rankings" title="18 · Phase 2 · Rankings" subtitle="Leaderboard, head-to-head, film room, Ring of Fire.">
        <DCArtboard id="leaderboard" label="RNK-1 · Leaderboard" width={430} height={884}><Phone dark><LeaderboardScreen /></Phone></DCArtboard>
        <DCArtboard id="h2h" label="RNK-2 · Head-to-head" width={430} height={884}><Phone dark><HeadToHeadScreen /></Phone></DCArtboard>
        <DCArtboard id="film-room" label="RNK-3 · Film room" width={430} height={884}><Phone dark><VideoLibraryScreen /></Phone></DCArtboard>
        <DCArtboard id="ring-of-fire" label="RNK-4 · Ring of Fire" width={430} height={884}><Phone dark><RingOfFireScreen /></Phone></DCArtboard>
      </DCSection>

      <DCSection
        id="phase2-gear"
        title="20 · Phase 2 · Gear tab · Store Hub + Takedown Store"
        subtitle="Gear is the new commerce home - hosts Designer, Takedown Store, Sponsor Drops, Team & Athlete Stores. 6 screens: hub → browse → PDP → cart → confirmation."
      >
        <DCArtboard id="gear-hub" label="STH-1 · Gear Hub" width={430} height={884}>
          <Phone dark><GearHubScreen /></Phone>
        </DCArtboard>
        <DCArtboard id="sponsor-drops" label="STH-2 · Sponsor Drops" width={430} height={884}>
          <Phone dark><SponsorDropsScreen /></Phone>
        </DCArtboard>
        <DCArtboard id="tkdn-store" label="GEN-1 · Takedown Store" width={430} height={884}>
          <Phone dark><TakedownStoreBrowseScreen /></Phone>
        </DCArtboard>
        <DCArtboard id="pdp" label="GEN-2 · Product detail" width={430} height={884}>
          <Phone dark><ProductDetailScreen /></Phone>
        </DCArtboard>
        <DCArtboard id="cart" label="GEN-3 · Cart" width={430} height={884}>
          <Phone dark><CartScreen /></Phone>
        </DCArtboard>
        <DCArtboard id="order-confirm" label="GEN-4 · Order confirmation" width={430} height={884}>
          <Phone dark><OrderConfirmationScreen /></Phone>
        </DCArtboard>
      </DCSection>

      <DCSection id="phase2-gymhq-owner" title="19 · Phase 2 · Gym HQ Owner" subtitle="Owner dashboard + 7 admin surfaces.">
        <DCArtboard id="gho-dash" label="GHO-1 · Dashboard" width={430} height={884}><Phone dark><GymOwnerDashboardScreen /></Phone></DCArtboard>
        <DCArtboard id="gho-roster" label="GHO-2 · Roster" width={430} height={884}><Phone dark><RosterScreen /></Phone></DCArtboard>
        <DCArtboard id="gho-anno" label="GHO-3 · Announcements" width={430} height={884}><Phone dark><AnnouncementsScreen /></Phone></DCArtboard>
        <DCArtboard id="gho-fin" label="GHO-4 · Financials" width={430} height={884}><Phone dark><FinancialsScreen /></Phone></DCArtboard>
        <DCArtboard id="gho-sched" label="GHO-5 · Class schedule" width={430} height={884}><Phone dark><ClassScheduleScreen /></Phone></DCArtboard>
        <DCArtboard id="gho-roles" label="GHO-6 · Roles & permissions" width={430} height={884}><Phone dark><RolesScreen /></Phone></DCArtboard>
        <DCArtboard id="gho-billing" label="GHO-7 · Billing" width={430} height={884}><Phone dark><BillingScreen /></Phone></DCArtboard>
        <DCArtboard id="gho-student" label="GHO-8 · Student detail" width={430} height={884}><Phone dark><StudentDetailScreen /></Phone></DCArtboard>
      </DCSection>

      <DCSection id="phase3-sponsors" title="21 · Phase 3 · Sponsors" subtitle="Marketplace, deal builder, escrow, proof-of-delivery, contract review.">
        <DCArtboard id="spn-marketplace" label="SPN-1 · Marketplace" width={430} height={884}><Phone dark><SponsorMarketplaceScreen /></Phone></DCArtboard>
        <DCArtboard id="spn-deal" label="SPN-2 · Deal builder" width={430} height={884}><Phone dark><SponsorDealBuilderScreen /></Phone></DCArtboard>
        <DCArtboard id="spn-escrow" label="SPN-3 · Escrow" width={430} height={884}><Phone dark><SponsorEscrowScreen /></Phone></DCArtboard>
        <DCArtboard id="spn-pod" label="SPN-4 · POD submission" width={430} height={884}><Phone dark><SponsorPODSubmissionScreen /></Phone></DCArtboard>
        <DCArtboard id="spn-contract" label="SPN-5 · Contract" width={430} height={884}><Phone dark><SponsorContractScreen /></Phone></DCArtboard>
      </DCSection>

      <DCSection id="phase3-athlete-store" title="22 · Phase 3 · Athlete Store" subtitle="Storefront, drops, sponsor row, orders, payouts, settings.">
        <DCArtboard id="ath-store" label="ATH-1 · Storefront" width={430} height={884}><Phone dark><AthleteStorefrontScreen /></Phone></DCArtboard>
        <DCArtboard id="ath-drops" label="ATH-2 · Drops" width={430} height={884}><Phone dark><AthleteDropsScreen /></Phone></DCArtboard>
        <DCArtboard id="ath-sponsors" label="ATH-3 · Sponsor row" width={430} height={884}><Phone dark><AthleteSponsorRowScreen /></Phone></DCArtboard>
        <DCArtboard id="ath-orders" label="ATH-4 · Orders" width={430} height={884}><Phone dark><AthleteStoreOrdersScreen /></Phone></DCArtboard>
        <DCArtboard id="ath-payouts" label="ATH-5 · Payouts" width={430} height={884}><Phone dark><AthletePayoutsScreen /></Phone></DCArtboard>
        <DCArtboard id="ath-settings" label="ATH-6 · Settings" width={430} height={884}><Phone dark><AthleteStoreSettingsScreen /></Phone></DCArtboard>
      </DCSection>

      <DCSection id="phase4-team-store" title="23 · Phase 4 · Team Store (Buyer + Mgmt)" subtitle="Catalog, PDP, bulk order, status (buyer) + catalog editor, orders, payouts, settings (management).">
        <DCArtboard id="tsb-catalog" label="TS-B-1 · Catalog (buyer)" width={430} height={884}><Phone dark><TeamStoreCatalogScreen /></Phone></DCArtboard>
        <DCArtboard id="tsb-pdp" label="TS-B-2 · PDP (member pricing)" width={430} height={884}><Phone dark><TeamStorePDPScreen /></Phone></DCArtboard>
        <DCArtboard id="tsb-bulk" label="TS-B-3 · Bulk order" width={430} height={884}><Phone dark><TeamStoreBulkOrderScreen /></Phone></DCArtboard>
        <DCArtboard id="tsb-status" label="TS-B-4 · Order status" width={430} height={884}><Phone dark><TeamStoreOrderStatusScreen /></Phone></DCArtboard>
        <DCArtboard id="tsm-catalog" label="TS-M-1 · Catalog editor" width={430} height={884}><Phone dark><TeamStoreCatalogEditorScreen /></Phone></DCArtboard>
        <DCArtboard id="tsm-orders" label="TS-M-2 · Orders mgmt" width={430} height={884}><Phone dark><TeamStoreOrdersMgmtScreen /></Phone></DCArtboard>
        <DCArtboard id="tsm-payouts" label="TS-M-3 · Payouts" width={430} height={884}><Phone dark><TeamStorePayoutsMgmtScreen /></Phone></DCArtboard>
        <DCArtboard id="tsm-settings" label="TS-M-4 · Settings" width={430} height={884}><Phone dark><TeamStoreSettingsMgmtScreen /></Phone></DCArtboard>
      </DCSection>

      <DCSection id="phase4-gym-store" title="24 · Phase 4 · Gym Store" subtitle="In-gym retail. Hub, member pricing, inventory, pickup, settings.">
        <DCArtboard id="gs-hub" label="GS-1 · Hub" width={430} height={884}><Phone dark><GymStoreHubScreen /></Phone></DCArtboard>
        <DCArtboard id="gs-member" label="GS-2 · Member pricing" width={430} height={884}><Phone dark><GymStoreMemberPricingScreen /></Phone></DCArtboard>
        <DCArtboard id="gs-inv" label="GS-3 · Inventory" width={430} height={884}><Phone dark><GymStoreInventoryScreen /></Phone></DCArtboard>
        <DCArtboard id="gs-pickup" label="GS-4 · Pickup at gym" width={430} height={884}><Phone dark><GymStorePickupScreen /></Phone></DCArtboard>
        <DCArtboard id="gs-settings" label="GS-5 · Settings" width={430} height={884}><Phone dark><GymStoreSettingsScreen /></Phone></DCArtboard>
      </DCSection>

      <DCSection id="phase5-ads-aff" title="25 · Phase 5 · Advertising + Affiliate" subtitle="Campaign builder, analytics, affiliate dashboard.">
        <DCArtboard id="ad-campaign" label="AD-1 · Campaign builder" width={430} height={884}><Phone dark><AdCampaignBuilderScreen /></Phone></DCArtboard>
        <DCArtboard id="ad-analytics" label="AD-2 · Analytics" width={430} height={884}><Phone dark><AdAnalyticsScreen /></Phone></DCArtboard>
        <DCArtboard id="aff-dash" label="AFF-1 · Affiliate dashboard" width={430} height={884}><Phone dark><AffiliateDashboardScreen /></Phone></DCArtboard>
      </DCSection>

    </DesignCanvas>
  );
};

// ── Tweaks panel ──────────────────────────────────────────────────
const TweaksContent = () => {
  const [tweaks, setTweak] = useTweaks(window.__TWEAKS_DEFAULTS);

  // Apply tweaks live: inject a high-specificity style rule that wins over
  // brand.css's :root/.tkdn-dark/.tkdn-light declarations.
  React.useEffect(() => {
    let el = document.getElementById("__tweak-style");
    if (!el) {
      el = document.createElement("style");
      el.id = "__tweak-style";
      document.head.appendChild(el);
    }
    el.textContent = `
      :root, .tkdn-dark, .tkdn-light {
        --accent: ${tweaks.accent} !important;
        --ring-focus: ${tweaks.accent} !important;
      }
    `;
  }, [tweaks.accent]);

  return (
    <TweaksPanel title="Tweaks">
      <TweakSection label="Accent">
        <TweakColor
          label="Brand signal"
          value={tweaks.accent}
          onChange={(v) => setTweak("accent", v)}
          options={["#F04B24", "#C61D1D", "#0D0808", "#1D8EC7", "#9AC78B"]}
        />
        <div style={{ fontSize: 11, color: "#7a6a5a", marginTop: 4 }}>
          F04B24 brand · C61D1D flag-red · 0D0808 mono · 1D8EC7 info · 9AC78B success.
        </div>
      </TweakSection>

      <TweakSection label="Notes">
        <div style={{ fontSize: 12, color: "#5a4a3a", lineHeight: 1.5 }}>
          Theme + CTA tone are tweakable <strong>inside</strong> the Profile→Settings prototype (artboard 07). Tap the gear, then toggle. This panel only changes globals.
        </div>
      </TweakSection>
    </TweaksPanel>
  );
};

// Mount
const App = () => (
  <>
    <TakedownCanvas />
    <TweaksContent />
  </>
);

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