/* ============================================
   KACHOURI.COM - Main Stylesheet
   Modern Glassmorphism Design System
   ============================================ */

/* ============================================
   CSS CUSTOM PROPERTIES (Variables)
   ============================================ */
:root {
    /* Dynamic Color System - Changes with scroll */
    --primary-hue: 240;
    --primary: hsl(var(--primary-hue), 70%, 65%);
    --primary-dark: hsl(var(--primary-hue), 70%, 50%);
    --primary-light: hsl(var(--primary-hue), 70%, 80%);
    
    /* Gradient System */
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gradient-dynamic: linear-gradient(135deg, 
        hsl(var(--primary-hue), 70%, 65%) 0%, 
        hsl(calc(var(--primary-hue) + 30), 60%, 60%) 100%);
    
    /* Neutral Colors */
    --bg-dark: #0a0a0f;
    --bg-card: rgba(255, 255, 255, 0.05);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    
    /* Light mode (optional) */
    --bg-light: #f8f9fa;
    --text-dark: #1a1a2e;
    
    /* Spacing System */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 2rem;
    --spacing-lg: 4rem;
    --spacing-xl: 6rem;
    
    /* Typography */
    --font-primary: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Courier New', Courier, monospace;
    
    /* Sizes */
    --header-height: 80px;
    --max-width: 1400px;
    --border-radius: 16px;
    --border-radius-sm: 8px;
    
    /* Effects */
    --blur-amount: 20px;
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 30px rgba(102, 126, 234, 0.3);
    
    /* Transitions */
    --transition-fast: 200ms ease;
    --transition-base: 300ms ease;
    --transition-slow: 400ms ease;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* FIX: Éviter que le header fixed cache les images en haut de page */
    padding-top: var(--header-height);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
    transition: all var(--transition-base);
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    transition: all var(--transition-base);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.gradient-text {
    background: var(--gradient-dynamic);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(var(--blur-amount));
    -webkit-backdrop-filter: blur(var(--blur-amount));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

/* ============================================
   NAVIGATION
   ============================================ */
.nav-glass {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: all var(--transition-base);
}

.nav-glass.scrolled {
    background: rgba(10, 10, 15, 0.95);
    box-shadow: var(--shadow-md);
}

.nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    position: relative;
}

.logo-text {
    background: var(--gradient-dynamic);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Nom complet "Mehdi Kachouri" à côté du logo MK */
.logo-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

/* Mobile : cacher le nom complet, garder seulement MK */
@media (max-width: 768px) {
    .logo-name {
        display: none;
    }
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: var(--spacing-md);
    align-items: center;
}

.nav-link {
    position: relative;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color var(--transition-base);
}

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

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--gradient-dynamic);
    transition: width var(--transition-base);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

.cta-nav {
    padding: 0.5rem 1.5rem;
    background: var(--gradient-dynamic);
    border-radius: 50px;
    color: white !important;
    font-weight: 600;
}

.cta-nav::after {
    display: none;
}

.cta-nav:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.social-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    transition: all var(--transition-base);
}

.social-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary);
    transform: translateY(-2px);
}

/* Mobile Navigation Toggle */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 30px;
    height: 30px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    /* FIX: ajout pour menu burger mobile */
    position: relative;
    z-index: 1001;
}

.hamburger {
    width: 100%;
    height: 2px;
    background: var(--text-primary);
    transition: all var(--transition-base);
    /* FIX: ajout pour animation hamburger */
    position: relative;
}

/* FIX: ajouter les 3 barres du hamburger */
.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    background: var(--text-primary);
    left: 0;
    transition: all var(--transition-base);
}

.hamburger::before {
    top: -8px;
}

.hamburger::after {
    bottom: -8px;
}

/* FIX: animation hamburger en X quand actif */
.nav-toggle.active .hamburger {
    background: transparent;
}

.nav-toggle.active .hamburger::before {
    top: 0;
    transform: rotate(45deg);
}

.nav-toggle.active .hamburger::after {
    bottom: 0;
    transform: rotate(-45deg);
}

/* ============================================
   HERO SECTION
   ============================================ */
.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl) var(--spacing-md);
    overflow: hidden;
}

.hero-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

#particlesCanvas {
    width: 100%;
    height: 100%;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: var(--max-width);
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
    align-items: center;
}

.hero-text {
    animation: fadeInUp 1s ease-out;
}

.hero-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: var(--spacing-md);
}

.title-line {
    display: block;
}

.hero-subtitle {
    font-size: clamp(1.1rem, 2vw, 1.3rem);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
    max-width: 600px;
}

