/*
  Styles de base pour portfolio simple
  - Thème basé sur un dégradé. Fallback défini ici; JS mettra à jour via variables CSS si color.png est présent.
*/
:root {
  --bg: #0b1020;
  --text: #e6e8ee;
  --muted: #9aa3b2;
  --card: #121a33;
  --accent: #7c3aed; /* fallback accent */
  --gradient-from: #7c3aed; /* fallback gradient start */
  --gradient-to: #06b6d4;   /* fallback gradient end */
  --container: 1100px;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0,0,0,0.25);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html {
  overflow-x: hidden;
  overflow-y: auto;
  scroll-behavior: smooth;
  scroll-padding-top: 100px;
}
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: radial-gradient(ellipse at top left, rgba(124,58,237,0.25) 0%, transparent 50%),
              radial-gradient(ellipse at top right, rgba(6,182,212,0.18) 0%, transparent 50%),
              #0b1020;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}

.container { max-width: var(--container); margin: 0 auto; padding: 0 20px; }

/* Responsive Container */
@media (max-width: 768px) {
  .container { padding: 0 16px; }
}

/* Header */
.site-header { position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px); background: rgba(11,16,32,0.6); border-bottom: 1px solid rgba(255,255,255,0.06); }
.header-inner { display: flex; align-items: center; gap: 20px; padding: 14px 0; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); letter-spacing: 0.2px; }
.nav { display: flex; gap: 16px; margin-left: auto; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.nav a:hover { color: var(--text); background: rgba(255,255,255,0.06); }

/* Header Mobile */
@media (max-width: 768px) {
  .header-inner { 
    gap: 12px; 
    padding: 12px 0;
    flex-direction: column;
    align-items: stretch;
  }
  .nav { 
    gap: 8px;
    width: 100%;
    justify-content: center;
    margin: 8px 0 0 0;
    order: 3;
  }
  .nav a { 
    padding: 10px 16px;
    font-size: 14px;
    text-align: center;
    flex: 1;
  }
  .contact-dropdown {
    order: 2;
    align-self: center;
  }
  .brand {
    order: 1;
    text-align: center;
    font-size: 18px;
  }
}

/* Animation des liens */
.nav a {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  cursor: pointer;
}

.nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--gradient-from), var(--gradient-to));
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.nav a:hover::after {
  transform: translateX(0);
}

.nav a:hover {
  color: var(--text);
  background: rgba(255,255,255,0.06);
  transform: translateY(-1px);
}

/* Animation de clic pour les liens de navigation */
.nav a:active {
  transform: translateY(-1px) scale(0.98);
}

/* Animation spéciale pour les sections ciblées */
.section-highlight {
  position: relative;
  overflow: hidden;
}

.section-highlight::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(124,58,237,0.05), 
    rgba(6,182,212,0.02), 
    transparent
  );
  animation: highlight-sweep 1.5s ease-out;
  pointer-events: none;
}

@keyframes highlight-sweep {
  0% { left: -100%; }
  100% { left: 100%; }
}

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.12); text-decoration: none; color: var(--text); transition: transform .05s ease; }
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: linear-gradient(135deg, var(--gradient-from), var(--gradient-to)); border: none; box-shadow: var(--shadow); }
.btn.ghost { background: transparent; }
.btn.small { padding: 8px 12px; font-size: 14px; }

/* Responsive Buttons */
@media (max-width: 768px) {
  .btn {
    padding: 12px 16px;
    font-size: 14px;
  }
  .btn.small {
    padding: 10px 14px;
    font-size: 13px;
  }
}

/* GitHub button styling */
.btn.github-link {
  padding: 16px 20px;
  font-size: 16px;
  min-width: 400px;
  justify-content: flex-start;
  gap: 15px;
  background: #121a33; /* Fallback couleur fixe */
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.12);
  transition: all 0.2s ease;
  /* Force le style même si les variables CSS ne marchent pas */
  color: #e6e8ee !important;
}

.btn.github-link:hover {
  background: linear-gradient(135deg, rgba(124,58,237,0.1), rgba(6,182,212,0.05));
  border-color: rgba(124,58,237,0.3);
  transform: translateY(-2px);
  box-shadow: 0 12px 35px rgba(0,0,0,0.35);
}

/* GitHub button mobile */
@media (max-width: 768px) {
  .btn.github-link {
    min-width: unset;
    width: 100%;
    padding: 14px 16px;
    font-size: 14px;
    gap: 12px;
    background: rgba(18,26,51,0.9);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(124,58,237,0.25);
  }
  
  .btn.github-link:hover {
    background: linear-gradient(135deg, rgba(124,58,237,0.15), rgba(6,182,212,0.08));
    border-color: rgba(124,58,237,0.4);
  }
}

