/* ==========================================================================
   OVERLAY GRID MENU (2 Rows, 4 Columns Layout)
   ========================================================================== */
.overlay-menu-grid {
    display: grid;
    /* Precise 4-column division */
    grid-template-columns: repeat(4, minmax(0, 1fr));
    /* High row gap dynamically separates Row 1 and Row 2 */
    row-gap: 60px;
    column-gap: 40px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    box-sizing: border-box;
    padding: 40px;
}

/* Category Parent Titles styling */
.overlay-menu-column .overlay-column-title {
    font-family: var(--e-global-typography-primary-font-family), Sans-serif;
    font-size: var(--e-global-typography-secondary-font-size);
    font-weight: var(--e-global-typography-secondary-font-weight);
    text-transform: uppercase; /* Matching design all-caps look */
    letter-spacing: 0.8px;
    margin-top: 0;
    margin-bottom: 20px;
}

/* Assign unique text colors matching the preview design headers */
.overlay-menu-grid > div:nth-child(1) .overlay-column-title a { color: #cc5a43 !important; }
.overlay-menu-grid > div:nth-child(2) .overlay-column-title a { color: #5a7b8c !important; }
.overlay-menu-grid > div:nth-child(3) .overlay-column-title a { color: #768a6b !important; }
.overlay-menu-grid > div:nth-child(4) .overlay-column-title a { color: #cc5a43 !important; }
.overlay-menu-grid > div:nth-child(5) .overlay-column-title a { color: #bca05c !important; }
.overlay-menu-grid > div:nth-child(6) .overlay-column-title a { color: #bca05c !important; }
.overlay-menu-grid > div:nth-child(7) .overlay-column-title a { color: #cc5a43 !important; }
.overlay-menu-grid > div:nth-child(8) .overlay-column-title a { color: #222222 !important; }

.overlay-column-title a {
    text-decoration: none !important;
    transition: opacity 0.2s ease;
}

.overlay-column-title a:hover {
    opacity: 0.8;
}

/* Children items subnavigation list rules */
.overlay-column-links {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.overlay-column-links li {
    margin-bottom: 12px;
    list-style-type: none !important; /* Secondary bullet guard override */
}

.overlay-column-links li a {
    color: #444444 !important; /* Elegant subtle dark tone */
    font-family: var(--e-global-typography-text-font-family), Sans-serif;
    font-size: var(--e-global-typography-text-font-size);
    font-weight: var(--e-global-typography-text-font-weight);
    text-decoration: none !important;
    line-height: 1.4;
    display: inline-block;
    transition: color 0.2s ease, transform 0.2s ease;
}

.overlay-column-links li a:hover {
    color: #111111 !important;
    transform: translateX(3px); /* Interactive movement on hover */
}

/* ==========================================================================
   RESPONSIVE DESIGN SYSTEM
   ========================================================================== */
@media (max-width: 1024px) {
    .overlay-menu-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)); /* 2 columns on tablets */
        row-gap: 40px;
    }
}

@media (max-width: 767px) {
    /* 1. Make the backdrop overlay scrollable */
    .cp-menu-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background-color: rgba(0, 0, 0, 0.95); /* Deep dark background */
        overflow-y: auto !important;           /* Enables touch scroll */
        -webkit-overflow-scrolling: touch;
        display: block !important;             /* Block display works best for scrolling containers */
        padding: 90px 24px 60px 24px !important; /* Top padding clears the close button, bottom padding protects text */
        box-sizing: border-box !important;
        align-items: flex-start;
    }

    /* 2. Transform the 8 columns into a clean single-column layout */
    .overlay-menu-grid {
        display: grid !important;
        grid-template-columns: 1fr !important; /* Forces 1 column instead of horizontal wrapping */
        row-gap: 32px !important;              /* Spacing between main categories */
        max-width: 100% !important;
        margin: 0 auto !important;
        padding: 20px 30px 60px 30px;
    }

    /* 3. Style the columns for readability */
    .overlay-menu-column {
        width: 100% !important;
        text-align: left !important;
    }

    /* 4. Main Category Headers (TERRITORIO, ESPERIENZE, etc.) */
    .overlay-column-title {
        font-size: 1.35rem !important;
        font-weight: 700 !important;
        text-transform: uppercase !important;
        letter-spacing: 1px !important;
        margin: 0 0 12px 0 !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important; /* Subtle separator line */
        padding-bottom: 6px !important;
    }

    .overlay-column-title a {
        color: #bca05c !important; /* Ochre accent color for main groups */
        text-decoration: none !important;
    }

    /* 5. Sub-links List */
    .overlay-column-links {
        list-style: none !important;
        padding: 0 !important;
        margin: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important; /* Elegant spacing between sub-links */
    }

    .overlay-column-links li a {
        font-size: 1.05rem !important;
        text-decoration: none !important;
        display: inline-block !important;
        padding: 2px 0 !important;
    }

    /* --- Hamburger Button (Trigger) --- */
    .cp-menu-burger-btn {
        position: fixed !important;
        top: 20px !important;
        right: 20px !important;
        display: flex !important;
        gap: 7px;
        padding: 8px;
        z-index: 999998 !important; /* One level below the Close button */
        transition: opacity 0.2s ease;
    }

    .cp-menu-burger-btn .burger-line {
        display: block !important;
        width: 26px;
        height: 2.5px;
    }

    .cp-menu-overlay.is-active ~ .cp-menu-burger-btn,
    body:has(.cp-menu-overlay.is-active) .cp-menu-burger-btn {
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important; /* Disables any accidental clicks while hidden */
    }

    /* Reposition the close button inside the overlay to match */
    .cp-menu-close-btn {
        position: fixed !important;
        top: 20px !important;
        right: 20px !important;
        font-size: 3rem !important;
        line-height: 1 !important;
        background: transparent !important;
        border: none !important;
        padding: 8px !important; /* Matches hamburger click area */
        cursor: pointer !important;
        /* Absolute highest priority to ensure it intercepts tap events */
        z-index: 1000000 !important;
        pointer-events: auto !important;
    }



    .overlay-column-title {
        font-size: 1.4rem;
        margin-bottom: 12px;
    }
}

/* ==========================================================================
   INTERACTIVE BUTTONS & TRANSITIONS
   ========================================================================== */
.cp-menu-burger-btn {
    background: transparent !important;
    border: none !important;
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 45px;    /* Regola a piacere la distanza dall'alto */
    margin-right: 25px;  /* Regola a piacere la distanza da destra */
    align-self: center;
}

.cp-menu-svg-icon {
    width: 64px;  /* Regola la dimensione desiderata */
    height: 64px;
    display: block;
    transition: filter 0.3s ease, transform 0.2s ease;
}

.cp-menu-burger-btn:hover .cp-menu-svg-icon {
    opacity: 0.8;
}

.cp-menu-burger-btn .burger-line {
    display: block;
    width: 45px;
    height: 4.5px;
    background-color: #FFFFFF; /* Alter to #ffffff if placed over a dark hero banner */
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Close UI Element Button (Top Right x layout to match mockup) */
.cp-menu-close-btn {
    position: absolute;
    top: 40px;
    right: 40px;
    background: transparent;
    border: none;
    font-size: 3.5rem;
    color: #222222;
    cursor: pointer;
    line-height: 1;
    z-index: 1001;
    transition: transform 0.2s ease;
}

.cp-menu-close-btn > img {
    width: 50px;
}

/* Fullscreen Backdrop Element Panel Overlay */
.cp-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Usa dynamic viewport height per i browser mobile */
    background-color: rgba(245, 245, 245, 0.98);
    backdrop-filter: blur(10px);
    z-index: 99999;

    display: flex;
    flex-direction: column; /* Assicura il flusso verticale */
    justify-content: flex-start; /* Parte dall'alto per evitare tagli superiori */
    align-items: center;

    /* ABILITA LO SCROLL SE IL CONTENUTO TRABOCCA */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Scroll fluido su iOS */
    padding: 60px 20px; /* Spazio di sicurezza in alto e in basso per il tasto chiudi e per gli schermi bassi */
    box-sizing: border-box;

    /* State animations */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s cubic-bezier(0.25, 1, 0.5, 1), visibility 0.4s;
}

.cp-menu-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

.cp-menu-overlay > * {
    margin-top: auto;
    margin-bottom: auto;
}

/* Ensure our grid handles its absolute max-width correctly inside the screen frame */
.overlay-menu-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    row-gap: 60px;
    column-gap: 40px;
    width: 100%;
    max-width: 1400px;
    padding: 60px;
    box-sizing: border-box;
}

/* ==========================================================================
   TRASPARENT HEADER
   ========================================================================== */
.elementor-location-header {
    position: fixed; /* Changed from absolute to fixed so it stays in view */
    top: 0;
    left: 0;
    width: 100%;
    z-index: 9999;
    background-color: transparent !important;
    transition: background-color 0.3s ease, box-shadow 0.3s ease; /* Smooth fade effect */
}

/* Clear internal container backgrounds */
.elementor-location-header .elementor-element-bff1723,
.elementor-location-header .e-con-inner {
    background: transparent !important;
    background-color: transparent !important;
}

/* --- Active Sticky State (Triggers on Scroll) --- */
.elementor-location-header.is-scrolled {
    background-color: #ffffff !important; /* Pure White background on scroll */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08); /* Optional subtle shadow */
}

.cp-menu-svg-icon {
    filter: invert(20%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(90%) contrast(90%);
}