:root {
    --bg-color: #F8F8F6;
    --text-color: #1A1A1A;
    --text-muted: #666666;
    --accent: #b48a01;
    --glass-bg: rgba(255, 255, 255, 0.4);
    --glass-border: rgba(255, 255, 255, 0.2);
    --font-title: 'Space Grotesk', sans-serif;
    --toggle-base-bg: rgba(0,0,0,0.05);
    --toggle-handle-bg: #ffffff;
    --card-info-bg: #F0EEE9;
    --section-padding: 100px;
    --content-gap: 60px;
    transition: background-color 0.4s ease, color 0.4s ease;
}

[data-theme="dark"] {
    --bg-color: #0f0f0f;
    --text-color: #f8f8f6;
    --text-muted: #AAAAAA;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --toggle-base-bg: rgba(255,255,255,0.1);
    --toggle-handle-bg: #1A1A1A;
    --card-info-bg: #161514;
}

[data-theme="dark"] body, 
[data-theme="dark"] .panel, 
[data-theme="dark"] footer,
[data-theme="dark"] #work.panel,
[data-theme="dark"] #about.panel {
    background-color: var(--bg-color) !important;
    color: var(--text-color) !important;
}

/* Force le light mode par défaut sur mobile si pas de thème défini */
@media (max-width: 768px) {
    body:not([data-theme]) {
        background-color: #F8F8F6 !important;
        color: #1A1A1A !important;
    }
    
    body:not([data-theme]) .panel,
    body:not([data-theme]) #work.panel,
    body:not([data-theme]) #about.panel {
        background-color: #F0EEE9 !important;
        color: #1A1A1A !important;
    }
    
    body:not([data-theme]) .hero.panel {
        background-color: #E6E6E3 !important;
    }
    
    body:not([data-theme]) #about.panel {
        background-color: #F8F8F6 !important;
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; cursor: none; }

