/* ==================== VARIABLES ==================== */
:root {
   --primary: #667eea;
   --primary-dark: #5568d3;
   --secondary: #764ba2;
   --dark: #1a1a2e;
   --light: #f5f7fa;
   --white: #ffffff;
   --gray: #6c757d;
   --shadow: rgba(0,0,0,0.1);
   --transition: all 0.3s ease;
}

/* ==================== THEME TOGGLE (CSS-only via checkbox) ==================== */
#theme-toggle { display: none; }

#theme-toggle:checked ~ * {
   --dark: #f5f7fa;
   --light: #1a1a2e;
   --white: #16213e;
   --gray: #a0aec0;
   --shadow: rgba(0,0,0,0.3);
}

/* Wrapper applique les variables sur tout le document */
body {
   font-family: 'Segoe UI', system-ui, sans-serif;
   background: var(--light);
   color: var(--dark);
   line-height: 1.6;
   transition: var(--transition);
}

/* ==================== DARK MODE (CSS-only via :has) ==================== */
/* Utilise :has() pour propager le thème depuis le checkbox caché */
:root:has(#theme-toggle:checked) {
   --dark: #f5f7fa;
   --light: #1a1a2e;
   --white: #16213e;
   --gray: #a0aec0;
   --shadow: rgba(0,0,0,0.3);
}

:root:has(#theme-toggle:checked) header {
   background: rgba(22,33,62,0.95);
}

/* ==================== RESET & BASE ==================== */
* {
   margin: 0;
   padding: 0;
   box-sizing: border-box;
}

html {
   scroll-behavior: smooth;
}

/* ==================== HEADER ==================== */
header {
   position: fixed;
   top: 0;
   width: 100%;
   background: rgba(255,255,255,0.95);
   backdrop-filter: blur(10px);
   box-shadow: 0 2px 10px var(--shadow);
   z-index: 1000;
   transition: var(--transition);
}

nav {
   max-width: 1200px;
   margin: 0 auto;
   padding: 0.5rem 1rem;
   display: flex;
   justify-content: space-between;
   align-items: center;
}

.logo {
   font-size: 1.5rem;
   font-weight: bold;
   background: linear-gradient(135deg, var(--primary), var(--secondary));
   -webkit-background-clip: text;
   -webkit-text-fill-color: transparent;
   background-clip: text;
}

.nav-links {
   display: flex;
   gap: 2rem;
   list-style: none;
}

.nav-links a {
   text-decoration: none;
   color: var(--dark);
   font-weight: 500;
   position: relative;
   transition: var(--transition);
}

.nav-links a::after {
   content: '';
   position: absolute;
   bottom: -5px;
   left: 0;
   width: 0;
   height: 2px;
   background: var(--primary);
   transition: width 0.3s;
}

.nav-links a:hover::after {
   width: 100%;
}

.nav-controls {
   display: flex;
   gap: 1rem;
   align-items: center;
}

/* ==================== THEME TOGGLE ==================== */

.theme-toggle-label {
   width: 60px;
   height: 30px;
   border-radius: 50px;
   background: linear-gradient(135deg, #ffd86f, #fc6262);
   position: relative;
   cursor: pointer;
   display: inline-block;
   transition: background 0.4s ease;
   box-shadow: inset 0 2px 6px rgba(0,0,0,0.2);
}

/* Cercle mobile */
.theme-toggle-label::before {
   content: "";
   position: absolute;
   width: 24px;
   height: 24px;
   border-radius: 50%;
   background: white;
   top: 3px;
   left: 3px;
   transition: 
       transform 0.4s cubic-bezier(.68,-0.55,.27,1.55),
       background 0.3s ease,
       box-shadow 0.3s ease;
   box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* MODE SOMBRE ACTIVÉ */
#theme-toggle:checked ~ header .theme-toggle-label {
   background: linear-gradient(135deg, var(--primary), var(--secondary));
}

#theme-toggle:checked ~ header .theme-toggle-label::before {
   transform: translateX(30px);
   background: #f1f1f1;
}
/* ==================== MOBILE MENU (CSS-only via checkbox) ==================== */
#menu-toggle { display: none; }

.menu-toggle-label {
   display: none;
   flex-direction: column;
   gap: 5px;
   background: none;
   border: none;
   cursor: pointer;
   padding: 5px;
}

.menu-toggle-label span {
   width: 25px;
   height: 3px;
   background: var(--dark);
   transition: 0.3s;
   border-radius: 3px;
   display: block;
}

