/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    --bg: #030305;
    --surface: #0a0a0c;
    --text-main: #ffffff;
    --text-muted: #888899;
    --border: rgba(255, 255, 255, 0.08);
    --alert-red: #ff3333;

    /* DÉFAUT (Index) : Bleu Électrique */
    --accent: #2e5cff;
    --accent-glow: rgba(46, 92, 255, 0.4);

    /* Fonts */
    --font-head: 'Syncopate', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-code: 'Space Mono', monospace;

    /* Dimensions Nav */
    --nav-height: 80px;

    /* Z-Index Hierarchy (Cursor always on top) */
    --z-ground: 0;
    --z-content: 100;
    --z-nav: 500;
    --z-drawer: 1000;
    --z-lightbox: 3000;
    --z-cursor: 10000;

    /* Status Colors */
    --status-live: var(--accent);
    --status-beta: #ff9900;
}

/* --- THEMES & MODULES --- */
body.theme-data,
.mod-data {
    --accent: #00f3ff;
    --accent-glow: rgba(0, 243, 255, 0.4);
}

body.theme-art,
.mod-art {
    --accent: #bd93f9;
    --accent-glow: rgba(189, 147, 249, 0.4);
}

body.theme-soft,
.mod-soft {
    --accent: #ff9900;
    --accent-glow: rgba(255, 153, 0, 0.4);
}

body.theme-journal,
.mod-journal {
    --accent: #00ff41;
    --accent-glow: rgba(0, 255, 65, 0.4);
}

body.theme-lab,
.mod-lab {
    --accent: #ccff00;
    --accent-glow: rgba(204, 255, 0, 0.4);
}

/* --- BASE --- */
html,
body {
    cursor: auto;
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--text-main);
    font-family: var(--font-body);
    overflow-x: hidden;
    line-height: 1.5;
    width: 100%;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

body.no-scroll {
    overflow: hidden !important;
    height: 100vh;
}

/* Applique le padding SAUF sur rien (Uniformisé) */
body {
    padding-top: var(--nav-height);
}

* {
    box-sizing: border-box;
}

a {
    text-decoration: none;
    color: inherit;
    cursor: none;
}

/* ELEVATE LINKS ON HOVER - REMOVED GLOBAL RULE */
/* Specific elements are elevated individually below */

button,
[role="button"] {
    cursor: none;
}

/* Scrollbar Custom */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* =========================================
   2. UI ELEMENTS
   ========================================= */
.noise {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: var(--z-ground);
    opacity: 0.05;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* CURSOR SYSTEM */
.cursor-dot {
    width: 6px;
    height: 6px;
    background: var(--text-main);
    position: fixed;
    border-radius: 50%;
    z-index: var(--z-cursor);
    /* Above Lightbox (50000) */
    pointer-events: none;
    mix-blend-mode: exclusion;
    left: -10px;
    top: -10px;
}

.cursor-ring {
    width: 40px;
    height: 40px;
    border: 1px solid var(--accent);
    position: fixed;
    border-radius: 50%;
    z-index: var(--z-cursor);
    /* Above Lightbox (80000) */
    pointer-events: none;
    transform: translate(-50%, -50%);
    transition: width 0.2s, height 0.2s, border-color 0.2s;
    left: -100px;
    top: -100px;
}

body.hover .cursor-ring {
    width: 80px;
    height: 80px;
    background: color-mix(in srgb, var(--accent-glow), transparent 20%);
    border-color: transparent;
    mix-blend-mode: normal;
    /* Changed from screen to normal to allow backdrop-filter */
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

/* Hide dot on hover for cleaner look */
body.hover .cursor-dot {
    opacity: 0;
    transition: opacity 0.2s;
}

/* --- CURSOR VARIANTS --- */

/* SHARED: Active State (Expanded Ring) */
/* Replaces: .cursor-home, .cursor-about, body.hover .cursor-ring */
.cursor-ring.cursor-active,
body.hover .cursor-ring {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    /* Empty ring for better text visibility */
    background: transparent;
    border: 1px solid var(--accent); /* Ensure border is visible */
    /* No blur or fill */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    mix-blend-mode: normal;
}

/* GLOBAL TEXT LINK HOVER */
a:hover,
.link-hover:hover {
    color: var(--accent);
    text-shadow: 0 0 8px var(--accent-glow);
    transition: color 0.2s, text-shadow 0.2s;
    cursor: none; /* Ensure system cursor is hidden if not already */
}

/* SHARED: Icon State (Ring with Icon) */
/* Replaces: .cursor-zoom, .lightbox-hover, .lightbox-close */
.cursor-ring.cursor-icon {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--accent);
    border-radius: 50%;
    mix-blend-mode: normal;
    box-shadow: 0 0 15px var(--accent-glow);
    
    /* Glassmorphism */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    
    /* Flexbox Centering */
    display: flex;
    justify-content: center;
    align-items: center;
}

.cursor-ring.cursor-icon::after {
    content: '';
    position: static;
    transform: none;
    font-family: var(--font-code);
    /* Base size, overridden by specific icons */
    font-size: 32px; 
    color: var(--accent);
    font-weight: 300;
    line-height: 1;
}

/* Specific Icons */
.cursor-ring.cursor-icon.icon-plus::after {
    content: '+';
    font-size: 36px; /* Increased */
}

.cursor-ring.cursor-icon.icon-minus::after {
    content: '-';
    font-size: 36px; /* Increased */
}

.cursor-ring.cursor-icon.icon-close::after {
    content: '✕';
    font-size: 28px;
    /* Decreased */
}

/* Hide System Cursor on specific elements */
.nav-root,
.article-content img,
#trigger-about,
.nav-item {
    cursor: none !important;
}

#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 5000; /* Preloader */
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-code);
    color: var(--accent);
}