html {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: 'DM Sans', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

/* --- STRUCTURE --- */
.stack-container { position: relative; width: 100%; }
.hero.panel { position: sticky; top: 0; height: 100vh; z-index: 1; background-color: #E6E6E3; display: flex; align-items: center; justify-content: center; }
[data-theme="dark"] .hero.panel { background-color: #1a1a18; }

#work.panel { position: relative; z-index: 2; background-color: var(--card-info-bg); min-height: 100vh; border-radius: 60px 60px 0 0; box-shadow: 0 -20px 50px rgba(0,0,0,0.15); padding-bottom: 120px; }
#about.panel { position: sticky; top: 0; min-height: 100vh; z-index: 3; background-color: var(--bg-color); border-radius: 60px 60px 0 0; box-shadow: 0 -20px 50px rgba(0,0,0,0.15); display: flex; flex-direction: column; align-items: center; justify-content: center; margin-top: -60px; padding: var(--section-padding) 5vw 40px; overflow-x: hidden; width: 100%; }

/* --- NAVIGATION & UI --- */
.floating-ui { position: fixed; top: 25px; left: 0; width: 100%; z-index: 5000; display: flex; justify-content: space-between; align-items: center; padding: 0 40px; pointer-events: none; }
.ui-element {
    pointer-events: auto;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    padding: 10px 22px;
    border-radius: 100px;
    display: flex;
    align-items: center;
    will-change: transform;
}
.nav-pill { gap: 25px; padding: 12px 35px; }
.nav-pill a { text-decoration: none; color: var(--text-color); font-family: var(--font-title); font-size: 0.75rem; text-transform: uppercase; font-weight: 500; }

.theme-pill { padding: 6px 10px; }
.switch-base { background: var(--toggle-base-bg); border-radius: 20px; width: 38px; height: 20px; padding: 2px; position: relative; display: flex; align-items: center; }
.switch-handle { background: var(--toggle-handle-bg); border-radius: 50%; position: absolute; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; transition: 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28); left: 2px; }
.dark-mode-active .switch-handle { transform: translateX(18px); }
.theme-icon { color: var(--text-color); width: 10px; height: 10px; position: absolute; }
.sun-icon { display: block; } .moon-icon { display: none; }
.dark-mode-active .sun-icon { display: none; } .dark-mode-active .moon-icon { display: block; }

/* --- HERO --- */
.hero-title { font-family: var(--font-title); font-size: clamp(3rem, 7vw, 7rem); line-height: 1.1; letter-spacing: -0.05em; text-align: center; }
.highlight { color: var(--accent); }

/* --- PROJETS --- */
.work-section { padding: var(--section-padding) 0; width: 100%; }
.section-header { max-width: 1400px; margin: 0 auto var(--content-gap); padding: 0 5vw; }
.section-header h2 { font-family: var(--font-title); font-size: 3.5rem; font-weight: 700; color: var(--text-color); }

.work-grid { max-width: 1400px; margin: 0 auto; padding: 0 5vw; display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 10px; gap: 0 40px; }
.project-card { position: relative; border-radius: 30px; overflow: hidden; background: #000; margin-bottom: 40px; display: block; text-decoration: none; }
.card-tall { grid-row: span 55; } .card-short { grid-row: span 40; }
.project-card img { width: 100%; height: 100%; object-fit: cover; transition: 1.6s cubic-bezier(0.19, 1, 0.22, 1); }

.project-name-static { position: absolute; bottom: 45px; left: 35px; color: white; font-family: var(--font-title); font-size: 1.6rem; font-weight: 500; z-index: 20; transition: transform 1.2s cubic-bezier(0.19, 1, 0.22, 1); }
.card-overlay { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.8), transparent); display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; padding: 35px; opacity: 0; transition: 1.2s; z-index: 10; }
.project-tag { display: inline-block; width: fit-content; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; padding: 6px 14px; border: 1px solid var(--accent); border-radius: 100px; background: rgba(180, 138, 1, 0.1); color: var(--accent); }

.project-card:hover .project-name-static { transform: translateY(-40px); }
.project-card:hover .card-overlay { opacity: 1; backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); }
.project-card:hover img { transform: scale(1.05); }

/* --- ABOUT & FOOTER --- */
.about-text-content { text-align: center; margin-bottom: 120px; }
.about-text-content h2 { font-family: var(--font-title); font-size: 3.5rem; font-weight: 700; color: var(--text-color); }
.about-text-content p { font-size: 1.25rem; line-height: 1.6; color: var(--text-muted); max-width: 700px; margin: 0 auto; }
.blob-container { width: 300px; height: 380px; background: var(--accent); border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; overflow: hidden; margin-bottom: 40px; animation: morphing 8s infinite alternate ease-in-out; }
@keyframes morphing { 0% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; } 100% { border-radius: 40% 60% 70% 30% / 40% 70% 30% 60%; } }
.blob-container img { width: 100%; height: 100%; object-fit: cover; }
footer { margin-top: auto; padding: 100px 0 20px; text-align: center; color: var(--text-muted); font-size: 0.7rem; letter-spacing: 0.2em; width: 100%; }

/* --- INTRO --- */
.intro-block {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    background-color: var(--bg-color);
    z-index: 9000;
    animation: fadeOutBlock 0.5s ease-in forwards 4.3s;
}
.intro-text {
    display: inline-block;
    font-family: var(--font-title);
    font-weight: 700;
    color: var(--text-color);
    animation: slideUp 0.8s forwards 0.3s, grow 1.2s forwards 1.3s;
    letter-spacing: normal;
}
.dot-j {
    position: absolute;
    background-color: var(--accent);
    width: 0.18em;
    height: 0.18em;
    top: 0.22em;
    left: 50%;
    transform: translateX(-50%);
    animation: organicShape 3s infinite alternate ease-in-out 1.3s;
    border-radius: 50%;
}

