/* ═══ Motion: the light rises ═══
   Loaded after light.css. One idea, used quietly: light comes up from the floor.
   The week's arches light in turn, charts grow from their base, figures count up,
   and a single ray crosses the one thing to do next.

   Rules kept here:
   - Everything sits inside the media query below, so "reduce motion" and printing
     get the plain page, and nothing is ever hidden by waiting for an animation:
     every keyframe starts from a state and ends on the element's own resting style.
   - Only transform, translate, scale and opacity move. Nothing that relays out.
   - Entrances are short and play once. The students are here to study. */

@view-transition { navigation: auto; }

@media (prefers-reduced-motion: no-preference) and screen {

:root {
    --rise-ease: cubic-bezier(.22, .7, .2, 1);
    --spring: cubic-bezier(.2, .8, .3, 1.25);
}

/* Between pages: the page cross-fades, the bars stay where they are.
   The home page runs its own theme reveal through the same pseudo-elements. */
html:not(:has(.lp-header))::view-transition-old(root),
html:not(:has(.lp-header))::view-transition-new(root) { animation-duration: .18s; }
.navbar-anwar { view-transition-name: anwar-bar; }
.bottom-nav { view-transition-name: anwar-tabs; }

@keyframes m-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes m-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes m-grow-up { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes m-grow-along { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes m-pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes m-door { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes m-ray { from { transform: translateX(130%); } to { transform: translateX(-130%); } }
@keyframes m-settle { from { opacity: 0; scale: .96; } to { opacity: 1; scale: 1; } }
@keyframes m-tab { from { opacity: 0; translate: 0 14px; } to { opacity: 1; translate: 0 0; } }
@keyframes m-menu { from { opacity: 0; translate: 0 -6px; } to { opacity: 1; translate: 0 0; } }

/* A page arrives top to bottom */
#main-content > * { animation: m-rise .42s var(--rise-ease) backwards; }
#main-content > :nth-child(2) { animation-delay: 50ms; }
#main-content > :nth-child(3) { animation-delay: 100ms; }
#main-content > :nth-child(4) { animation-delay: 150ms; }
#main-content > :nth-child(5) { animation-delay: 200ms; }
#main-content > :nth-child(n+6) { animation-delay: 240ms; }
/* A moving ancestor would drag anything position:fixed with it (the grading dock) */
#main-content > :has(.sub-dock, .grade-dock, [class*="-dock"]) { animation-name: m-fade; }

/* The week's hall: the arches she has finished light up in turn */
.sh-hall .sh-arch.is-done:not(.is-just)::before {
    animation: m-fade .55s ease both;
    animation-delay: calc(var(--i, 0) * 70ms + 160ms);
}
.sh-hall.is-celebrating .sh-arch.is-done:not(.is-just)::before { animation: none; }

/* Doors rise from the floor in order, and lift a little under the pointer */
.todo-card { animation: m-door .5s var(--rise-ease) backwards; }
.todo-card:nth-child(2) { animation-delay: 70ms; }
.todo-card:nth-child(3) { animation-delay: 140ms; }
.todo-card:nth-child(4) { animation-delay: 210ms; }
:root a.todo-card { transition: transform .22s var(--rise-ease), color .18s ease; }
@media (hover: hover) { :root a.todo-card:hover { transform: translateY(-4px); } }

/* Charts grow from their base */
.progress-bar { transform-origin: right center; animation: m-grow-along .8s var(--rise-ease) .2s backwards; }
.colonnade-col { transform-origin: bottom center; animation: m-grow-up .55s var(--rise-ease) backwards; animation-delay: calc(var(--i, 0) * 40ms + 120ms); }
.colonnade-col:nth-child(1) { --i: 0; } .colonnade-col:nth-child(2) { --i: 1; } .colonnade-col:nth-child(3) { --i: 2; }
.colonnade-col:nth-child(4) { --i: 3; } .colonnade-col:nth-child(5) { --i: 4; } .colonnade-col:nth-child(6) { --i: 5; }
.colonnade-col:nth-child(7) { --i: 6; } .colonnade-col:nth-child(8) { --i: 7; } .colonnade-col:nth-child(9) { --i: 8; }
.colonnade-col:nth-child(10) { --i: 9; } .colonnade-col:nth-child(11) { --i: 10; } .colonnade-col:nth-child(12) { --i: 11; }
.lvl-col { animation: m-door .55s var(--rise-ease) backwards; }
.lvl-col:nth-child(2) { animation-delay: 90ms; }
.lvl-col:nth-child(3) { animation-delay: 180ms; }
.lvl-col:nth-child(n+4) { animation-delay: 240ms; }

/* Medals settle into place */
.pair-arch { animation: m-door .5s var(--rise-ease) .1s backwards; }
.pair-arch:nth-child(2) { animation-delay: .18s; }

/* One ray of light crosses the next step, twice, then leaves it alone */
:root .sh-next .btn-anwar { position: relative; overflow: hidden; }
:root .sh-next .btn-anwar::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(105deg, transparent 30%, rgba(255, 249, 231, .34) 50%, transparent 70%);
    transform: translateX(130%);
    animation: m-ray 1.25s ease-in-out 1s 2;
}
[data-theme="dark"] .sh-next .btn-anwar::after {
    background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, .55) 50%, transparent 70%);
}

/* Things you press answer the finger */
:root :is(.btn-anwar, .btn-accent, .btn-outline-anwar, .btn-secondary, .btn-danger, .btn-outline-danger, .btn-undo) {
    transition: background-color .18s ease, color .18s ease, scale .12s ease;
}
:root :is(.btn-anwar, .btn-accent, .btn-outline-anwar, .btn-secondary, .btn-danger, .btn-outline-danger, .btn-undo):active:not(:disabled) { scale: .97; }

/* The tab bar: the active arch rises into place */
:root .bottom-nav-item.active::before { animation: m-tab .32s var(--rise-ease) backwards; }
:root .bottom-nav-item :is(i, .ic) { transition: scale .14s ease; }
:root .bottom-nav-item:active :is(i, .ic) { scale: .86; }
:root .bottom-nav-badge, :root .nav-badge { animation: m-pop .32s var(--spring) .3s backwards; }

/* The menu */
:root .navbar-anwar .nav-link { transition: translate .18s var(--rise-ease), background-color .18s ease, color .18s ease; }
@media (hover: hover) and (min-width: 992px) { :root .navbar-anwar .nav-link:hover { translate: -3px 0; } }
:root .dropdown-menu.show { animation: m-menu .16s ease-out; }

/* Sign in: the mark settles, the form comes up under it */
.login-card { animation: m-rise .5s var(--rise-ease) .1s backwards; }
.login-logo, .login-brand { animation: m-settle .6s var(--rise-ease) backwards; }

}
