/* ================================================================
   CHAT HERITAGE - MENU HAMBURGER FULL SCREEN
   Versione Unificata e Ottimizzata
   Menu a tendina che copre tutta la schermata con logo centrato
   ================================================================ */

/* ================================================================
   1. RESET MOBILE BUTTON ESISTENTE
   ================================================================ */

.mobile-menu-btn {
    display: none !important;
    visibility: hidden !important;
}

/* ================================================================
   2. CHECKBOX E HAMBURGER - BASE (nascosti su desktop)
   ================================================================ */

.nav-container input[type="checkbox"] {
    display: none;
}

.hamburger-lines {
    display: none;
}

/* ================================================================
   3. MOBILE STYLES (≤ 768px)
   ================================================================ */

@media (max-width: 768px) {
    
    /* ============================================================
       3.1 LAYOUT MOBILE HEADER
       ============================================================ */
    
    .nav-container {
        display: flex;
        flex-wrap: wrap;
        position: relative;
        height: 64px;
        padding: 0 1rem;
        align-items: center;
        justify-content: space-between;
    }
    
    /* Logo CENTRATO */
    .logo {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        height: 35px;
        z-index: 1002;
        transition: opacity 0.3s ease;
    }
    
    /* Nascondi logo quando menu aperto (opzionale) */
    .nav-container input[type="checkbox"]:checked ~ a .logo {
        opacity: 0;
        pointer-events: none;
    }
    
    /* Dropdown lingue sempre visibile a destra */
    .dropdown {
        position: absolute !important;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 1003 !important;
    }
    
    .dropdown button {
        min-width: 100px !important;
        padding: 0.5rem 0.8rem !important;
        font-size: 0.85rem !important;
    }
    
    /* ============================================================
       3.2 CHECKBOX POSIZIONAMENTO (area cliccabile)
       ============================================================ */
    
    .nav-container input[type="checkbox"] {
        display: block !important;
        position: absolute;
        height: 44px;
        width: 44px;
        top: 10px;
        left: 10px;
        z-index: 1004;
        opacity: 0 !important;
        cursor: pointer;
        pointer-events: all !important;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* ============================================================
       3.3 HAMBURGER ICON (3 linee) - A SINISTRA
       ============================================================ */
    
    .hamburger-lines {
        display: flex !important;
        flex-direction: column;
        justify-content: space-between;
        height: 22px;
        width: 28px;
        position: absolute;
        top: 21px;
        left: 18px;
        z-index: 1003;
        pointer-events: none !important;
        visibility: visible !important;
    }
    
    .hamburger-lines .line {
        display: block;
        height: 3px;
        width: 100%;
        border-radius: 3px;
        background: #0e2431;
        transition: all 0.4s ease-in-out;
    }
    
    .hamburger-lines .line1 {
        transform-origin: 0% 0%;
    }
    
    .hamburger-lines .line2 {
        transition: transform 0.2s ease-in-out;
    }
    
    .hamburger-lines .line3 {
        transform-origin: 0% 100%;
    }
    
    /* ============================================================
       3.4 ANIMAZIONE HAMBURGER → X
       Hamburger NERO quando chiuso, X NERO quando aperto
       ============================================================ */
    
    /* Stato DEFAULT: Hamburger NERO (quando menu chiuso) */
    .hamburger-lines .line {
        background: #0e2431;
    }
    
    /* Stato APERTO: X NERO (quando menu aperto) */
    .nav-container input[type="checkbox"]:checked ~ .hamburger-lines .line {
        background: #0e2431;
    }
    
    .nav-container input[type="checkbox"]:checked ~ .hamburger-lines .line1 {
        transform: rotate(45deg);
    }
    
    .nav-container input[type="checkbox"]:checked ~ .hamburger-lines .line2 {
        transform: scaleY(0);
        opacity: 0;
    }
    
    .nav-container input[type="checkbox"]:checked ~ .hamburger-lines .line3 {
        transform: rotate(-45deg);
    }
    
    /* ============================================================
       3.5 MENU FULL SCREEN (copre tutta la schermata)
       IMPORTANTE: Usa TRANSFORM per animazioni fluide
       ============================================================ */
    
    nav[role="navigation"] {
        position: fixed;
        top: 64px;
        left: 0;
        width: 100vw;
        height: calc(100vh - 64px);
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.4s ease-in-out;
        overflow-y: auto;
        background: rgba(14, 36, 49, 0.98);
        backdrop-filter: blur(10px);
        /* NON usare display: none qui - rompe le animazioni! */
    }
    
    /* Menu items CENTRATI */
    .nav-menu {
        display: flex !important;
        flex-direction: column !important;
        gap: 0;
        margin: 0;
        padding: 2rem 0 0 0;
        background: transparent;
        width: 100%;
        justify-content: center !important;
        align-items: center !important;
        flex: 0 0 auto;
    }

    /* Container per menu completo con social icons */
    nav[role="navigation"] {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
    
    .nav-menu li {
        margin: 0;
        width: 100%;
        text-align: center;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .nav-menu li:last-child {
        border-bottom: none;
    }
    
    .nav-menu a {
        display: block;
        width: 100%;
        padding: 1.5rem 2rem;
        font-size: 1.4rem;
        font-weight: 600;
        color: #ffffff;
        text-align: center;
        transition: all 0.3s ease;
        text-decoration: none;
        letter-spacing: 0.02em;
    }
    
    .nav-menu a:hover,
    .nav-menu a:active {
        background: rgba(59, 130, 246, 0.2);
        color: #3b82f6;
        transform: scale(1.05);
    }
    
    /* Rimuovi underline effect mobile */
    .nav-menu a::after {
        display: none;
    }

    /* ============================================================
       3.5.5 SOCIAL ICONS nel Mobile Menu (solo mobile)
       ============================================================ */

    .mobile-menu-social {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 2rem 1rem 3rem;
        margin-top: auto;
        width: 100%;
        border-top: 1px solid rgba(255, 255, 255, 0.15);
    }

    .mobile-social-icons {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 1.5rem;
        flex-wrap: wrap;
    }

    .mobile-social-icons a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 50px;
        height: 50px;
        min-width: 50px;
        min-height: 50px;
        background: linear-gradient(135deg, #8e5edc 0%, #667eea 100%);
        border-radius: 50%;
        color: white;
        font-size: 1.5rem;
        transition: all 0.3s ease;
        text-decoration: none;
        box-shadow: rgba(142, 94, 220, 0.3) 0px 6px 20px;
    }

    .mobile-social-icons a:hover,
    .mobile-social-icons a:active {
        transform: translateY(-3px) scale(1.1);
        box-shadow: rgba(142, 94, 220, 0.5) 0px 8px 25px;
    }

    .mobile-social-icons a:focus-visible {
        outline: 3px solid #3b82f6;
        outline-offset: 4px;
    }

    /* Colori specifici per ogni social nel mobile menu */
    .mobile-social-icons a:nth-child(1):hover {
        background: #1877f2;
    }

    .mobile-social-icons a:nth-child(2):hover {
        background: linear-gradient(135deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    }

    .mobile-social-icons a:nth-child(3):hover {
        background: #000000;
    }

    /* ============================================================
       3.6 MENU APERTO (quando checkbox è checked)
       ============================================================ */
    
    .nav-container input[type="checkbox"]:checked ~ nav[role="navigation"] {
        transform: translateX(0);
    }
    
    /* ============================================================
       3.7 PREVIENI SCROLL BODY quando menu aperto
       ============================================================ */
    
    body:has(.nav-container input[type="checkbox"]:checked) {
        overflow: hidden;
    }
    
    /* ============================================================
       3.8 DROPDOWN LINGUE - Mantieni visibile sopra il menu
       ============================================================ */
    
    .nav-container input[type="checkbox"]:checked ~ .dropdown {
        z-index: 1003 !important;
    }
    
    .nav-container input[type="checkbox"]:checked ~ .dropdown button {
        background: rgba(255, 255, 255, 0.95);
        color: #0e2431;
    }
}

/* ================================================================
   4. MOBILE EXTRA SMALL (≤ 500px)
   ================================================================ */

@media (max-width: 500px) {
    .nav-container {
        padding: 0 0.75rem;
    }

    .logo {
        height: 32px;
    }

    .dropdown {
        right: 12px;
    }

    .dropdown button {
        min-width: 90px !important;
        padding: 0.4rem 0.7rem !important;
        font-size: 0.8rem !important;
    }

    .hamburger-lines {
        left: 15px;
        width: 26px;
        height: 20px;
    }

    .hamburger-lines .line {
        height: 2.5px;
    }

    .nav-container input[type="checkbox"] {
        left: 8px;
        width: 40px;
        height: 40px;
    }

    .nav-menu a {
        font-size: 1.2rem;
        padding: 1.3rem 1.5rem;
    }

    .mobile-social-icons {
        gap: 1.2rem;
    }

    .mobile-social-icons a {
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
        font-size: 1.4rem;
    }

    .mobile-menu-social {
        padding: 1.5rem 1rem 2.5rem;
    }
}

/* ================================================================
   5. MOBILE EXTRA SMALL (≤ 374px)
   ================================================================ */

@media (max-width: 374px) {
    .logo {
        height: 28px;
    }

    .dropdown button {
        min-width: 80px !important;
        font-size: 0.75rem !important;
        padding: 0.35rem 0.6rem !important;
    }

    .nav-menu a {
        font-size: 1.1rem;
        padding: 1.2rem 1rem;
    }

    .mobile-social-icons {
        gap: 1rem;
    }

    .mobile-social-icons a {
        width: 45px;
        height: 45px;
        min-width: 45px;
        min-height: 45px;
        font-size: 1.3rem;
    }

    .mobile-menu-social {
        padding: 1.2rem 0.75rem 2rem;
    }
}

/* ================================================================
   6. TABLET (481px - 768px)
   ================================================================ */

@media (min-width: 481px) and (max-width: 768px) {
    .logo {
        height: 38px;
    }

    .dropdown button {
        min-width: 110px !important;
    }

    .nav-menu a {
        font-size: 1.5rem;
        padding: 1.6rem 2rem;
    }

    .mobile-social-icons {
        gap: 2rem;
    }

    .mobile-social-icons a {
        width: 55px;
        height: 55px;
        min-width: 55px;
        min-height: 55px;
        font-size: 1.6rem;
    }

    .mobile-menu-social {
        padding: 2.5rem 1rem 3.5rem;
    }
}

/* ================================================================
   7. LANDSCAPE MOBILE (max-height: 500px)
   ================================================================ */

@media (max-width: 768px) and (max-height: 500px) and (orientation: landscape) {
    .nav-menu {
        padding: 1rem 0;
        justify-content: flex-start;
    }

    .nav-menu a {
        padding: 1rem 2rem;
        font-size: 1.2rem;
    }

    nav[role="navigation"] {
        top: 60px;
        height: calc(100vh - 60px);
    }

    .mobile-menu-social {
        padding: 1rem 1rem 1.5rem;
    }

    .mobile-social-icons {
        gap: 1rem;
    }

    .mobile-social-icons a {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        font-size: 1.2rem;
    }
}

/* ================================================================
   8. DESKTOP (> 768px) - RIPRISTINA LAYOUT NORMALE
   ================================================================ */

@media (min-width: 769px) {
    /* Nascondi hamburger e checkbox */
    .hamburger-lines,
    .nav-container input[type="checkbox"] {
        display: none !important;
    }

    /* Nascondi social icons mobile menu su desktop */
    .mobile-menu-social {
        display: none !important;
    }

    /* Ripristina nav desktop */
    nav[role="navigation"] {
        position: static !important;
        transform: none !important;
        width: auto !important;
        height: auto !important;
        background: transparent !important;
        overflow: visible !important;
        flex-direction: row !important;
        justify-content: flex-start !important;
    }
    
    /* Menu desktop orizzontale */
    .nav-menu {
        display: flex !important;
        flex-direction: row !important;
        gap: 2.5rem !important;
        padding: 0 !important;
        justify-content: flex-start !important;
        align-items: center !important;
        height: auto !important;
        background: transparent !important;
    }
    
    .nav-menu li {
        width: auto !important;
        text-align: left !important;
        border-bottom: none !important;
        margin-right: 0 !important;
    }
    
    .nav-menu a {
        padding: 0 !important;
        font-size: 0.95rem !important;
        font-weight: 500 !important;
        color: #64748b !important;
        text-align: left !important;
        position: relative;
    }
    
    .nav-menu a:hover {
        color: #3b82f6 !important;
        background: transparent !important;
        transform: none !important;
    }
    
    /* Ripristina underline effect desktop */
    .nav-menu a::after {
        display: block !important;
        content: '';
        position: absolute;
        bottom: -4px;
        left: 0;
        width: 0;
        height: 2px;
        background: #3b82f6;
        transition: width 0.3s ease;
    }
    
    .nav-menu a:hover::after {
        width: 100%;
    }
    
    /* Logo desktop normale */
    .logo {
        position: static !important;
        transform: none !important;
        height: 40px !important;
        opacity: 1 !important;
    }
    
    /* Ripristina body scroll */
    body {
        overflow: visible !important;
    }
}

/* ================================================================
   9. ACCESSIBILITY - FOCUS STATES
   ================================================================ */

@media (max-width: 768px) {
    /* Focus sul checkbox (visibile tramite hamburger) */
    .nav-container input[type="checkbox"]:focus ~ .hamburger-lines {
        outline: 3px solid #3b82f6;
        outline-offset: 4px;
        border-radius: 4px;
    }
    
    /* Focus sui link menu */
    .nav-menu a:focus-visible {
        outline: 3px solid #3b82f6;
        outline-offset: -3px;
        background: rgba(59, 130, 246, 0.2);
    }
}

/* ================================================================
   10. TOUCH OPTIMIZATION
   ================================================================ */

@media (max-width: 768px) and (hover: none) and (pointer: coarse) {
    /* Aumenta area tap per hamburger */
    .nav-container input[type="checkbox"] {
        width: 48px;
        height: 48px;
        top: 8px;
        left: 6px;
    }
    
    .hamburger-lines {
        top: 21px;
        left: 18px;
    }
    
    /* Touch target menu items */
    .nav-menu a {
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ================================================================
   11. REDUCED MOTION
   ================================================================ */

@media (prefers-reduced-motion: reduce) {
    @media (max-width: 768px) {
        .hamburger-lines .line,
        nav[role="navigation"],
        .nav-menu a,
        .logo,
        .mobile-social-icons a {
            transition: none !important;
        }

        .mobile-social-icons a:hover,
        .mobile-social-icons a:active {
            transform: none !important;
        }
    }
}

/* ================================================================
   12. HIGH CONTRAST MODE
   ================================================================ */

@media (prefers-contrast: high) {
    @media (max-width: 768px) {
        .hamburger-lines .line {
            background: #000;
            height: 4px;
        }
        
        .nav-container input[type="checkbox"]:checked ~ .hamburger-lines .line {
            background: #fff;
        }
        
        nav[role="navigation"] {
            background: #000 !important;
            border: 3px solid #fff;
        }
        
        .nav-menu a {
            color: #fff;
            border-bottom: 2px solid #fff;
        }
        
        .nav-menu a:hover {
            background: #fff;
            color: #000;
        }
    }
}