@keyframes slideUp { 0% { transform: translateY(80px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
@keyframes grow { 0% { font-size: 3rem; letter-spacing: normal; } 100% { font-size: clamp(6rem, 18vw, 18rem); letter-spacing: -0.04em; } }
@keyframes organicShape {
    0% { border-radius: 50%; }
    50% { border-radius: 40% 60% 45% 55% / 55% 45% 60% 40%; }
    100% { border-radius: 50%; }
}
@keyframes fadeOutBlock { to { opacity: 0; visibility: hidden; } }

/* --- CURSOR --- */
.cursor-dot { width: 6px; height: 6px; background: var(--text-color); position: fixed; border-radius: 50%; pointer-events: none; z-index: 9999; }
.cursor-circle { width: 34px; height: 34px; border: 1px solid var(--text-color); position: fixed; border-radius: 50%; pointer-events: none; z-index: 9999; transition: 0.15s; }

/* --- BACK TO TOP BUTTON --- */
.back-to-top {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 50px;
    height: 50px;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-5px);
}

.back-to-top svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-color);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- REVEAL --- */
.reveal { opacity: 0; transform: translateY(40px); transition: 1.2s cubic-bezier(0.19, 1, 0.22, 1); }
.reveal.active { opacity: 1; transform: translateY(0); }

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

/* TABLETTE (769px - 1024px) */
@media (max-width: 1024px) {
    * { cursor: auto !important; }
    
    html, body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }
    
    .cursor-dot, .cursor-circle { display: none !important; }
    
    .back-to-top {
        bottom: 30px;
        right: 30px;
        width: 45px;
        height: 45px;
    }
    
    .back-to-top svg {
        width: 18px;
        height: 18px;
    }
    
    .floating-ui { padding: 0 30px; top: 20px; }
    
    .nav-pill { gap: 20px; padding: 10px 25px; }
    .nav-pill a { font-size: 0.7rem; }
    
    .hero-title { font-size: clamp(2.5rem, 6vw, 5rem); }
    
    .section-header h2 { font-size: 2.8rem; }
    
    /* Grille 2 colonnes sur tablette */
    .work-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0 30px;
    }
    
    .card-tall { grid-row: span 45; }
    .card-short { grid-row: span 35; }
    
    .project-name-static { font-size: 1.4rem; bottom: 55px; left: 25px; }
    .card-overlay { padding: 25px; }
    
    #work.panel, #about.panel { border-radius: 40px 40px 0 0; }
    
    .about-container {
        flex-direction: column !important;
        align-items: center !important;
        gap: 40px !important;
        max-width: 100% !important;
        padding: 0 30px !important;
    }
    
    .about-text-content {
        max-width: 100% !important;
        text-align: left !important;
    }
    
    .about-text-content h2 {
        max-width: 100%;
    }
    
    .about-paragraphs {
        max-width: 100%;
    }
    
    .about-paragraphs p {
        max-width: 100%;
    }
    
    .blob-container { width: 250px; height: 320px; }
    
    .about-text-content h2 { font-size: 2.8rem; }
    .about-text-content p { font-size: 1.1rem; }
}

