/* HIEX Portal: pages shown inside a portal box drop the site chrome. */
html.hx-embedded nav.navbar.blur,
html.hx-embedded .fixed-plugin,
html.hx-embedded #scroll-up-btn,
html.hx-embedded .footer {
    display: none !important;
}

html.hx-embedded body {
    min-height: 100%;
}

html.hx-embedded .main-content {
    padding-top: .5rem;
}

/* The sidebar shows unless its handle closes it; My Profile / My Services / Work with us always show.
   Of the site's top bar only those section buttons stay; breadcrumbs, icons and sign out live in the portal's own bar. */
html.hx-embedded #navbarBlur {
    margin: .5rem 1rem 0 !important;
    padding: 0 !important;
    position: static !important;
    background: transparent !important;
    box-shadow: none !important;
}
html.hx-embedded #navbarBlur > .container-fluid { padding: 0 !important; }
html.hx-embedded #navbarBlur nav[aria-label="breadcrumb"],
html.hx-embedded #navbarBlur #navbar,
html.hx-embedded #navbarBlur .navbar-toggler,
html.hx-embedded #navbarBlur .sidenav-toggler {
    display: none !important;
}
html.hx-embedded-nomenu #sidenav-main {
    display: none !important;
}

/* Boxes are often narrower than the site's 1200px breakpoint, where the sidebar would slide off screen
   with its toggle hidden. Keep it open and a little narrower instead. */
html.hx-embedded:not(.hx-embedded-nomenu) .g-sidenav-show .sidenav,
html.hx-embedded:not(.hx-embedded-nomenu) #sidenav-main {
    transform: none !important;
}
@media (max-width: 1199.98px) {
    html.hx-embedded:not(.hx-embedded-nomenu) #sidenav-main {
        max-width: 13rem !important;
        width: 13rem !important;
    }
    html.hx-embedded:not(.hx-embedded-nomenu) .g-sidenav-show .sidenav.fixed-start + .main-content,
    html.hx-embedded:not(.hx-embedded-nomenu) .g-sidenav-show .main-content {
        margin-left: 14.25rem !important;
    }
}

html.hx-embedded-nomenu .g-sidenav-show .main-content,
html.hx-embedded-nomenu .main-content {
    margin-left: 0 !important;
}

html.hx-embedded .container-fluid.py-4 {
    padding-top: .75rem !important;
}

/* Matches highlighted by the portal's search-all bar */
mark.hx-portal-hit {
    background: #ffe066;
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

/* Search Results box: the portal's top bar already has the search form */
html.hx-results-only .page-header:has(#searchForm) {
    display: none !important;
}

html.hx-results-only body > .container,
html.hx-results-only .container:has(> h2) {
    padding-top: 1rem;
}

/* Pages on the portal screen and in pop-ups always scroll, with a visible scrollbar */
html.hx-embedded,
html.hx-embedded body {
    height: auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(106, 79, 216, .55) transparent;
}

html.hx-embedded .main-content {
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
}

html.hx-embedded ::-webkit-scrollbar { width: 10px; height: 10px; }
html.hx-embedded ::-webkit-scrollbar-thumb { background: rgba(106, 79, 216, .5); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
html.hx-embedded ::-webkit-scrollbar-track { background: transparent; }

/* Sidebar handle: a tab on the sidebar's edge that opens and closes it */
#hx-menu-handle {
    position: fixed;
    top: 50%;
    left: calc(1rem + 17.125rem - 4px);
    z-index: 1100;
    width: 20px;
    height: 64px;
    margin-top: -32px;
    padding: 0;
    border: 0;
    border-radius: 0 10px 10px 0;
    background: #2b2b33;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, .2);
    cursor: pointer;
    transition: left .2s ease, background .15s ease;
}
#hx-menu-handle:hover { background: #e91e63; }
#hx-menu-handle span {
    display: block;
    width: 8px;
    height: 8px;
    margin: 0 auto;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: translateX(2px) rotate(45deg);
}
@media (max-width: 1199.98px) {
    #hx-menu-handle { left: calc(1rem + 13rem - 4px); }
}
html.hx-embedded-nomenu #hx-menu-handle { left: 0; }
html.hx-embedded-nomenu #hx-menu-handle span { transform: translateX(-2px) rotate(-135deg); }

/* The site's sidebar sizes its link list for a whole browser window (100vh - 360px). In a short screen or box
   that left room for only the first link, so the list now takes its natural height and the sidebar scrolls. */
html.hx-embedded #sidenav-main {
    max-height: calc(100vh - 1.5rem) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scrollbar-width: thin;
}
html.hx-embedded #sidenav-main #sidenav-scrollbar,
html.hx-embedded #sidenav-main .navbar-collapse {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

/* With the sidebar open in a narrow frame, four stat cards in a row get squeezed: show two per row instead. */
@media (max-width: 1399.98px) {
    html.hx-embedded:not(.hx-embedded-nomenu) .row > .col-xl-3:has(> .card) {
        flex: 0 0 auto;
        width: 50%;
    }
}

/* The portal screen: a compact layout so a page fits the frame. */
html.hx-screen .main-content { padding-top: .25rem; }
html.hx-screen #navbarBlur { margin: .4rem .75rem 0 !important; }
html.hx-screen .container-fluid.py-4 {
    padding: .5rem .75rem 1rem !important;
}
html.hx-screen .row.g-3 { --bs-gutter-y: .75rem; --bs-gutter-x: .75rem; }
html.hx-screen .mb-4 { margin-bottom: 1rem !important; }
