/*
  ╔══════════════════════════════════════════════════════════════════════════╗
  ║         components.css — Cards, Buttons, Modal, Carousel, etc.           ║
  ╚══════════════════════════════════════════════════════════════════════════╝
*/

/* ══════════════════════════════════════════════════════════════════════════ */
/* COMPONENTS: Header, Navbar & Hero Section                                  */
/* ══════════════════════════════════════════════════════════════════════════ */

.header {
    background: var(--bg-primary-gradient);
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 100px var(--page-h-padding) var(--spacing-xl);
    text-align: center;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    width: 100%;
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: center; /* Centre le contenu de la navbar */
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0; /* More robust full-width */
  padding-top: 25px;
  padding-bottom: 25px;
  z-index: 100;
  background-color: transparent;
  transition: background-color var(--transition-normal), padding var(--transition-normal), border-bottom var(--transition-normal);
  border-bottom: 1px solid transparent;
}

.navbar > .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1200px; /* Largeur maximale pour le contenu de la navbar */
  margin: 0 auto; /* Centre le conteneur dans la navbar */
  padding: 0 var(--page-h-padding); /* Re-apply padding here */
}

.navbar.is-scrolled {
  background-color: var(--color-bg-secondary);
  padding-top: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.nav-brand {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--font-size-xl); /* Augmentation de la taille de police par défaut */
  color: var(--color-text-primary);
  text-decoration: none;
  flex-shrink: 0;
  transition: font-size var(--transition-normal); /* Transition plus douce */
}

.navbar.is-scrolled .nav-brand {
  font-size: var(--font-size-lg); /* Réduction de la taille de police au défilement */
}

.nav-toggle {
  display: none; /* Le bouton hamburger est caché par défaut */
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 101;
  -webkit-tap-highlight-color: transparent;
}

.nav-toggle-icon {
  position: relative;
  width: 24px;
  height: 2px;
  background: var(--color-text-primary);
  transition: all 0.2s ease-out;
}
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  content: '';
  position: absolute;
  left: 0;
  width: 24px;
  height: 2px;
  background: var(--color-text-primary);
  transition: transform 0.2s ease-out, top 0.2s ease-out;
}
.nav-toggle-icon::before { top: -8px; }
.nav-toggle-icon::after { top: 8px; }

.nav-toggle[aria-expanded="true"] .nav-toggle-icon {
  background: transparent;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-icon::before {
  transform: rotate(45deg);
  top: 0;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-icon::after {
  transform: rotate(-45deg);
  top: 0;
}

.nav-menu {
  display: none; /* Le menu est caché par défaut sur mobile */
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: var(--spacing-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.nav-menu::-webkit-scrollbar {
  display: none;
}

.nav-item {
  margin: 0;
  flex-shrink: 0;
}

.nav-link {
  font-family: var(--font-primary);
  font-size: clamp(13px, 3vw, 15px);
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
  padding: var(--spacing-xs) var(--spacing-sm);
  position: relative;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
  color: var(--color-text-primary);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background-color: var(--color-accent);
  border-radius: 50%;
}

/* Styles pour le menu mobile (écrans < 700px) */
@media (max-width: 699px) {
  .nav-toggle {
    display: flex; /* Affiche le bouton hamburger sur mobile */
  }

  .nav-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-bg-primary);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transform: translateY(-100%);
    transition: transform var(--transition-normal);
    visibility: hidden;
    z-index: 99;
    gap: var(--spacing-md);
  }

  .nav-menu.is-active {
    display: flex; /* Affiche le menu quand il est actif */
    transform: translateY(0);
    visibility: visible;
  }

  .nav-link {
    font-family: var(--font-heading);
    font-size: var(--font-size-2xl);
  }
}

/* Styles pour les écrans > 700px (remplace l'ancienne media query) */
@media (min-width: 700px) {
  
  .nav-toggle {
    display: none; /* Cache le bouton hamburger sur grand écran */
  }

  .nav-menu {
    display: flex; /* Affiche le menu horizontalement sur desktop */
    flex-direction: row; /* S'assure que les liens sont horizontaux sur desktop */
    flex-wrap: nowrap; /* Empêche les liens de passer à la ligne sur desktop */
    gap: var(--spacing-md);
  }

  .nav-link {
    font-size: var(--font-size-base);
  }

  .nav-link.active::after {
    width: 6px;
    height: 6px;
  }
}

/* ══════════════════════════════════════════════════════════════════════════ */
/* COMPONENTS: Buttons                                                        */
/* ══════════════════════════════════════════════════════════════════════════ */

.btn,
.btn-outline,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  min-height: 44px;
  border: 1px solid transparent;
  letter-spacing: 0.3px;
  transition: background-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.btn:focus-visible,
.btn-outline:focus-visible,
.btn-ghost:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text-secondary);
  border-color: var(--color-border);
  font-weight: 400;
  padding: 10px 24px;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--color-text-primary);
  transform: translateY(-2accent-hover);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--color-text-primary);
  border-color: #dcdcdc;
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}

