/* motion.css — everything on this site that moves by itself.
 *
 * The second global stylesheet, and the only one. site.css remains the shared stylesheet for
 * how the site *looks*; this file is how it *behaves over time*, kept separate so the whole
 * layer can be read, reviewed and switched off as one thing rather than as 500 lines buried in
 * a file that was already 2070.
 *
 * ---------------------------------------------------------------------------------------------
 * THE GATE
 *
 * Every automatic effect here is behind `.motion-on`, a class App.razor's head script puts on
 * <html> and js/site.js keeps there. No script, or a visitor who asked for reduced motion, and
 * not one of these rules matches — the site renders exactly as it did before this file existed.
 *
 * Hover and press effects are deliberately NOT gated. They are state changes a person asked for
 * by pointing or tapping, not motion that happens at them, and site.css's prefers-reduced-motion
 * block already collapses their duration. Those live beside the rules they extend, in site.css
 * and in the scoped sheets, because a `transition` shorthand REPLACES the one it overrides —
 * writing them here would mean copying every existing property list and keeping the copy in step
 * forever. The one thing this file does own on that side is the press state and the focus ring,
 * neither of which any other rule declares.
 *
 * ---------------------------------------------------------------------------------------------
 * THREE RULES THAT ARE NOT STYLE PREFERENCES
 *
 * 1. Animate `opacity`, `translate`, `scale` and `rotate`. Never `transform`.
 *    Eighteen selectors in this codebase already own `transform` for their hover lift, and
 *    `.motion-on .route-card.is-revealed` (0,3,0) outranks `.route-card:hover` (0,2,0) — so a
 *    reveal written with `transform` does not merely collide with the lift, it deletes it.
 *    `translate` is applied before `transform` in the transform stack, so the two compose: a card
 *    can rise into place and still lift 5px under the cursor, with no wrapper and no coordination.
 *
 * 2. Keyframes may only touch `opacity`, `translate`, `scale`, `rotate` and `filter`.
 *    CLAUDE.md states that an inline style outranks the stylesheet. That is true of normal
 *    declarations and false of animations — the animation origin sits above the style attribute.
 *    RidesBoard computes `style="left: min(Xpx, calc(100vw - 210px))"` in C# to keep its context
 *    menu on screen; a keyframe touching `left` would silently defeat that clamp.
 *
 * 3. Never move anything horizontally, and never move a full-bleed band.
 *    `html, body { overflow-x: hidden }` clips rather than scrolls, so a sideways entrance is
 *    invisible rather than sliding. And `body` is `#111` on the four pages that do not override
 *    it, so a `.white-section` translating 18px down opens an 18px stripe of near-black above
 *    itself and slides it shut — invisible on a desktop first load, obvious on every phone.
 *    Full-bleed bands therefore take `data-reveal="fade"`; the rise goes on the inner wrapper.
 *
 * ---------------------------------------------------------------------------------------------
 * THE SCALE
 *
 *   scroll reveal   450ms ease-out, rising 18px      stagger 70ms, capped at the 8th child
 *   page enter      350ms ease-out, rising 10px
 *   hero entrance   600ms ease-out, rising 14px      explicit delays, never :nth-child
 *   fold open       300ms ease
 *   dialog, menu    200ms ease-out, 8px + scale(0.98)
 *   press           instant
 *
 * Entrances use `ease-out`; state changes keep the house `ease`. That keyword is the only new
 * easing — no cubic-bezier, in a codebase that has none. Every value is a literal, because there
 * are no custom properties anywhere here and this file is not the place to introduce the first.
 */


/* =========================================
   1. KEYFRAMES
   The first in this codebase, so the names cannot collide with anything. Prefixed anyway, in
   case a third-party stylesheet ever arrives.
========================================= */

@keyframes chamois-rise {
    from { opacity: 0; translate: 0 18px; }
    to   { opacity: 1; translate: 0 0; }
}

@keyframes chamois-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes chamois-page-in {
    from { opacity: 0; translate: 0 10px; }
    to   { opacity: 1; translate: 0 0; }
}

@keyframes chamois-hero-in {
    from { opacity: 0; translate: 0 14px; }
    to   { opacity: 1; translate: 0 0; }
}

