/* Motion: the student pages move from one view to the next instead of
   cutting (Omar, 2026-10-28; asked for the phone app, which shows these very
   pages, so browsers get it too). Which way a change goes is decided in
   assets/js/motion.js. To take it off a page, remove this file's <link>, the
   <script src="…motion.js"> and the <style>@view-transition…</style> at the
   top of its <head>.

   On the student pages since 2026-10-28, and on mom's admin pages since
   2026-11-10 (Omar: "apply to the admin page as well"). Those redraw their
   cards after every upload, move or delete, where cards arriving again each
   time would read as flicker: there they arrive (1) only when she comes to a
   page or opens a folder (motion.js marks <html class="motion-arriving"> for
   that moment), never when a page is drawn again after something she did.

   The second round (Omar, 2026-11-10, "very static and boring on the long
   run"; all eight of the motion lab's proposals chosen):
     1  Cascade: cards and rows arrive one after another, rising into place.
     2  Spring press: a card sinks under the finger and springs back just
        past its size.
     3  Touch light: a soft blue light spreads from where the finger landed
        (motion.js draws it).
     4  Open from the card: a course or a folder grows out of the card that
        was tapped; going back, the page shrinks into the place it came from.
     5  Deeper slide: the next page travels the whole width while the one
        left drifts a third of the way and fades.
     6  Progress fills: a lesson's blue bar fills to where she stopped, and
        its percentage counts up (motion.js counts).
     7  Theme circle: light and dark spread in a circle from the button.
     8  The lesson grows into the player and shrinks back into its card
        (motion.js; not inside the phone app, whose own player sits over it).

   1. Page to page (cross-document view transitions). The navbar holds still
      through it. The browser keeps the old page on screen until the new one
      has drawn its first frame, so there is never a blank moment. Both pages
      must take part, which is why all six do.
   2. A course's folders, which open in place, move the same way.
   3. The tapped course's name flies up into the course page's path.

   What it costs: opacity and transform only, which the graphics chip does by
   itself, except the counting numbers (6), a few short words redrawn for
   about a second when a folder opens. Nothing runs between changes; no
   request, no server work. A browser without view transitions (before iOS
   18.2 and Chrome 126) switches pages as before; a device that asks for less
   motion gets none of it. */

/* Each student page also says this in a <style> at the very top of its
   <head>. Said only here, Chrome missed it on the course page about one tap
   in three ("ViewTransition opt-in disabled", 2026-10-28): that page shows
   its first frame while its outside scripts are still loading, before it had
   taken this in. Said at the top, it is known before anything is drawn; it
   stays here too so this file still describes the whole of it. */
@view-transition { navigation: auto; }

/* A screen's slide is about as long as an iPhone's, on the curve iOS draws
   its own screens on (look.css, --look-ease): fast away, a long settle. The
   spring is a real one where the browser can draw it (linear()), and a curve
   that overshoots once where it cannot. */
:root {
    --motion-slide:  460ms;
    --motion-zoom:   480ms;
    --motion-ease:   cubic-bezier(0.32, 0.72, 0, 1);
    --motion-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}
@supports (transition-timing-function: linear(0, 1)) {
    :root {
        --motion-spring: linear(0, 0.048, 0.172, 0.342, 0.531, 0.719, 0.887, 1.026, 1.129, 1.195, 1.228, 1.232, 1.214, 1.181, 1.139, 1.094, 1.051, 1.014, 0.985, 0.964, 0.951, 0.946, 0.947, 0.952, 0.961, 0.971, 0.982, 0.991, 0.999, 1.006, 1.01, 1.012, 1.013, 1.012, 1.01, 1.008, 1.006, 1.003, 1.001, 1, 1);
    }
}

/* ── The parts that move on their own ────────────────────
   Named only while a change is under way (motion.js sets data-motion): at
   rest these rules do not apply and the page is exactly as it was. Each page
   has exactly one of the three containers.

   The navbar is NOT one of them, on purpose. It stays in the root with the
   page's background and the blue wash, and the root crossfades into itself:
   the same navbar over the same background reads as standing still (and a
   changed active tab simply fades). Named on its own, it ended the whole
   change early: navbar.js draws it again once the login check comes back,
   which replaced the element mid-change, and Chrome stops a transition whose
   part is replaced (2026-10-28, measured: a 360 ms slide over in 50 ms).
   Because it stays in the root, the moving pages are drawn over it: they
   stay see-through (no background of their own), so the bar shows through
   the empty top of every page that crosses it. */
html[data-motion] :is(.page-wrapper, .page-center, .home-fullscreen) { view-transition-name: page; }

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration:        200ms;
    animation-timing-function: ease-out;
}

