.ai-nav-item,
.ai-nav {
    position: static;
}

.ai-nav > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    list-style: none;
    cursor: pointer;
    white-space: nowrap;
}

.ai-nav > summary::-webkit-details-marker {
    display: none;
}

.ai-nav-arrow {
    /* Same arrow, size and spacing as the Digital Services link (img.down-arrow). */
    filter: brightness(0);
    width: 10px;
    height: auto;
    transform: rotate(90deg);
    transition: transform .2s;
}

.ai-nav[open] .ai-nav-arrow {
    transform: rotate(270deg);
}

.ai-nav-current {
    font-family: var(--fw-600);
}

.ai-nav .ai-mega-panel {
    display: block;
    position: absolute;
    z-index: 20;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
}

.ai-nav .ai-mega-panel a[aria-current="page"] {
    color: #9948e8 !important;
}

.ai-nav summary:focus-visible,
.ai-mega-panel a:focus-visible {
    outline: 2px solid #9948e8;
    outline-offset: 5px;
}

@media (min-width: 992px) and (max-width: 1600px) {
    .header-has-ai .nav-item .nav-link {
        margin-left: 24px !important;
        font-size: 18px !important;
    }
}

@media (min-width: 992px) {
    .ai-nav,
    .ai-nav > summary {
        height: 100%;
    }

    .ai-nav[open]::before {
        content: "";
        position: absolute;
        left: 0;
        top: calc(100% - 24px);
        width: 100%;
        height: 24px;
        z-index: 19;
    }

    .dark .header-has-ai .ai-nav > summary {
        color: #fff;
    }

    .dark .header-has-ai .ai-nav-arrow {
        filter: brightness(0) invert(1);
    }

    .dark .header-has-ai.sticky .ai-nav > summary {
        color: #341552;
    }

    .dark .header-has-ai.sticky .ai-nav-arrow {
        filter: brightness(0);
    }
}

@media (max-width: 991px) {
    .ai-nav-item,
    .ai-nav {
        width: 100%;
    }

    /* Same row metrics as the Digital Services accordion button in the drawer. */
    header.header-site.header-has-ai .ai-nav > summary.nav-link {
        justify-content: space-between;
        margin: 0 !important;
        padding: 0 7px !important;
        font-size: 16px !important;
        line-height: 65px !important;
        color: #fff;
    }

    /* Match the Digital Services accordion chevron (Bootstrap's icon) in the mobile drawer. */
    .ai-nav-arrow {
        display: none !important;
    }

    .header-has-ai .ai-nav > summary::after {
        content: "";
        flex-shrink: 0;
        width: 20px;
        height: 20px;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23212529'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-size: 24px auto;
        filter: brightness(15) invert(0);
        transform: scale(.7);
        transition: transform .2s ease-in-out;
    }

    .header-has-ai .ai-nav[open] > summary::after {
        transform: scale(.7) rotate(-180deg);
    }

    .ai-nav .ai-mega-panel {
        position: static;
        left: auto !important;
        max-width: 100% !important;
        max-height: none;
        transform: none;
        margin-top: 12px;
    }

    .ai-mega-panel .menu_mega a {
        padding: 0;
    }
}