/* Dialogs and menus. Slightly smaller and slightly low, so they arrive from where they were
   summoned rather than simply appearing. */
@keyframes chamois-pop {
    from { opacity: 0; translate: 0 8px; scale: 0.98; }
    to   { opacity: 1; translate: 0 0;   scale: 1; }
}

/* The unread badge and anything else that appears on an element already on screen. */
@keyframes chamois-badge-in {
    from { opacity: 0; scale: 0.4; }
    60%  { opacity: 1; scale: 1.15; }
    to   { opacity: 1; scale: 1; }
}

/* A ring breathing outward from the next-ride dot. box-shadow on a 6px element costs no layout
   and no repaint of anything around it. */
@keyframes chamois-dot {
    0%       { box-shadow: 0 0 0 0 rgba(255,90,90,0.55); }
    70%,100% { box-shadow: 0 0 0 7px rgba(255,90,90,0); }
}

/* The rides board's modal backdrop. It animates its background-color rather than its opacity,
   deliberately: .scrim is position:fixed inset:0 with backdrop-filter: blur(3px), and animating
   opacity on that makes the element its own backdrop root, forcing a full-viewport readback and
   re-blur every frame — on a phone, the most expensive 200ms available anywhere on this site.
   Fading the tint alone leaves the blur static and costs nothing. This is the one keyframe here
   that touches a property other than opacity/translate/scale/rotate/filter, and background-color
   is safe in a way `left` or `width` would not be: nothing computes it in C# or inline. */
@keyframes chamois-scrim-in {
    from { background-color: rgba(17,17,17,0); }
    to   { background-color: rgba(17,17,17,0.55); }
}


/* =========================================
   2. REVEAL ON SCROLL
   js/site.js adds .is-revealed. Two shapes: one element, or a container whose children stagger.
========================================= */

/* The resting state hangs off :not(.is-revealed) rather than being unset by the revealed rule,
   so an element that has been revealed carries no motion declaration at all — nothing lingers to
   outrank a hover, and nothing needs animation-fill-mode to hold it there. */
.motion-on [data-reveal]:not(.is-revealed) {
    opacity: 0;
}

.motion-on [data-reveal].is-revealed {
    animation: chamois-rise 450ms ease-out;
}

/* Full-bleed bands. See rule 3 in the header: these may fade, never move. */
.motion-on [data-reveal="fade"].is-revealed {
    animation: chamois-fade 450ms ease-out;
}

/* ---- groups ----
   The container is what gets observed; its children carry the delays. Observing each child
   separately would fire them on their own schedules and lose the sequence entirely. */
.motion-on [data-reveal-group]:not(.is-revealed) > * {
    opacity: 0;
}

.motion-on [data-reveal-group].is-revealed > * {
    /* `backwards` so a child holds its from-state through its delay instead of flashing at full
       opacity and then starting the animation. */
    animation: chamois-rise 450ms ease-out backwards;
}

.motion-on [data-reveal-group="fade"].is-revealed > * {
    animation: chamois-fade 450ms ease-out backwards;
}

.motion-on [data-reveal-group].is-revealed > *:nth-child(2) { animation-delay: 70ms; }
.motion-on [data-reveal-group].is-revealed > *:nth-child(3) { animation-delay: 140ms; }
.motion-on [data-reveal-group].is-revealed > *:nth-child(4) { animation-delay: 210ms; }
.motion-on [data-reveal-group].is-revealed > *:nth-child(5) { animation-delay: 280ms; }
.motion-on [data-reveal-group].is-revealed > *:nth-child(6) { animation-delay: 350ms; }
.motion-on [data-reveal-group].is-revealed > *:nth-child(7) { animation-delay: 420ms; }

/* Everything from the eighth onward shares one delay. The rides archive shows up to 24 cards and
   a 24-deep stagger is 1.6 seconds of watching a list assemble itself. */
.motion-on [data-reveal-group].is-revealed > *:nth-child(n+8) { animation-delay: 490ms; }

