/*
    What styles the site's own header and footer around the Site Header and Site Footer blocks:
    the sticky header, the tenant's caption, the floating "Tenant" link, the footer's background and
    the copyright, credit and version line at the very bottom. The menu bar and the footer's links
    are the blocks', and their CSS is in each block (FinalSprint.Web.Library/SiteChrome holds what
    a block comes with).

    The footer's line is rooted on the layout's footer inside :where(), so a theme restyles or hides
    it with an ordinary selector such as `footer a`. The class names and ids here (#versionInfo,
    #tenantCopyright, caption-wrapper) are part of what themes are built against.
*/

/* from site.css, unchanged and not rooted: the bare header and footer rules still reach any in
   page content */

/* 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);
}

/* A Site Header set to sit over the page's top (SiteHeaderSettings): it takes no room, so the page's
   first row starts under it and shows through wherever the header paints nothing; it stays at the top
   of the window as the page scrolls, or scrolls away with the page. Rooted at the layout's own header,
   so a header in page content isn't moved. */
.site-layout > header.header-over-page {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
}

.site-layout > header.header-over-page.header-scrolls-away {
    position: absolute;
}

/* A header above the page that scrolls away with it, rather than staying at the top of the window */
.site-layout > header.header-scrolls-away:not(.header-over-page) {
    position: relative;
}

/* A header that slides away as the page scrolls down and back as it scrolls up (common.js, watchHeaderScroll,
   adds header-hidden): it goes up by its own height, so nothing of it is left showing */
.site-layout > header.header-hides {
    transition: transform 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

.site-layout > header.header-hides.header-hidden {
    transform: translateY(-100%);
}

/* A header over the page that takes a solid background once the page has scrolled (watchHeaderScroll adds
   header-scrolled): the header's own colour (--header-solid, from its settings), or the site's background, which
   follows its light or dark version. Its menu's colour then follows what it is on (setHeaderTone) */
.site-layout > header.header-solid-on-scroll {
    transition: transform 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

.site-layout > header.header-solid-on-scroll.header-scrolled {
    background-color: var(--header-solid, var(--site-background, #fff));
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
}

@media (prefers-reduced-motion: reduce) {
    .site-layout > header:is(.header-hides, .header-solid-on-scroll) {
        transition: none;
    }
}

/* A transparent header over a light or a dark part of the page (common.js, setHeaderTone): the menu's toggle,
   and its links where the menu is a bar, in --header-ink, a colour that reads there (black or white until the
   site's own is worked out), so they don't vanish into a row of their own colour. Rooted at the layout's header
   with its class, to outweigh the header block's own colours for them (a lifted header's included); a block
   that wants others there writes them against header-on-light and header-on-dark. */
.site-layout > header.header-on-light {
    --header-ink-now: var(--header-ink, #000);
}

.site-layout > header.header-on-dark {
    --header-ink-now: var(--header-ink, #fff);
}

.site-layout > header:is(.header-on-light, .header-on-dark) .site-nav-toggle {
    color: var(--header-ink-now);
}

@media (min-width: 992px) {
    .site-layout > header:is(.header-on-light, .header-on-dark) .site-nav[data-folds="lg"] .site-nav-links > .site-nav-list > .site-nav-item > :is(a, .site-nav-sub-toggle > summary) {
        color: var(--header-ink-now);
    }
}

.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;
}

/* The tenant link: a small, quiet badge floating in the bottom left corner of every page, the same whatever header
   the site or the page has, and nothing in the tenant's own menu or design. It is clear of the header and of
   whatever a site puts at the bottom right (a chat button, back to top). Its
   own colours, not the site's, so it reads on any page. It grows in from its corner when the site's script shows it,
   and opens out to show its label on hover or focus. */
.site-tenant-link {
    position: fixed;
    left: 1rem;
    bottom: 1rem;
    z-index: 9999;
    display: inline-block;
    box-sizing: border-box;
    height: 2.25rem;
    min-width: 2.25rem;
    padding: 0 0.6rem;
    border-radius: 1.125rem;
    background-color: rgba(20, 20, 24, 0.72);
    color: #fff;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18), 0 2px 10px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(6px);
    font-size: 0.85rem;
    line-height: 2.25rem;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    opacity: 0.6;
    transform-origin: left bottom;
    transition: opacity 0.2s ease, background-color 0.2s ease, transform 0.3s ease-out;
}

    /* where it starts from as it is shown: a browser without @starting-style just shows it */
    @starting-style {
        .site-tenant-link {
            opacity: 0;
            transform: scale(0.5);
        }
    }

    .site-tenant-link[hidden] {
        display: none;
    }

    .site-tenant-link:hover,
    .site-tenant-link:focus-visible {
        background-color: rgba(20, 20, 24, 0.9);
        color: #fff;
        text-decoration: none;
        opacity: 1;
    }

    .site-tenant-link:focus-visible {
        outline: 2px solid #fff;
        outline-offset: 2px;
    }

    /* the label is there for a screen reader all the time; at rest it has no width, so the badge is a circle round the
       icon, and on hover or focus it opens out beside the icon, the badge growing with it (max-width, not width, as
       width: auto can't be moved towards). 5rem is room enough for "Tenant". */
    .site-tenant-label {
        display: inline-block;
        max-width: 0;
        overflow: hidden;
        vertical-align: top;
        opacity: 0;
        transition: max-width 0.3s ease, margin-left 0.3s ease, opacity 0.2s ease;
    }

    .site-tenant-link:hover .site-tenant-label,
    .site-tenant-link:focus-visible .site-tenant-label {
        max-width: 5rem;
        margin-left: 0.45rem;
        opacity: 1;
        transition: max-width 0.3s ease, margin-left 0.3s ease, opacity 0.2s ease 0.1s;
    }

@media (prefers-reduced-motion: reduce) {
    .site-tenant-link,
    .site-tenant-label {
        transition: none;
    }
}

@media print {
    .site-tenant-link {
        display: none;
    }
}

/* Footer Styles */
footer {
    background-color: var(--dark);
    color: white;
}

/* ---------- 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;
    }
}


/* A menu item that shows only its icon (MenuMarkup.IconOnlyClass: the Main menu's search button as it comes): its
   label is kept for a screen reader, out of sight. Remove the class in the menu builder to show the label too. */
.site-nav-icon-only .site-nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* the page behind an open Menu Panel (SiteChromeBlocks.MenuPanel) doesn't scroll, whatever header the site has */
body:has(.site-menu-panel:popover-open) {
    overflow: hidden;
}
