/* ==========================================
   NAVBAR & MEGA MENU STYLES
   With taller height, logo image, right button, and mobile burger
   ========================================== */

/* ----- CSS Variables ----- */
:root {
    --bg-base: #0a0a0a;
    --bg-surface: #111111;
    --bg-elevated: #1c1c1c;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --accent: #3b82f6;
    --transition-smooth: all 0.3s ease;
}

/* ----- Navbar Container (taller) ----- */
.navbar {
    position: absolute;
    top: 0;
    width: 100%;
    padding: 2.25rem 5%;           /* 50% taller than original 1.5rem */
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    backdrop-filter: none;
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
    transition: background 0.3s ease;
}

/* Scroll background (light overlay) */
.navbar.scrolled {
    background: rgba(0, 0, 0, 0.2);
}

/* ----- Logo (image) ----- */
.nav-logo {
    display: flex;
    align-items: center;
}

.nav-logo img {
    height: auto;
    max-height: 100px;     /* scales with navbar, adjust as needed */
    width: auto;
    max-width: 180px;
    object-fit: contain;
}

/* ----- Navigation Links Container (centered) ----- */
.nav-links {
    list-style: none;
    display: flex;
    gap: 2.5rem;
    align-items: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    padding: 0;
}

/* Larger hover area */
.nav-links li {
    padding: 1rem 0;
}

/* ----- FLIP ANIMATION FOR LINKS ----- */
.flip-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    overflow: hidden;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.2;
    padding-bottom: 6px;
    background-image: linear-gradient(#C89B3C, #C89B3C);
    background-position: left bottom;
    background-repeat: no-repeat;
    background-size: 0% 2px;
    transition: color 0.2s ease, background-size 0.3s ease;
}

.flip-link:hover {
    background-size: 100% 2px;
}

