/*
 * Motion: one set of tokens and keyframes for the whole app (spec: short, small, opacity and transform only).
 *   html.m-arrive   first paint only (head script, motion allowed): the first blocks of a page rise in once
 *   .m-pending      below the fold when the motion controller ran; .m-in brings it in when it scrolls into view
 *   .m-pulse        a live refresh changed this row: one ember ring
 * Nothing here hides content without JS or under reduced motion: the classes only exist when the scripts set them.
 */
:root {
    --m-press: 110ms;
    --m-quick: 200ms;
    --m-enter: 320ms;
    --m-slow: 420ms;
    --m-ease: cubic-bezier(0.2, 0, 0, 1);
    --m-ease-in: cubic-bezier(0.05, 0.7, 0.1, 1);
    --m-rise: 8px;
    --m-stagger: 40ms;
}

@keyframes m-rise { from { opacity: 0; translate: 0 var(--m-rise); } }
@keyframes m-fade { from { opacity: 0; } }
@keyframes m-scale-in { from { opacity: 0; scale: 0.94; } }
@keyframes m-glow-in { from { opacity: 0; } }
@keyframes m-grow { from { scale: 1 0; } }
@keyframes m-pulse { 0% { opacity: 0; } 18% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- Arrival: the first blocks of the page, once ---------- */
.m-arrive main.page > .wrap > :nth-child(-n+5):not(.evening-nav, [data-kb], dialog, template, script, [hidden]),
.m-arrive .home-jobs > :nth-child(-n+4):not(h1),
.m-arrive main.page > .hero .hero__text > *,
.m-arrive .tv > * {
    animation: m-rise var(--m-enter) var(--m-ease-in) both;
}
.m-arrive main.page > .wrap > :nth-child(2), .m-arrive .home-jobs > :nth-child(3), .m-arrive .hero__text > :nth-child(2), .m-arrive .tv > :nth-child(2) { animation-delay: calc(1 * var(--m-stagger)); }
.m-arrive main.page > .wrap > :nth-child(3), .m-arrive .home-jobs > :nth-child(4), .m-arrive .hero__text > :nth-child(3) { animation-delay: calc(2 * var(--m-stagger)); }
.m-arrive main.page > .wrap > :nth-child(4), .m-arrive .hero__text > :nth-child(4) { animation-delay: calc(3 * var(--m-stagger)); }
.m-arrive main.page > .wrap > :nth-child(5), .m-arrive .hero__text > :nth-child(5) { animation-delay: calc(4 * var(--m-stagger)); }

/* Rows of the boards in view at arrival: a short cascade, then the rest stays put. */
.m-arrive :is(.nose-list, .board, .event-list) > :nth-child(-n+6) { animation: m-rise var(--m-enter) var(--m-ease-in) both; animation-delay: calc(var(--m-row, 0) * 35ms + 120ms); }
:is(.nose-list, .board, .event-list) > :nth-child(2) { --m-row: 1; }
:is(.nose-list, .board, .event-list) > :nth-child(3) { --m-row: 2; }
:is(.nose-list, .board, .event-list) > :nth-child(4) { --m-row: 3; }
:is(.nose-list, .board, .event-list) > :nth-child(5) { --m-row: 4; }
:is(.nose-list, .board, .event-list) > :nth-child(6) { --m-row: 5; }

/* The evening's bowls light up one by one in the switcher. */
.m-arrive .bowl-switch__chip { animation: m-scale-in var(--m-enter) var(--m-ease-in) both; }
.bowl-switch__chip:nth-of-type(2) { animation-delay: 30ms; }
.bowl-switch__chip:nth-of-type(3) { animation-delay: 60ms; }
.bowl-switch__chip:nth-of-type(4) { animation-delay: 90ms; }
.bowl-switch__chip:nth-of-type(n+5) { animation-delay: 120ms; }

/* Progress rings and the rank ring settle in. */
.m-arrive :is(.ring-progress, .rank-ring, .home-me__ring) { animation: m-scale-in var(--m-slow) var(--m-ease-in) both 80ms; }

/* ---------- Coals ignite one after another (display coals only, never the rating input) ---------- */
.coals:not(.coals--empty) .coal__glow { transition: opacity var(--m-slow) var(--m-ease); }
.coals .coal:nth-child(2) .coal__glow { transition-delay: 70ms; }
.coals .coal:nth-child(3) .coal__glow { transition-delay: 140ms; }
.coals .coal:nth-child(4) .coal__glow { transition-delay: 210ms; }
.coals .coal:nth-child(5) .coal__glow { transition-delay: 280ms; }
.m-pending .coals .coal__glow { opacity: 0; }
.m-arrive .coals:not(.coals--alive) .coal__glow { animation: m-glow-in var(--m-slow) var(--m-ease) both; animation-delay: calc(var(--m-coal, 0) * 70ms + 160ms); }
.m-arrive .coals--alive .coal__glow { animation: m-glow-in var(--m-slow) var(--m-ease) both calc(var(--m-coal, 0) * 70ms + 160ms), flicker 3.2s ease-in-out infinite; }
.coals .coal:nth-child(2) { --m-coal: 1; }
.coals .coal:nth-child(3) { --m-coal: 2; }
.coals .coal:nth-child(4) { --m-coal: 3; }
.coals .coal:nth-child(5) { --m-coal: 4; }

/* ---------- Reveal on scroll (motion controller) ---------- */
.m-pending { opacity: 0; translate: 0 var(--m-rise); }
.m-in { transition: opacity var(--m-enter) var(--m-ease-in), translate var(--m-enter) var(--m-ease-in); transition-delay: calc(var(--m-i, 0) * var(--m-stagger)); }
/* Bars grow from their base once they come in. */
:is(.m-in, .m-arrive) :is(.mini-bars__col, .spread__slot) i { animation: m-grow var(--m-slow) var(--m-ease-in) both 120ms; transform-origin: 50% 100%; }

/* ---------- Press and hover ---------- */
:is(.card--link, .event-row, .mix-tile, .catalogue-row, .line-card__link, .nose-row__btn, .nose-podium__person, .bowl-switch__chip, .home-me, .home-next, .home-last, .home-pack, .home-more__item, .guest-card, .tabbar a, .poll-option, .bowl-row__link) {
    transition: scale var(--m-press) var(--m-ease), translate var(--m-quick) var(--m-ease), transform var(--m-quick) var(--m-ease),
        border-color var(--m-quick), background-color var(--m-quick), color var(--m-quick), box-shadow var(--m-quick);
}
:is(.card--link, .event-row, .mix-tile, .catalogue-row, .line-card__link, .nose-row__btn, .nose-podium__person, .home-me, .home-next, .home-last, .home-pack, .home-more__item, .guest-card):active { scale: 0.985; }
:is(.bowl-switch__chip, .tabbar a):active { scale: 0.94; }
@media (hover: hover) and (pointer: fine) {
    :is(.event-row, .mix-tile, .catalogue-row, .nose-row__btn, .home-pack, .guest-card):hover { translate: 0 -2px; }
    .nose-podium__person:hover { translate: 0 -2px; }
}

/* ---------- Live: a row that changed glows once ---------- */
.m-pulse { position: relative; }
.m-pulse::after {
    content: "";
    position: absolute;
    inset: -1px;
    z-index: 1;
    border-radius: inherit;
    box-shadow: 0 0 0 1.5px color-mix(in oklab, var(--accent) 80%, transparent), 0 0 22px -2px var(--glow);
    pointer-events: none;
    opacity: 0;
    animation: m-pulse 1.2s var(--m-ease) both;
}

/* ---------- Between pages: a short cross-fade; the bars stay where they are ---------- */
@media (prefers-reduced-motion: no-preference) {
    @view-transition { navigation: auto; }
    header.appbar[data-kb] { view-transition-name: appbar; }
    nav.tabbar[data-kb] { view-transition-name: tabbar; }
    ::view-transition-old(root) { animation: 120ms var(--m-ease) both m-vt-out; }
    ::view-transition-new(root) { animation: 180ms var(--m-ease-in) both m-vt-in; }
}
@keyframes m-vt-out { to { opacity: 0; } }
@keyframes m-vt-in { from { opacity: 0; translate: 0 4px; } }

/* ---------- Reduced motion: off, not shortened ---------- */
@media (prefers-reduced-motion: reduce) {
    .m-pending { opacity: 1; translate: none; }
    .m-pulse::after { display: none; }
    .coals .coal__glow { transition: none; }
}
