---
import DefaultLayout from '@/layouts/DefaultLayout.astro';

type Project = {
  title: string;
  faculty: string;
  sponsor: string;
  category: string;
  period: string;
  source: string;
};

type GrantAnnouncement = {
  scheme: string;
  faculty: string;
  title: string;
  coPi?: string;
};

const projects: Project[] = [
  {
    title: 'Approximate Shortest Paths in Graphs',
    faculty: 'Manoj D Gupta',
    sponsor: 'Anusandhan National Research Foundation',
    category: 'ANRF/SERB',
    period: 'July-September 2026',
    source: 'https://iitgn.ac.in/newsletter/projects/q3_2026',
  },
  {
    title: 'Chitrabhasha: Developing India\'s Largest Dataset and Foundation Models for Multimodal AI',
    faculty: 'Mayank Singh',
    sponsor: 'Anusandhan National Research Foundation',
    category: 'ANRF/SERB',
    period: 'July-September 2026',
    source: 'https://iitgn.ac.in/newsletter/projects/q3_2026',
  },
  {
    title: 'Scalable Detection of Brick Kilns from Low-Resolution Satellite Imagery for Environmental Compliance',
    faculty: 'Nipun Batra',
    sponsor: 'Anusandhan National Research Foundation',
    category: 'ANRF/SERB',
    period: 'Announced in 2026',
    source: 'https://www.linkedin.com/school/indian-institute-of-technology-gandhinagar-iitgn-/posts/',
  },
  {
    title: 'iGazeBuddy: Multimodal gaze-controlled learning system for dyslexia support',
    faculty: 'Yogesh Kumar Meena',
    sponsor: 'Anusandhan National Research Foundation (PMECRG)',
    category: 'ANRF/SERB',
    period: 'Announced in 2026',
    source: 'https://www.linkedin.com/posts/ykmeena_hiring-research-assistivetechnology-activity-7406640584490336256-wDnH',
  },
  {
    title: 'Fair Federated Learning Framework in the Presence of Heterogeneous, Strategic, and Malicious Clients',
    faculty: 'Manisha Padala',
    sponsor: 'Anusandhan National Research Foundation (ECRG)',
    category: 'ANRF/SERB',
    period: 'April-June 2026',
    source: 'https://iitgn.ac.in/newsletter/projects/q2_2026',
  },
  {
    title: 'Understanding and Ensuring the Privacy of User Data',
    faculty: 'Abhishek Bichhawat',
    sponsor: 'Science & Engineering Research Board',
    category: 'ANRF/SERB',
    period: 'October-December 2023',
    source: 'https://iitgn.ac.in/newsletter/projects/q4_2023',
  },
  {
    title: 'Curating and constructing benchmarks and development of ML models for low-level NLP tasks in Hindi-English code-mixing',
    faculty: 'Mayank Singh',
    sponsor: 'Science & Engineering Research Board (Core Research Grant)',
    category: 'ANRF/SERB',
    period: 'January-March 2023',
    source: 'https://iitgn.ac.in/newsletter/projects/q1_2023',
  },
  {
    title: 'Verifying Security Properties of Group Messaging Protocols',
    faculty: 'Abhishek Bichhawat',
    sponsor: 'Centre Franco-Indien pour la Promotion de la Recherche Avancee',
    category: 'International',
    period: 'October-December 2023',
    source: 'https://iitgn.ac.in/newsletter/projects/q4_2023',
  },
  {
    title: 'A Brain-Computer Interface Driven Mental Fatigue Monitoring System to Improve Stroke Rehabilitation Therapy',
    faculty: 'Yogesh Kumar Meena',
    sponsor: 'Department for the Economy, Northern Ireland',
    category: 'International',
    period: 'October-December 2024',
    source: 'https://iitgn.ac.in/newsletter/projects/q4_2024',
  },
  {
    title: 'Microsoft Research PhD Fellowship for Zeel B Patel',
    faculty: 'Nipun Batra',
    sponsor: 'Microsoft Research Lab India Private Ltd',
    category: 'Industry/Research Lab',
    period: 'July-September 2024',
    source: 'https://iitgn.ac.in/newsletter/projects/q3_2024',
  },
  {
    title: 'Automated Crop mapping using time-series satellite and ancillary data',
    faculty: 'Nipun Batra',
    sponsor: 'Indian Space Research Organisation',
    category: 'Sponsored',
    period: 'April-June 2026',
    source: 'https://iitgn.ac.in/newsletter/projects/q2_2026',
  },
  {
    title: 'Specialized language models deployable on end points with low compute resources',
    faculty: 'Anirban Dasgupta',
    sponsor: 'Indian Space Research Organisation',
    category: 'Sponsored',
    period: 'July-September 2026',
    source: 'https://iitgn.ac.in/newsletter/projects/q3_2026',
  },
  {
    title: 'Development of Quantum Machine Learning Use Cases and Applications',
    faculty: 'Sameer G Kulkarni',
    sponsor: 'Ministry of Electronics and Information Technology (MeitY)',
    category: 'Sponsored',
    period: 'October-December 2024',
    source: 'https://iitgn.ac.in/newsletter/projects/q4_2024',
  },
  {
    title: 'exploreCSR: Bridging Digital Divides Through Computing',
    faculty: 'Nipun Batra',
    sponsor: 'Google',
    category: 'Sponsored',
    period: 'October-December 2024',
    source: 'https://iitgn.ac.in/newsletter/projects/q4_2024',
  },
  {
    title: 'How smart roads are different from conventional city roads and have brought ease of mobility to Indian cities?',
    faculty: 'Mayank Singh',
    sponsor: 'Ministry of Housing and Urban Affairs',
    category: 'Consultancy',
    period: 'January-March 2026',
    source: 'https://iitgn.ac.in/newsletter/projects/q1_2026',
  },
  {
    title: 'Development of Large Language Models based Chat plugin for Answering Website-specific Queries',
    faculty: 'Mayank Singh',
    sponsor: 'Silver Touch Technologies Limited',
    category: 'Consultancy',
    period: 'July-September 2023',
    source: 'https://iitgn.ac.in/newsletter/projects/q3_2023',
  },
];