/* The page takes its new size at once; its two pictures slide. */
::view-transition-group(page) { animation: none; }

/* 5 · Deeper slides the next page the whole width in from the left, as an
   Arabic app's next screen does, while the page left drifts a third of the
   way to the right and fades; back is the other way round. The page left
   fades because the pages are see-through (above): left in full view under
   the arriving one, their words would cross. Between pages of one depth, a
   fade. */
html[data-motion="forward"]::view-transition-old(page) { animation: motion-drift-right var(--motion-slide) var(--motion-ease) both, motion-fade-out var(--motion-slide) linear both; }
html[data-motion="forward"]::view-transition-new(page) { animation: motion-in-left     var(--motion-slide) var(--motion-ease) both; }
html[data-motion="back"]::view-transition-old(page)    { animation: motion-out-left    var(--motion-slide) var(--motion-ease) both; }
html[data-motion="back"]::view-transition-new(page)    { animation: motion-drift-in-right var(--motion-slide) var(--motion-ease) both, motion-fade-in var(--motion-slide) linear both; }
html[data-motion="fade"]::view-transition-old(page),
html[data-motion="fade"]::view-transition-new(page)    { animation-duration: 220ms; }

@keyframes motion-in-left        { from { transform: translateX(-100%); } }
@keyframes motion-out-left       { to   { transform: translateX(-100%); } }
@keyframes motion-drift-right    { to   { transform: translateX(30%); } }
@keyframes motion-drift-in-right { from { transform: translateX(30%); } }
/* The page left is gone a little after half way; the one returned to is
   there by half. */
@keyframes motion-fade-out { 55%, to { opacity: 0; } }
@keyframes motion-fade-in  { from { opacity: 0; } 50% { opacity: 1; } }

/* ── 4 · Open from the card ──────────────────────────────
   Going in: the tapped card and the next page are one part (motion-zoom),
   which grows from the card's box to the page's. The card's own picture
   fades in the first third; the page grows with the box, rounded and cut
   off by it below. The page left behind sinks back and fades.

   Going back: the page shrinks into the place the card was, fading as it
   goes. The card itself is not there yet (the list waits for the server),
   so motion.js puts an empty, invisible box in its place for the change to
   aim at; the cards then arrive as always (1).

   motion.js sets data-motion-zoom: "card" on the page with the card, "in"
   on the page that grows, "out" on the page that shrinks back, "landing" on
   the page it shrinks into. */
html[data-motion][data-motion-zoom="in"] :is(.page-wrapper, .page-center, .home-fullscreen),
html[data-motion][data-motion-zoom="out"] :is(.page-wrapper, .page-center, .home-fullscreen) { view-transition-name: motion-zoom; }

.motion-zoom-target {
    position:             fixed;
    pointer-events:       none;
    border-radius:        16px;
    view-transition-name: motion-zoom;
}

::view-transition-group(motion-zoom) {
    animation-duration:        var(--motion-zoom);
    animation-timing-function: var(--motion-ease);
    overflow:                  clip;
    border-radius:             16px;
}
/* Each picture is scaled to the box's width, whole, and cut off only below
   (the browser's own way): the page grows out of the card and shrinks back
   into it as one piece. Shown at its own size and cut by the box instead
   (2026-11-10, first version), the shrinking page left half-cut words
   sliding into a corner over the page arriving, which read as a glitch. */
::view-transition-image-pair(motion-zoom) { isolation: auto; }
::view-transition-old(motion-zoom),
::view-transition-new(motion-zoom) {
    mix-blend-mode: normal;
}

/* The card itself stays its own size in the middle of the growing box and
   is gone in the first quarter: grown with the box, its name swelled into
   large blurred letters over the arriving page's title. */
html[data-motion="zoom"]::view-transition-old(motion-zoom) {
    width:           100%;
    height:          100%;
    object-fit:      none;
    object-position: 50% 50%;
    animation:       motion-zoom-card-out var(--motion-zoom) linear both;
}
html[data-motion="zoom"]::view-transition-new(motion-zoom) { animation: motion-zoom-page-in  var(--motion-zoom) linear both; }
html[data-motion="zoom"]::view-transition-old(page)        { animation: motion-sink var(--motion-zoom) var(--motion-ease) both; }

html[data-motion="zoom-back"]::view-transition-old(motion-zoom) { animation: motion-zoom-page-out var(--motion-zoom) linear both; }
html[data-motion="zoom-back"]::view-transition-new(motion-zoom) { animation: none; opacity: 0; }
html[data-motion="zoom-back"]::view-transition-new(page)        { animation: motion-rise var(--motion-zoom) var(--motion-ease) both; }

