{% extends "core/base.html" %}
{% load static %}

{% block title %}Archives Projets - Portfolio{% endblock %}

{% block extra_css %}
<style>
/* ===== VARIABLES CYBERPUNK HARDCORE ===== */
:root {
  --cyber-yellow: #fcee0a;
  --neon-cyan: #00f3ff;
  --neon-blue: #0099ff;
  --cyber-red: #ff003c;
  --electric-blue: #00d4ff;
  --dark-bg: #0a0a0f;
  --card-bg: rgba(15, 15, 25, 0.95);
  --border-glow: rgba(0, 243, 255, 0.4);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --technical-gray: #8b8b8b;
}

/* ===== FIX SCROLL HORIZONTAL ===== */
html,
body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

* {
  box-sizing: border-box;
}

.container {
  max-width: 100%;
  overflow-x: hidden;
}

/* ===== BACKGROUND TECHNIQUE ===== */
body {
  background: #0a0a0f;
  min-height: 100vh;
  position: relative;
}

/* Grille technique agressive */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(rgba(252, 238, 10, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 243, 255, 0.03) 1px, transparent 1px);
  background-size: 30px 30px;
  pointer-events: none;
  z-index: 0;
  animation: grid-drift 20s linear infinite;
}

@keyframes grid-drift {
  0% { transform: translate(0, 0); }
  100% { transform: translate(30px, 30px); }
}

/* Scanlines CRT hardcore */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(252, 238, 10, 0.02) 0px,
    transparent 1px,
    transparent 2px,
    rgba(252, 238, 10, 0.02) 3px
  );
  pointer-events: none;
  z-index: 0;
  animation: scanlines-move 8s linear infinite;
}

@keyframes scanlines-move {
  0% { transform: translateY(0); }
  100% { transform: translateY(3px); }
}

/* ===== TERMINAL HEADER - ARASAKA STYLE ===== */
.page-header {
  text-align: center;
  padding: 3rem 0 2rem;
  position: relative;
  z-index: 1;
  background: linear-gradient(180deg, rgba(252, 238, 10, 0.03), transparent);
  border-bottom: 2px solid rgba(252, 238, 10, 0.3);
  overflow: hidden;
}

/* Texture scanline locale */
.page-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    180deg,
    transparent 0px,
    rgba(0, 243, 255, 0.03) 2px,
    transparent 4px
  );
  pointer-events: none;
  animation: header-scan 3s linear infinite;
}

@keyframes header-scan {
  0% { transform: translateY(0); opacity: 0.3; }
  50% { opacity: 0.5; }
  100% { transform: translateY(4px); opacity: 0.3; }
}

/* HUD décoratif */
.page-header::after {
  content: '';
  position: absolute;
  top: 20px;
  right: 40px;
  width: 150px;
  height: 150px;
  border: 1px solid var(--cyber-yellow);
  clip-path: polygon(0 0, 100% 0, 100% 80%, 80% 100%, 0 100%);
  opacity: 0.15;
  animation: hud-rotate 8s linear infinite;
}

@keyframes hud-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Conteneur du titre avec éléments techniques */
.page-title-container {
  position: relative;
  display: inline-block;
  padding: 1.5rem 3rem;
}

/* Brackets techniques */
.page-title-container::before {
  content: '[ SYSTEM ONLINE ]';
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: var(--cyber-yellow);
  font-family: 'Courier New', monospace;
  letter-spacing: 3px;
  font-weight: 700;
}

.page-title-container::after {
  content: '[ v.2.0.77 // ACCESS LEVEL: PUBLIC ]';
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  color: var(--technical-gray);
  font-family: 'Courier New', monospace;
  letter-spacing: 2px;
  font-weight: 400;
}