/* ---- the keyboard escape ----
   A link inside an unrevealed block is still in the tab order and still activatable, and its
   focus ring would be invisible — WCAG 2.4.7 in the plainest possible terms. site.js also adds
   .is-revealed on focusin, but that fires after the browser has already scrolled and drawn, so
   this is what makes it instant. `animation: none` matters as much as the opacity: focus can
   arrive mid-animation, and without it the running animation would keep overriding this. */
.motion-on [data-reveal]:focus-within,
.motion-on [data-reveal-group]:focus-within > * {
    opacity: 1;
    animation: none;
}

/* Belt and braces for a mid-session change of the setting, in the moments before site.js's
   matchMedia listener has taken the gate off again. */
@media (prefers-reduced-motion: reduce) {
    .motion-on [data-reveal],
    .motion-on [data-reveal-group] > * {
        opacity: 1 !important;
        animation: none !important;
    }
}


/* =========================================
   3. THE PAGE ENTER
   .auth-page is the shell the account and system pages share and no public page uses, which
   makes it exactly the line between the two families. Public pages get their soft rise from the
   reveal system — whatever is already in the viewport when a page paints animates in together,
   and that *is* the page transition. These pages have no reveals, so they get this instead.
========================================= */

.motion-on .auth-page:not([data-no-motion]) {
    animation: chamois-page-in 350ms ease-out;
}

/* /dev/logs and /dev/settings opt out with data-no-motion. The diagnostics page is the one you
   open *because* the site is misbehaving; it should be readable the instant it paints, not 350ms
   later. Same argument that keeps it free of a render mode. */


/* =========================================
   4. THE HEROES
   Above the fold by definition, so there is nothing to observe and no reason to wait for an
   IntersectionObserver callback — which is delivered after first paint and would cost the page
   its LCP element.

   Both hero BOXES are left completely alone. .hero has no z-index and therefore no stacking
   context, which is what lets NextRideBadge (2), .hero-content (1), the scrim (-1) and the video
   (-2) compare directly; opacity or transform on it would create one, and would also make it a
   backdrop root for the badge's backdrop-filter, which is a full-viewport readback per frame
   over a decoding video. Only the text children move.
========================================= */

.motion-on .hero-title,
.motion-on .hero-tagline,
.motion-on .next-ride,
.motion-on .kiezel-hero-logo,
.motion-on .kiezel-hero-date,
.motion-on .kiezel-hero-place,
.motion-on .kiezel-hero-cta {
    animation: chamois-hero-in 600ms ease-out backwards;
}

/* Explicit delays, never :nth-child. NextRideBadge renders nothing at all when there is no
   upcoming ride or the rides store is down, so a positional stagger would shift the whole
   sequence depending on whether the club had a ride booked. */
.motion-on .hero-tagline        { animation-delay: 110ms; }
.motion-on .next-ride           { animation-delay: 260ms; }
.motion-on .kiezel-hero-date    { animation-delay: 110ms; }
.motion-on .kiezel-hero-place   { animation-delay: 190ms; }
.motion-on .kiezel-hero-cta     { animation-delay: 300ms; }

/* The one thing on the site that never stops moving: a slow ring off the next ride's dot. It is
   6px across, the animation is box-shadow only, and it is the single clearest signal that this
   panel is about something happening soon rather than a decoration. */
.motion-on .nr-dot {
    animation: chamois-dot 2.4s ease-out infinite;
}


/* =========================================
   5. PRESS AND FOCUS
   Not gated. A phone never fires :hover, so eleven files in this codebase switch hover effects
   off under (hover: none) — correctly, since they otherwise stick after a tap — and until now
   nothing was put back in their place. Every control on the site acknowledged a tap with
   absolutely nothing.

   The press is instant in both directions on purpose. A transition would have to restate each
   element's existing `transition` shorthand to avoid deleting it, and an immediate response is
   what a press should feel like anyway.

   `scale`, not `transform`, for the reason in the header: .btn-solid, .board-add, .btn-primary,
   .btn-register, .strava-connect and friends all own `transform` for their hover lift, and this
   has to compose with it rather than replace it.
========================================= */

