/*
    Everything that styles the site header and footer. Themes restyle these, so the rules from the
    header and footer components (the header and footer sections below) follow two rules:

    - Each is rooted on the header or footer the layout renders, inside :where(), so it
      only reaches the menu bar and the footer's own lines (not a <header> or <footer> in page
      content, and not the tenant's caption or footer panel) and the root adds no specificity.
    - What is left is one class, the same weight as Bootstrap's. These load after Bootstrap and
      before the tenant's stylesheet, so they beat Bootstrap by order, a theme at the top of the
      tenant's stylesheet beats them by order, and the tenant's own rules beat the theme.

    The class names here (navbar-menu-line, navbar-toggle, data-section, footer-link, #versionInfo
    and the rest) are part of what themes are built against. Renaming one breaks themes.

    Those were Blazor scoped CSS, which added a per-build attribute to every selector: one class
    heavier than Bootstrap and impossible for a theme to match. The section that comes first was
    in site.css and keeps its original selectors.
*/

/* ---------- moved from site.css ----------

   These came from site.css unchanged, selectors and all, so they are not rooted like the rules
   further down: some of them still reach beyond the header and footer (.nav-item also styles a
   form's tabs, .logo any image with that class, and bare header and footer any in page content).
   They come first so they keep their place before the rules below. */

body:has(.navbar-toggle:checked) {
    overflow: hidden;
}

/* Header Styles */
header {
    display: flex;
    flex-direction: column;
    z-index: 1030;
    position: sticky;
    top: 0;
}

.sticky-header {
    box-shadow: 0 3px 5px rgba(0,0,0,.2);
}

.caption-wrapper {
    width: 100%;
    transition: all 0.3s ease-in-out;
    overflow: hidden;
    height: 28px;
}

.sticky-header .caption-wrapper {
    opacity: 0;
    height: 0px;
    visibility: hidden;
}

/* Floats over the top right corner instead of taking part in the page layout, so it needs nothing
   rendered for it and can't disturb a tenant's caption. */