.page-title {
  font-size: clamp(2.5rem, 6vw, 5rem);
  font-weight: 900;
  background: linear-gradient(135deg, var(--cyber-yellow) 0%, var(--neon-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-transform: uppercase;
  letter-spacing: 8px;
  margin: 0;
  position: relative;
  z-index: 1;
  animation: title-glitch-hardcore 4s infinite;
  filter: drop-shadow(0 0 20px rgba(252, 238, 10, 0.5));
}

@keyframes title-glitch-hardcore {
  0%, 90%, 100% { 
    text-shadow: none;
    transform: skew(0deg);
  }
  91% { 
    text-shadow: 
      -4px 0 var(--cyber-red),
      4px 0 var(--neon-cyan),
      -2px 2px var(--cyber-yellow);
    transform: skew(2deg) translateX(-3px);
  }
  93% { 
    text-shadow: 
      4px 0 var(--cyber-red),
      -4px 0 var(--neon-cyan),
      2px -2px var(--cyber-yellow);
    transform: skew(-2deg) translateX(3px);
  }
  95% { 
    text-shadow: none;
    transform: skew(0deg);
  }
}

.page-subtitle {
  font-size: 1rem;
  color: var(--technical-gray);
  font-weight: 400;
  letter-spacing: 4px;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
  font-family: 'Courier New', monospace;
  margin-top: 1rem;
}

.page-subtitle::before {
  content: '// ';
  color: var(--cyber-yellow);
}

.page-subtitle::after {
  content: ' //';
  color: var(--cyber-yellow);
}

/* Lignes techniques décoratives */
.tech-line-left,
.tech-line-right {
  position: absolute;
  top: 50%;
  width: 120px;
  height: 2px;
  background: linear-gradient(90deg, var(--cyber-yellow), transparent);
  transform: translateY(-50%);
}

.tech-line-left {
  left: 0;
}

.tech-line-right {
  right: 0;
  background: linear-gradient(270deg, var(--cyber-yellow), transparent);
}

/* ===== ONGLETS ANGULAIRES (FILTERS) ===== */
.filters-bar {
  padding: 2rem 0;
  position: relative;
  z-index: 1;
}

.filters-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyber-yellow), transparent);
  box-shadow: 0 0 10px var(--cyber-yellow);
}

.filters-container {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--cyber-yellow) transparent;
  position: relative;
  padding: 0.5rem 0;
}

.filters-container::-webkit-scrollbar {
  height: 4px;
}

.filters-container::-webkit-scrollbar-track {
  background: rgba(252, 238, 10, 0.05);
}

.filters-container::-webkit-scrollbar-thumb {
  background: var(--cyber-yellow);
  box-shadow: 0 0 8px var(--cyber-yellow);
}

.filters-list {
  display: flex;
  gap: 0.8rem;
  padding: 0.5rem;
  white-space: nowrap;
  justify-content: center;
}

/* Boutons angulaires */
.filter-btn {
  flex: 0 0 auto;
  padding: 0.9rem 2rem;
  background: rgba(0, 243, 255, 0.05);
  border: 2px solid var(--border-glow);
  color: var(--neon-cyan);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-decoration: none;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  font-family: 'Courier New', monospace;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}

.filter-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(252, 238, 10, 0.2), transparent);
  transition: left 0.5s;
}

.filter-btn:hover::before {
  left: 100%;
}

.filter-btn:hover {
  background: rgba(252, 238, 10, 0.1);
  border-color: var(--cyber-yellow);
  color: var(--cyber-yellow);
  box-shadow: 0 0 20px rgba(252, 238, 10, 0.3);
  transform: translateY(-2px);
}