/* :not(.kit-thumb) is not tidiness. A kit thumbnail is a <button> wrapped round a [data-merch3d]
   stage, and merch3d.js reads that stage's rect every frame while holding its padding as a cached,
   unscaled px value — so scaling any ancestor of a stage mis-insets the garment for as long as the
   press lasts. The thumbnails already answer a tap: .is-active takes them from 0.55 opacity to 1.

   :not(:disabled) so the save button in the ride dialog, which is disabled while saving, does not
   invite a press it will ignore. */
button:not(:disabled):not(.kit-thumb):active,
.home-btn:active,
.home-partners-btn:active,
.login-btn:active,
.logout-btn:active,
.btn-register:active,
.btn-ghost:active,
.sponsors-contact-btn:active,
.affiche-dl:active,
.next-ride:active,
.log-chip:active,
.log-settings-link:active,
.nav-user-menu-item:active,
.notif-all:active,
.notif-line:active,
.board-switch:active,
.strava-connect:active {
    scale: 0.97;
}

/* Cards are large, and 3% of a 500px card is a 15px lurch. They take a fifth of it.
   .kit-card is absent for the same reason as .kit-thumb above — it wraps the hero stage. */
.ride-card:active,
.route-card:active,
.ig-card:active,
.sponsor-box:active,
.contact-card:active {
    scale: 0.995;
}

/* ---- focus ----
   The 2px/#b30000/2px recipe six scoped stylesheets already define, applied everywhere so that
   the press states above are not mouse-only. :focus-visible, so a mouse click never draws it.

   [tabindex="-1"] is excluded deliberately: Routes.razor runs <FocusOnNavigate Selector="h1" />,
   which gives the heading tabindex="-1" and focuses it on every navigation. site.css turns that
   ring off (h1:focus { outline: none }) because it is a programmatic focus nobody asked for, and
   a blanket [tabindex] rule here would turn it straight back on. */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible {
    outline: 2px solid #b30000;
    outline-offset: 2px;
}


/* =========================================
   6. FOLDING
   Six things on this site opened and closed by snapping. All six are a `display` switch, which
   cannot be transitioned on its own — so this uses @starting-style for the entrance and
   transition-behavior: allow-discrete to hold `display` through the exit.

   Where a browser lacks either, the transition is simply skipped and the element appears or
   disappears at once — which is today's behaviour. Nothing can end up hidden, which is the only
   property that actually matters here.
========================================= */

/* ---- the mobile navigation panel ----
   Inside the media query, and it has to be: above 1200px #nav-menu is `display: contents`, which
   generates no box at all, so opacity and translate would mean nothing there and a display
   transition would be actively wrong. site.js is untouched — it still only toggles .active. */
@media (max-width: 1200px) {
    .motion-on #nav-menu {
        opacity: 0;
        translate: 0 -10px;
        /* pointer-events with normal (immediate) behaviour, not allow-discrete: allow-discrete
           would keep the closing panel hit-testable for the whole 300ms and it would swallow the
           click aimed at the page underneath it. */
        pointer-events: none;
        transition: opacity 300ms ease, translate 300ms ease, display 300ms allow-discrete;
    }

    .motion-on #nav-menu.active {
        opacity: 1;
        translate: 0 0;
        pointer-events: auto;
    }

    @starting-style {
        .motion-on #nav-menu.active {
            opacity: 0;
            translate: 0 -10px;
        }
    }

    /* The hamburger becomes an X. The bars already carry `transition: 0.3s` with no property,
       i.e. `all`, so this costs no new transition declaration and no JavaScript — .active lands
       on #nav-menu and :has() reaches back up to the bars. The 8px is the bar height (3) plus
       the flex gap (5), so each outer bar travels exactly to the middle one.

       .hamburger::after, the unread dot, is a pseudo-element on the hamburger rather than on a
       bar, so none of this touches it. */
    .motion-on nav:has(#nav-menu.active) .hamburger span:nth-child(1) {
        translate: 0 8px;
        rotate: 45deg;
    }

    .motion-on nav:has(#nav-menu.active) .hamburger span:nth-child(2) {
        opacity: 0;
        scale: 0.4 1;
    }

    .motion-on nav:has(#nav-menu.active) .hamburger span:nth-child(3) {
        translate: 0 -8px;
        rotate: -45deg;
    }
}

