/* --- TECHENCLAIR PWA & MOBILE OPTIMIZATION --- */

/* 1. ASPECT APP & UI CLEANUP */
:root {
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior-y: contain; /* Empêche le pull-to-refresh parasite */
}

/* On autorise la sélection sur les blocs de code pour permettre le copier/coller */
code, pre, input, textarea {
    -webkit-user-select: text;
    user-select: text;
}

/* Cacher les barres de défilement tout en gardant le scroll fonctionnel */
::-webkit-scrollbar {
    width: 0px;
    background: transparent;
}

/* 2. ZONES DE CLIC OPTIMISÉES */
a, button, .nav-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

/* 3. MENU MOBILE PLEIN ÉCRAN */
#mobile-menu-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #040707;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 2rem 2rem 5rem;
    padding-top: 5rem;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s cubic-bezier(0.8, 0, 0.2, 1);
    backdrop-filter: blur(20px);
}

#mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
    width: 100%;
    max-width: 340px;
}

.mobile-nav-link {
    font-size: 1.7rem;
    font-weight: 900;
    text-transform: uppercase;
    font-style: italic;
    letter-spacing: -0.05em;
    color: white;
    transition: all 0.3s ease;
    padding: 0.5rem 0;
    display: block;
}

.mobile-nav-link:hover, .mobile-nav-link.active {
    color: var(--link-color, #22d3ee);
    transform: scale(1.05);
    text-shadow: 0 0 20px rgba(34, 211, 238, 0.4);
}

/* Titre de catégorie (TUTORIELS, INFOS) */
.mobile-nav-category {
    font-size: 1.7rem;
    font-weight: 900;
    text-transform: uppercase;
    font-style: italic;
    letter-spacing: -0.05em;
    padding: 0.5rem 0 0.2rem;
    margin-top: 0.8rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    opacity: 0.7;
    cursor: default;
    display: block;
}

/* Sous-liens (Flash OS, HACS, etc.) */
.mobile-nav-sublink {
    font-size: 1rem;
    font-weight: 900;
    text-transform: uppercase;
    font-style: italic;
    letter-spacing: 0.05em;
    transition: all 0.3s ease;
    padding: 0.3rem 0 0.3rem 1.5rem;
    display: block;
    text-align: left;
    opacity: 0.9;
}

.mobile-nav-sublink:hover, .mobile-nav-sublink.active {
    opacity: 1;
    transform: translateX(5px);
    text-shadow: 0 0 15px currentColor;
}

/* HAMBURGER BUTTON */
#hamburger-btn {
    position: fixed;
    right: 1.5rem;
    top: 1.5rem;
    width: 55px;
    height: 55px;
    background: rgba(4, 7, 7, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    z-index: 101;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

/* Hide hamburger on desktop */
@media (min-width: 768px) {
    #hamburger-btn, #mobile-menu-overlay {
        display: none !important;
    }
}

.hamburger-line {
    width: 30px;
    height: 3px;
    background: white;
    position: relative;
    transition: all 0.3s ease;
}

.hamburger-line::before, .hamburger-line::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 3px;
    background: white;
    left: 0;
    transition: all 0.3s ease;
}

.hamburger-line::before { top: -10px; }
.hamburger-line::after { bottom: -10px; }

#hamburger-btn.active .hamburger-line {
    background: transparent;
}

#hamburger-btn.active .hamburger-line::before {
    top: 0;
    transform: rotate(45deg);
    background: #22d3ee;
}

#hamburger-btn.active .hamburger-line::after {
    bottom: 0;
    transform: rotate(-45deg);
    background: #22d3ee;
}

/* ANIMATION LINKS */
.mobile-nav-link {
    transform: translateY(30px);
    opacity: 0;
}

#mobile-menu-overlay.active .mobile-nav-link {
    transform: translateY(0);
    opacity: 1;
}

#mobile-menu-overlay.active .mobile-nav-link:nth-child(1) { transition-delay: 0.1s; }
#mobile-menu-overlay.active .mobile-nav-link:nth-child(2) { transition-delay: 0.2s; }
#mobile-menu-overlay.active .mobile-nav-link:nth-child(3) { transition-delay: 0.3s; }
#mobile-menu-overlay.active .mobile-nav-link:nth-child(4) { transition-delay: 0.4s; }
#mobile-menu-overlay.active .mobile-nav-link:nth-child(5) { transition-delay: 0.5s; }
#mobile-menu-overlay.active .mobile-nav-link:nth-child(6) { transition-delay: 0.6s; }
#mobile-menu-overlay.active .mobile-nav-link:nth-child(7) { transition-delay: 0.7s; }

/* 4. UTILS POUR CACHER LE NAV NATIF SUR MOBILE */
@media (max-width: 767px) {
    .nav-links-container {
        display: none !important;
    }
    
    /* On recentre le logo sur mobile pour un look plus propre si besoin, 
       mais ici on le laisse à gauche (flex-row justify-between) */
    nav {
        flex-direction: row !important;
        justify-content: space-between !important;
        gap: 0 !important;
        padding-right: 80px !important; /* Laisse la place pour le bouton fixed */
    }
}