/* État actif JAUNE */
.filter-btn.active {
  background: var(--cyber-yellow);
  border-color: var(--cyber-yellow);
  color: #0a0a0f;
  font-weight: 900;
  box-shadow: 
    0 0 30px rgba(252, 238, 10, 0.6),
    inset 0 0 20px rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.filter-btn.active::after {
  content: '►';
  margin-left: 0.5rem;
  animation: arrow-blink 1s infinite;
}

@keyframes arrow-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== PROJECTS GRID ===== */
.projects-section {
  padding: 2rem 0 5rem;
  position: relative;
  z-index: 1;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2rem;
}

/* ===== DATA CHIP CARDS - ANGULAIRES ===== */
.project-card-wrapper {
  text-decoration: none;
  color: inherit;
  display: block;
  height: 100%;
  position: relative;
}

.project-card {
  background: var(--card-bg);
  border: 2px solid var(--border-glow);
  overflow: hidden;
  backdrop-filter: blur(15px);
  transition: all 0.4s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
  box-shadow: 
    0 10px 40px rgba(0, 0, 0, 0.7),
    inset 0 0 30px rgba(0, 243, 255, 0.03);
  position: relative;
  clip-path: polygon(15px 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%, 0 15px);
  animation: card-glitch-in 0.6s ease both;
}

.project-card-wrapper:nth-child(1) .project-card { animation-delay: 0.05s; }
.project-card-wrapper:nth-child(2) .project-card { animation-delay: 0.1s; }
.project-card-wrapper:nth-child(3) .project-card { animation-delay: 0.15s; }
.project-card-wrapper:nth-child(4) .project-card { animation-delay: 0.2s; }
.project-card-wrapper:nth-child(5) .project-card { animation-delay: 0.25s; }
.project-card-wrapper:nth-child(6) .project-card { animation-delay: 0.3s; }

@keyframes card-glitch-in {
  from {
    opacity: 0;
    transform: translateY(30px);
    filter: blur(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

/* Ligne scan qui traverse */
.project-card::before {
  content: '';
  position: absolute;
  top: -100%;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyber-yellow), transparent);
  box-shadow: 0 0 15px var(--cyber-yellow);
  opacity: 0;
  transition: top 0.8s ease, opacity 0.8s ease;
  z-index: 20;
}

.project-card:hover::before {
  top: 100%;
  opacity: 1;
}

/* Hover effect */
.project-card:hover {
  transform: translateY(-10px);
  border-color: var(--cyber-yellow);
  box-shadow: 
    0 25px 60px rgba(252, 238, 10, 0.3),
    0 0 40px rgba(252, 238, 10, 0.2),
    inset 0 0 50px rgba(252, 238, 10, 0.05);
}

/* MICRO-TEXTES TECHNIQUES */
.card-tech-id {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.65rem;
  color: var(--technical-gray);
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
  z-index: 15;
  opacity: 0.6;
}

.card-tech-secure {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 0.6rem;
  color: var(--neon-cyan);
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
  z-index: 15;
  opacity: 0.7;
  border: 1px solid var(--neon-cyan);
  padding: 2px 6px;
  clip-path: polygon(3px 0, 100% 0, 100% calc(100% - 3px), calc(100% - 3px) 100%, 0 100%, 0 3px);
}

/* ZONE IMAGE */
.card-image-wrapper {
  width: 100%;
  height: 220px;
  overflow: hidden;
  background: #000;
  flex-shrink: 0;
  position: relative;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s ease, filter 0.6s ease;
  filter: brightness(0.8) contrast(1.2) saturate(0.9);
}

.project-card:hover .card-image {
  transform: scale(1.1);
  filter: brightness(0.6) contrast(1.5) grayscale(0.4);
}

/* Overlay dégradé */
.card-image-wrapper::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60%;
  background: linear-gradient(180deg, transparent, rgba(10, 10, 15, 0.95));
  pointer-events: none;
}

/* Badge catégorie angulaire */
.card-category-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 0.4rem 1.2rem;
  background: rgba(0, 243, 255, 0.9);
  border: 1px solid var(--neon-cyan);
  color: #0a0a0f;
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 2px;
  box-shadow: 0 4px 15px rgba(0, 243, 255, 0.5);
  z-index: 10;
  font-family: 'Courier New', monospace;
  clip-path: polygon(4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%, 0 4px);
}

/* Texte "ACCESS GRANTED" au hover */
.card-access-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  color: var(--cyber-yellow);
  font-weight: 900;
  font-family: 'Courier New', monospace;
  letter-spacing: 3px;
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 15;
  text-shadow: 0 0 20px var(--cyber-yellow);
  pointer-events: none;
}

.project-card:hover .card-access-text {
  opacity: 1;
}

/* ZONE CONTENU */
.card-content {
  padding: 1.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  flex-grow: 1;
  position: relative;
}

.card-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.3;
  margin: 0;
  transition: all 0.3s ease;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  z-index: 1;
  font-family: 'Arial', sans-serif;
  letter-spacing: 1px;
}

.project-card:hover .card-title {
  color: var(--cyber-yellow);
  text-shadow: 0 0 15px rgba(252, 238, 10, 0.8);
  transform: translateX(5px);
}

.card-summary {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
  flex-grow: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  z-index: 1;
}

/* STACK TECHNIQUE */
.card-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(252, 238, 10, 0.2);
  position: relative;
  z-index: 1;
}

.skill-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 243, 255, 0.1);
  border: 2px solid var(--neon-cyan);
  color: var(--neon-cyan);
  font-size: 0.95rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  clip-path: polygon(4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%, 0 4px);
}

.skill-icon:hover {
  background: var(--cyber-yellow);
  border-color: var(--cyber-yellow);
  color: #0a0a0f;
  transform: translateY(-5px) scale(1.1);
  box-shadow: 0 8px 20px rgba(252, 238, 10, 0.5);
}

.skill-icon i {
  position: relative;
  z-index: 1;
}