const categories = ['ANRF/SERB', 'International', 'Sponsored', 'Industry/Research Lab', 'Consultancy'];

const recentGrantAnnouncements: GrantAnnouncement[] = [
  {
    scheme: 'Prime Minister Early Career Research Grant (PMECRG)',
    faculty: 'Manisha Padala',
    title:
      'Fair Federated Learning Framework in the Presence of Heterogeneous, Strategic, and Malicious Clients',
  },
  {
    scheme: 'Prime Minister Early Career Research Grant (PMECRG)',
    faculty: 'Shouvick Mondal',
    title:
      'Testing of Pre-trained Large Language Models for Zero-shot Software Engineering Tasks',
  },
  {
    scheme: 'Advanced Research Grant (ARG)',
    faculty: 'Mayank Singh',
    title:
      'Chitrabhasha: Developing India\'s Largest Dataset and Foundation Models for Multimodal AI',
  },
  {
    scheme: 'Prime Minister Early Career Research Grant (PMECRG)',
    faculty: 'Yogesh Kumar Meena',
    title:
      'iGazeBuddy: Multimodal Gaze-Controlled On-Screen Assisted Learning System for Dyslexia Detection and Intervention in Regional Indian Languages',
  },
  {
    scheme: 'Advanced Research Grant (ARG)',
    faculty: 'Nipun Batra',
    title:
      'Scalable Detection of Brick Kilns from Low-Resolution Satellite Imagery for Environmental Compliance',
  },
  {
    scheme: 'Advanced Research Grant (ARG) MATRICS',
    faculty: 'Bireswar Das',
    title: 'Quantum Algorithms for Group Theoretic Problems',
  },
  {
    scheme: 'Advanced Research Grant (ARG) MATRICS',
    faculty: 'Balagopal Komarath',
    title:
      'On the Role of Multilinearity and Monotonicity in Algebraic Computation',
  },
  {
    scheme: 'Advanced Research Grant (ARG)',
    faculty: 'Abhishek Bichhawat',
    coPi: 'Co-PI: Mainak Mondal, IIT Kharagpur',
    title:
      'Towards a Private yet Functional Web: Designing a Usable and Privacy-compliant Consent Management Framework for Online Browsing',
  },
  {
    scheme: 'Advanced Research Grant (ARG) MATRICS',
    faculty: 'Manoj Gupta',
    title: 'Approximate Shortest Paths in Graphs',
  },
];
---