/* Hamburger → croix */
#menu-toggle:checked ~ nav .menu-toggle-label span:nth-child(1) {
   transform: rotate(45deg) translate(5px, 5px);
}
#menu-toggle:checked ~ nav .menu-toggle-label span:nth-child(2) {
   opacity: 0;
}
#menu-toggle:checked ~ nav .menu-toggle-label span:nth-child(3) {
   transform: rotate(-45deg) translate(5px, -5px);
}

/* ==================== SECTIONS ==================== */
section {
   padding: 20px 1rem;
   max-width: 1200px;
   margin: 0 auto;
}

h2 {
   font-size: 2.5rem;
   text-align: center;
   margin-bottom: 3rem;
   position: relative;
   display: inline-block;
   left: 50%;
   transform: translateX(-50%);
}

h2::after {
   content: '';
   position: absolute;
   bottom: -10px;
   left: 50%;
   transform: translateX(-50%);
   width: 60px;
   height: 4px;
   background: linear-gradient(90deg, var(--primary), var(--secondary));
   border-radius: 2px;
}

/* ==================== SCROLL ANIMATIONS (CSS-only via @keyframes + animation-timeline) ==================== */
/* Fallback : animation au chargement avec délai pour chaque section */
.fade-in {
   animation: fadeInUp 0.8s ease both;
   animation-play-state: paused;
}

/* Utilise animation-timeline: view() pour déclencher au scroll si supporté */
@supports (animation-timeline: view()) {
   .fade-in {
       opacity: 0;
       transform: translateY(30px);
       animation: fadeInUp 0.8s ease forwards;
       animation-timeline: view();
       animation-range: entry 0% entry 30%;
       animation-play-state: running;
   }
}

/* Fallback si animation-timeline non supporté : fade-in au chargement */
@supports not (animation-timeline: view()) {
   .fade-in {
       animation: fadeInUp 0.8s ease both;
       animation-play-state: running;
   }
}

/* ==================== HERO ==================== */
.hero {
   min-height: 90vh;
   display: flex;
   align-items: center;
   justify-content: center;
   text-align: center;
   /*padding-top: 80px;*/
}

.hero-content h1 {
   font-size: 3.5rem;
   margin-bottom: 1rem;
   animation: fadeInUp 1s ease both;
}

.hero-content .subtitle {
   font-size: 1.5rem;
   color: var(--gray);
   margin-bottom: 2rem;
   animation: fadeInUp 1s 0.2s ease both;
}

.cta-buttons {
   display: flex;
   gap: 1rem;
   justify-content: center;
   animation: fadeInUp 1s 0.4s ease both;
}

.btn {
   padding: 1rem 2rem;
   border-radius: 50px;
   text-decoration: none;
   font-weight: bold;
   transition: var(--transition);
   display: inline-block;
}

.btn-primary {
   background: linear-gradient(135deg, var(--primary), var(--secondary));
   color: white;
   box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
   transform: translateY(-3px);
   box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-secondary {
   border: 2px solid var(--primary);
   color: var(--primary);
}

.btn-secondary:hover {
   background: var(--primary);
   color: white;
}

/* ==================== ABOUT ==================== */
.about-content {
   display: grid;
   grid-template-columns: 1fr 2fr;
   gap: 4rem;
   align-items: center;
}

.about-img img {
   width: 100%;
   border-radius: 20px;
   box-shadow: 0 20px 40px var(--shadow);
}

.about-text h3 {
   font-size: 2rem;
   margin-bottom: 1rem;
}

.skills {
   margin-top: 2rem;
}

.skill {
   margin-bottom: 1.5rem;
}

.skill-header {
   display: flex;
   justify-content: space-between;
   margin-bottom: 0.5rem;
}

.skill-bar {
   height: 10px;
   background: rgba(102, 126, 234, 0.2);
   border-radius: 5px;
   overflow: hidden;
}

/* ==================== SKILL BARS ANIMATION (CSS-only via @keyframes + animation-timeline) ==================== */
.skill-progress {
   height: 100%;
   background: linear-gradient(90deg, var(--primary), var(--secondary));
   border-radius: 5px;
   width: 0;
   animation: growBar 1.5s ease-out forwards;
   animation-play-state: paused;
}

@supports (animation-timeline: view()) {
   .skill-progress {
       animation-timeline: view();
       animation-range: entry 10% entry 40%;
       animation-play-state: running;
   }
}

@supports not (animation-timeline: view()) {
   .skill-progress {
       animation-play-state: running;
       animation-delay: 0.5s;
   }
}

.skill-progress-95 { animation-name: growBar95; }
.skill-progress-85 { animation-name: growBar85; }
.skill-progress-80 { animation-name: growBar80; }

@keyframes growBar95 { from { width: 0; } to { width: 95%; } }
@keyframes growBar85 { from { width: 0; } to { width: 85%; } }
@keyframes growBar80 { from { width: 0; } to { width: 80%; } }
@keyframes growBar { from { width: 0; } to { width: 100%; } }

/* ==================== PORTFOLIO ==================== */
.filter-buttons {
   display: flex;
   justify-content: center;
   gap: 1rem;
   margin-bottom: 3rem;
   flex-wrap: wrap;
}

/* Filtre CSS-only : radio buttons cachés + :checked ~ sélecteurs */
.filter-radio { display: none; }

.filter-btn {
   padding: 0.5rem 1.5rem;
   border: 2px solid var(--primary);
   background: transparent;
   color: var(--primary);
   border-radius: 25px;
   cursor: pointer;
   transition: var(--transition);
   font-weight: 500;
   display: inline-block;
   user-select: none;
}

.filter-btn:hover {
   background: var(--primary);
   color: white;
}

/* État actif par défaut : "Tous" coché */
#filter-all:checked ~ .filter-buttons label[for="filter-all"],
#filter-frontend:checked ~ .filter-buttons label[for="filter-frontend"],
#filter-backend:checked ~ .filter-buttons label[for="filter-backend"],
#filter-design:checked ~ .filter-buttons label[for="filter-design"] {
   background: var(--primary);
   color: white;
}