@keyframes motion-zoom-card-out { 25%, to { opacity: 0; } }
@keyframes motion-zoom-page-in  { from, 12% { opacity: 0; } 55%, to { opacity: 1; } }
@keyframes motion-zoom-page-out { from, 25% { opacity: 1; } 80%, to { opacity: 0; } }
@keyframes motion-sink { to   { transform: scale(0.94); opacity: 0; } }
@keyframes motion-rise { from { transform: scale(0.94); opacity: 0; } }

/* The course's name, from its card up into the path. Measured as wide as its
   words, for the flight only (motion.js marks it): the card's name is as
   wide as the card, the path's as its words, and Chrome stretched the one
   box into the other, smearing the text across the screen as it flew. */
[data-motion-title] { width: fit-content; }

::view-transition-group(course-title) {
    animation-duration:        420ms;
    animation-timing-function: var(--motion-ease);
}

/* Each picture of the name keeps its own proportions while it moves (scaled
   by its height, never stretched), and the card's small one hands over to
   the path's large one in the first part of the flight: left to the default
   fade, the small name blown up to the large one's size lingered as a ghost
   beside it. */
::view-transition-old(course-title),
::view-transition-new(course-title) {
    width:  auto;
    height: 100%;
}
::view-transition-old(course-title) { animation: motion-hand-over-out 420ms linear both; }
::view-transition-new(course-title) { animation: motion-hand-over-in  420ms linear both; }
@keyframes motion-hand-over-out { 40%, to { opacity: 0; } }
@keyframes motion-hand-over-in  { from { opacity: 0; } 40%, to { opacity: 1; } }

/* ── 7 · Theme circle ─────────────────────────────────────
   The new look is drawn over the old inside a circle that grows from the
   button (motion.js puts the centre where the finger was). */
