/* =========================================================
   AZ-CNC navigation
   Tesla-inspired full-width mega menus
   ========================================================= */


/* =========================================================
   1. Navbar shell
   ========================================================= */

.site-navbar {
    width: 100%;
    min-height: var(--navbar-height);
    padding: 0;
    background: #000000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-family: var(--font-family-base);
    z-index: 1050;
}

.navbar-container {
    width: 100%;
    max-width: 1600px;
    min-height: 64px;
    margin: 0 auto;
    padding: 0 36px;
}

.site-navbar-brand {
    margin: 0 56px 0 0;
    padding: 0;
}

.navbar-logo {
    display: block;
    width: auto;
    height: 28px;
    transition: opacity 0.2s ease;
}

.site-navbar-brand:hover .navbar-logo {
    opacity: 0.88;
}


/* =========================================================
   2. Main links
   ========================================================= */

.site-navbar .navbar-collapse {
    align-self: stretch;
    align-items: stretch;
}

.main-navigation {
    align-items: stretch;
    gap: 8px;
    margin-right: auto;
}

.main-navigation .nav-item {
    display: flex;
    align-items: stretch;
}

.main-navigation .nav-link {
    position: relative;
    display: flex;
    min-height: 64px;
    align-items: center;
    padding: 0 14px;
    border-radius: 4px;
    color: #ffffff;
    background: transparent;
    font-size: 0.84rem;
    line-height: 1;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    transition:
        background-color 0.2s ease,
        color 0.2s ease;
}

.main-navigation .nav-link:hover,
.main-navigation .nav-link:focus,
.main-navigation .nav-link.show {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.main-navigation .dropdown-toggle::after {
    width: 9px;
    height: 9px;
    margin: 1px 0 0 7px;
    border: 0;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='9' viewBox='0 0 9 9'%3E%3Cpath d='M1.5 3L4.5 6L7.5 3' fill='none' stroke='%23ffffff' stroke-width='1.25' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
        center / 9px 9px no-repeat;
    transition: transform 0.2s ease;
}

.main-navigation .dropdown-toggle.show::after {
    transform: rotate(180deg);
}


/* =========================================================
   3. Full-width mega menu
   ========================================================= */

.site-navbar .mega-menu {
    position: fixed !important;
    top: 64px !important;
    right: 0 !important;
    left: 0 !important;
    width: 100vw;
    min-width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #ffffff;
    box-shadow:
        0 20px 45px rgba(0, 0, 0, 0.16),
        0 1px 0 rgba(0, 0, 0, 0.08);
    transform: none !important;
}

.mega-menu-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 230px;
    gap: clamp(52px, 7vw, 110px);
    width: min(calc(100% - 80px), 1460px);
    margin: 0 auto;
    padding: 42px 0 48px;
}

.mega-menu-products {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 22px;
}

.mega-resource-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mega-product {
    display: block;
    min-width: 0;
    color: #171a20;
    text-decoration: none;
    text-align: center;
}

.mega-product-image {
    position: relative;
    aspect-ratio: 1.58 / 1;
    overflow: hidden;
    border-radius: 4px;
}

.mega-product-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.35s ease;
}

