import type { Metadata } from "next";
import Link from "next/link";
import styles from "./privacy.module.css";
import { DISCORD_INVITE_URL, SITE_NAME } from "@/lib/constants";

export const metadata: Metadata = {
  title: "Privacy Notice & Data Policy | sinss.lol",
  description: "Learn how sinss.lol collects, protects, and stores account data, cookies, and security signals.",
  alternates: { canonical: "/privacy" },
};

export default function PrivacyPage() {
  return (
    <main className={styles.privacyPage}>
      <div className={styles.privacyShell}>
        <header className={styles.privacyTopbar}>
          <Link className={styles.privacyBrand} href="/" aria-label={`${SITE_NAME} home`}>
            {/* eslint-disable-next-line @next/next/no-img-element */}
            <img src="/addons/logo.svg" alt="" width={24} height={24} />
            <span>{SITE_NAME}</span>
          </Link>
          <Link className={styles.privacyHome} href="/">Back to home</Link>
        </header>

        <section className={styles.privacyHero} aria-labelledby="privacy-title">
          <div className={styles.privacyEyebrow}>Account and data</div>
          <h1 id="privacy-title">Privacy Notice</h1>
          <p className={styles.privacyLead}>
            A transparent guide to how {SITE_NAME} collects, safeguards, and processes personal information, security signals, and your privacy rights.
          </p>
        </section>

        <div className={styles.privacyLayout}>
          <article className={styles.privacyArticle}>
            <section className={styles.privacySection} id="security-signals">
              <p className={styles.privacySectionLabel}>01 / Collection</p>
              <h2>Information we collect</h2>
              <p>
                When you create an account and configure your bio link on {SITE_NAME}, we collect the following necessary information:
              </p>
              <ul className={styles.privacyRules} style={{ marginTop: 12 }}>
                <li><strong>Account details:</strong> Email address, hashed password, username, display name, and linked third-party IDs (such as Discord user ID and avatar when linked).</li>
                <li><strong>Profile data:</strong> Custom bios, links, badges, audio tracks, themes, and images you deliberately upload to your public profile.</li>
                <li><strong>Security signals:</strong> To prevent brute-force attacks, multi-account spam, and fraud, we associate signed-in accounts with a random browser ID in an HttpOnly cookie and store a one-way keyed HMAC hash of the IP address. We never store raw IP addresses in permanent telemetry records.</li>
              </ul>
              <div className={styles.privacyCallout} style={{ marginTop: 16 }}>
                We never sell, rent, or monetize your personal information or browsing history to third-party data brokers or advertising networks.
              </div>
            </section>

            <section className={styles.privacySection} id="access-retention">
              <p className={styles.privacySectionLabel}>02 / Safeguards</p>
              <h2>Access and retention</h2>
              <p>
                Account signals and security logs are accessible exclusively to authorized site administrators strictly for moderation and fraud prevention purposes.
              </p>
              <p>
                Security signals and anti-alt indicators are automatically purged from active storage on a rolling 90-day retention schedule.
              </p>
            </section>

            <section className={styles.privacySection} id="moderation-records">
              <p className={styles.privacySectionLabel}>03 / Moderation</p>
              <h2>Moderation records</h2>
              <p>
                When an administrator takes action on an account (such as a warning, temporary suspension, or permanent ban), the reason, timestamp, and action type are recorded in an internal audit trail. These records are retained to maintain platform safety and enforce bans against repeat bad actors.
              </p>
            </section>

            <section className={styles.privacySection} id="childrens-privacy">
              <p className={styles.privacySectionLabel}>04 / Minors</p>
              <h2>Children&apos;s privacy (COPPA)</h2>
              <p>
                {SITE_NAME} is strictly directed to users aged 13 and older (or 16 in the European Economic Area). We do not knowingly collect personal data from children under 13.
              </p>
              <p>
                If we discover that a user under 13 has created an account, we will immediately take steps to permanently delete their account and associated data. If you believe a minor under 13 has registered, contact us at{" "}
                <a href="mailto:legal@sinss.lol" style={{ color: "var(--privacy-mint)", textDecoration: "underline" }}>
                  legal@sinss.lol
                </a>.
              </p>
            </section>

            <section className={styles.privacySection} id="your-controls">
              <p className={styles.privacySectionLabel}>05 / Your choices</p>
              <h2>Data rights and controls (GDPR / CCPA)</h2>
              <p>
                Depending on your jurisdiction, you have the right to request access to your personal data, request a machine-readable export, or request the permanent erasure of your account and profile data (&quot;Right to be Forgotten&quot;).
              </p>
              <p>
                To exercise any of these rights, email us at{" "}
                <a href="mailto:legal@sinss.lol" style={{ color: "var(--privacy-mint)", textDecoration: "underline" }}>
                  legal@sinss.lol
                </a>{" "}
                or open a support ticket in our{" "}
                <a href={DISCORD_INVITE_URL} target="_blank" rel="noreferrer" style={{ color: "var(--privacy-mint)", textDecoration: "underline" }}>
                  Discord server
                </a>. Requests are verified and processed within 30 days.
              </p>
            </section>
          </article>

          <aside className={styles.privacyContents} aria-label="On this page">
            <p className={styles.privacyContentsTitle}>On this page</p>
            <nav>
              <a href="#security-signals">Information we collect</a>
              <a href="#access-retention">Access and retention</a>
              <a href="#moderation-records">Moderation records</a>
              <a href="#childrens-privacy">Children&apos;s privacy</a>
              <a href="#your-controls">Data rights & controls</a>
            </nav>
          </aside>
        </div>

        <footer className={styles.privacyFooter}>
          <span>{SITE_NAME} · Privacy Notice</span>
          <Link href="/terms">Terms of Service</Link>
        </footer>
      </div>
    </main>
  );
}
