;; ---------------------------------------------------------------------------
;; Social Sharing
;; ---------------------------------------------------------------------------

(defcomp ()
  (~docs/page :title "Social Network Sharing"

    (~docs/section :title "Context" :id "context"
      (p "Rose Ash already has ActivityPub for federated social sharing. This plan adds OAuth-based sharing to mainstream social networks — Facebook, Instagram, Threads, Twitter/X, LinkedIn, and Mastodon.")
      (p "All social logic lives in the " (strong "account") " microservice. Content apps get a share button that opens the account share page."))

    (~docs/section :title "What remains" :id "remains"
      (~docs/note "Nothing has been implemented. This is the full scope of work.")

      (div (~tw :tokens "space-y-4")

        (div (~tw :tokens "rounded border border-stone-200 p-4")
          (h4 (~tw :tokens "font-semibold text-stone-700 mb-2") "Phase 1: Data Model + Encryption")
          (ul (~tw :tokens "list-disc pl-5 text-stone-700 space-y-1 text-sm")
            (li (code "shared/models/social_connection.py") " — SocialConnection model (user_id, platform, tokens, scopes, extra_data)")
            (li (code "shared/infrastructure/social_crypto.py") " — Fernet encrypt/decrypt for tokens")
            (li "Alembic migration for social_connections table")
            (li "Environment variables for per-platform OAuth credentials")))

        (div (~tw :tokens "rounded border border-stone-200 p-4")
          (h4 (~tw :tokens "font-semibold text-stone-700 mb-2") "Phase 2: Platform OAuth Clients")
          (p (~tw :tokens "text-sm text-stone-600 mb-2") "All in " (code "account/services/social_platforms/") ":")
          (ul (~tw :tokens "list-disc pl-5 text-stone-700 space-y-1 text-sm")
            (li (code "base.py") " — SocialPlatform ABC, OAuthResult, ShareResult")
            (li (code "meta.py") " — Facebook + Instagram + Threads (Graph API)")
            (li (code "twitter.py") " — OAuth 2.0 with PKCE")
            (li (code "linkedin.py") " — LinkedIn Posts API")
            (li (code "mastodon.py") " — Dynamic app registration per instance")))

        (div (~tw :tokens "rounded border border-stone-200 p-4")
          (h4 (~tw :tokens "font-semibold text-stone-700 mb-2") "Phase 3: Account Blueprint")
          (ul (~tw :tokens "list-disc pl-5 text-stone-700 space-y-1 text-sm")
            (li (code "account/bp/social/routes.py") " — /social/ list, /social/connect/<platform>/, /social/callback/<platform>/, /social/share/")
            (li "Register before account blueprint (account has catch-all /<slug>/ route)")))

        (div (~tw :tokens "rounded border border-stone-200 p-4")
          (h4 (~tw :tokens "font-semibold text-stone-700 mb-2") "Phase 4: Templates")
          (ul (~tw :tokens "list-disc pl-5 text-stone-700 space-y-1 text-sm")
            (li "Social panel — platform cards, connect/disconnect")
            (li "Share panel — content preview, account checkboxes, share button")
            (li "Share result — per-platform success/failure with links")))

        (div (~tw :tokens "rounded border border-stone-200 p-4")
          (h4 (~tw :tokens "font-semibold text-stone-700 mb-2") "Phase 5: Share Button in Content Apps")
          (ul (~tw :tokens "list-disc pl-5 text-stone-700 space-y-1 text-sm")
            (li "share-button fragment from account service")
            (li "Blog, events, market detail pages fetch and render the fragment")))

        (div (~tw :tokens "rounded border border-stone-200 p-4")
          (h4 (~tw :tokens "font-semibold text-stone-700 mb-2") "Phase 6: Token Refresh + Share History")
          (ul (~tw :tokens "list-disc pl-5 text-stone-700 space-y-1 text-sm")
            (li "Automatic token refresh before posting")
            (li "Optional social_shares table for history and duplicate prevention")))))))

;; ---------------------------------------------------------------------------
;; Isomorphic Architecture Roadmap
;; ---------------------------------------------------------------------------