html.motion-theme::view-transition-old(root) { animation: none; }
html.motion-theme::view-transition-new(root) {
    animation: motion-theme-circle 560ms cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes motion-theme-circle {
    from { clip-path: circle(0px at var(--motion-cx, 50%) var(--motion-cy, 0px)); }
    to   { clip-path: circle(var(--motion-cr, 150vmax) at var(--motion-cx, 50%) var(--motion-cy, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
    ::view-transition-group(*),
    ::view-transition-old(*),
    ::view-transition-new(*) {
        animation: none !important;
    }
}

/* ── Cards arriving, pressed and touched; bars filling; sheets ── */
@media (prefers-reduced-motion: no-preference) {

    /* 1 · Cascade. Every card is there at once, faint (30%), the moment
       the list arrives, and is full within 0.2 s; each then rises into place
       in turn, by its place in its grid (the first ten; the rest come with
       the tenth), which also sets when its bar fills (6). Cards that started
       unseen and came in one by one (2026-11-10, first version) left the
       screen empty between the grey shapes of the wait and the first card,
       a blink filmed on every page change. `backwards` holds a card low
       only while it waits; once run the animations are gone and the press
       is free. */
    .drive-card,
    .drive-list-item,
    .course-card,
    .course-type-btn,
    .admin-course-card,
    .quick-action-card,
    .stat-card,
    #studentsTableBody > tr {
        animation:       motion-arrive-fade 200ms ease-out backwards,
                         motion-arrive-rise 560ms var(--motion-ease) backwards;
        animation-delay: 0ms, calc(40ms + var(--motion-i, 0) * 40ms);
    }
    :is(#driveFolders, #driveGrid, #courseGrid, .courses-type, #coursesGrid, .admin-quick-actions, #statsGrid, #studentsTableBody) > :nth-child(2)  { --motion-i: 1; }
    :is(#driveFolders, #driveGrid, #courseGrid, .courses-type, #coursesGrid, .admin-quick-actions, #statsGrid, #studentsTableBody) > :nth-child(3)  { --motion-i: 2; }
    :is(#driveFolders, #driveGrid, #courseGrid, .courses-type, #coursesGrid, .admin-quick-actions, #statsGrid, #studentsTableBody) > :nth-child(4)  { --motion-i: 3; }
    :is(#driveFolders, #driveGrid, #courseGrid, .courses-type, #coursesGrid, .admin-quick-actions, #statsGrid, #studentsTableBody) > :nth-child(5)  { --motion-i: 4; }
    :is(#driveFolders, #driveGrid, #courseGrid, .courses-type, #coursesGrid, .admin-quick-actions, #statsGrid, #studentsTableBody) > :nth-child(6)  { --motion-i: 5; }
    :is(#driveFolders, #driveGrid, #courseGrid, .courses-type, #coursesGrid, .admin-quick-actions, #statsGrid, #studentsTableBody) > :nth-child(7)  { --motion-i: 6; }
    :is(#driveFolders, #driveGrid, #courseGrid, .courses-type, #coursesGrid, .admin-quick-actions, #statsGrid, #studentsTableBody) > :nth-child(8)  { --motion-i: 7; }
    :is(#driveFolders, #driveGrid, #courseGrid, .courses-type, #coursesGrid, .admin-quick-actions, #statsGrid, #studentsTableBody) > :nth-child(9)  { --motion-i: 8; }
    :is(#driveFolders, #driveGrid, #courseGrid, .courses-type, #coursesGrid, .admin-quick-actions, #statsGrid, #studentsTableBody) > :nth-child(n+10) { --motion-i: 9; }
    /* Mom's pages: only as she arrives, never on a redraw after an action
       (top of this file). */
    html:not(.motion-arriving) body.admin-page :is(.drive-card, .drive-list-item, .course-type-btn, .admin-course-card, .quick-action-card, .stat-card, #studentsTableBody > tr) {
        animation: none;
    }

    /* 6 · Progress fills: the bar grows from the side reading starts on. */
    .vcard__prog i {
        animation:       motion-fill 900ms cubic-bezier(0.2, 0.7, 0.2, 1) backwards;
        animation-delay: calc(260ms + var(--motion-i, 0) * 90ms);
        transform-origin: left center;
    }
    .vcard__prog i:dir(rtl) { transform-origin: right center; }

    /* 2 · Spring press: down quickly, back on the spring. A card gives a
       little more than a button, a whole-width row a little less. */
    .course-card,
    .drive-card,
    .course-type-btn,
    .btn,
    .drive-list-item,
    .admin-course-card,
    .quick-action-card {
        transition: transform 620ms var(--motion-spring), box-shadow 160ms ease, background-color 160ms ease, color 160ms ease, opacity 160ms ease, border-color 160ms ease;
    }
    .course-card:active,
    .drive-card:active,
    .course-type-btn:active,
    .btn:active,
    .drive-list-item:active,
    .admin-course-card:active,
    .quick-action-card:active {
        transition: transform 110ms cubic-bezier(0.3, 0, 0.5, 1), box-shadow 160ms ease, background-color 120ms ease, color 160ms ease, opacity 160ms ease, border-color 160ms ease;
    }
    .course-card:active,
    .drive-card:active,
    .admin-course-card:active,
    .quick-action-card:active { transform: scale(0.95); }
    .course-type-btn:active { transform: scale(0.965); }
    .btn:active             { transform: scale(0.955); }
    .drive-list-item:active { transform: scale(0.975); }

    /* 3 · Touch light: motion.js puts a .motion-glow in the card at the
       finger. Under the card's words, over its background. */
    .course-card,
    .drive-card,
    .course-type-btn,
    .drive-list-item,
    .admin-course-card,
    .quick-action-card {
        position:  relative;
        overflow:  hidden;
        isolation: isolate;
    }
    .motion-glow {
        position:       absolute;
        z-index:        -1;
        border-radius:  50%;
        pointer-events: none;
        background:     radial-gradient(circle, color-mix(in srgb, var(--color-primary) 30%, transparent) 0%, transparent 62%);
    }
    .course-type-btn .motion-glow {
        background: radial-gradient(circle, rgba(255, 255, 255, 0.35) 0%, transparent 62%);
    }

    /* The sheet's slide is 340 ms (look.css, 15); the window it sits in now
       stays for all of it, fading as the sheet goes down. */
    @media (max-width: 768px) {
        #pledgeModal,
        #pdfModal,
        #imageModal {
            transition: opacity 340ms ease, visibility 340ms;
        }
    }

    /* The side menu on a phone or tablet (Omar, 2026-11-10, "the same level
       for mobile and tablet"). The page behind dims as the menu comes in and
       brightens as it goes, instead of turning grey, and back, in one frame
       (filmed); the menu travels on the screens' own curve. Shown by
       opacity, not display, so it can fade: unseen it is also not there to
       be touched (visibility). */
    .nav-sidebar-overlay {
        display:    block;
        opacity:    0;
        visibility: hidden;
        transition: opacity 340ms ease, visibility 340ms;
    }
    .nav-sidebar-overlay.open {
        opacity:    1;
        visibility: visible;
    }
    .nav-sidebar,
    .admin-sidebar {
        transition: transform 380ms var(--motion-ease);
    }

    /* Cards drawn again only to change their layout (grid or list): already
       seen, so they neither come in again nor count again (motion.js,
       Motion.swap `still`). */
    .motion-settled,
    .motion-settled .vcard__prog i {
        animation: none !important;
    }
}

@keyframes motion-arrive-fade {
    from { opacity: 0.3; }
}
@keyframes motion-arrive-rise {
    from { transform: translateY(18px) scale(0.96); }
}
@keyframes motion-fill {
    from { transform: scaleX(0); }
}