<DefaultLayout title="Projects" description="Funded research projects, collaborations, and consultancies.">
  <section class="border-b bg-muted/40">
    <div class="container py-14 md:py-18">
      <p class="text-sm font-medium text-secondary">
        Department of Computer Science &amp; Engineering, IIT Gandhinagar
      </p>
      <div class="mt-5 max-w-3xl">
        <h1 class="text-3xl font-semibold leading-tight md:text-5xl">
          Projects and consultancies
        </h1>
        <p class="mt-5 text-lg leading-relaxed text-muted-foreground">
          Selected publicly listed sponsored projects, international
          collaborations, industry engagements, and consultancies involving CSE
          faculty and affiliated faculty.
        </p>
      </div>
    </div>
  </section>

  <section class="section-padding">
    <div class="container">
      <div class="rounded-lg border border-border bg-muted/30 p-5">
        <div class="max-w-3xl">
          <p class="text-sm font-medium text-secondary">Recent ANRF grants</p>
          <h2 class="mt-2 text-2xl font-semibold">
            CSE faculty members have secured multiple recent ANRF grants in the latest cycle
          </h2>
        </div>
        <div class="mt-5 grid gap-4 md:grid-cols-3">
          {
            recentGrantAnnouncements.map((grant) => (
              <article class="rounded-lg border bg-background p-4">
                <p class="text-sm font-medium text-secondary">{grant.scheme}</p>
                <h3 class="mt-3 text-lg font-semibold">{grant.title}</h3>
                <p class="mt-3 text-sm font-medium">PI: {grant.faculty}</p>
                {grant.coPi && (
                  <p class="mt-1 text-xs text-muted-foreground">{grant.coPi}</p>
                )}
              </article>
            ))
          }
        </div>
      </div>

      <div class="mt-8 flex flex-wrap items-center gap-2" aria-label="Filter projects by category">
        <button
          type="button"
          class="rounded-full border bg-background px-3 py-1 text-sm text-muted-foreground transition-colors hover:border-primary hover:text-foreground data-[active=true]:border-primary data-[active=true]:bg-primary data-[active=true]:text-primary-foreground"
          data-project-filter="all"
          data-active="true"
          aria-pressed="true"
        >
          All
        </button>
        {
          categories.map((category) => (
            <button
              type="button"
              class="rounded-full border bg-background px-3 py-1 text-sm text-muted-foreground transition-colors hover:border-primary hover:text-foreground data-[active=true]:border-primary data-[active=true]:bg-primary data-[active=true]:text-primary-foreground"
              data-project-filter={category}
              data-active="false"
              aria-pressed="false"
            >
              {category}
            </button>
          ))
        }
      </div>

      <div class="mt-10 flex flex-col gap-2 sm:flex-row sm:items-end sm:justify-between">
        <h2 class="text-2xl font-semibold">Selected project listings</h2>
        <p
          class="text-sm text-muted-foreground"
          data-project-filter-count
          aria-live="polite"
        >
          {projects.length} selected projects
        </p>
      </div>

      <div class="mt-5 grid gap-4 md:grid-cols-2">
        {
          projects.map((project) => (
            <article
              class="rounded-lg border border-border bg-card p-5 shadow-sm"
              data-project-card
              data-project-category={project.category}
            >
              <div class="flex flex-wrap items-center gap-2">
                <span class="rounded-full bg-secondary/10 px-3 py-1 text-xs font-medium text-secondary">
                  {project.category}
                </span>
                <span class="text-xs text-muted-foreground">{project.period}</span>
              </div>
              <h2 class="mt-4 text-xl font-semibold">{project.title}</h2>
              <dl class="mt-4 space-y-3 text-sm">
                <div>
                  <dt class="font-medium">Faculty</dt>
                  <dd class="mt-1 text-muted-foreground">{project.faculty}</dd>
                </div>
                <div>
                  <dt class="font-medium">Agency / partner</dt>
                  <dd class="mt-1 text-muted-foreground">{project.sponsor}</dd>
                </div>
              </dl>
            </article>
          ))
        }
      </div>
    </div>
  </section>

  <script>
    const filterButtons = document.querySelectorAll('[data-project-filter]');
    const projectCards = document.querySelectorAll('[data-project-card]');
    const projectCount = document.querySelector('[data-project-filter-count]');

    function applyProjectFilter(filter) {
      let visibleCount = 0;

      projectCards.forEach((card) => {
        const isVisible =
          filter === 'all' || card.dataset.projectCategory === filter;
        card.toggleAttribute('hidden', !isVisible);
        if (isVisible) visibleCount += 1;
      });

      filterButtons.forEach((button) => {
        const isActive = button.dataset.projectFilter === filter;
        button.dataset.active = String(isActive);
        button.setAttribute('aria-pressed', String(isActive));
      });

      if (projectCount) {
        projectCount.textContent = `${visibleCount} selected project${visibleCount === 1 ? '' : 's'}`;
      }
    }

    filterButtons.forEach((button) => {
      button.addEventListener('click', () => {
        applyProjectFilter(button.dataset.projectFilter || 'all');
      });
    });
  </script>
</DefaultLayout>