/* Contact Dropdown Styles */
.contact-dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}

.dropdown-arrow {
  transition: transform 0.2s ease;
}

.contact-dropdown.active .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 180px;
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  z-index: 1000;
  margin-top: 8px;
}

.contact-dropdown.active .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s ease;
  border-radius: 8px;
  margin: 4px;
}

.dropdown-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--accent);
  transform: translateX(4px);
}

.dropdown-item svg {
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.dropdown-item:hover svg {
  opacity: 1;
}

/* Contact Dropdown Mobile */
@media (max-width: 768px) {
  .dropdown-menu {
    left: 0;
    right: 0;
    min-width: unset;
    margin-top: 4px;
  }
  
  .dropdown-item {
    padding: 14px 16px;
    justify-content: center;
  }
}

.github-text {
  font-weight: 500;
  color: #e6e8ee; /* Couleur fixe en fallback */
  color: var(--text);
  display: flex;
  align-items: center;
}

.project-scroller {
  position: relative;
  overflow: hidden;
  height: 1.2em;
  display: inline-block;
  vertical-align: top;
  width: 150px;
  /* Debug: bordure temporaire pour voir si le conteneur est là */
  /* border: 1px solid red; */
}

.project-name {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  line-height: 1.2em;
  opacity: 0;
  transform: translateY(100%);
  color: #e6e8ee; /* Couleur fixe */
  /* Debug: test si les éléments sont présents */
  /* background: rgba(255,0,0,0.1); */
}

.project-name {
  animation: scroll-up 10s infinite;
}

.project-name:nth-child(1) { animation-delay: 0s; }
.project-name:nth-child(2) { animation-delay: 2s; }
.project-name:nth-child(3) { animation-delay: 4s; }
.project-name:nth-child(4) { animation-delay: 6s; }
.project-name:nth-child(5) { animation-delay: 8s; }

@keyframes scroll-up {
  0% {
    transform: translateY(100%);
    opacity: 0;
  }
  5%, 18% {
    transform: translateY(0);
    opacity: 1;
  }
  23%, 100% {
    transform: translateY(-100%);
    opacity: 0;
  }
}

.github-logo {
  flex-shrink: 0;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.btn.github-link:hover .github-logo {
  opacity: 1;
}

/* Sections */
.section { padding: 60px 0; }
.section.alt { background: none; }

/* Section Projets avec même fond que hero */
#projets {
  background: linear-gradient(135deg, color-mix(in oklab, var(--gradient-from) 20%, transparent), transparent) !important;
}

/* Responsive Sections */
@media (max-width: 768px) {
  .section { 
    padding: 40px 0; 
  }
  .section h2 { 
    text-align: center; 
    font-size: clamp(24px, 5vw, 32px); 
    margin: 0 0 25px 0; 
    color: var(--text);
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
  }
  
  /* Section À propos avec fond amélioré pour mobile */
  #a-propos {
    background: linear-gradient(180deg, 
      rgba(124,58,237,0.02) 0%, 
      rgba(18,26,51,0.2) 20%,
      rgba(18,26,51,0.2) 80%,
      rgba(6,182,212,0.02) 100%
    );
    backdrop-filter: blur(1px);
    padding: 40px 0;
  }
  
  /* Conteneur mobile avec marges internes pour préserver l'espacement */
  #a-propos .container {
    padding: 0 16px;
  }
  

}

/* Section À propos avec effet de transparence */
#a-propos {
  position: relative;
  padding: 60px 0;
  isolation: isolate;
}

/* Force la section à prendre toute la largeur */
#a-propos::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 100vw;
  height: 100%;
  background: linear-gradient(180deg, 
    rgba(124,58,237,0.01) 0%, 
    rgba(18,26,51,0.15) 30%,
    rgba(18,26,51,0.15) 70%,
    rgba(6,182,212,0.01) 100%
  );
  transform: translateX(-50%);
  z-index: -1;
}

/* Remettre le contenu dans le bon cadre */
#a-propos .container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px;
}

/* Assurer une largeur maximale cohérente pour le contenu */
#a-propos .container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px;
}
.hero { padding: 84px 0 64px; background: linear-gradient(135deg, color-mix(in oklab, var(--gradient-from) 20%, transparent), transparent); }
.hero h1 { font-size: clamp(28px, 4vw, 44px); margin: 0 0 12px; }
.hero .lead { color: var(--muted); margin: 0 0 20px; }
.cta-row { display: flex; gap: 12px; }