/* ---- the signed-in menu and the notification panel ----
   Same shape, same JS, same treatment. Both are position:absolute dropdowns hanging off the nav.
   The chevron already rotates on aria-expanded, which JS sets, so that half was done. */
.motion-on .nav-user-menu,
.motion-on .notif-menu {
    opacity: 0;
    translate: 0 -8px;
    pointer-events: none;
    transition: opacity 200ms ease, translate 200ms ease, display 200ms allow-discrete;
    transform-origin: top right;
}

.motion-on .nav-user-menu.active,
.motion-on .notif-menu.active {
    opacity: 1;
    translate: 0 0;
    pointer-events: auto;
}

@starting-style {
    .motion-on .nav-user-menu.active,
    .motion-on .notif-menu.active {
        opacity: 0;
        translate: 0 -8px;
    }
}

/* Below 1200px the signed-in menu stops being a dropdown: site.css renders it inline inside the
   hamburger panel and does not draw the toggle at all. Nothing adds .active to it there — so
   without this it would sit at opacity 0 with pointer-events off, permanently, which is the exact
   failure this whole layer is gated to make impossible. The panel's own fold is the only one that
   should be running at this width. */
@media (max-width: 1200px) {
    .motion-on .nav-user-menu,
    .motion-on .nav-user-menu.active {
        opacity: 1;
        translate: none;
        pointer-events: auto;
        transition: none;
    }
}

/* Below 1200px NotificationBell.razor.css sets `display: none !important` on the panel and the
   bell becomes a plain link to /notifications instead — there is nowhere for a 350px dropdown to
   go. !important beats everything here, so no transition can run and none should. */

/* ---- <details> on /dev/logs ----
   interpolate-size is scoped to these elements and is NOT on :root. It is an inherited property:
   declared at the root it would reach every element on the site, and every existing transition
   naming a size property — or `all`, which #lang-toggle uses — would start animating to and from
   `auto`.

   Both the closed and the open state are written on ::details-content, and that is the whole
   trick. Firefox does not support the pseudo-element, and an unsupported pseudo-element
   invalidates the entire rule it appears in — so Firefox drops both halves together and gets
   today's instant open. Split them across a supported and an unsupported selector and Firefox
   would apply the closed half and drop the open one, leaving every expanded log entry at zero
   height forever. */
.motion-on details {
    interpolate-size: allow-keywords;
}

.motion-on details::details-content {
    block-size: 0;
    overflow: hidden;
    transition: block-size 300ms ease, content-visibility 300ms allow-discrete;
}

.motion-on details[open]::details-content {
    block-size: auto;
}

/* ---- the rides board ----
   Blazor creates and destroys these nodes with a Razor @if, so a CSS animation runs on insert
   with no JavaScript at all — which is the only thing that works inside the circuit, where no
   enhancedload ever fires. Entrance only: the node is removed synchronously on cancel and there
   is no exit hook short of a _closing flag in C#. */
.motion-on .scrim {
    animation: chamois-scrim-in 200ms ease-out;
}

.motion-on .dialog,
.motion-on .ride-menu {
    animation: chamois-pop 200ms ease-out;
}


/* =========================================
   7. THE NAVIGATION PILL ON SCROLL
   js/site.js adds .is-scrolled past 40px. The pill tightens and its shadow deepens, so it reads
   as floating over the page rather than being part of it.

   `translate`, not `transform`: nav is centred by `transform: translateX(-50%)` and rewriting
   that here would throw the pill half a screen to the right. The two compose.
========================================= */

.motion-on nav {
    transition: padding 250ms ease, box-shadow 250ms ease, translate 250ms ease;
}

.motion-on nav.is-scrolled {
    padding-top: 6px;
    padding-bottom: 6px;
    translate: 0 -6px;
    box-shadow: 0 14px 40px rgba(0,0,0,0.28);
}

.motion-on nav.is-scrolled .logo-img {
    height: 38px;
}

.motion-on .logo-img {
    transition: height 250ms ease;
}


/* =========================================
   8. IMAGES
   An allow-list, never a deny-list. Opacity is load-bearing state on three sets of images here —
   .sponsor-box img rests at 0.6, .kit-thumb at 0.55, and [data-merch3d] img at 0 while the WebGL
   viewer is live — and fading any of those in would fight the rule that owns them.
========================================= */