.portfolio-grid {
   display: grid;
   grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
   gap: 2rem;
}

.portfolio-item {
   background: var(--white);
   border-radius: 15px;
   overflow: hidden;
   box-shadow: 0 5px 15px var(--shadow);
   transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
   opacity: 1;
}

.portfolio-item:hover {
   transform: translateY(-10px);
   box-shadow: 0 15px 30px var(--shadow);
}

/* Filtrage CSS-only : masquer les items qui ne correspondent pas */
#filter-frontend:checked ~ .portfolio-grid .portfolio-item[data-category="backend"],
#filter-frontend:checked ~ .portfolio-grid .portfolio-item[data-category="design"],
#filter-backend:checked ~ .portfolio-grid .portfolio-item[data-category="frontend"],
#filter-backend:checked ~ .portfolio-grid .portfolio-item[data-category="design"],
#filter-design:checked ~ .portfolio-grid .portfolio-item[data-category="frontend"],
#filter-design:checked ~ .portfolio-grid .portfolio-item[data-category="backend"] {
   display: none;
}

/* Nécessite que les radios et la grille soient frères — voir HTML */
.portfolio-wrapper { }

.portfolio-img {
   height: 200px;
   background: linear-gradient(135deg, var(--primary), var(--secondary));
   display: flex;
   align-items: center;
   justify-content: center;
   color: white;
   font-size: 3rem;
}
.portfolio-img img{
   height: 100%;
   width: 100%;
}

.portfolio-content {
   padding: 1.5rem;
}

.portfolio-content h3 {
   margin-bottom: 0.5rem;
}

.portfolio-content p {
   color: var(--gray);
   font-size: 0.95rem;
}

.portfolio-tags {
   display: flex;
   gap: 0.5rem;
   margin-top: 1rem;
   flex-wrap: wrap;
}

.tag {
   padding: 0.25rem 0.75rem;
   background: rgba(102, 126, 234, 0.1);
   color: var(--primary);
   border-radius: 15px;
   font-size: 0.85rem;
}

/* ==================== CONTACT ==================== */
.contact-content {
   display: grid;
   grid-template-columns: 1fr 1fr;
   gap: 4rem;
}

.contact-info h3 {
   font-size: 1.5rem;
   margin-bottom: 1rem;
}

.contact-item {
   display: flex;
   align-items: center;
   gap: 1rem;
   margin-bottom: 1.5rem;
}

.contact-icon {
   width: 50px;
   height: 50px;
   background: linear-gradient(135deg, var(--primary), var(--secondary));
   color: white;
   border-radius: 50%;
   display: flex;
   align-items: center;
   justify-content: center;
   font-size: 1.2rem;
   flex-shrink: 0;
}

.contact-form {
   background: var(--white);
   padding: 2rem;
   border-radius: 15px;
   box-shadow: 0 5px 15px var(--shadow);
}

