/* Responsive Design optimisé */

/* Section scroll snap mobile */
@media (max-width: 768px) {
    .scroll-container {
        scroll-snap-type: y mandatory;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        scroll-padding-top: 70px;
        height: 100vh;
        height: 100dvh;
    }
    
    /* Force les sections à occuper exactement l'écran */
    .section {
        scroll-snap-align: start;
        scroll-snap-stop: always;
    }
    
    .section {
        scroll-snap-align: start;
        scroll-snap-stop: always;
        min-height: 100vh !important;
        min-height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        height: 100vh !important;
        height: 100dvh !important;
        padding-top: 85px;
        padding-bottom: 15px;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
        margin: 0 !important;
        overflow: hidden;
        background-attachment: scroll;
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
        position: relative;
    }
    
    body {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Hero optimisé mobile */
    .hero-section {
        min-height: 100vh !important;
        min-height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        height: 100vh !important;
        height: 100dvh !important;
        padding-top: 85px !important;
        padding-bottom: 15px !important;
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
        margin: 0 !important;
        overflow: hidden !important;
        justify-content: center;
        align-items: center;
        display: flex !important;
        box-sizing: border-box !important;
        scroll-snap-align: start !important;
    }
    
    .hero-container {
        height: calc(100vh - 90px) !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-sizing: border-box !important;
    }
    
    .hero-content {
        transform: scale(1) !important;
        padding: 1rem !important;
        width: 90% !important;
        gap: 1.5rem !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .hero-name {
        margin-bottom: 1.5rem !important;
    }
    
    /* Retour à la ligne après Raphaël sur mobile */
    .hero-name .name-space {
        display: block !important;
        height: 0.5rem !important;
    }
    
    .hero-job {
        margin-bottom: 1.5rem !important;
    }
    
    .hero-description {
        margin-top: 1.5rem !important;
    }
    

    /* Parcours avec carrousel */
    .section#parcours {
        min-height: 100vh !important;
        min-height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        height: 100vh !important;
        height: 100dvh !important;
        padding-top: 85px;
        padding-bottom: 15px;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
        margin: 0 !important;
        overflow: hidden;
        justify-content: flex-start;
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
    }

    /* Carrousels actifs sur mobile */
    .certifications-carousel,
    .projects-carousel {
        display: block !important;
        opacity: 1;
        visibility: visible;
        flex: 1;
        display: flex !important;
        flex-direction: column;
        justify-content: space-between;
        margin-top: 0.5rem;
        overflow: hidden;
        min-height: 0;
    }
    
    .certifications-desktop-carousel,
    .projects-grid {
        display: none !important;
    }
    
    .certifications-track,
    .projects-track {
        flex: 1;
        display: flex;
        align-items: center;
        min-height: 0;
    }
    
    .certification-slide,
    .project-slide {
        display: flex !important;
        align-items: center;
        justify-content: center;
        padding: 0.5rem;
        min-height: 0;
        opacity: 1 !important;
        transform: none !important;
    }
    
    .certification-slide .certification-card {
        max-width: 95%;
        width: 95%;
        padding: 1rem;
        margin: 0;
        box-sizing: border-box;
    }
    
    .project-slide .project-card {
        max-width: 90%;
        width: 90%;
        padding: 0.8rem;
        margin: 0;
        box-sizing: border-box;
        max-height: calc(100vh - 280px);
        overflow-y: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .project-slide .project-card::-webkit-scrollbar {
        display: none;
    }
    
    .carousel-navigation {
        display: flex !important;
        margin-top: 1rem;
        margin-bottom: 1rem;
        flex-shrink: 0;
        justify-content: center !important;
        align-items: center !important;
        padding: 0 1rem !important;
        gap: 1.5rem !important;
    }
    
    .carousel-btn {
        width: 45px !important;
        height: 45px !important;
        font-size: 1rem !important;
        background: linear-gradient(135deg, var(--primary-color), var(--accent-color)) !important;
        color: white !important;
        border: none !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
        box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3) !important;
        touch-action: manipulation !important;
        user-select: none !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    
    .carousel-btn:hover {
        transform: translateY(-2px) scale(1.05) !important;
        box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4) !important;
    }
    
    .carousel-btn:active {
        transform: translateY(0) scale(0.98) !important;
    }
    
    .dot {
        width: 10px !important;
        height: 10px !important;
        border-radius: 50% !important;
        background: rgba(255, 255, 255, 0.4) !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
        touch-action: manipulation !important;
        user-select: none !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    
    .dot.active {
        background: var(--primary-color) !important;
        transform: scale(1.3) !important;
        box-shadow: 0 0 15px rgba(37, 99, 235, 0.6) !important;
    }
    
    .dot:hover {
        background: var(--primary-color) !important;
        transform: scale(1.2) !important;
    }
    
    .carousel-dots {
        gap: 0.8rem !important;
        display: flex !important;
        align-items: center !important;
    }

    /* Timeline mobile */
    .timeline-desktop {
        display: none !important;
    }
    
    .timeline-mobile {
        display: flex !important;
        flex-direction: column;
        flex: 1;
        margin-top: 0.5rem;
        overflow: hidden;
        min-height: 0;
    }
    
    /* Cacher les descriptions sur mobile et réduire les cartes */
    .timeline-mobile .timeline-description {
        display: none !important;
    }
    
    .timeline-mobile .timeline-content {
        min-height: auto !important;
        max-height: auto !important;
        padding: 1.5rem !important;
    }
    
    /* Pareil pour les projets */
    .projects-carousel .project-description {
        display: none !important;
    }
    
    .project-slide .project-card {
        min-height: auto !important;
        max-height: auto !important;
        padding: 1.2rem !important;
    }
    
    .project-impact {
        margin-top: 0.5rem !important;
        padding: 0.8rem !important;
    }
    
    .timeline-track {
        flex: 1;
        display: flex;
        align-items: center;
        min-height: 0;
        height: 100%;
    }
    
    .timeline-slide {
        min-width: 100%;
        width: 100%;
        flex-shrink: 0;
        display: flex !important;
        justify-content: center;
        align-items: center;
        padding: 0;
        box-sizing: border-box;
    }
    
    .timeline-mobile .timeline-item {
        width: 100%;
        max-width: 100%;
        display: flex;
        justify-content: center;
        padding: 0 1rem;
        box-sizing: border-box;
    }
    
    .timeline-mobile .timeline-content {
        background: var(--bg-primary);
        padding: 2rem;
        border-radius: 15px;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
        border: 1px solid var(--border-color);
        width: 100%;
        max-width: 600px;
        min-height: 350px;
        max-height: 450px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        margin: 0 auto;
        position: relative;
    }

    /* Contact optimisé mobile - aligné avec les autres sections */
    .section#contact {
        min-height: 100vh !important;
        min-height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        height: 100vh !important;
        height: 100dvh !important;
        padding-top: 85px !important;
        padding-bottom: 15px !important;
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
        margin: 0 !important;
        justify-content: flex-start !important;
        overflow: hidden !important;
        scroll-snap-align: start !important;
        position: relative !important;
        display: flex !important;
        flex-direction: column !important;
        box-sizing: border-box !important;
        background-attachment: scroll !important;
    }
    
    .section#contact .container {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 0;
        margin: 0;
        box-sizing: border-box;
        min-height: 0;
    }
    
    .section#contact .section-title {
        font-size: 1.6rem !important;
        margin-bottom: 1rem !important;
        margin-top: 0.5rem !important;
        flex-shrink: 0;
    }
    
    .section#contact .contact-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        margin-top: 0;
        padding: 0;
        overflow: hidden;
        box-sizing: border-box;
    }
    
    /* Cacher le formulaire sur mobile */
    .contact-form {
        display: none !important;
    }
    
    .contact-info {
        flex: 1;
        max-width: 100% !important;
        display: flex;
        flex-direction: column;
        justify-content: center;
        height: 100%;
        overflow: hidden;
        padding: 0 0.5rem;
        box-sizing: border-box;
    }
    
    .contact-info h3 {
        font-size: 1.2rem !important;
        margin-bottom: 0.8rem !important;
        text-align: center;
        color: var(--text-primary);
    }
    
    .contact-info > p {
        font-size: 0.9rem !important;
        margin-bottom: 1.5rem !important;
        line-height: 1.4;
        text-align: center;
        color: var(--text-secondary);
    }
    
    .contact-methods {
        display: flex;
        flex-direction: column;
        gap: 0.8rem;
        padding: 0;
        flex-shrink: 0;
    }
    
    .contact-link {
        padding: 0.8rem !important;
        border-radius: 12px !important;
        gap: 0.8rem !important;
        min-height: 50px;
        display: flex;
        align-items: center;
        background: rgba(255, 255, 255, 0.1) !important;
        backdrop-filter: blur(10px) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        transition: all 0.3s ease;
        box-sizing: border-box;
    }
    
    .contact-link:hover {
        background: rgba(255, 255, 255, 0.2) !important;
        transform: translateY(-2px);
    }
    
    .contact-method i {
        width: 40px !important;
        height: 40px !important;
        font-size: 1rem !important;
        flex-shrink: 0;
        background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    }
    
    .contact-link span {
        font-size: 0.9rem !important;
        font-weight: 500 !important;
        color: var(--text-primary) !important;
    }
    
    /* Titres des sections - espacement avec navbar - rapprochés du contenu */
    .section-title {
        margin-top: 0 !important;
        margin-bottom: 0.8rem !important;
    }
    
    /* Sections plus proches du titre - déjà géré par le padding général */
}

