/* ============
   Variables
   ============ */
:root {
    --nav-height: 64px;
    /* hauteur de la navbar (modifie ici si besoin) */
    --bg-top: #0a0a0f;
    --bg-bottom: #0d0d18;
    --accent-start: #6f6fff;
    --accent-end: #9a4dff;
}

/* =====================
   NAVBAR: hauteur fixe + centrage vertical robuste
   ===================== */
nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    /* utiliser la variable centrale */
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(8, 8, 12, 0.97);
    /* Solid background - no backdrop-filter for GPU */
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 1000;
    animation: slideDown 0.6s ease-out;
}

nav>.brand,
nav>div {
    height: 100%;
    display: flex;
    align-items: center;
}

nav .brand img {
    height: 40px;
    width: auto;
    display: block;
    margin: 0;
    border-radius: 8px;
}

nav .brand .brand-text {
    margin-left: 10px;
    font-family: 'Artonex', sans-serif;
    font-weight: 800;
    letter-spacing: .3px;
    font-size: 1.15rem;
    background: linear-gradient(90deg, var(--accent-start), var(--accent-end));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 0 18px rgba(154, 77, 255, 0.35);
    user-select: none;
    white-space: nowrap;
}

nav>div:last-child {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
    gap: 4px;
}

.menu-toggle span {
    height: 3px;
    width: 25px;
    background: #fff;
    border-radius: 3px;
    display: block;
}

nav ul {
    display: flex;
    align-items: center;
    gap: 20px;
    list-style: none;
    margin: 0;
    padding: 0;
    height: 100%;
    margin-left: 18px;
}

nav ul li {
    height: 100%;
    display: flex;
    align-items: center;
}

nav ul li a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 0 10px;
    line-height: 1;
    font-size: 1rem;
    white-space: nowrap;
}

nav ul li a:hover {
    color: var(--accent-end);
    transition: color 160ms ease;
}

.nav-right {
    display: flex;
    align-items: center;
    height: 100%;
    gap: 12px;
    margin-left: 18px;
}

.nav-user {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
}

.nav-user button.trigger {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(111, 111, 255, 0.06);
    border: 1px solid rgba(111, 111, 255, 0.09);
    color: white;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 6px 12px;
    border-radius: 10px;
    transition: box-shadow 140ms ease, transform 140ms ease, outline-color 140ms ease;
    line-height: 1;
    height: auto;
    max-height: calc(100% - 12px);
    -webkit-tap-highlight-color: transparent;
}

.nav-user button.trigger,
.nav-user button.trigger:focus,
.nav-user button.trigger:active {
    outline: none !important;
    box-shadow: none !important;
    border-color: rgba(111, 111, 255, 0.09);
}

.nav-user button.trigger::-moz-focus-inner {
    border: 0;
}

.nav-user button.trigger:focus-visible {
    outline: none;
    box-shadow: 0 6px 18px rgba(106, 90, 255, 0.12);
    border-color: rgba(106, 90, 255, 0.14);
}

.nav-user button.trigger:focus {
    outline: none;
}

.nav-user:hover .trigger,
.nav-user:focus-within .trigger {
    outline: none;
    box-shadow: 0 6px 18px rgba(106, 90, 255, 0.06);
    transform: translateY(-1px);
}

.avatar-wrap {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
    border: 2px solid rgba(255, 255, 255, 0.04);
    background: transparent;
    flex: 0 0 36px;
}

.avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: transparent;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    pointer-events: none;
}

.user-dropdown {
    position: absolute;
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    top: calc(100% + 6px);
    background: rgba(20, 20, 30, 0.95);
    border-radius: 10px;
    padding: 8px;
    min-width: 200px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 1200;
    opacity: 0;
    transition: opacity 120ms ease, transform 120ms ease;
}

.user-dropdown.show {
    display: block;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.user-dropdown a,
.user-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    color: #fff;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.95rem;
}

.user-dropdown a:hover,
.user-dropdown button:hover {
    background: rgba(106, 90, 255, 0.08);
    color: var(--accent-end);
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }

    to {
        transform: translateY(0);
    }
}