.motion-on .about-photo img,
.motion-on .ig-card img,
.motion-on .affiche-frame img {
    opacity: 0;
    transition: opacity 500ms ease;
}

.motion-on .about-photo img.is-loaded,
.motion-on .ig-card img.is-loaded,
.motion-on .affiche-frame img.is-loaded {
    opacity: 1;
}


/* =========================================
   9. WHAT IS DELIBERATELY NOT IN THIS FILE

   Every new HOVER effect, and its @media (hover: none) counterpart. They live beside the rules
   they extend — in site.css and in the scoped sheets — for one concrete reason: `transition` is
   a shorthand, so a rule here declaring it would REPLACE the element's existing list rather than
   add to it. `.motion-on .ig-card { transition: opacity … }` is (0,2,0) against `.ig-card`'s
   (0,1,0), and would silently delete the 0.3s lift that card has had all along. Restating each
   existing property list here would work exactly until somebody edited the original.

   So: a hover effect goes where the element's other hover rules already are, its transition list
   is extended in place, and its (hover: none) reset joins the block that file already has. Nine
   of them exist. The press states and the focus ring above are the exception, because no other
   rule in the codebase declares either.

   Also not here: .conn and #blazor-error-ui. They are the circuit-failure UI, and a message
   saying the connection has dropped should not spend 300ms arriving.
========================================= */

/* ==========================================================================
   THE LEVEL-UP CARD
   --------------------------------------------------------------------------
   The one place on this site where something is allowed to look pleased with
   itself. It appears a handful of times a year per member, on a panel that
   covers the page, so it can afford what the klassement deliberately cannot —
   see Members.razor.css: "a klassement with two glowing cards is a page, with
   forty it is a fairground."

   GATED LIKE EVERYTHING ELSE. No .motion-on, no animation: the card is still
   there, still legible, still dismissible. That is the whole safety story and
   it is why nothing here touches opacity on the card itself in a way that
   could leave it invisible — the resting state of every element below is the
   finished state, and the keyframes animate TOWARDS it.

   ONLY opacity, translate, scale and rotate, per the rule at the top of this
   file. The card's position is `position: fixed; inset: 0` on its backdrop,
   which an animation touching `inset` would fight.
   ========================================================================== */

@keyframes levelup-backdrop {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes levelup-card {
    from { opacity: 0; translate: 0 18px; scale: 0.94; }
    to { opacity: 1; translate: 0 0; scale: 1; }
}

/* The badge arrives after the card it sits on, which is what makes it read as
   the thing being presented rather than as part of the box. */
@keyframes levelup-badge {
    0% { opacity: 0; scale: 0.55; rotate: -12deg; }
    60% { opacity: 1; scale: 1.08; rotate: 3deg; }
    100% { opacity: 1; scale: 1; rotate: 0deg; }
}

@keyframes levelup-rise {
    from { opacity: 0; translate: 0 10px; }
    to { opacity: 1; translate: 0 0; }
}

.motion-on .levelup {
    animation: levelup-backdrop 0.25s ease both;
}

.motion-on .levelup-card {
    animation: levelup-card 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2) 0.08s both;
}

/* 0.62 cubic-bezier overshoot on the badge: it lands, it does not float in.
   The delay is what separates it from the card's own arrival. */
.motion-on .levelup-badge {
    animation: levelup-badge 0.62s cubic-bezier(0.2, 0.8, 0.3, 1.25) 0.3s both;
}

/* Explicit delays rather than :nth-child, for the reason the hero already
   documents: the perk line is not always rendered — a level with no discount
   has none — so a positional stagger would shift depending on which level
   somebody happened to reach. */
.motion-on .levelup-level { animation: levelup-rise 0.4s ease 0.62s both; }
.motion-on .levelup-name { animation: levelup-rise 0.4s ease 0.68s both; }
.motion-on .levelup-perk { animation: levelup-rise 0.4s ease 0.76s both; }
.motion-on .levelup-line { animation: levelup-rise 0.4s ease 0.82s both; }
.motion-on .levelup-close { animation: levelup-rise 0.4s ease 0.9s both; }