.site-tenant-link {
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0 0.6rem;
    border: 1px solid var(--primary, #444);
    border-radius: 4px;
    background-color: var(--primary-lightest, #fff);
    color: var(--primary, #444);
    font-size: 0.75rem;
    line-height: 22px;
    text-decoration: none;
    white-space: nowrap;
    opacity: 1;
    transition: all 0.3s ease-in-out;
    z-index: 9999;
}

    .site-tenant-link:hover,
    .site-tenant-link:focus {
        background-color: var(--primary, #444);
        color: var(--primary-lightest, #fff);
        text-decoration: none;
    }

/* visibility as well as opacity, like the caption bar above - faded out on its own the link is
   still the hit target for that corner, so clicks meant for the sticky header would land on it */
.sticky-header .site-tenant-link {
    opacity: 0;
    visibility: hidden;
}

.logo,
.svg-logo {
    object-fit: contain;
    padding: 2px;
    height: 40px;
    transition: all 0.3s ease-in-out;
}

.home-header .logo,
.home-header .svg-logo {
    height: 40px;
}

@media (min-width: 768px) {
    .logo,
    .svg-logo {
        padding: 4px;
        height: 80px;
    }

    .home-header .logo,
    .home-header .svg-logo {
        height: 120px;
    }

    .sticky-header .logo,
    .sticky-header .svg-logo {
        height: 80px;
    }
}

/* Footer Styles */
footer {
    background-color: var(--dark);
    color: white;
}

.footer-links {
    padding: 0.5em;
}

h3.footer-link-item {
    font-size: 0.8rem;
}

li.footer-link-item {
    font-size: 0.7rem;
}

a.footer-link {
    color: white;
}

    a.footer-link[disabled] {
        cursor: default;
    }

        a.footer-link[disabled]:hover {
            text-decoration: none;
        }

.footer-link-group {
    flex-basis: 0;
    flex-grow: 1;
    max-width: 100%;
    text-align: center;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

@media (max-width: 800px) {
    .footer-link-group {
        flex-basis: 33%;
    }
}

.footer-link-list {
    list-style-type: none;
    list-style-position: outside;
    margin: 0;
    padding: 0;
}

/* Navbar styles */
@media (max-width: 991.98px) {
    .nav-item {
        font-size: 1.6rem;
        margin-bottom: 1.6rem;
    }

    .dropdown-item {
        font-size: 1.2rem;
        margin-top: 0.4rem;
    }
}

.navbar .dropdown-menu {
    position: absolute;
}

.nav-item {
    border: 1px solid transparent;
    border-radius: 0.25rem;
    cursor: pointer;
    white-space: nowrap;
}

    .nav-item:has(.nav-link[disabled]):hover {
        cursor: unset;
    }

    .nav-link,
    .nav-item:hover .nav-link {
        color: var(--body);
    }

    .nav-item:has(.btn):hover {
        background-color: transparent;
        border: 1px solid transparent;
    }

/* ---------- header ---------- */

:where(.site-layout > header .header-content) .navbar-toggler {
    margin-left: auto;
}

:where(.site-layout > header .header-content) .navbar-menu-icon {
    display: inline-flex;
    padding: 6px;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: ease opacity 0.3s;
}

:where(.site-layout > header .header-content) .navbar-menu-line {
    position: relative;
    width: 40px;
    height: 2px;
    margin-top: 3px;
    margin-bottom: 3px;
    padding-top: 0px;
    padding-bottom: 0px;
    transition: all 400ms cubic-bezier(0.165, 0.84, 0.44, 1);
    background-color: var(--primary);
}

:where(.site-layout > header .header-content) .navbar-toggle:checked ~ .navbar-menu-icon .navbar-menu-line:first-child {
    transform: rotateZ(35deg) scaleX(1.25) translate(1px, 8px);
}

:where(.site-layout > header .header-content) .navbar-toggle:checked ~ .navbar-menu-icon .navbar-menu-line:nth-child(2) {
    width: 0px;
    transform: translateX(-100%);
    opacity: 0;
}

:where(.site-layout > header .header-content) .navbar-toggle:checked ~ .navbar-menu-icon .navbar-menu-line:last-child {
    transform: rotateZ(-35deg) scaleX(1.25) translate(2px, -9px);
}

:where(.site-layout > header .header-content) .dropdown-toggle {
    flex-grow: unset;
}

:where(.site-layout > header .header-content) .dropdown-menu {
    opacity: 0;
    visibility: hidden;
    height: 0;
    display: block !important;
    transition-delay: 0.2s !important;
    transition-property: height, opacity, visibility !important;
    transition-duration: 0.3s !important;
    transition-timing-function: ease-in-out !important;
    overflow: hidden;
    padding: 0 !important;
    border: none;
}

:where(.site-layout > header .header-content) .dropdown:hover .dropdown-menu {
    visibility: visible;
    opacity: 1;
    padding: 0.5rem 0;
    height: fit-content;
    border: 1px solid rgba(0,0,0,.15);
}

:where(.site-layout > header .header-content) .not-collapsable {
    flex-direction: row;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
}

:where(.site-layout > header .header-content) .not-collapsable-dropdown {
    position: absolute !important;
}

:where(.site-layout > header .header-content) .navbar-role-label {
    margin-right: 0.5rem;
    white-space: nowrap;
}

:where(.site-layout > header .header-content) .dropdown-toggle .nav-label {
    padding-right: 16px;
}

:where(.site-layout > header .header-content) .navbar-toggle {
    display: none;
}

:where(.site-layout > header .header-content) .navigation-list-item:hover .navigation-submenu {
    display: block;
}

:where(.site-layout > header .header-content) .navbar-nav[data-section="2"] {
    margin-left: auto;
}

@media (max-width: 991.98px) {
    :where(.site-layout > header .header-content) .dropdown-toggle::after {
        display: none;
    }

    :where(.site-layout > header .header-content) .dropdown-toggle .nav-label {
        padding-right: 0;
    }

    /* static rather than relative, otherwise bootstrap's top: 100% pushes the
       sub menu down by the height of its parent and over the next item */
    :where(.site-layout > header .header-content) .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        height: fit-content;
        background-color: transparent;
        text-align: center;
        border: none !important;
    }

    :where(.site-layout > header .header-content) .nav-item {
        width: 100%;
        text-align: center;
    }

    /* Scoped CSS never reached a button item with a link, because NavLink renders those. The
       ones it did reach have no href, and :where() keeps this one class heavy. */
    :where(.site-layout > header .header-content) .btn:where(:not([href])) {
        display: block;
    }

    :where(.site-layout > header .header-content) .navbar-role-label {
        margin-right: 0;
    }

    :where(.site-layout > header .header-content) .navbar-collapse {
        max-height: 0;
        overflow: hidden;
        transition: all 1s ease;
        position: fixed;
        width: 100%;
        background-color: var(--light);
        bottom: 0;
        left: 0;
        right: 0;
        top: 0;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    :where(.site-layout > header .header-content) .navbar-toggler:has(.navbar-toggle:checked) + .navbar-collapse {
        max-height: unset;
        overflow-y: auto;
    }

    :where(.site-layout > header .header-content) .navbar-nav[data-section="1"],
    :where(.site-layout > header .header-content) .navbar-nav[data-section="2"] {
        display: flex;
        flex-direction: column;
        width: 100%;
        justify-content: center;
     }

    :where(.site-layout > header .header-content) .navbar-nav[data-section="1"] {
        flex-grow: 1;
    }

    /* Ensure the toggler and nav items are above the collapse background */
    :where(.site-layout > header .header-content) .navbar-toggler,
    :where(.site-layout > header .header-content) .navbar-nav[data-section="0"] {
        z-index: 30;
    }
}


@media print {
    :where(.site-layout > header .header-content), :where(.site-layout > header .header-content) * {
        display: none !important;
    }
}


/* ---------- footer ---------- */

:where(.content-wrapper > footer #versionInfo) {
    display: flex;
    font-size: 0.5rem;
    justify-content: space-between;
    padding-left: 0.3em;
    padding-right: 0.3em;
}

@media (min-width: 576px) {
    :where(.content-wrapper > footer #versionInfo) {
        font-size: 0.8rem;
        padding-left: 0.5em;
        padding-right: 0.5em;
        padding-bottom: 0.5em;
    }
}

:where(.content-wrapper > footer #versionInfo) p {
    margin: 0;
}

:where(.content-wrapper > footer #versionInfo) a {
    color: white;
    text-decoration: none;
}

    :where(.content-wrapper > footer #versionInfo) a:hover {
        color: #d22956;
    }

:where(.content-wrapper > footer #tenantCopyright) {
    cursor: default;
}

    :where(.content-wrapper > footer #tenantCopyright):hover {
        color: white;
    }

@media print {
    :where(.content-wrapper > footer), :where(.content-wrapper > footer) * {
        display: none !important;
    }
}