.hero-ctas {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.btn-primary,
.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-weight: 600;
    transition: all var(--transition-base);
}

.btn-primary {
    background: var(--gradient-dynamic);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
}

.btn-ghost {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Hero Visual - Floating Cards */
.hero-visual {
    position: relative;
    height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.floating-card {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    animation: float 6s ease-in-out infinite;
}

.floating-card span {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.floating-card.card-1 {
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.floating-card.card-2 {
    top: 50%;
    right: 10%;
    animation-delay: 2s;
}

.floating-card.card-3 {
    bottom: 10%;
    left: 30%;
    animation-delay: 4s;
}

.scroll-indicator {
    position: absolute;
    bottom: var(--spacing-lg);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    animation: bounce 2s infinite;
}

/* ============================================
   SECTIONS LAYOUT
   ============================================ */
.about-section,
.featured-projects,
.contact-section {
    padding: var(--spacing-xl) 0;
    position: relative;
}

.section-header {
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

.section-tag {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary);
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--spacing-sm);
}

.section-title {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 800;
    margin-bottom: var(--spacing-sm);
}

.section-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto;
}

/* ============================================
   ABOUT SECTION
   ============================================ */
.about-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
    align-items: start;
}

.about-text {
    font-size: 1.1rem;
}

.lead {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
}

.about-text p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

.about-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 2.5rem;
    font-weight: 800;
    background: var(--gradient-dynamic);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.about-skills {
    display: grid;
    gap: var(--spacing-md);
}

.skill-card {
    padding: var(--spacing-md);
    background: var(--bg-card);
    backdrop-filter: blur(var(--blur-amount));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    transition: all var(--transition-base);
}

.skill-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-glow);
}

.skill-icon {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-sm);
}

.skill-card h3 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.skill-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */
@media (max-width: 1024px) {
    :root {
        --spacing-xl: 4rem;
        --spacing-lg: 3rem;
    }
    
    .hero-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .hero-visual {
        height: 300px;
    }
    
    .hero-subtitle {
        margin-left: auto;
        margin-right: auto;
    }
    
    .hero-ctas {
        justify-content: center;
    }
    
    .about-content {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 768px) {
    :root {
        --spacing-xl: 3rem;
        --spacing-lg: 2rem;
        --spacing-md: 1.5rem;
        --header-height: 60px;
    }
    
    .nav-toggle {
        display: flex;
    }
    
    .nav-menu {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        flex-direction: column;
        background: rgba(10, 10, 15, 0.98);
        backdrop-filter: blur(20px);
        padding: var(--spacing-md);
        transform: translateY(-100%);
        opacity: 0;
        transition: all var(--transition-base);
        pointer-events: none;
    }
    
    .nav-menu.active {
        transform: translateY(0);
        opacity: 1;
        pointer-events: all;
    }
    
    .hero {
        min-height: 90vh;
        padding: var(--spacing-lg) var(--spacing-sm);
    }
    
    .hero-visual {
        display: none;
    }
    
    .about-stats {
        grid-template-columns: 1fr;
    }
    
    .stat-number {
        font-size: 2rem;
    }
}


/* =========================================
   PATCH MOBILE - FIX D'AFFICHAGE ANDROID/CHROME
   ========================================= */

@media (max-width: 992px) {

    /* 1. FORCE L'AFFICHAGE DU HEADER DE SECTION (Page Accueil) */
    .section-header {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        margin-bottom: 3rem !important;
        padding: 0 1rem;
    }

    .section-tag, 
    .section-title, 
    .section-subtitle {
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        display: block !important;
    }

    /* 2. FIX DES GRILLES QUI DISPARAISSENT (Blog & Projets) */
    .projects-grid, 
    .blog-grid {
        display: flex !important; /* Flex est plus sûr que Grid sur certains vieux Android */
        flex-direction: column !important;
        gap: 2rem !important;
        opacity: 1 !important;
    }

    /* 3. DÉSACTIVATION DES ANIMATIONS SCROLL SUR MOBILE */
    /* C'est souvent la cause principale : l'élément attend de scroller pour apparaître mais bug */
    .scroll-reveal,
    .project-card,
    .blog-card,
    .glass-card {
        opacity: 1 !important;
        transform: translate(0, 0) !important;
        transition: none !important; /* On coupe la transition pour éviter le flash */
        visibility: visible !important;
        animation: none !important;
    }
    
    /* 4. AJUSTEMENT DES IMAGES SUR MOBILE */
    .card-image, 
    .blog-image {
        min-height: 200px;
        height: auto !important;
    }
}