/* =========================================
   1. VARIABLES & BASE
   ========================================= */
:root {
  --bg: #0f0f0f;
  --bg-2: #151515;
  --text: #e8e8e8;
  --muted: #b7c2b5;
  --accent: #2f8f4b;     /* Vert style Breaking Bad */
  --accent-2: #8cc63f;   /* Vert plus clair */
  --card: #1a1a1a;
  --border: #2a2a2a;
  --yellow: #caa351;     /* Touche jaune désert */
}

* { box-sizing: border-box; }

html, body {
  margin: 0; 
  padding: 0;
  background: none !important; /* Le fond est géré par le canvas JS */
  color: var(--text);
  font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
  scroll-behavior: smooth;
}

/* Arrière-plan animé (Canvas) */
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1; 
}


/* =========================================
   2. HEADER & NAVIGATION
   ========================================= */
.site-header {
  position: sticky; 
  top: 0; 
  z-index: 999;
  display: flex; 
  align-items: center; 
  justify-content: space-between;
  padding: 12px 20px;
  background: transparent !important;
  backdrop-filter: none !important;
  border: none !important;
  box-shadow: none !important;
}

/* Logo */
.brand { display: flex; align-items: center; gap: 10px; }
.brand a { display: inline-block; }
.brand-logo { height: 120px; width: auto; display: block; }
.brand a:hover img { opacity: 0.85; }

/* Menu */
.nav { display: flex; gap: 14px; flex-wrap: wrap; }
.nav-link {
  color: var(--text); 
  text-decoration: none; 
  padding: 8px 10px; 
  border-radius: 6px;
  transition: background .2s ease, color .2s ease;
  font-weight: 600;
}
.nav-link:hover, .nav-link.active { 
  background: var(--bg-2); 
  color: var(--accent-2); 
}


/* =========================================
   3. HERO SECTION & GENERAL SECTIONS
   ========================================= */
.section { 
  padding: 50px 20px; 
  max-width: 1200px; 
  margin: 0 auto; 
  position: relative; 
}

.section-head { 
  margin-bottom: 2rem; 
  position: relative; 
  z-index: 0; 
}