.btn-ghost:hover {
  color: var(--color-text-primary);
}

/* ══════════════════════════════════════════════════════════════════════════ */
/* COMPONENTS: Project Cards                                                  */
/* ══════════════════════════════════════════════════════════════════════════ */

.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  transition: box-shadow 0.2s ease-out;
  will-change: box-shadow, transform;
  contain: layout style paint;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  cursor: pointer;
}

.card:hover {
  transform: translate3d(0, -4px, 0);
  box-shadow: var(--shadow-md);
}

.card-media {
  width: 100%;
  height: 200px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.project-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none; /* Empêche la sélection de l'image */
  -webkit-user-drag: none;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.card-body {
  padding: 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: 0.3px;
}

.project-desc {
  margin: 0 0 12px;
  color: var(--color-text-muted);
  font-size: 13px;
  flex: 1;
  line-height: 1.5;
  letter-spacing: 0.2px;
}

.project-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-md);
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.tags {
  font-size: 11px;
  color: var(--color-text-muted);
  flex: 1;
  min-width: 0;
  text-overflow: ellipsis;
  overflow: hidden;
  letter-spacing: 0.2px;
}

.project-link {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast), color var(--transition-fast);
  letter-spacing: 0.3px;
}

.project-link:hover {
  background-color: rgba(125, 179, 255, 0.1);
  color: var(--color-accent-hover);
}

.project-link:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ══════════════════════════════════════════════════════════════════════════ */
/* COMPONENTS: Footer                                                         */
/* ══════════════════════════════════════════════════════════════════════════ */

.footer {
  border-top: 2px solid rgba(255, 255, 255, 0.1);
  background: var(--bg-secondary-gradient);
  width: 100%;
  box-sizing: border-box;
  padding: 24px var(--page-h-margin);
  text-align: center;
  color: var(--color-text-muted);
  font-size: 13px;
  letter-spacing: 0.3px;
}

.footer > * {
  padding: 0;
}

.footer .container {
  padding-left: 0;
  padding-right: 0;
}

/* ══════════════════════════════════════════════════════════════════════════ */
/* COMPONENTS: Carousel                                                       */
/* ══════════════════════════════════════════════════════════════════════════ */

.carousel-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  gap: var(--spacing-sm);
}

.carousel {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: auto;
}

.carousel-viewport {
  padding: 0 var(--page-h-margin);
  position: relative;
  overflow: hidden;
  min-width: 0;
  contain: layout style paint;
  height: auto;
  min-height: 420px;
  display: flex;
  align-items: stretch;
  box-sizing: border-box; /* Assure que le padding est inclus dans la largeur */
}

.carousel-track {
  display: flex;
  gap: var(--spacing-lg);
  overflow-x: auto;
  scroll-behavior: auto;
  padding: 12px 0;
  -ms-overflow-style: none;
  scrollbar-width: none;
  min-width: 0;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  contain: layout style paint;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  height: auto;
  flex-wrap: nowrap;
  align-items: stretch;
}

