/*
  page.tsx
  spboucher.ai Web
  Author: Simon-Pierre Boucher
  Mail: contact@spboucher.ai
*/

import type { Metadata } from "next";
import Link from "next/link";
import {
  ArrowUpRight,
  BookOpenCheck,
  ExternalLink,
  FileText,
  FlaskConical,
  Github,
  GraduationCap,
  Mic,
  ScrollText,
} from "lucide-react";

import { Badge } from "@/components/ui/badge";
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card";
import { PillLink } from "@/components/pill-link";
import { Reveal } from "@/components/reveal";
import { SectionHeading } from "@/components/section-heading";
import { thesisChapters, uqoWorkingPapers } from "@/lib/research";

export const metadata: Metadata = {
  title: "Research",
  description:
    "Publications, working papers, and conference presentations by Simon-Pierre Boucher — financial econometrics, commodity markets, monetary policy, and high-frequency finance.",
};

const workingPapers = [
  {
    title:
      "Has Financialization Changed the Impact of Macro Announcements on U.S. Commodity Markets?",
    venue: "SSRN Working Paper",
    date: "May 2022",
    link: "https://ssrn.com/abstract=400929",
  },
  {
    title:
      "Modelling Volatility Dynamics Between Commodity ETFs and Their Net Asset Value using BVAR and HAR Models",
    venue: "Working Paper",
    date: "January 2023",
  },
  {
    title:
      "Returns and Volatility Around FOMC Announcements: A High-Frequency Analysis of Policy Tone and Novelty",
    venue: "Working Paper",
    date: "November 2023",
  },
];

const presentations = [
  { event: "CRREP Research Day", detail: "2022, 2023" },
  {
    event: "Canadian Economics Association — 61st & 62nd Annual Conferences",
    detail: "2022, 2023",
  },
  {
    event: "7th Winter Workshop on Commodity Markets",
    detail: "Mont-Tremblant, 2024",
  },
];