.section-title {
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.section-desc {
  color: var(--muted);
  max-width: 600px;
}

/* Boutons */
.buttons-row {
  display: flex; gap: 15px; flex-wrap: wrap; margin-top: 20px;
}
.btn {
  display: inline-block; padding: 10px 20px; 
  text-decoration: none; border-radius: 4px; font-weight: 700;
  transition: 0.3s;
}
.btn-outline {
  border: 1px solid var(--accent);
  color: var(--accent);
}
.btn-outline:hover {
  background: var(--accent);
  color: #fff;
}

/* Hero Cleaning */
.hero, .hero-inner {
  background: none !important;
  box-shadow: none !important;
  border: none !important;
  text-align: center;
  padding: 80px 20px;
}
.hero-title {
  font-family: 'Oswald', sans-serif;
  font-size: 4rem;
  text-transform: uppercase;
  margin-bottom: 10px;
}


/* =========================================
   4. SYSTÈME DE GRILLE (AVEC CENTRAGE AUTO)
   ========================================= */
.grid { display: grid; gap: 16px; }

.grid-3 { 
  grid-template-columns: repeat(3, minmax(0, 1fr)); 
  justify-items: stretch; /* S'assure que les cartes prennent la place */
}

/* --- LOGIQUE DE CENTRAGE --- */

/* 1. Sur PC (3 colonnes) : Si le dernier est seul sur une ligne (ex: 4ème, 7ème) */
.grid-3 > :last-child:nth-child(3n + 1) {
  grid-column: 2; /* On le force au milieu */
}

/* 2. Sur Tablette (2 colonnes) */
@media (max-width: 980px) { 
  .grid-3 { 
    grid-template-columns: repeat(2, minmax(0, 1fr)); 
  }
  
  /* Reset de la règle PC */
  .grid-3 > :last-child:nth-child(3n + 1) {
    grid-column: auto;
  }

  /* Si le dernier est impair (seul sur la ligne en mode 2 colonnes) */
  .grid-3 > :last-child:nth-child(odd) {
    grid-column: 1 / -1;   /* Prend toute la largeur */
    max-width: 50%;        /* Reste à la taille d'une carte */
    justify-self: center;  /* Se centre */
    margin: 0 auto;
  }
}

/* 3. Sur Mobile (1 colonne) */
@media (max-width: 640px) { 
  .grid-3 { 
    grid-template-columns: 1fr; 
  }
  /* On annule tout centrage spécial */
  .grid-3 > :last-child:nth-child(odd),
  .grid-3 > :last-child:nth-child(3n + 1) {
    grid-column: auto;
    max-width: none;
  }
}


/* =========================================
   5. CARTES MEMBRES (CORRIGÉES)
   ========================================= */
/* Conteneur principal transparent (Suppression du fond noir) */
.card.member-card { 
  perspective: 1000px; 
  width: 100%; 
  aspect-ratio: 3 / 4; 
  position: relative; 
  background: transparent; 
  border: none;
}

/* Élément rotatif */
.card.member-card .card-inner { 
  position: absolute; 
  inset: 0; 
  width: 100%; height: 100%;
  transition: transform 0.8s; 
  transform-style: preserve-3d; 
}

.card.member-card:hover .card-inner { 
  transform: rotateY(180deg); 
}

/* Configuration commune Faces */
.card.member-card .card-front, 
.card.member-card .card-back { 
  position: absolute; 
  inset: 0; 
  width: 100%; height: 100%;
  backface-visibility: hidden; 
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

/* Face Avant */
.card.member-card .card-front {
  background: var(--card);
}
.card.member-card .card-media img { 
  width: 100%; height: 100%; object-fit: cover; display: block; 
}
.card.member-card .card-body { 
  position: absolute; left: 0; right: 0; bottom: 0; 
  padding: 10px 12px; 
  background: rgba(0,0,0,0.7); 
  color: var(--text); 
  z-index: 2;
}

/* Face Arrière */
.card.member-card .card-back { 
  transform: rotateY(180deg); 
  background: var(--card); /* Fond gris propre */
  color: var(--text);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 20px;
}
.card.member-card .card-back h3 {
    color: var(--accent);
    margin-top: 0;
}


/* =========================================
   6. CARTES HOTLINES
   ========================================= */
.card.hotline-card {
  perspective: 1000px;
  width: 100%;
  aspect-ratio: 3 / 4;
  position: relative;
  border-radius: 12px;
  background: transparent;
}

.card.hotline-card .card-inner {
  position: absolute; inset: 0; width: 100%; height: 100%;
  transition: transform 0.8s;
  transform-style: preserve-3d;
}

.card.hotline-card:hover .card-inner { transform: rotateY(180deg); }

.card.hotline-card .card-front,
.card.hotline-card .card-back {
  position: absolute; inset: 0; width: 100%; height: 100%;
  backface-visibility: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

/* Front Hotline */
.card.hotline-card .card-front { background: var(--card); }
.card.hotline-card .card-media.hotline-media {
  position: absolute; inset: 0; width: 100%; height: 100%;
  background: none;
}
.card.hotline-card .card-media img {
  width: 100%; height: 100%; object-fit: cover;
}
.card.hotline-card .card-body {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 10px 12px;
  background: linear-gradient(0deg, rgba(0,0,0,0.9), transparent);
  z-index: 2;
}

/* Back Hotline */
.card.hotline-card .card-back {
  transform: rotateY(180deg);
  background: var(--card);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}


/* =========================================
   7. PLANNING (STYLE CHIMIE)
   ========================================= */
.planning-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 25px;
  margin-top: 20px;
}

.planning-card {
  background: rgba(26, 26, 26, 0.6);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 25px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.planning-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(47, 143, 75, 0.15);
  border-color: var(--accent);
}

/* En-tête Tableau Périodique */
.chemical-header {
  display: flex; align-items: center; gap: 15px;
  margin-bottom: 30px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 15px;
}

.element-square {
  width: 60px; height: 60px;
  background-color: var(--accent);
  color: #fff;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-family: 'Oswald', sans-serif;
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(47, 143, 75, 0.4);
  position: relative;
}

.atomic-number { position: absolute; top: 2px; left: 4px; font-size: 0.7rem; opacity: 0.8; }
.symbol { font-size: 1.8rem; font-weight: 700; line-height: 1; }

.day-name {
  margin: 0; font-size: 1.5rem; text-transform: uppercase;
  font-family: 'Oswald', sans-serif; letter-spacing: 1px;
}

/* Liste Horaires */
.schedule-items { display: flex; flex-direction: column; gap: 20px; }

.time-slot { display: flex; align-items: flex-start; gap: 15px; position: relative; }

/* Ligne verte */
.time-slot::before {
  content: ''; position: absolute; left: 0; top: 5px; bottom: -25px;
  width: 1px; background: rgba(255,255,255,0.1);
  margin-left: 28px; z-index: 0;
}
.planning-card .time-slot:last-child::before { display: none; }

.time {
  font-family: 'Oswald', sans-serif; font-weight: 600;
  color: var(--accent-2); font-size: 1.1rem;
  background: var(--card); /* Cache la ligne */
  z-index: 1; padding-right: 10px; min-width: 60px;
}

.event { font-size: 1rem; font-weight: 600; line-height: 1.4; color: #fff; }
.event small { display: block; font-weight: 400; color: var(--muted); margin-top: 4px; font-size: 0.85rem; }

@media (max-width: 850px) {
  .planning-grid { grid-template-columns: 1fr; max-width: 500px; margin: 0 auto; }
}


/* =========================================
   8. GALERIE (BANDEROLE CORRIGÉE)
   ========================================= */
.gallery-section {
  position: relative;
  overflow: hidden;
  padding-bottom: 80px;
}

/* La Banderole */
/* --- 1. LE STYLE BANDEROLE (CARROUSEL INFINI) --- */
.gallery-banderole {
  display: flex;
  gap: 4px; /* Écart très réduit */
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  
  /* Padding ajusté */
  padding: 40px 20vw; 
  
  /* IMPORTANT : On enlève le smooth ici pour que le JS gère la boucle invisible */
  scroll-behavior: auto; 
  
  scrollbar-width: none; 
  -ms-overflow-style: none;
}
.gallery-banderole::-webkit-scrollbar { display: none; }

.banderole-item {
  flex: 0 0 60vw;
  max-width: 800px;
  aspect-ratio: 16/9;
  scroll-snap-align: center;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  transition: transform 0.4s ease, opacity 0.4s ease;
  opacity: 0.6; /* Transparence inactive */
  transform: scale(0.92); 
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.banderole-item img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

.banderole-item.is-active {
  opacity: 1;
  transform: scale(1);
  border: 1px solid rgba(255,255,255,0.2);
  z-index: 10;
}

@media (max-width: 768px) { .banderole-item { flex: 0 0 85vw; } }

/* Lightbox (Plein écran) */
.lightbox {
  display: none; 
  position: fixed; z-index: 10000; left: 0; top: 0;
  width: 100%; height: 100%; 
  background-color: rgba(0, 0, 0, 0.98);
  align-items: center; justify-content: center;
  flex-direction: column;
}

.lightbox-content {
  max-width: 90%; max-height: 75vh;
  box-shadow: 0 0 50px rgba(0,0,0,1);
  border-radius: 4px;
  transition: opacity 0.2s;
}

/* Lightbox Controls */
.close-lightbox, .close-grid {
  position: absolute; top: 20px; right: 30px;
  color: #fff; font-size: 40px; cursor: pointer; z-index: 10002;
  font-family: sans-serif; line-height: 1;
}

.prev-lightbox, .next-lightbox {
  cursor: pointer; position: absolute; top: 50%;
  transform: translateY(-50%);
  width: 60px; height: 60px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 30px; transition: 0.3s; user-select: none;
}
.prev-lightbox { left: 20px; }
.next-lightbox { right: 20px; }
.prev-lightbox:hover, .next-lightbox:hover { background: var(--accent); }

/* Bouton Grille */
.btn-grid-view {
  margin-top: 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white; padding: 10px 20px; border-radius: 30px;
  cursor: pointer; font-family: 'Montserrat', sans-serif;
  display: flex; align-items: center; gap: 8px; transition: 0.3s;
}
.btn-grid-view:hover { background: white; color: black; }

/* Grille Overlay */
.grid-overlay {
  display: none; position: fixed; inset: 0;
  background: #0f0f0f; z-index: 10001;
  padding: 80px 20px 20px 20px; overflow-y: auto;
}

.grid-header {
  position: fixed; top: 0; left: 0; right: 0; height: 70px;
  background: rgba(15, 15, 15, 0.95);
  display: flex; align-items: center; padding-left: 30px;
  z-index: 2; border-bottom: 1px solid #333;
}

.grid-container {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px; max-width: 1400px; margin: 0 auto;
}

.grid-item-thumb {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 4px; cursor: pointer; transition: transform 0.2s;
}
.grid-item-thumb:hover { transform: scale(1.05); z-index: 1; box-shadow: 0 4px 15px rgba(0,0,0,0.5); }


/* =========================================
   9. FOOTER
   ========================================= */
.site-footer {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 0.9rem;
  border-top: 1px solid rgba(255,255,255,0.05);
  margin-top: 40px;
}