.carousel-track::-webkit-scrollbar {
  display: none;
}

.carousel-track .project-card {
  flex: 0 0 clamp(280px, 40%, 320px);
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #212529;
  color: var(--color-text-primary);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease-out, box-shadow 0.15s ease-out;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.carousel-btn:active {
  background: #1a1a1a;
}

.carousel-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.carousel-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.carousel-viewport .carousel-btn.next {
  right: var(--page-h-margin);
}

.carousel-viewport .carousel-btn.prev {
  left: var(--page-h-margin);
}

/* ══════════════════════════════════════════════════════════════════════════ */
/* COMPONENTS: Modal (Project Details)                                        */
/* ══════════════════════════════════════════════════════════════════════════ */

.project-modal {
  all: revert;
  position: fixed;
  inset: 0; /* Remplace top, right, bottom, left: 0; */
  width: 100%; /* S'adapte au conteneur, pas au viewport */
  height: 100%;
  max-width: none;
  max-height: none;
  border: none;
  padding: 0;
  margin: 0;
  background: transparent;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: none;
  overflow: visible;
}

.project-modal[open]::backdrop {
  display: none;
}

.project-modal:not([open]) {
  display: none;
  pointer-events: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.3s var(--easing-premium);
  z-index: -1;
}

.modal-container {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  background: var(--color-bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: scaleIn 0.3s var(--easing-premium);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.3);
  border: none;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background-color var(--transition-fast);
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.5);
}

.modal-project {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.modal-image-wrapper {
  flex-shrink: 0;
  width: 100%;
  height: auto;
  max-height: 40vh;
  overflow: hidden;
}

.modal-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-body {
  padding: var(--spacing-lg);
  flex: 1;
  overflow-y: auto;
}

.modal-title {
  margin: 0 0 var(--spacing-sm);
  font-size: var(--font-size-xl);
  font-family: var(--font-heading);
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.modal-tags span {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
}

.modal-description {
  margin: 0 0 var(--spacing-lg);
  color: var(--color-text-secondary);
}

.modal-actions {
  margin-top: auto;
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--color-border);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}


/* ============================================ */
/*                 TIMELINE                     */
/* ============================================ */

/* --- Variables pour une maintenance facile --- */
:root {
  --timeline-img-size: clamp(60px, 8vw, 90px);
  --timeline-card-padding: clamp(20px, 3vw, 30px);
}

.timeline-container {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 0;
}

/* --- Ligne verticale centrale (Desktop) --- */
.timeline-container::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background-color: var(--color-border);
  transform: translateX(-50%);
  z-index: 0;
}

/* --- Style de base pour chaque item de la timeline --- */
.timeline-item {
  position: relative;
  width: 50%;
  box-sizing: border-box;
  padding: 20px 50px; /* Espace pour la flèche et l'image */
}

/* --- Positionnement alterné avec :nth-child --- */
.timeline-item:nth-child(odd) {
  left: 0;
  padding-right: calc(var(--timeline-img-size) / 2 + 30px);
}

.timeline-item:nth-child(even) {
  left: 50%;
  padding-left: calc(var(--timeline-img-size) / 2 + 30px);
}

/* --- Image / Cercle --- */
.timeline-img {
  position: absolute;
  top: 25px;
  width: var(--timeline-img-size);
  height: var(--timeline-img-size);
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--color-bg-secondary);
  z-index: 10;
  background-color: var(--color-bg-secondary);
}

.timeline-item:nth-child(odd) .timeline-img {
  right: calc(var(--timeline-img-size) / -2);
}

.timeline-item:nth-child(even) .timeline-img {
  left: calc(var(--timeline-img-size) / -2);
}

/* --- Contenu de la carte --- */
.timeline-content {
  padding: var(--timeline-card-padding);
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.timeline-content:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
  border-color: rgba(255, 255, 255, 0.2);
}

/* --- Flèches pointant vers la ligne --- */
.timeline-content::before {
  content: '';
  position: absolute;
  top: 40px;
  width: 0;
  height: 0;
  border-style: solid;
}

