/*
 * Public site motion (musaed.live, 2026-11).
 * Every rule that hides or moves content sits under html.site-motion, which the <head> sets only when the
 * visitor allows motion (prefers-reduced-motion: no-preference) and JavaScript runs. Every animation ends
 * at the static design, so the resting page is the reference layout.
 * Motion uses the individual translate / scale / rotate properties: they compose with the inline
 * transform: rotate(...) the stickers already carry, instead of replacing it.
 */
:root {
    --site-ease: cubic-bezier(.22, 1, .36, 1);
    --site-spring: cubic-bezier(.34, 1.56, .64, 1);
}

/* ---------- Reveal on scroll ---------- */
.site-motion [data-reveal] {
    opacity: 0;
    transition: opacity .7s var(--site-ease), translate .9s var(--site-ease), scale .8s var(--site-spring);
    transition-delay: var(--d, 0ms);
}
.site-motion [data-reveal="rise"] { translate: 0 28px; }
.site-motion [data-reveal="rise-lg"] { translate: 0 72px; }
.site-motion [data-reveal="slide"] { translate: 44px 0; }
.site-motion [data-reveal="drop"] { translate: 0 -34px; scale: 1.08; }
.site-motion [data-reveal="pop"] { scale: .82; }
.site-motion [data-reveal="stamp"] { scale: 1.7; transition-duration: .45s, .45s, .55s; }
.site-motion [data-reveal].is-in { opacity: 1; translate: 0 0; scale: 1; }

/* Children of a stagger group come in one after another (--i is set by motion.js). */
.site-motion [data-stagger] > * {
    opacity: 0;
    transition: opacity .6s var(--site-ease), translate .8s var(--site-ease), scale .6s var(--site-spring);
    transition-delay: calc(var(--d, 0ms) + var(--i, 0) * 90ms);
}
.site-motion [data-stagger="rise"] > * { translate: 0 26px; }
.site-motion [data-stagger="pop"] > * { scale: .6; }
.site-motion [data-stagger="cell"] > * { scale: .2; transition-delay: calc(var(--d, 0ms) + var(--i, 0) * 22ms); }
.site-motion [data-stagger].is-in > * { opacity: 1; translate: 0 0; scale: 1; }

/* After the entrance, hover and idle motion respond at once. */
.site-motion .is-done, .site-motion .is-done > * { transition-delay: 0ms !important; }

/* ---------- Things that grow ---------- */
.site-motion [data-bars] > * {
    scale: 1 0;
    transform-origin: 50% 100%;
    transition: scale 1.1s var(--site-ease);
    transition-delay: calc(var(--d, 0ms) + var(--i, 0) * 80ms);
}
.site-motion [data-bars].is-in > * { scale: 1 1; }

.site-motion [data-fill] {
    scale: 0 1;
    transform-origin: 100% 50%;
    transition: scale 1.3s var(--site-ease) var(--d, 0ms);
}
.site-motion [data-fill].is-in { scale: 1 1; }

/* Module switches flip on one by one (an illustration, not controls). */
.site-motion [data-switch] { transition: background-color .35s ease var(--sw, 0ms); }
.site-motion [data-switch] > i { transition: translate .45s var(--site-spring) var(--sw, 0ms), background-color .35s ease var(--sw, 0ms); }
.site-motion [data-switch]:not(.is-in) { background-color: #2A3D36 !important; }
.site-motion [data-switch]:not(.is-in) > i { translate: 20px 0; background-color: #7FA79B !important; }

/* Success tick draws itself. */
.site-motion [data-check] path { stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .6s var(--site-ease) .35s; }
.site-motion [data-check].is-in path { stroke-dashoffset: 0; }

/* ---------- Idle motion (starts after the entrance) ---------- */
@keyframes site-float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -8px; } }
@keyframes site-wobble { 0%, 100% { rotate: 0deg; } 50% { rotate: -5deg; } }
@keyframes site-scan { 0%, 100% { translate: 0 -24px; } 50% { translate: 0 24px; } }
@keyframes site-nudge { 0%, 72%, 100% { translate: 0 0; } 82% { translate: -4px 0; } 92% { translate: 1px 0; } }

