/*
 * The bars as materials (design package 5, 5 Dec 2026; the founder: "OK let's get going on this all in the most efficient way
 * possible"). Printed in the head of every public and app layout just before touch.css (partials/touch-head), so it follows
 * app-shell.css, app-header.css, site-web.css and style.css and wins at the same specificity.
 *
 *   1. Tab bars (the app's and the phone website's, partials/app-tabbar): a light translucent material, content scrolls under.
 *   2. Dark headers (style.css `header`, site-web .sh, the lg-app bar): the same in dark, only while the page is scrolled
 *      (html.sp-scrolled, set by partials/sp-bars-head), so at rest the header is the brand black it has always been.
 *   3. The race page's slim Register bar (.spw-slim): light material instead of a border and a shadow.
 *   4. Tab labels fit at 360 px (English "Communities" was the one cut).
 *   5. The website header's Explore and Results menus: open from their link, on tap and keyboard too.
 *   6. Fallbacks: no backdrop-filter, reduced transparency, more contrast = today's solid bars.
 *
 * One blurred surface per bar, never on a scrolling child. The dark header's blur sits on its ::before, not on <header>:
 * backdrop-filter makes an element the containing block of its position:fixed descendants, and the header holds the menus.
 * Nothing translucent stands on these bars: sheets, menus and the cookie notice are opaque.
 */

/* ---- 1 + 3. Light material -------------------------------------------------------------------------------------- */
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    html.is-app .sp-tabbar,
    html:not(.is-app) .sp-tabbar,
    .spw-slim {
        background: rgba(255, 255, 255, 0.82);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        backdrop-filter: saturate(180%) blur(20px);
    }
    /* the edge reads as light catching the material, with the faintest shade beyond it, not a grey rule */
    html.is-app .sp-tabbar,
    html:not(.is-app) .sp-tabbar {
        border-top: 1px solid rgba(255, 255, 255, 0.7);
        box-shadow: 0 -0.5px 0 rgba(0, 0, 0, 0.12);
    }
    .spw-slim {
        border-bottom: 1px solid rgba(255, 255, 255, 0.7);
        box-shadow: 0 0.5px 0 rgba(0, 0, 0, 0.12);
    }
}

/* ---- 2. Dark material, only while content is under the header ---------------------------------------------------- */
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    html body > header,
    html.is-app body > .sp-apphdr {
        background-color: transparent;
    }
    html:not(.is-app) .sh {
        background: transparent;
    }
    html body > header::before,
    html.is-app body > .sp-apphdr::before {
        content: "";
        position: absolute;
        inset: 0;
        z-index: -1;
        pointer-events: none;
        background-color: var(--dark-page-bg, #040505);
        transition: background-color 0.2s ease;
    }
    html.sp-scrolled body > header::before,
    html.sp-scrolled.is-app body > .sp-apphdr::before {
        background-color: rgba(4, 5, 5, 0.8);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        backdrop-filter: saturate(180%) blur(20px);
    }
}

/* ---- 3. The race page's tab row: no animated `top` --------------------------------------------------------------- */
/* site-web.css moved the sticky tab row down under the slim bar with `transition: top`. The row is never stuck when the bar
   comes or goes (the bar follows the Register button in the race head, which is above the row), so the move is never seen;
   a transform would push the row down in the flow while it is not stuck. The step stays, the layout animation goes. */
@media (min-width: 768px) {
    body:has(.spw-slim.is-on) .tab_line_style_blk .top-header-height {
        transition: none;
    }
}

/* ---- 4. Tab labels fit (360 px and up, English and French) -------------------------------------------------------- */
html.is-app .sp-tabbar__tab,
html:not(.is-app) .sp-tabbar__tab {
    padding: 0 1px;
}
html.is-app .sp-tabbar__label,
html:not(.is-app) .sp-tabbar__label {
    letter-spacing: -0.01em;
}

/* ---- 5. The website header's Explore and Results menus (site-web.css .sh__navmenu) --------------------------------- */
/* They grow out of their link (top left) and go back the same way, faster. Hover and focus still open them; .is-open is a
   tap or ArrowDown, .is-shut is Escape or a tap outside (partials/site-header's script). visibility keeps a closed menu out
   of reach of the pointer and the Tab key. */
.sh__navmenu {
    display: flex;
    visibility: hidden;
    opacity: 0;
    transform: scale(0.96);
    transform-origin: top left;
    pointer-events: none;
    transition: opacity 0.1s ease-in, transform 0.1s ease-in, visibility 0s linear 0.1s;
}
.sh__navgroup:hover .sh__navmenu,
.sh__navgroup:focus-within .sh__navmenu,
.sh__navgroup.is-open .sh__navmenu {
    visibility: visible;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    transition: opacity 0.15s ease-out, transform 0.15s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s;
}
.sh__navgroup.is-open .sh__navchev {
    transform: rotate(180deg);
}
.sh__navgroup.is-shut .sh__navmenu {
    visibility: hidden;
    opacity: 0;
    transform: scale(0.96);
    pointer-events: none;
    transition: opacity 0.1s ease-in, transform 0.1s ease-in, visibility 0s linear 0.1s;
}
.sh__navgroup.is-shut .sh__navchev {
    transform: none;
}
@media (prefers-reduced-motion: reduce) {
    .sh__navmenu,
    .sh__navgroup:hover .sh__navmenu,
    .sh__navgroup:focus-within .sh__navmenu,
    .sh__navgroup.is-open .sh__navmenu,
    .sh__navgroup.is-shut .sh__navmenu {
        transform: none;
    }
}

/* ---- 6. Fallbacks ------------------------------------------------------------------------------------------------- */
/* touch.css drops every backdrop-filter under reduced transparency; the surfaces must be opaque on their own then. */
@media (prefers-reduced-transparency: reduce) {
    html.is-app .sp-tabbar,
    html:not(.is-app) .sp-tabbar,
    .spw-slim {
        background: #fff;
    }
    /* touch.css's `:root *` does not reach a pseudo-element: the header's blur is dropped here */
    html.sp-scrolled body > header::before,
    html.sp-scrolled.is-app body > .sp-apphdr::before {
        background-color: var(--dark-page-bg, #040505);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}
@media (prefers-contrast: more) {
    html.is-app .sp-tabbar,
    html:not(.is-app) .sp-tabbar {
        background: #fff;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        border-top: 1px solid #767676;
        box-shadow: none;
    }
    .spw-slim {
        background: #fff;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        border-bottom: 1px solid #767676;
        box-shadow: none;
    }
    html.sp-scrolled body > header::before,
    html.sp-scrolled.is-app body > .sp-apphdr::before {
        background-color: var(--dark-page-bg, #040505);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}