/* Tablettes (1024px et moins) */
@media (max-width: 1024px) {
    .container {
        padding: 0 1.5rem;
    }
    
    .hero-name {
        font-size: 3.3rem;
    }
    
    .job-title {
        font-size: 2.5rem;
    }
    
    .hero-description {
        font-size: 2rem;
    }
    
    .section-title {
        font-size: 2rem;
        margin-bottom: 3rem;
        margin-top: -1rem;
    }
    
    .section {
        padding-top: 120px;
        padding-bottom: 60px;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
    }
    
    .contact-content {
        flex-direction: column;
        gap: 2rem;
    }
    
    .contact-form {
        max-width: 100%;
    }
}

/* Smartphones (480px et moins) */
@media (max-width: 480px) {
    .scroll-container {
        scroll-padding-top: 60px;
        height: 100vh;
        height: 100dvh;
    }
    
    .container {
        padding: 0 1rem;
    }
    
    .nav-container {
        height: 60px;
        padding: 0 1rem;
    }
    
    /* Ajustement pour la navbar plus petite sur mobile */
    .section {
        padding-top: 70px !important;
        padding-bottom: 10px !important;
        height: 100vh !important;
        height: 100dvh !important;
        min-height: 100vh !important;
        min-height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        margin: 0 !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
        box-sizing: border-box !important;
        position: relative !important;
    }
    
    .hero-section {
        padding-top: 70px !important;
        padding-bottom: 10px !important;
        overflow: hidden !important;
    }
    
    .section#contact {
        padding-top: 70px !important;
        padding-bottom: 10px !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        overflow: hidden !important;
    }
    
    .section {
        max-height: 100vh;
        max-height: 100dvh;
        min-height: 100vh;
        min-height: 100dvh;
        padding-top: 80px;
        padding-bottom: 20px;
        padding-left: 1rem;
        padding-right: 1rem;
        justify-content: flex-start;
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
    }
    
    .hero-section {
        justify-content: center;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        padding-top: 75px !important;
        height: 100vh !important;
        height: 100dvh !important;
    }
    
    .hero-container {
        height: calc(100vh - 75px) !important;
    }
    
    .hero-name {
        font-size: 2.5rem;
        margin: 0.3rem 0;
        letter-spacing: 0px;
    }
    
    .job-title {
        font-size: 1.4rem;
        padding: 0.3rem 0.8rem;
    }
    
    .hero-description {
        font-size: 1.5rem;
        margin: 1rem 0;
        line-height: 1.4;
    }
    
    .section-title {
        font-size: 1.6rem;
        margin-bottom: 1.2rem;
        margin-top: 0;
    }

    /* Contact mobile très petit écran - déjà géré par les règles au-dessus */
    
    .section#contact .section-title {
        margin-bottom: 1rem !important;
        margin-top: 0.5rem !important;
        font-size: 1.4rem !important;
    }
    
    .section#contact .contact-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        height: 100%;
        overflow: hidden;
        padding: 0;
        box-sizing: border-box;
    }

    /* Optimisation cards mobile */
    .certification-slide .certification-card {
        padding: 0.8rem !important;
        max-width: 95% !important;
    }
    
    .project-slide .project-card {
        padding: 0.8rem !important;
        max-width: 92% !important;
        width: 92% !important;
        max-height: calc(100vh - 220px) !important;
        overflow-y: auto !important;
    }
    
    .carousel-btn {
        width: 42px !important;
        height: 42px !important;
        font-size: 0.9rem !important;
        background: linear-gradient(135deg, var(--primary-color), var(--accent-color)) !important;
        box-shadow: 0 3px 10px rgba(37, 99, 235, 0.3) !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    
    .carousel-btn:hover {
        transform: translateY(-2px) scale(1.05) !important;
        box-shadow: 0 5px 15px rgba(37, 99, 235, 0.4) !important;
    }
    
    .carousel-navigation {
        gap: 1.2rem !important;
        margin: 0.8rem 0 !important;
        padding: 0 1rem !important;
        justify-content: center !important;
        align-items: center !important;
    }
    
    .dot {
        width: 8px !important;
        height: 8px !important;
        background: rgba(255, 255, 255, 0.5) !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    
    .dot.active {
        background: var(--primary-color) !important;
        transform: scale(1.4) !important;
        box-shadow: 0 0 12px rgba(37, 99, 235, 0.6) !important;
    }
    
    .dot:hover {
        background: var(--primary-color) !important;
        transform: scale(1.3) !important;
    }

    /* Textes réduits */
    .certification-card h3,
    .project-card .project-header h3 {
        font-size: 1rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .cert-icon {
        width: 50px !important;
        height: 50px !important;
        font-size: 1.5rem !important;
        margin-bottom: 1rem !important;
    }
    
    .project-description,
    .timeline-description {
        font-size: 0.85rem !important;
        line-height: 1.4 !important;
        margin-bottom: 0.8rem !important;
    }
    
    .tag {
        font-size: 0.7rem !important;
        padding: 0.2rem 0.5rem !important;
    }
    
    .project-impact {
        font-size: 0.8rem !important;
        padding: 0.6rem !important;
        margin-top: 0.8rem !important;
    }
}

/* Desktop - S'assurer que le formulaire est visible */
@media (min-width: 769px) {
    .contact-form {
        display: block !important;
    }
    
    .contact-content {
        display: block !important;
    }
    
    .contact-info {
        width: 100% !important;
    }

    .contact-methods {
        display: flex !important;
        flex-direction: row !important;
        gap: 2rem !important;
        justify-content: space-between !important;
    }

    .contact-method {
        flex: 1 !important;
    }

    .contact-link {
        width: 100% !important;
        justify-content: flex-start !important;
        align-items: center !important;
        gap: 1rem !important;
    }

    .contact-link span {
        text-align: left !important;
        flex: 1 !important;
    }
    
    .contact-form {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
    
    /* S'assurer que la section contact utilise le margin-top standard */
    .section#contact .section-title {
        margin-top: 0.5rem !important;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    [data-scroll] {
        transform: none !important;
        opacity: 1 !important;
    }
}