/* MOBILE (max 768px) */
@media (max-width: 768px) {
    * { cursor: auto !important; }
    
    html, body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }
    
    .cursor-dot, .cursor-circle { display: none !important; }
    
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
    }
    
    .back-to-top svg {
        width: 18px;
        height: 18px;
    }
    
    :root {
        --section-padding: 60px;
        --content-gap: 40px;
    }
    
    .floating-ui {
        padding: 0 20px;
        top: 15px;
        justify-content: space-between;
    }
    
    .ui-element { padding: 8px 18px; }
    
    /* Cache le brand sur mobile SAUF sur les pages projet */
    .brand { display: none; }
    
    /* Sur les pages projet, on garde le bouton retour */
    .project-page .brand {
        display: flex !important;
    }
    
    .nav-pill {
        gap: 15px;
        padding: 10px 20px;
    }
    
    .nav-pill a { font-size: 0.65rem; }
    
    .hero.panel { height: 80vh; }
    .hero-title {
        font-size: clamp(2rem, 10vw, 3.5rem);
        padding: 0 20px;
    }
    
    .work-section { padding: var(--section-padding) 0 60px; }
    
    .section-header { margin-bottom: 40px; }
    .section-header h2 { font-size: 2rem; }
    
    /* 1 COLONNE sur mobile */
    .work-grid {
        grid-template-columns: 1fr;
        gap: 0;
        padding: 0 20px;
    }
    
    .card-tall, .card-short {
        grid-row: span 50;
        margin-bottom: 30px;
        border-radius: 20px;
    }
    
    .project-name-static {
        font-size: 1.2rem;
        bottom: 55px;
        left: 20px;
        z-index: 25;
    }
    
    .card-overlay {
        padding: 20px;
        opacity: 1;
    }
    
    .project-tag {
        font-size: 0.6rem;
        padding: 5px 12px;
        align-self: flex-start;
    }
    
    /* Overlay toujours visible sur mobile */
    .project-card .card-overlay {
        opacity: 1;
    }
    
    #work.panel, #about.panel {
        border-radius: 30px 30px 0 0;
        padding: 60px 0 40px;
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }
    
    .about-container {
        flex-direction: column !important;
        align-items: center !important;
        gap: 30px !important;
        padding: 0 !important;
        max-width: 100% !important;
        width: 100%;
        box-sizing: border-box;
    }
    
    .blob-container {
        width: 200px;
        height: 260px;
        margin-bottom: 20px;
        flex-shrink: 0;
    }
    
    .about-text-content {
        margin-bottom: 60px;
        max-width: 100% !important;
        width: 100%;
        text-align: left !important;
        padding: 0 20px !important;
        box-sizing: border-box;
    }
    
    .about-text-content h2 {
        font-size: 2rem;
        margin-bottom: 25px !important;
        max-width: 100%;
        width: 100%;
        word-break: keep-all;
        overflow-wrap: normal;
        hyphens: none;
        white-space: normal;
    }
    
    .about-text-content p {
        font-size: 1rem;
        line-height: 1.5;
        max-width: 100%;
        width: 100%;
    }
    
    .about-paragraphs {
        max-width: 100%;
        width: 100%;
    }
    
    .about-paragraphs p {
        margin-bottom: 20px !important;
        max-width: 100%;
        width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    footer {
        padding: 60px 0 20px;
        font-size: 0.6rem;
    }
    
    .intro-text {
        font-size: 2rem !important;
        letter-spacing: normal !important;
    }
}

/* TRÈS PETIT MOBILE (max 480px) */
@media (max-width: 480px) {
    .back-to-top {
        bottom: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
    }
    
    .back-to-top svg {
        width: 16px;
        height: 16px;
    }
    
    .floating-ui { padding: 0 15px; }
    
    .ui-element { padding: 6px 15px; font-size: 0.9rem; }
    
    .nav-pill a { font-size: 0.6rem; }
    
    .hero-title { font-size: clamp(1.8rem, 9vw, 3rem); }
    
    .section-header h2 { font-size: 1.75rem; }
    
    .work-grid { padding: 0 15px; }
    
    .project-name-static { font-size: 1.1rem; }
    
    #about.panel {
        padding: 60px 0 40px;
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }
    
    .about-container {
        padding: 0 !important;
        width: 100%;
        max-width: 100%;
    }
    
    .about-text-content {
        padding: 0 15px !important;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .about-text-content h2 {
        font-size: 1.75rem;
        width: 100%;
        max-width: 100%;
        word-break: keep-all;
        overflow-wrap: normal;
        hyphens: none;
    }
    
    .about-text-content p {
        font-size: 0.95rem;
        width: 100%;
        max-width: 100%;
    }
    
    .about-paragraphs {
        width: 100%;
        max-width: 100%;
    }
    
    .about-paragraphs p {
        width: 100%;
        max-width: 100%;
    }
    
    .blob-container { width: 180px; height: 230px; }
}