/* Hero Mobile */
@media (max-width: 768px) {
  .hero { 
    padding: 60px 0 40px;
    text-align: center;
    background: linear-gradient(180deg, 
      rgba(124,58,237,0.1) 0%, 
      transparent 50%
    );
  }
  .hero h1 { 
    font-size: clamp(24px, 6vw, 32px);
    margin: 0 0 16px;
    text-shadow: 0 2px 12px rgba(124,58,237,0.3);
  }
  .hero .lead { 
    margin: 0 0 24px;
    font-size: 16px;
    color: rgba(230,232,238,0.9);
  }
  .cta-row { 
    flex-direction: column;
    gap: 12px;
    align-items: center;
  }
  .cta-row .btn {
    width: 100%;
    max-width: 280px;
    justify-content: center;
  }
}

.grid-2 { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 28px; align-items: start; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; gap: 24px; } }

/* Styles pour écrans de taille intermédiaire (tablettes) */
@media (max-width: 1024px) and (min-width: 769px) {
  #a-propos {
    background: linear-gradient(180deg, 
      rgba(124,58,237,0.015) 0%, 
      rgba(18,26,51,0.18) 25%,
      rgba(18,26,51,0.18) 75%,
      rgba(6,182,212,0.015) 100%
    );
    backdrop-filter: blur(1px);
    padding: 50px 0;
  }
  
  #a-propos .container {
    padding: 0 24px;
  }
}

/* Grid Mobile Improvements */
@media (max-width: 768px) {
  .grid-2 { 
    gap: 20px;
  }
  .about-links {
    justify-content: center;
  }
  .about-content p {
    text-align: center;
  }
  .about-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  .about-content p {
    font-size: 16px;
    line-height: 1.7;
    margin: 0;
  }
  .about-links {
    display: flex;
    justify-content: center;
    align-items: flex-start;
  }
}