.form-group {
   margin-bottom: 1.5rem;
}

.form-group label {
   display: block;
   margin-bottom: 0.5rem;
   font-weight: 500;
}

.form-group input,
.form-group textarea {
   width: 100%;
   padding: 0.75rem;
   border: 2px solid #e1e8ed;
   border-radius: 8px;
   background: var(--white);
   color: var(--dark);
   transition: var(--transition);
   font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
   outline: none;
   border-color: var(--primary);
}

/* Feedback de validation CSS-only via :valid/:invalid */
.form-group input:not(:placeholder-shown):valid,
.form-group textarea:not(:placeholder-shown):valid {
   border-color: #48bb78;
}

.form-group input:not(:placeholder-shown):invalid,
.form-group textarea:not(:placeholder-shown):invalid {
   border-color: #fc8181;
}

/* ==================== FOOTER ==================== */
footer {
   background: var(--dark);
   color: var(--light);
   text-align: center;
   padding: 2rem;
}
footer i{
   color: var(--light);
}

.social-links {
   display: flex;
   justify-content: center;
   gap: 1.5rem;
   margin-bottom: 1rem;
}

.social-links a {
   width: 40px;
   height: 40px;
   background: rgba(255,255,255,0.1);
   color: white;
   border-radius: 50%;
   display: flex;
   align-items: center;
   justify-content: center;
   text-decoration: none;
   transition: var(--transition);
}

.social-links a:hover {
   background: var(--primary);
   transform: translateY(-3px);
}

/* ==================== BACK TO TOP (CSS-only via :target ou scroll-driven) ==================== */
/* Astuce : anchor #top visible via lien, bouton toujours accessible */
.back-to-top {
   position: fixed;
   bottom: 30px;
   right: 30px;
   width: 50px;
   height: 50px;
   background: var(--primary);
   color: white;
   border-radius: 50%;
   display: flex;
   align-items: center;
   justify-content: center;
   text-decoration: none;
   box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
   font-size: 1.2rem;

   /* Etat caché */
   opacity: 0;
   transform: translateY(20px);
   pointer-events: none;

   transition: 
      opacity 0.4s ease,
      transform 0.4s ease,
      background 0.3s ease;

   /* Animation scroll CSS moderne */
   animation: showBackTop linear;
   animation-timeline: scroll(root);
   animation-range: 200px 400px;
   animation-fill-mode: forwards;
}

@keyframes showBackTop {
   from {
      opacity: 0;
      transform: translateY(20px);
      pointer-events: none;
   }
   to {
      opacity: 1;
      transform: translateY(0);
      pointer-events: auto;
   }
}

.back-to-top:hover {
   background: var(--primary-dark);
   transform: translateY(-3px);
}
/* ==================== ANIMATIONS ==================== */
@keyframes fadeInUp {
   from {
       opacity: 0;
       transform: translateY(30px);
   }
   to {
       opacity: 1;
       transform: translateY(0);
   }
}

/* ==================== HEADER scroll shadow (CSS-only via animation-timeline) ==================== */
header {
   animation: headerShadow linear;
   animation-timeline: scroll(root);
   animation-range: 0px 100px;
   animation-fill-mode: forwards;
}

@keyframes headerShadow {
   from { box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
   to   { box-shadow: 0 2px 20px rgba(0,0,0,0.15); }
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 768px) {

   .nav-links {
       position: fixed;
       top: 70px;
       left: 0;
       width: 100%;
       background: var(--white);
       flex-direction: column;
       text-align: center;
       padding: 0;
       box-shadow: 0 10px 27px var(--shadow);

       /* Etat fermé */
       max-height: 0;
       overflow: hidden;
       opacity: 0;
       transform: translateY(-10px);

       transition:
           max-height 0.5s ease,
           opacity 0.4s ease,
           transform 0.4s ease;
   }

   /* MENU OUVERT */
   #menu-toggle:checked ~ header nav .nav-links {
       max-height: 500px; /* suffisamment grand */
       opacity: 1;
       transform: translateY(0);
       padding: 2rem 0;
   }

   .menu-toggle-label {
       display: flex;
   }

   .hero-content h1 {
       font-size: 2.5rem;
   }
   
   .about-content,
   .contact-content {
       grid-template-columns: 1fr;
       gap: 2rem;
   }
   
   .cta-buttons {
       flex-direction: column;
       align-items: center;
   }
   
   section {
       padding: 80px 1.5rem;
   }
}