.site-motion [data-float].is-floating { animation: site-float 5s ease-in-out infinite; }
.site-motion [data-float="slow"].is-floating { animation-duration: 7s; }
.site-motion [data-wobble].is-floating { animation: site-wobble 6s ease-in-out infinite; }
.site-motion [data-scan].is-in { animation: site-scan 2.6s ease-in-out infinite; }
.site-motion [data-nudge] svg { animation: site-nudge 3.2s ease-in-out infinite; }
.site-motion .is-paused, .site-motion .is-paused * { animation-play-state: paused !important; }

/* ---------- Micro-interactions ---------- */
@media (prefers-reduced-motion: no-preference) {
    /* Pill buttons and links: lift on hover, press on click, the arrow leans forward (RTL: left). */
    a[style*="border-radius:999px"][style*="height:"],
    button[type="submit"] {
        transition: translate .25s var(--site-ease), box-shadow .25s var(--site-ease), scale .15s ease, filter .2s ease;
    }
    a[style*="border-radius:999px"][style*="height:"]:hover,
    button[type="submit"]:hover {
        translate: 0 -2px;
        box-shadow: 0 14px 28px -14px rgba(2, 31, 25, .55);
        filter: brightness(1.04);
    }
    a[style*="border-radius:999px"][style*="height:"]:active,
    button[type="submit"]:active { translate: 0 0; scale: .97; }
    a[style*="border-radius:999px"] svg,
    button[type="submit"] svg,
    [data-nudge]:hover svg { transition: translate .25s var(--site-ease); }
    a[style*="border-radius:999px"]:hover svg,
    button[type="submit"]:hover svg { translate: -4px 0; }

    /* App Store badge */
    a[href*="apps.apple.com"] img { transition: translate .25s var(--site-ease); }
    a[href*="apps.apple.com"]:hover img { translate: 0 -2px; }

    /* Feature cards lift a little. */
    [data-card] { transition: translate .4s var(--site-ease); }
    .site-motion [data-stagger].is-done > [data-card]:hover,
    html:not(.site-motion) [data-card]:hover { translate: 0 -6px; }

    /* Register switch (teacher / school) and chips */
    nav[aria-labelledby="join-as"] a { transition: background-color .2s ease, color .2s ease, box-shadow .2s ease; }
    nav[aria-labelledby="join-as"] a:not([aria-current]):hover { background-color: rgba(255, 255, 255, .55) !important; color: #111827 !important; }
    .site-chip span { transition: background-color .2s ease, border-color .2s ease, color .2s ease, scale .15s ease; }
    .site-chip:hover input:not(:checked) + span { border-color: #9CA3AF; }
    .site-chip:active span { scale: .95; }
    .site-chip input:checked + span { animation: site-chip-pop .3s var(--site-spring); }
    @keyframes site-chip-pop { 0% { scale: .92; } 100% { scale: 1; } }

    input[type="text"], input[type="tel"], select { transition: border-color .2s ease, box-shadow .2s ease; }
}

/* Header nav and footer links: an underline grows in. */
header nav a {
    background: linear-gradient(#22FFA0, #22FFA0) no-repeat 50% calc(100% - 6px) / 0 2px;
    transition: background-size .3s var(--site-ease);
}
header nav a:hover { background-size: calc(100% - 24px) 2px; }
footer a:hover { text-decoration: underline !important; text-underline-offset: 5px; text-decoration-thickness: 1.5px; }

input[type="text"]:focus, input[type="tel"]:focus, select:focus { border-color: #047857 !important; box-shadow: 0 0 0 4px rgba(4, 120, 87, .14); }

/* Sending: the submit button waits. */
button[type="submit"][aria-busy="true"] { cursor: progress; opacity: .85; }
button[type="submit"][aria-busy="true"] svg { display: none; }
button[type="submit"][aria-busy="true"]::after {
    content: ""; width: 18px; height: 18px; border-radius: 50%;
    border: 2.5px solid currentColor; border-inline-end-color: transparent;
    animation: site-spin .7s linear infinite;
}
@keyframes site-spin { to { rotate: 360deg; } }

@media print {
    .site-motion [data-reveal], .site-motion [data-stagger] > *, .site-motion [data-bars] > *, .site-motion [data-fill] {
        opacity: 1 !important; translate: none !important; scale: none !important;
    }
}