.about-card { background: var(--card); border: 1px solid rgba(255,255,255,0.08); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.bullets { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.bullets li { color: var(--muted); }
.bullets strong { color: var(--text); }

/* Cards projets */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.card { background: var(--card); border: 1px solid rgba(255,255,255,0.08); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-body { padding: 16px; }
.card h3 { margin: 0 0 8px; font-size: 18px; }
.card p { margin: 0 0 14px; color: var(--muted); }
.card-actions { display: flex; gap: 10px; }

/* Cards Mobile */
@media (max-width: 768px) {
  .cards { 
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .card { 
    background: rgba(18,26,51,0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(124,58,237,0.15);
  }
  .card-body { 
    padding: 18px;
  }
  .card h3 { 
    font-size: 19px;
    margin: 0 0 10px;
  }
  .card p { 
    margin: 0 0 16px;
    line-height: 1.7;
  }
  .card-actions { 
    gap: 8px;
    flex-wrap: wrap;
  }
  .card-actions .btn {
    flex: 1;
    min-width: 0;
    justify-content: center;
  }
}

/* Liens */
.links { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.links a { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 14px; border-radius: 12px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.07); text-decoration: none; color: var(--text); }
.links a:hover { background: linear-gradient(135deg, color-mix(in oklab, var(--gradient-from) 20%, transparent), color-mix(in oklab, var(--gradient-to) 12%, transparent)); }
.link-title { font-weight: 600; }
.link-sub { color: var(--muted); font-size: 14px; }

/* Links Mobile */
@media (max-width: 768px) {
  .links a {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 16px;
  }
  .link-title {
    font-size: 16px;
  }
  .link-sub {
    font-size: 13px;
  }
}

/* Footer */
.site-footer { 
  padding: 24px 0 24px; 
  margin-top: 80px; 
  background: transparent;
}

/* Footer mobile improvements */
@media (max-width: 768px) {
  .site-footer {
    text-align: center;
    padding: 30px 0 20px;
    background: linear-gradient(180deg, rgba(11,16,32,0.3) 0%, rgba(11,16,32,0.9) 100%);
    border-top: 1px solid rgba(124,58,237,0.15);
    backdrop-filter: blur(8px);
  }
  .footer-content p {
    margin: 0;
    color: var(--muted);
  }
  .footer-content .footer-subtitle {
    font-size: 14px;
    opacity: 0.7;
    margin-top: 4px;
  }
}
.accent {
  background: linear-gradient(135deg, var(--gradient-from), var(--gradient-to)); 
  -webkit-background-clip: text; 
  background-clip: text; 
  color: transparent;
}

/* Animations pour le texte */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes typing {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

@keyframes blink {
  0%, 50% {
    border-color: transparent;
  }
  51%, 100% {
    border-color: var(--accent);
  }
}

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

/* Application des animations */
.hero h1 {
  animation: fadeInUp 1s ease-out;
}

.hero .lead {
  animation: fadeInUp 1s ease-out 0.3s both;
}

.cta-row {
  animation: fadeInUp 1s ease-out 0.6s both;
}

.accent {
  animation: glow 3s ease-in-out infinite;
}

.section h2 {
  animation: fadeInUp 0.8s ease-out;
}

.card {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease-out, transform 0.3s ease-out;
}

.card.visible {
  opacity: 1;
  transform: translateY(0);
}

.card:hover {
  transform: translateY(-5px);
}

/* Animation en cascade quand la section devient visible */
#projets.visible .card:nth-child(1),
.card.visible:nth-child(1) { transition-delay: 0.1s; }
#projets.visible .card:nth-child(2),
.card.visible:nth-child(2) { transition-delay: 0.2s; }
#projets.visible .card:nth-child(3),
.card.visible:nth-child(3) { transition-delay: 0.3s; }
#projets.visible .card:nth-child(4),
.card.visible:nth-child(4) { transition-delay: 0.4s; }
#projets.visible .card:nth-child(5),
.card.visible:nth-child(5) { transition-delay: 0.5s; }

/* Supprimer le delay lors du hover pour une réaction uniforme */
.card:hover {
  transition-delay: 0s !important;
}

/* Animation des éléments au scroll */
.fade-in-section {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.fade-in-section.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Animation flottante pour le logo GitHub */
.github-logo {
  flex-shrink: 0;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

/* Animation subtile pour les boutons */
.btn {
  position: relative;
  overflow: hidden;
}

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

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

/* Animation de rebond pour les cartes */
@keyframes bounce-in {
  0% {
    opacity: 0;
    transform: translateY(50px) scale(0.8);
  }
  50% {
    opacity: 0.8;
    transform: translateY(-10px) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card.animate-in {
  animation: bounce-in 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Fond avec particules */
#particles-js {
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: -10;
  pointer-events: none;
}

/* ======================================
   OPTIMISATIONS MOBILES GLOBALES
====================================== */

/* Améliorer les interactions tactiles */
@media (max-width: 768px) {
  /* Optimiser le fond pour mobile */
  body {
    background: 
      radial-gradient(ellipse at top center, rgba(124,58,237,0.15) 0%, transparent 40%),
      radial-gradient(ellipse at bottom center, rgba(6,182,212,0.12) 0%, transparent 40%),
      linear-gradient(180deg, #0b1020 0%, #0f1729 50%, #0b1020 100%);
    background-attachment: fixed;
    background-size: 100% 50%, 100% 50%, 100% 100%;
    background-position: top, bottom, center;
    font-size: 16px;
    line-height: 1.7;
  }
  
  /* Zones de touch plus grandes pour les liens et boutons */
  .nav a, .btn, .dropdown-item {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Désactiver le hover sur tactile pour éviter les états collants */
  @media (hover: none) {
    .nav a:hover,
    .btn:hover,
    .card:hover,
    .dropdown-item:hover,
    .links a:hover {
      transform: none;
      background: inherit;
      color: inherit;
    }
    
    .nav a:hover::after {
      transform: translateX(-100%);
    }
  }
  
  /* Améliorer la lisibilité du texte */
  
  /* Réduire les animations pour économiser la batterie */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
  
  /* Optimiser l'affichage du texte défilant des projets */
  .project-scroller {
    width: 120px;
    font-size: 14px;
  }
  
  /* Améliorer l'espacement des sections */
  .about-card {
    padding: 20px;
    margin-top: 0;
    background: rgba(18,26,51,0.7);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(124,58,237,0.2);
  }
  
  /* Optimiser les titres de sections */
  .section h2 {
    font-size: clamp(24px, 5vw, 32px);
    margin-bottom: 25px;
    text-align: center;
  }
  
  /* Footer mobile */
  .site-footer {
    text-align: center;
    padding: 30px 0 20px;
  }
  
  /* Amélioration du header mobile */
  .site-header {
    background: rgba(11,16,32,0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(124,58,237,0.2);
  }
}

/* Optimisations pour très petits écrans */
@media (max-width: 480px) {
  .container {
    padding: 0 12px;
  }
  
  .hero {
    padding: 40px 0 30px;
  }
  
  .section {
    padding: 30px 0;
  }
  
  .card-body {
    padding: 16px;
  }
  
  .btn.github-link {
    padding: 12px 14px;
    font-size: 13px;
  }
}

/* Gestion de l'orientation paysage sur mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .hero {
    padding: 30px 0 20px;
  }
  
  .section {
    padding: 25px 0;
  }
}