.flip-link span {
    display: inline-block;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.flip-link::before {
    content: attr(data-text);
    position: absolute;
    top: 100%;
    left: 0;
    color: var(--text-primary);
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.flip-link:hover span {
    transform: translateY(calc(-100% - 6px));
}

.flip-link:hover::before {
    transform: translateY(calc(-100% - 6px));
}

.flip-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}

/* ----- Right side actions (Quote button) ----- */
.nav-actions {
    display: flex;
    align-items: center;
}

.nav-btn {
    background: transparent;
    border: 2px solid #ffffff;
    color: #ffffff;
    padding: 0.75rem 2rem;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 500;
    font-size: 1.1rem;
    transition: background-color 0.3s ease, color 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover {
    background-color: #ffffff;
    color: #050505;
}

/* --- DROPDOWN MENU STYLES --- */
.dropdown-wrapper {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 90%;
    left: 50%;
    min-width: 220px;
    background: rgba(5, 5, 5, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 1rem 0;
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, 15px);
    transition: all 0.3s ease;
    z-index: 100;
    list-style: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.dropdown-wrapper:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

.dropdown-menu li {
    margin: 0;
}

/* ===== MOBILE HAMBURGER MENU ===== */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.8rem;
    cursor: pointer;
    z-index: 1001;
}

/* ==========================================
   MOBILE STYLES — SLIDING PICTURE FRAME
   ========================================== */
@media (max-width: 768px) {
    .navbar {
        padding: 1.2rem 5%;
    }

    /* 1. Hide the Logo entirely on mobile */
    .nav-logo {
        display: none !important;
    }

    /* 2. Pin the Burger to the top left and make it sticky */
    .mobile-menu-btn {
        display: block;
        position: fixed;
        top: 1.5rem;
        left: 5%;
        z-index: 2000;
    }

    /* 3. The Picture Frame — hides anything outside of it */
    .nav-links {
        position: fixed;
        top: 0;
        left: 0; /* THE FIX: Changed from -100% to 0 */
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: rgba(10, 10, 10, 0.95);
        backdrop-filter: blur(12px);
        flex-direction: column;
        justify-content: center;
        gap: 2rem;
        
        /* THE FIX: Use GPU-Accelerated Transform instead of CPU-heavy 'left' */
        transform: translateX(-100%); 
        transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
        
        z-index: 1500;
        border-right: 1px solid rgba(255, 255, 255, 0.1);
        overflow-x: hidden; 
    }

    .nav-links.active {
        /* THE FIX: Slide into view using transform */
        transform: translateX(0); 
    }

    .nav-links li {
        width: 100%;
        text-align: center;
        padding: 0.5rem 0;
    }

    /* 4. Animate the main links sliding to the left (hidden) */
    .nav-links > li > a {
        display: inline-block; /* THE FIX: Shrinks the link (and the gold line) down to just the word */
        
        /* THE FIX: Removed the opacity delay which contributes to the click-freeze */
        transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1); 
    }

    .nav-links.menu-sliding > li > a {
        transform: translateX(-100%);
        opacity: 0;
        pointer-events: none;
    }

    /* THE FIX: Remove relative positioning so the submenu can fill the whole screen */
    .dropdown-wrapper {
        position: static;
    }

    /* 5. The Submenu — starts hidden off-screen to the right */
    .dropdown-wrapper .dropdown-menu {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: transparent;
        border: none;
        box-shadow: none;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        
        /* THE FIX: Force it off-screen and hide it completely */
        transform: translateX(100%); 
        opacity: 0;
        visibility: hidden !important; /* <--- ADD THIS LINE */
        pointer-events: none; /* <--- ADD THIS LINE */
        
        transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.4s ease;
        padding: 2rem 1.5rem;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    /* 6. The Trigger Class — slides the submenu into view */
    .dropdown-wrapper .dropdown-menu.slide-in {
        transform: translateX(0);
        opacity: 1;
        visibility: visible !important; /* <--- ADD THIS LINE */
        pointer-events: auto; /* <--- ADD THIS LINE */
    }

    /* 7. Back Button — auto-injected by JavaScript */
    .mobile-back-btn {
        color: #C89B3C;
        font-size: 0.9rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.1em;
        margin-bottom: 2rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 8px;
        background: none;
        border: none;
        padding: 0.5rem 0;
        transition: opacity 0.2s ease;
    }

    .mobile-back-btn:hover {
        opacity: 0.7;
    }

    .mobile-back-btn i {
        font-size: 1rem;
    }

    /* 8. Force the Quote button to the far right */
    .nav-actions {
        margin-left: auto;
        position: relative;
        z-index: 1001;
    }

    /* 9. Adjust logo size on mobile (hidden above, kept for safety) */
    .nav-logo img {
        max-height: 40px;
    }

    /* 10. Disable the flip text effect & delay on mobile */
    .flip-link::before {
        display: none;
    }

    .flip-link:hover span,
    .flip-link:active span {
        transform: none;
    }

    /* THE FIX: Kills the 0.3s desktop hover transition so mobile taps fire instantly */
    .flip-link {
        transition: none !important; 
    }

    /* 11. Dropdown items: clean typography on mobile */
    .dropdown-menu a,
    .flyout-menu a {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
        text-align: center;
    }

    /* 12. Flyout menus become inline sub-items on mobile */
    .flyout-wrapper {
        position: static;
    }

    .flyout-menu {
        position: static;
        transform: none !important;
        opacity: 1;
        visibility: visible;
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0.5rem 0 0 0;
        display: none;
        width: 100%;
    }

    .flyout-menu.mobile-open {
        display: block;
    }

    .flyout-menu::before {
        display: none;
    }

    /* 13. Keep the caret-right hidden on mobile (optional) */
    .flyout-wrapper > a > i.fa-caret-right {
        display: none;
    }
}

/* Mega menu */
.mega-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100vw;
    background: var(--bg-surface);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 3rem 5%;
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px);
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 999;
    box-sizing: border-box;
}

.has-mega-menu:hover .mega-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.mega-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.mega-card {
    background: var(--bg-base);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    transition: var(--transition-smooth);
    cursor: pointer;
}

.mega-card:hover {
    background: var(--bg-elevated);
}

.mega-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 1rem;
    background: #2a2a2a;
}

.mega-card h4 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.mega-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ==========================================
   MULTI-LEVEL FLYOUT MENUS
   ========================================== */

/* 1. Ensure the parent list item can anchor the new menu */
.flyout-wrapper {
    position: relative;
}

/* 2. The Nested Flyout Menu (Accreditations & ISO) */
.flyout-menu {
    position: absolute;
    top: 0;
    left: 100%;
    min-width: 200px;
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 0.5rem 0;
    opacity: 0;
    visibility: hidden;
    transform: translateX(10px);
    transition: all 0.3s ease;
    z-index: 110;
    list-style: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

/* 3. The Invisible Hover Bridge */
.flyout-menu::before {
    content: '';
    position: absolute;
    top: 0;
    left: -15px;
    width: 15px;
    height: 100%;
}

/* 4. Trigger the flyout on hover */
.flyout-wrapper:hover > .flyout-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* 5. Typography and Spacing for all dropdown items */
.dropdown-menu a,
.flyout-menu a {
    display: block;
    padding: 0.8rem 1.5rem;
    color: #A0A0A0;
    text-decoration: none;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color 0.3s ease, background-color 0.3s ease;
}

.dropdown-menu a:hover,
.flyout-menu a:hover {
    color: #C89B3C;
    background-color: rgba(255, 255, 255, 0.03);
}

/* Pushes the tiny arrow icon to the right side of the list item */
.flyout-wrapper > a > i.fa-caret-right {
    float: right;
    margin-top: 4px;
}