/* Overlay action */
.card-action-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1.5rem;
  background: linear-gradient(180deg, transparent, rgba(252, 238, 10, 0.1));
  backdrop-filter: blur(10px);
  transform: translateY(100%);
  transition: transform 0.4s ease;
  z-index: 20;
  border-top: 2px solid var(--cyber-yellow);
}

.project-card:hover .card-action-overlay {
  transform: translateY(0);
}

.card-action-btn {
  width: 100%;
  padding: 0.9rem;
  background: var(--cyber-yellow);
  border: 2px solid var(--cyber-yellow);
  color: #0a0a0f;
  font-weight: 900;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  box-shadow: 0 5px 20px rgba(252, 238, 10, 0.5);
  transition: all 0.3s ease;
  font-family: 'Courier New', monospace;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}

.card-action-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(252, 238, 10, 0.7);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 5rem 2rem;
  background: var(--card-bg);
  border: 2px solid var(--border-glow);
  backdrop-filter: blur(15px);
  max-width: 600px;
  margin: 3rem auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  clip-path: polygon(20px 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%, 0 20px);
}

.empty-icon {
  font-size: 5rem;
  color: var(--cyber-yellow);
  opacity: 0.5;
  margin-bottom: 2rem;
  animation: empty-float 3s ease-in-out infinite;
}

@keyframes empty-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

.empty-title {
  font-size: 2rem;
  color: var(--text-primary);
  font-weight: 800;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--cyber-yellow), var(--neon-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.empty-message {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  line-height: 1.7;
}

.empty-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2.5rem;
  background: var(--cyber-yellow);
  border: 2px solid var(--cyber-yellow);
  color: #0a0a0f;
  font-weight: 800;
  text-transform: uppercase;
  text-decoration: none;
  transition: all 0.3s ease;
  box-shadow: 0 8px 25px rgba(252, 238, 10, 0.4);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

.empty-btn:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 35px rgba(252, 238, 10, 0.6);
}

/* ===== PAGINATION ===== */
.pagination-wrapper {
  display: flex;
  justify-content: center;
  padding: 4rem 0 2rem;
}

.pagination {
  display: flex;
  gap: 0.6rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 48px;
  padding: 0.6rem 1rem;
  background: rgba(0, 243, 255, 0.05);
  border: 2px solid var(--border-glow);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  font-family: 'Courier New', monospace;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}

.page-link:hover {
  border-color: var(--cyber-yellow);
  color: var(--cyber-yellow);
  background: rgba(252, 238, 10, 0.1);
  box-shadow: 0 0 20px rgba(252, 238, 10, 0.3);
  transform: translateY(-2px);
}

.page-item.active .page-link {
  background: var(--cyber-yellow);
  border-color: var(--cyber-yellow);
  color: #0a0a0f;
  box-shadow: 0 8px 25px rgba(252, 238, 10, 0.5);
  font-weight: 900;
}

.page-item.disabled .page-link {
  opacity: 0.2;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .projects-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
  }
}