/* Responsive adjustments (avec menu mobile hamburger taille optimisée) */
@media (max-width: 992px) {
    nav {
        padding: 0 24px;
    }

    nav ul {
        gap: 16px;
        margin-left: 12px;
    }

    nav ul li a {
        padding: 0 8px;
        font-size: 0.95rem;
    }

    .nav-right {
        margin-left: 12px;
        gap: 8px;
    }

    .nav-right {
        margin-left: 12px;
        gap: 8px;
    }
}

/* Default hidden on desktop */
.mobile-discord-link {
    display: none;
}

@media (max-width: 768px) {
    :root {
        --nav-height: 56px;
    }

    nav {
        height: var(--nav-height);
        padding: 0 16px;
        flex-wrap: nowrap;
    }

    nav .brand img {
        height: 32px;
    }

    .menu-toggle {
        display: flex;
        order: 3;
        z-index: 1002;
        position: relative;
    }

    .mobile-discord-link {
        display: flex;
        align-items: center;
        margin-right: 15px;
        order: 2;
    }

    .mobile-discord-link img {
        height: 24px;
        width: auto;
        /* filter removed to keep original color */
        transition: transform 0.2s ease;
    }

    .mobile-discord-link:hover img {
        transform: scale(1.1) rotate(5deg);
    }

    nav ul {
        display: none !important;
        position: fixed;
        top: var(--nav-height);
        left: 0;
        right: 0;
        width: 100vw;
        height: auto;
        max-height: calc(100vh - var(--nav-height));
        padding: 30px 20px 40px;
        background: rgba(8, 8, 12, 0.98);
        /* Solid background - no backdrop-filter */
        flex-direction: column;
        gap: 12px;
        margin-left: 0;
        z-index: 1001;
        justify-content: flex-start;
        align-items: center;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
        border-radius: 0 0 20px 20px;
    }

    nav ul.show {
        display: flex !important;
    }

    nav ul li {
        width: 100%;
        max-width: 300px;
        height: auto;
        text-align: center;
    }

    /* FIX: centrer correctement le contenu (dont le logo Discord) dans les boutons du menu mobile */
    nav ul li a {
        width: 100%;
        padding: 18px 24px;
        font-size: 1.1rem;
        border-radius: 12px;
        transition: all 0.3s ease;
        height: auto;
        display: inline-flex;
        /* etait 'block' -> passe en inline-flex */
        align-items: center;
        /* centre verticalement */
        justify-content: center;
        /* centre horizontalement */
        font-weight: 500;
        background: rgba(20, 20, 30, 0.8);
        border: 1px solid rgba(154, 77, 255, 0.2);
        margin-bottom: 8px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    }

    /* Optionnel: s'assurer que tout <img> dans ces liens est bien centré */
    nav ul li a img {
        display: block;
        margin: 0 auto;
    }

    nav ul li a:hover {
        background: rgba(154, 77, 255, 0.2);
        border-color: rgba(154, 77, 255, 0.5);
        color: #e6d6ff;
        transform: translateY(-3px);
        box-shadow: 0 8px 25px rgba(154, 77, 255, 0.3);
    }

    nav>div:last-child {
        order: 1;
        gap: 8px;
    }

    .avatar-wrap {
        width: 32px;
        height: 32px;
        flex: 0 0 32px;
    }

    .nav-user button.trigger {
        padding: 4px 8px;
        max-height: calc(100% - 8px);
        font-size: 0.9rem;
        gap: 6px;
    }

    .nav-right {
        margin-left: 8px;
        gap: 6px;
        flex-shrink: 0;
    }

    .user-dropdown {
        min-width: 180px;
        left: auto;
        right: 0;
        transform: translateY(-6px);
    }

    .user-dropdown.show {
        transform: translateY(0);
    }
}

@media (max-width: 480px) {
    nav {
        height: 52px;
        padding: 0 12px;
    }

    nav .brand img {
        height: 28px;
    }

    nav ul {
        padding: 20px 16px 30px;
        gap: 8px;
    }

    nav ul li a {
        padding: 16px 20px;
        font-size: 1rem;
    }

    .avatar-wrap {
        width: 28px;
        height: 28px;
        flex: 0 0 28px;
    }

    .nav-user button.trigger {
        padding: 3px 6px;
        font-size: 0.85rem;
        gap: 4px;
    }

    .nav-right {
        margin-left: 6px;
        gap: 4px;
    }
}