.timeline-item:nth-child(odd) .timeline-content::before {
  right: -10px;
  border-width: 10px 0 10px 10px;
  border-color: transparent transparent transparent var(--color-border);
}

.timeline-item:nth-child(even) .timeline-content::before {
  left: -10px;
  border-width: 10px 10px 10px 0;
  border-color: transparent var(--color-border) transparent transparent;
}

/* --- Styles du texte et des badges --- */
.timeline-date {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: 8px;
  display: block;
}

.timeline-content h3 {
  margin-top: 0;
  margin-bottom: 5px;
  font-size: var(--font-size-lg);
  color: var(--color-text-primary);
}

.timeline-subtitle {
  font-size: var(--font-size-base);
  color: var(--color-accent);
  margin-top: 0;
  margin-bottom: 15px;
  font-weight: 500;
}

.timeline-content p {
  margin-bottom: 15px;
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.timeline-list {
  margin-bottom: 15px;
  padding-left: 20px;
  color: var(--color-text-secondary);
  line-height: 1.6;
  font-size: var(--font-size-base);
}

.timeline-list li {
  margin-bottom: 5px;
}

.timeline-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  text-transform: capitalize;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.status-terminé { background-color: #28a745; }
.status-en-cours { background-color: #fd7e14; }
.status-à-venir { background-color: #6c757d; }

/* --- Animations au scroll --- */
.timeline-item.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
  z-index: 2; /* S'assure que l'item complet passe au-dessus de la ligne en mode desktop/mobile */
}

.timeline-item.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}


/* ══════════════════════════════════════════════════════════════════════════ */
/* TIMELINE: RESPONSIVE (Tablets & Mobiles < 1024px)                          */
/* ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1023px) {
  
  /* --- La ligne verticale passe à gauche --- */
  .timeline-container::before {
    left: calc(var(--timeline-img-size) / 2 - 1px); /* Center the 2px line */
  }

  /* --- Reset du layout 2 colonnes --- */
  .timeline-item,
  .timeline-item:nth-child(odd),
  .timeline-item:nth-child(even) {
    width: 100%;
    left: 0;
    padding: 20px 0;
    display: flex; /* Passage en Flexbox pour un alignement simple */
    flex-direction: row-reverse; /* Place l'image à gauche */
    gap: 20px;
    align-items: flex-start; /* Aligne l'image et le texte en haut */
  }

  /* --- L'image devient un item flex --- */
  .timeline-img {
    position: static; /* Supprime le positionnement absolu */
    flex-shrink: 0; /* Empêche l'image de rétrécir */
  }

  /* --- Le contenu prend l'espace restant --- */
  .timeline-content {
    flex-grow: 1;
  }
  
  /* --- On unifie la direction des flèches pour le mobile --- */
  .timeline-item:nth-child(odd) .timeline-content::before,
  .timeline-item:nth-child(even) .timeline-content::before {
    display: block;
    left: -10px;
    right: auto; /* Annule le 'right' du style desktop pour les items impairs */
    top: 30px; /* Ajustement vertical */
    border-width: 10px 10px 10px 0;
    border-color: transparent var(--color-border) transparent transparent;
  }
}

/* ══════════════════════════════════════════════════════════════════════════ */
/* COMPONENTS: Project Description & Carousel Responsive Adjustments          */
/* ══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  .project-desc {
    display: none;
  }  
    .carousel-viewport {
    min-height: 340px;
    height: auto;
  }
  
}


@media (max-width: 499px) {
  .carousel-wrapper,
  .carousel {
    height: 100%;
  }

  .carousel-viewport {
    height: 100%;
    max-height: none; /* Reset max-height for vertical view */
    overflow-y: auto;
    padding: 0 20px;
  }

  .carousel-track {
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-lg) 0;
  }

  .carousel-track .project-card {
    width: 100%;
    margin-bottom: var(--spacing-lg);
    height: auto;
    flex-shrink: 0;
  }

  .carousel-btn {
    display: none;
  }
}