@media (max-width: 991px) {
  .page-header {
    padding: 2.5rem 0 1.5rem;
  }
  
  .page-title {
    font-size: 2.5rem;
    letter-spacing: 4px;
  }
  
  .filters-list {
    justify-content: flex-start;
  }
  
  .projects-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

@media (max-width: 767px) {
  .page-title {
    font-size: 2rem;
    letter-spacing: 3px;
  }
  
  .filter-btn {
    padding: 0.7rem 1.5rem;
    font-size: 0.85rem;
  }
  
  .card-image-wrapper {
    height: 200px;
  }
}

@media (max-width: 576px) {
  .page-title {
    font-size: 1.75rem;
  }
  
  .filter-btn {
    padding: 0.6rem 1.2rem;
  }
  
  .card-image-wrapper {
    height: 180px;
  }
}
</style>
{% endblock %}

{% block content %}

<!-- PAGE HEADER - TERMINAL -->
<section class="page-header">
  <div class="container">
    <div class="page-title-container">
      <h1 class="page-title">ARCHIVES // PROJETS</h1>
    </div>
    <p class="page-subtitle">Base de données des réalisations</p>
    <div class="tech-line-left"></div>
    <div class="tech-line-right"></div>
  </div>
</section>

<!-- FILTERS BAR - ONGLETS ANGULAIRES -->
<section class="filters-bar">
  <div class="container">
    <div class="filters-container">
      <div class="filters-list">
        <a href="{% url 'projects:list' %}" 
           class="filter-btn {% if not active_category %}active{% endif %}">
          TOUT
        </a>
        
        {% for category in categories %}
        <a href="?category={{ category.slug }}" 
           class="filter-btn {% if active_category == category.slug %}active{% endif %}">
          {{ category.name|upper }}
        </a>
        {% endfor %}
      </div>
    </div>
  </div>
</section>

<!-- PROJECTS GRID - DATA CHIPS -->
<section class="projects-section">
  <div class="container">
    
    {% if page_obj %}
    <div class="projects-grid">
      {% for project in page_obj %}
      <a href="{% url 'projects:detail' project.slug %}" class="project-card-wrapper">
        <article class="project-card">
          
          <!-- MICRO-TEXTES TECHNIQUES -->
          <span class="card-tech-id">ID: #{{ forloop.counter|stringformat:"04d" }}</span>
          <span class="card-tech-secure">SECURE</span>
          
          <!-- IMAGE -->
          <div class="card-image-wrapper">
            <img src="{{ project.cover_image.url }}" 
                 alt="{{ project.title }}" 
                 class="card-image"
                 loading="lazy">
            
            <div class="card-access-text">ACCESS GRANTED</div>
            
            {% if project.category %}
            <span class="card-category-badge">{{ project.category.name|upper }}</span>
            {% endif %}
          </div>
          
          <!-- CONTENU -->
          <div class="card-content">
            <h3 class="card-title">{{ project.title }}</h3>
            <p class="card-summary">{{ project.summary }}</p>
            
            {% if project.skills.all %}
            <div class="card-skills">
              {% for skill in project.skills.all|slice:":6" %}
              <span class="skill-icon" title="{{ skill.name }}">
                <i class="{{ skill.icon_class }}"></i>
              </span>
              {% endfor %}
            </div>
            {% endif %}
          </div>
          
          <!-- OVERLAY ACTION -->
          <div class="card-action-overlay">
            <div class="card-action-btn">
              <i class="fa-solid fa-arrow-right"></i>
              ACCÉDER AU PROJET
            </div>
          </div>
          
        </article>
      </a>
      {% endfor %}
    </div>
    
    <!-- PAGINATION -->
    {% if is_paginated %}
    <div class="pagination-wrapper">
      <ul class="pagination">
        
        {% if page_obj.has_previous %}
        <li class="page-item">
          <a href="?{% if active_category %}category={{ active_category }}&{% endif %}page={{ page_obj.previous_page_number }}" 
             class="page-link">
            <i class="fa-solid fa-chevron-left"></i>
          </a>
        </li>
        {% else %}
        <li class="page-item disabled">
          <span class="page-link">
            <i class="fa-solid fa-chevron-left"></i>
          </span>
        </li>
        {% endif %}
        
        {% for num in page_obj.paginator.page_range %}
          {% if page_obj.number == num %}
          <li class="page-item active">
            <span class="page-link">{{ num }}</span>
          </li>
          {% elif num > page_obj.number|add:'-3' and num < page_obj.number|add:'3' %}
          <li class="page-item">
            <a href="?{% if active_category %}category={{ active_category }}&{% endif %}page={{ num }}" 
               class="page-link">{{ num }}</a>
          </li>
          {% endif %}
        {% endfor %}
        
        {% if page_obj.has_next %}
        <li class="page-item">
          <a href="?{% if active_category %}category={{ active_category }}&{% endif %}page={{ page_obj.next_page_number }}" 
             class="page-link">
            <i class="fa-solid fa-chevron-right"></i>
          </a>
        </li>
        {% else %}
        <li class="page-item disabled">
          <span class="page-link">
            <i class="fa-solid fa-chevron-right"></i>
          </span>
        </li>
        {% endif %}
        
      </ul>
    </div>
    {% endif %}
    
    {% else %}
    <!-- EMPTY STATE -->
    <div class="empty-state">
      <div class="empty-icon">
        <i class="fa-solid fa-folder-open"></i>
      </div>
      <h2 class="empty-title">Aucun Projet Trouvé</h2>
      <p class="empty-message">
        {% if active_category %}
        Aucun projet n'est disponible dans cette catégorie pour le moment.
        {% else %}
        Les archives de projets sont actuellement vides.
        {% endif %}
      </p>
      <a href="{% url 'projects:list' %}" class="empty-btn">
        <i class="fa-solid fa-rotate-right"></i>
        Réinitialiser
      </a>
    </div>
    {% endif %}
    
  </div>
</section>

{% endblock %}