.mega-product span {
    display: inline-flex;
    align-items: center;
    margin-top: 15px;
    color: #171a20;
    font-size: 0.92rem;
    line-height: 1.35;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.mega-product:hover img {
    transform: scale(1.035);
}

.mega-product:hover span {
    text-decoration: underline;
    text-underline-offset: 4px;
}

.mega-menu-context {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 6px 0 6px 34px;
    border-left: 1px solid #d9d9dc;
}

.mega-context-label {
    margin-bottom: 17px;
    color: #8a8a8f;
    font-size: 0.68rem;
    line-height: 1;
    font-weight: 650;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.mega-menu-context a {
    padding: 7px 0;
    color: #171a20;
    font-size: 0.9rem;
    line-height: 1.35;
    font-weight: 500;
    text-decoration: none;
}

.mega-menu-context a:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
}


/* =========================================================
   4. Right side
   ========================================================= */

.navbar-right {
    display: flex;
    align-self: center;
    align-items: center;
}

.navbar-phone,
.navbar-location {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    color: #ffffff;
    text-decoration: none;
}

.navbar-phone i,
.navbar-location i {
    flex: 0 0 auto;
    color: var(--footer-accent);
    font-size: 0.94rem;
}

.navbar-phone {
    font-size: 0.86rem;
    font-weight: 700;
    white-space: nowrap;
}

.navbar-location {
    max-width: 235px;
}

.navbar-address {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.navbar-address strong {
    color: #ffffff;
    font-size: 0.77rem;
    line-height: 1.15;
    font-weight: 700;
    white-space: nowrap;
}

.navbar-address small {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.7rem;
    line-height: 1.2;
    white-space: nowrap;
}

.navbar-quote-btn {
    display: inline-flex;
    height: 38px;
    align-items: center;
    justify-content: center;
    margin-left: 18px;
    padding: 0 22px;
    border-radius: 4px;
    background: var(--footer-accent);
    color: #000000;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    transition:
        background-color 0.2s ease,
        transform 0.15s ease;
}

.navbar-quote-btn:hover {
    background: #ffd84d;
    color: #000000;
    transform: translateY(-1px);
}


/* =========================================================
   5. Desktop behavior
   ========================================================= */

@media (min-width: 992px) {
    .mega-dropdown:hover > .mega-menu {
        display: block;
        animation: megaMenuFadeIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    }

    .mega-dropdown:hover > .nav-link {
        background: rgba(255, 255, 255, 0.1);
    }
}

@keyframes megaMenuFadeIn {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================================
   6. Compact desktop
   ========================================================= */

@media (max-width: 1399.98px) {
    .navbar-container {
        padding: 0 24px;
    }

    .site-navbar-brand {
        margin-right: 30px;
    }

    .main-navigation {
        gap: 4px;
    }

    .main-navigation .nav-link {
        padding: 0 10px;
        font-size: 0.8rem;
    }

    .navbar-phone,
    .navbar-location {
        padding: 0 10px;
    }

    .mega-menu-inner {
        width: calc(100% - 48px);
    }
}

@media (max-width: 1199.98px) and (min-width: 992px) {
    .navbar-location {
        display: none;
    }

    .mega-menu-products {
        gap: 16px;
    }

    .mega-menu-inner {
        grid-template-columns: minmax(0, 1fr) 200px;
        gap: 46px;
    }
}



/* =========================================================
   Traditional desktop dropdowns
   ========================================================= */

@media (min-width: 992px) {
    .main-navigation .mega-dropdown {
        position: relative;
    }

    .site-navbar .mega-menu {
        position: absolute !important;
        top: 100% !important;
        right: auto !important;
        left: 0 !important;
        width: 320px;
        min-width: 320px;
        margin: 0;
        padding: 10px 0;
        border: 1px solid rgba(0, 0, 0, 0.1);
        border-radius: 0 0 6px 6px;
        background: #ffffff;
        box-shadow: 0 14px 32px rgba(0, 0, 0, 0.18);
        transform: none !important;
    }

    .mega-menu-inner,
    .mega-menu-inner-resources {
        display: block;
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .mega-menu-products,
    .mega-resource-grid {
        display: block;
    }

    .mega-product {
        display: block;
        padding: 11px 20px;
        color: #171a20;
        text-align: left;
        transition: background-color 0.18s ease;
    }

    .mega-product:hover,
    .mega-product:focus {
        background: #f3f4f5;
    }

    .mega-product span {
        display: block;
        margin: 0;
        color: inherit;
        font-size: 0.9rem;
        line-height: 1.35;
        font-weight: 550;
        letter-spacing: 0;
    }

    .mega-product:hover span {
        text-decoration: none;
    }

    .mega-menu-context {
        display: block;
        margin-top: 8px;
        padding: 10px 0 0;
        border-top: 1px solid #e2e3e5;
        border-left: 0;
    }

    .mega-context-label {
        display: block;
        margin: 0;
        padding: 7px 20px 6px;
    }

    .mega-menu-context a {
        display: block;
        padding: 10px 20px;
        transition: background-color 0.18s ease;
    }

    .mega-menu-context a:hover,
    .mega-menu-context a:focus {
        background: #f3f4f5;
        text-decoration: none;
    }
}

/* =========================================================
   7. Mobile toggler
   ========================================================= */

.custom-toggler {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.custom-toggler:focus {
    box-shadow: none;
}

.navbar-toggler-line {
    display: block;
    width: 25px;
    height: 2px;
    background: #ffffff;
}


/* =========================================================
   8. Tablet and mobile
   ========================================================= */

@media (max-width: 991.98px) {
    .site-navbar,
    .navbar-container {
        min-height: 64px;
    }

    .navbar-container {
        padding: 0 20px;
    }

    .site-navbar-brand {
        margin-right: 0;
    }

    .navbar-logo {
        height: 24px;
    }

    .site-navbar .navbar-collapse {
        position: absolute;
        top: 64px;
        right: 0;
        left: 0;
        max-height: calc(100svh - 64px);
        overflow-y: auto;
        padding: 14px 20px 24px;
        background: #000000;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .main-navigation {
        align-items: stretch;
        gap: 0;
        margin: 0;
    }

    .main-navigation .nav-item {
        display: block;
    }

    .main-navigation .nav-link {
        min-height: 54px;
        padding: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 0;
        font-size: 0.98rem;
    }

    .main-navigation .nav-link:hover,
    .main-navigation .nav-link:focus,
    .main-navigation .nav-link.show {
        background: transparent;
    }

    .site-navbar .mega-menu {
        position: static !important;
        width: 100%;
        min-width: 100%;
        padding: 0;
        background: transparent;
        box-shadow: none;
    }

    .mega-menu-inner,
    .mega-menu-inner-resources {
        display: block;
        width: 100%;
        padding: 8px 0 16px 16px;
    }

    .mega-menu-products,
    .mega-resource-grid {
        display: block;
    }

    .mega-product {
        padding: 10px 0;
    }

    .mega-product-image {
        display: none;
    }

    .mega-product span {
        margin: 0;
        color: rgba(255, 255, 255, 0.76);
        font-size: 0.9rem;
        font-weight: 500;
    }

    .mega-menu-context {
        margin-top: 5px;
        padding: 8px 0 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        border-left: 0;
    }

    .mega-context-label {
        margin: 6px 0 10px;
        color: rgba(255, 255, 255, 0.42);
    }

    .mega-menu-context a {
        padding: 8px 0;
        color: rgba(255, 255, 255, 0.76);
        font-size: 0.9rem;
    }

    .navbar-right {
        flex-direction: column;
        align-items: stretch;
        margin-top: 14px;
    }

    .navbar-phone,
    .navbar-location {
        min-height: 52px;
        padding: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .navbar-location {
        max-width: none;
    }

    .navbar-quote-btn {
        min-height: 50px;
        margin: 18px 0 0;
    }
}

@media (max-width: 575.98px) {
    .navbar-container,
    .site-navbar .navbar-collapse {
        padding-right: 15px;
        padding-left: 15px;
    }
}

/* Keep a desktop mega menu closed after an in-page section link is clicked,
   even while the pointer is still inside the dropdown's hover area. */
@media (min-width: 992px) {
    .mega-dropdown.section-link-selected > .mega-menu {
        display: none !important;
    }

    .mega-dropdown.section-link-selected > .nav-link {
        background: transparent;
    }
}