export default function ResearchPage() {
  return (
    <div className="mx-auto max-w-5xl px-4 py-16 sm:px-6">
      <Reveal>
        <SectionHeading
          as="h1"
          eyebrow="Publications & Papers"
          title="Research"
          icon={FlaskConical}
          description="Financial econometrics, commodity markets, monetary policy announcements, high-frequency finance, volatility modelling, textual analysis, and financialization."
        />
      </Reveal>

      {/* Publication */}
      <section className="mt-12">
        <Reveal>
          <SectionHeading title="Publication" icon={BookOpenCheck} />
          <Card className="mt-4">
            <CardHeader>
              <Badge className="w-fit">The Energy Journal · 2025</Badge>
              <CardTitle className="text-lg leading-snug">
                Speculative Trading in Energy Markets: Evidence from
                Macroeconomic Surprises
              </CardTitle>
              <CardDescription>
                Boucher, S.-P., Gagnon, M.-H., &amp; Power, G. J. (2025)
              </CardDescription>
            </CardHeader>
            <CardContent>
              <Link
                href="/research/chapter-1"
                className="inline-flex items-center gap-1.5 rounded-[0.5rem] bg-foreground px-3 py-1.5 text-xs font-medium text-background shadow-[var(--shadow-soft)] transition-all hover:-translate-y-px hover:bg-foreground/85"
              >
                <ArrowUpRight className="h-3.5 w-3.5" aria-hidden="true" />
                Details
              </Link>
            </CardContent>
          </Card>
        </Reveal>
      </section>

      {/* PhD thesis */}
      <section className="mt-12">
        <Reveal>
          <SectionHeading title="PhD Thesis" icon={GraduationCap} />
          <p className="mt-3 max-w-3xl text-sm text-muted-foreground">
            <em>
              Three Essays on High-Frequency Return and Volatility Dynamics in
              Commodities and Financial Futures Markets
            </em>{" "}
            — doctoral thesis by articles, Université Laval (188 pages).
            Co-authors: Marie-Hélène Gagnon &amp; Gabriel J. Power.
          </p>
          <div className="mt-4 flex flex-wrap gap-2">
            <PillLink
              href="https://git.spboucher.ai/phd_thesis/blob/main/these-ulaval/main.pdf"
              icon={FileText}
            >
              Full thesis (PDF)
            </PillLink>
            <PillLink
              href="https://git.spboucher.ai/phd_thesis"
              icon={Github}
            >
              GitHub repository
            </PillLink>
          </div>
        </Reveal>
        <div className="mt-4 space-y-4">
          {thesisChapters.map((chapter, i) => (
            <Reveal key={chapter.num} delay={i * 0.08}>
              <Card>
                <CardHeader>
                  <Badge variant="secondary" className="w-fit">
                    {chapter.num} · {chapter.status}
                  </Badge>
                  <CardTitle className="text-lg leading-snug">
                    {chapter.title}
                  </CardTitle>
                </CardHeader>
                <CardContent className="flex flex-wrap gap-2">
                  <Link
                    href={`/research/${chapter.slug}`}
                    className="inline-flex items-center gap-1.5 rounded-[0.5rem] bg-foreground px-3 py-1.5 text-xs font-medium text-background shadow-[var(--shadow-soft)] transition-all hover:-translate-y-px hover:bg-foreground/85"
                  >
                    <ArrowUpRight className="h-3.5 w-3.5" aria-hidden="true" />
                    Details
                  </Link>
                  <PillLink href={chapter.pdf} icon={FileText}>
                    Paper PDF
                  </PillLink>
                  <PillLink href={chapter.source!} icon={Github}>
                    LaTeX source
                  </PillLink>
                </CardContent>
              </Card>
            </Reveal>
          ))}
        </div>
      </section>

      {/* UQO working paper series */}
      <section className="mt-12">
        <Reveal>
          <SectionHeading
            title="UQO Working Paper Series"
            icon={ScrollText}
            description="Applied econometrics research produced at the Département des sciences administratives, UQO — hedonic pricing, housing markets, and derivatives. Each paper is backed by a fully reproducible pipeline."
          />
        </Reveal>
        <div className="mt-4 space-y-4">
          {uqoWorkingPapers.map((paper, i) => (
            <Reveal key={paper.num} delay={i * 0.08}>
              <Card>
                <CardHeader>
                  <Badge variant="secondary" className="w-fit">
                    {paper.num} · {paper.pages}
                  </Badge>
                  <CardTitle className="text-lg leading-snug">
                    {paper.title}
                  </CardTitle>
                  <CardDescription>{paper.description}</CardDescription>
                </CardHeader>
                <CardContent className="flex flex-wrap gap-2">
                  <Link
                    href={`/research/${paper.slug}`}
                    className="inline-flex items-center gap-1.5 rounded-[0.5rem] bg-foreground px-3 py-1.5 text-xs font-medium text-background shadow-[var(--shadow-soft)] transition-all hover:-translate-y-px hover:bg-foreground/85"
                  >
                    <ArrowUpRight className="h-3.5 w-3.5" aria-hidden="true" />
                    Details
                  </Link>
                  <PillLink href={paper.pdf} icon={FileText}>
                    Paper PDF
                  </PillLink>
                  {paper.repo && (
                    <PillLink href={paper.repo} icon={Github}>
                      Code &amp; data repository
                    </PillLink>
                  )}
                </CardContent>
              </Card>
            </Reveal>
          ))}
        </div>
      </section>

      {/* Working papers */}
      <section className="mt-12">
        <Reveal>
          <SectionHeading title="Earlier Working Papers" icon={FlaskConical} />
        </Reveal>
        <div className="mt-4 space-y-4">
          {workingPapers.map((paper, i) => (
            <Reveal key={paper.title} delay={i * 0.08}>
              <Card>
                <CardHeader>
                  <Badge variant="secondary" className="w-fit">
                    {paper.venue} · {paper.date}
                  </Badge>
                  <CardTitle className="text-lg leading-snug">
                    {paper.title}
                  </CardTitle>
                </CardHeader>
                {paper.link && (
                  <CardContent>
                    <PillLink href={paper.link} icon={ExternalLink}>
                      View on SSRN
                    </PillLink>
                  </CardContent>
                )}
              </Card>
            </Reveal>
          ))}
        </div>
      </section>

      {/* Presentations */}
      <section className="mt-12">
        <Reveal>
          <SectionHeading title="Conference Presentations" icon={Mic} />
        </Reveal>
        <div className="mt-4 grid gap-4 sm:grid-cols-3">
          {presentations.map((p, i) => (
            <Reveal key={p.event} delay={i * 0.08}>
              <Card className="h-full hover:-translate-y-1 hover:shadow-[var(--shadow-lift)]">
                <CardHeader>
                  <CardTitle className="text-base leading-snug">
                    {p.event}
                  </CardTitle>
                  <CardDescription>{p.detail}</CardDescription>
                </CardHeader>
              </Card>
            </Reveal>
          ))}
        </div>
      </section>
    </div>
  );
}