.boot-text::after {
    content: '_';
    animation: blink 1s infinite;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

/* =========================================
   3. GLOBAL NAVIGATION (FIXED GLASS)
   ========================================= */
.nav-fixed-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    z-index: var(--z-nav);
    /* Below cursor (60001) */
    background: rgba(5, 5, 5, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    pointer-events: none;
}

.nav-fixed-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: calc(var(--z-nav) + 5); /* Above nav */
    /* Above cursor (60001) but BELOW Drawer (99999) */
    pointer-events: none;
    /* Let clicks pass through empty areas */
    height: var(--nav-height);
    background: transparent;
    border-bottom: none;
}

.nav-glass {
    pointer-events: auto;
    max-width: 1400px;
    margin: 0 auto;
    height: var(--nav-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    background: transparent;
    border: none;
}

/* --- HEADER LOGIC (LOGO & MODULES) --- */
.nav-brand {
    font-family: var(--font-code);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    /* Flexbox gère l'alignement, pas de gap pour coller le _ si besoin */
}

.nav-root {
    color: var(--text-main);
    text-decoration: none;
}

.nav-suffix {
    color: var(--accent);
    /* Couleur dynamique du module */
    margin-left: 8px;
    /* L'espace entre CHMRQS et LE SUFFIXE */
}

.cursor-blink {
    color: var(--accent);
    /* Le curseur prend la couleur du thème */
    font-weight: 700;
    margin-left: 2px;
    animation: blink 1s step-end infinite;
}

.nav-links {
    display: flex;
    gap: 30px;
    font-family: var(--font-code);
    font-size: 0.85rem;
    text-transform: uppercase;
    align-items: center; /* Fix vertical alignment */
}

.nav-item {
    color: var(--text-muted);
    transition: 0.3s;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}
/* ... existing code ... */

/* Drawer styles moved to section 7 (line ~873) to avoid duplication */

.nav-item:hover {
    color: var(--accent);
}

/* Responsive Nav */
@media (max-width: 768px) {
    .nav-glass {
        padding: 0 20px;
    }

    .nav-brand {
        font-size: 0.85rem;
    }
}

/* =========================================
   4. LAYOUT
   ========================================= */
.wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px;
    position: relative;
    z-index: auto;
    /* Ensure no stacking context traps children */
}

header.hero {
    border-bottom: 1px solid var(--border);
    padding-bottom: 40px;
    margin-bottom: 40px;
    margin-top: 20px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 1px solid var(--border);
    padding-bottom: 20px;
    margin-bottom: 40px;
}

/* LIEN RETOUR (Corps de page) */
.back-link-body {
    font-family: var(--font-code);
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: 0.3s;
    cursor: pointer;
    position: relative;
    z-index: calc(var(--z-nav) + 5); /* Above cursor */
    /* Above cursor */
}

.back-link-body:hover {
    color: var(--accent);
    border-bottom-color: transparent;
    text-shadow: 0 0 10px var(--accent-glow);
}

h1 {
    font-family: var(--font-head);
    font-size: 2.5rem;
    margin: 0;
    color: var(--accent);
    line-height: 1;
    letter-spacing: -2px;
    text-transform: uppercase;
}

/* =========================================
   5. HOME & BENTO
   ========================================= */
.hero h1 {
    font-size: clamp(2.5rem, 8vw, 6rem);
}

.hero h1 span {
    display: block;
    -webkit-text-stroke: 1px var(--text-main);
    color: transparent;
    transition: 0.5s;
}

.hero h1 span:hover {
    color: var(--accent);
    -webkit-text-stroke: 0;
    text-shadow: 0 0 30px var(--accent);
}

.hero-meta {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 30px;
    font-family: var(--font-code);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.grid-section {
    padding: 60px 0;
}

.section-title {
    font-family: var(--font-code);
    color: var(--accent);
    margin-bottom: 30px;
    display: block;
}

.bento {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
    grid-auto-rows: 300px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 25px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.tag {
    font-family: var(--font-code);
    font-size: 0.7rem;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    text-transform: uppercase;
    color: var(--text-muted);
    transition: 0.3s;
}

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.card h3 {
    font-family: var(--font-head);
    font-size: 1.8rem;
    margin: 0;
    z-index: 2;
    line-height: 1;
    color: #fff;
}

.card p {
    color: var(--text-muted);
    font-size: 0.85rem;
    z-index: 2;
    max-width: 90%;
    margin-top: 10px;
}

/* --- NAV BACK LINK (RIGHT SIDE) --- */
.nav-back {
    color: var(--text-muted);
    margin-right: 15px;
    font-weight: 400;
    transition: color 0.3s;
    text-decoration: none;
    font-family: var(--font-code);
    font-size: 0.9rem;
}

.nav-back:hover {
    color: var(--accent);
    text-shadow: 0 0 8px var(--accent-glow);
}

.nav-sep {
    color: var(--border);
    margin-right: 15px;
    opacity: 0.3;
}

/* --- BURGER MENU --- */
#trigger-menu {
    font-size: 1.2rem;
    cursor: pointer;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Drawer duplication removed - see section 7 (line ~873) */

/* --- MENU OPEN STATE (BLUR BACKGROUND) --- */
body.menu-open .wrapper,
body.menu-open .nav-fixed-wrapper,
body.menu-open .nav-fixed-bg,
body.menu-open canvas {
    filter: blur(8px);
    transition: filter 0.4s ease;
    pointer-events: none;
}

.drawer.open {
    right: 0;
}

.drawer-content {
    display: flex;
    flex-direction: column;
    gap: 40px;
    margin-top: 40px;
}

.drawer-nav {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.drawer-link {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-main);
    text-decoration: none;
    text-transform: uppercase;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    transition: color 0.3s, transform 0.3s;
}

.drawer-link:hover {
    color: var(--accent);
    transform: translateX(10px);
}

.drawer-link .d-num {
    font-family: var(--font-code);
    font-size: 1rem;
    color: var(--border);
    font-weight: 400;
}

.drawer-about {
    border-top: 1px solid var(--border);
    padding-top: 30px;
}

.close-btn {
    position: absolute;
    top: 30px;
    right: 30px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.3s;
}

.close-btn:hover {
    color: var(--accent);
}

/* Grid Layout Classes for Module Cards */
.c-full {
    grid-column: span 12;
}

.c-large {
    grid-column: span 8;
    background: linear-gradient(160deg, var(--surface) 0%, #0e1224 100%);
}

.c-tall {
    grid-column: span 4;
    grid-row: span 2;
}

.c-std {
    grid-column: span 4;
}

.c-art {
    background-image: url('https://images.unsplash.com/photo-1614850523459-c2f4c699c52e?q=80&w=2070&auto=format&fit=crop');
    background-size: cover;
    background-position: center;
    filter: grayscale(100%) contrast(1.2);
}

.c-art:hover {
    filter: grayscale(0%);
}

.c-art::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    transition: 0.3s;
}

.c-art:hover::before {
    background: rgba(0, 0, 0, 0.2);
}

@media (hover: hover) {
    .card:hover {
        border-color: var(--accent);
        transform: translateY(-3px);
        box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    }

    .card:hover .tag {
        color: var(--accent);
        border-color: var(--accent);
        background: rgba(255, 255, 255, 0.05);
    }

    .card:hover .card-head div:last-child {
        color: var(--accent);
    }
}

/* =========================================
   6. OTHER GRIDS (Gallery / Tools)
   ========================================= */
.gallery-grid,
.tools-grid,
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.art-item,
.tool-card,
.project-card {
    background: var(--surface);
    border: 1px solid var(--border);
    transition: 0.3s;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.art-item img,
.p-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    filter: grayscale(100%) contrast(1.1);
    transition: 0.5s;
}

.art-item:hover img {
    filter: grayscale(0%) contrast(1);
}

.p-image {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    font-family: var(--font-code);
}

.art-meta,
.p-content,
.tool-card {
    padding: 20px;
}

.tool-card {
    height: 100%;
}

.art-title,
.tool-title,
.p-title {
    font-family: var(--font-head);
    font-size: 1.3rem;
    margin: 10px 0 5px;
    color: #fff;
}

.art-tech,
.tool-desc,
.p-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.art-status,
.tool-status {
    font-family: var(--font-code);
    font-size: 0.65rem;
    padding: 2px 6px;
    border: 1px solid var(--accent);
    color: var(--accent);
    display: inline-block;
}

.status-live {
    color: var(--status-live);
    border-color: var(--status-live);
}

.status-beta {
    color: var(--status-beta);
    border-color: var(--status-beta);
}

.tool-action,
.btn {
    font-family: var(--font-code);
    font-size: 0.8rem;
    margin-top: auto;
    padding-top: 15px;
    display: block;
    color: var(--accent);
    text-align: right;
}

.btn {
    width: 100%;
    text-align: center;
    border: 1px solid var(--border);
    padding: 10px;
    margin-top: 15px;
    color: #fff;
    transition: 0.3s;
}

.btn:hover {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

/* =========================================
   7. DRAWER (About Me)
   ========================================= */
.drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: 400px;
    max-width: 100%;
    height: 100%;
    background: #050505;
    border-left: 1px solid var(--accent);
    z-index: var(--z-drawer);
    padding: 100px 40px 40px 40px;
    transition: 0.4s cubic-bezier(0.77, 0, 0.175, 1);
    box-shadow: -50px 0 100px rgba(0, 0, 0, 0.8);
    visibility: hidden;
    opacity: 0;
}

.drawer.open {
    right: 0;
    visibility: visible;
    opacity: 1;
}

.skill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
}

.skill {
    border: 1px solid var(--border);
    padding: 6px 12px;
    font-size: 0.75rem;
    color: var(--accent);
    font-family: var(--font-code);
}

.close-btn {
    position: absolute;
    top: 30px;
    right: 30px;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: calc(var(--z-cursor) - 1); /* Above cursor */
    /* Above cursor */
}

/* =========================================
   8. RESPONSIVE
   ========================================= */
@media (max-width: 1024px) {
    .wrapper {
        padding: 20px;
    }

    .bento {
        grid-template-columns: 1fr 1fr;
        grid-auto-rows: auto;
    }

    .c-full,
    .c-large,
    .c-tall,
    .c-std {
        grid-column: auto;
        grid-row: auto;
        min-height: 250px;
    }

    .c-full {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    .wrapper {
        padding: 15px;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .hero {
        padding: 40px 0;
    }

    .hero h1 {
        font-size: 2.5rem;
    }

    .hero-meta {
        flex-direction: column;
        gap: 10px;
    }

    .bento {
        grid-template-columns: 1fr;
    }

    .c-full {
        grid-column: span 1;
    }

    .nav-links {
        display: flex;
        gap: 15px;
        margin-top: 10px;
    }

    .nav-links span {
        margin-left: 0;
    }

    .cursor-dot,
    .cursor-ring {
        display: none !important;
    }

    html,
    body,
    a,
    button {
        cursor: auto !important;
    }
}


/* --- CURSOR ACCESSIBILITY --- */
body.custom-cursor-active {
    cursor: none;
}
/* ... existing code ... */

body.custom-cursor-active a,
body.custom-cursor-active button,
body.custom-cursor-active [role="button"] {
    cursor: none;
}

/* =========================================
   9. FOOTER FREESTYLE
   ========================================= */
.main-footer {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-code);
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-top: auto;
}

.footer-left span {
    color: var(--text-main);
    font-weight: 600;
}

.copyright-symbol {
    font-family: sans-serif;
    font-size: 1.3em;
    vertical-align: -1px;
    margin-right: 4px;
    display: inline-block;
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-text {
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent-glow);
    font-weight: 700;
}

@media (max-width: 768px) {
    .main-footer {
        flex-direction: column;
        gap: 20px;
        text-align: center;
        padding: 30px 20px;
    }
}