/* ===== MOTION — animations for the Aurora theme =====
   Section entrances, scroll reveals, aurora backdrop drift, menu stagger + sliding indicator, ripples,
   tilts, ticks and pops. Every entrance uses `backwards` fill so nothing keeps a transform afterwards
   (a lingering transform would trap fixed overlays). Everything turns off for reduced motion. */

@keyframes mo-rise { from { opacity: 0; transform: translateY(22px) scale(0.985); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes mo-up { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: none; } }
@keyframes mo-pop { 0% { opacity: 0; transform: scale(0.7) translateY(10px); } 60% { opacity: 1; transform: scale(1.04); } 100% { opacity: 1; transform: none; } }
@keyframes mo-slide { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }
@keyframes mo-drop { from { opacity: 0; transform: translateY(-26px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes mo-drawer { from { opacity: 0; transform: translateX(-30px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes mo-modal { from { opacity: 0; transform: translateY(26px) scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes mo-toast { from { opacity: 0; transform: translateY(-18px) scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes mo-swap { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes mo-tick { 0% { transform: none; } 30% { transform: scale(1.14) rotate(-3deg); } 100% { transform: none; } }
@keyframes mo-wiggle { 25% { transform: rotate(-12deg); } 50% { transform: rotate(9deg); } 75% { transform: rotate(-4deg); } }
@keyframes mo-bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -4px; } }
@keyframes mo-float { 0%, 100% { translate: 0 0; rotate: 0deg; } 50% { translate: 0 -3px; rotate: -3deg; } }
@keyframes mo-shine { from { background-position: 0% 50%; } to { background-position: 100% 50%; } }
@keyframes mo-ripple { to { transform: scale(1); opacity: 0; } }
@keyframes mo-drift-a { 0%, 100% { transform: translate3d(0, 0, 0) scale(1); } 25% { transform: translate3d(14vw, 9vh, 0) scale(1.15); } 50% { transform: translate3d(5vw, 24vh, 0) scale(0.9); } 75% { transform: translate3d(-5vw, 10vh, 0) scale(1.06); } }
@keyframes mo-drift-b { 0%, 100% { transform: translate3d(0, 0, 0) scale(1); } 33% { transform: translate3d(-16vw, -10vh, 0) scale(1.12); } 66% { transform: translate3d(-6vw, 14vh, 0) scale(0.92); } }
@keyframes mo-drift-c { 0%, 100% { transform: translate3d(0, 0, 0) scale(1); } 50% { transform: translate3d(18vw, -16vh, 0) scale(1.2); } }
@keyframes mo-stars { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-260px, -220px, 0); } }
@keyframes mo-twinkle { 0%, 100% { opacity: var(--star-lo, 0.25); } 50% { opacity: var(--star-hi, 0.6); } }
@keyframes mo-pulse-ring { 0% { box-shadow: 0 0 0 0 rgba(255, 79, 154, 0.45); } 70% { box-shadow: 0 0 0 9px rgba(255, 79, 154, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 79, 154, 0); } }

/* ---------- aurora backdrop ---------- */
.bg-orbs .orb.o1 { animation: mo-drift-a 28s ease-in-out infinite; }
.bg-orbs .orb.o2 { animation: mo-drift-b 34s ease-in-out infinite; }
.bg-orbs .orb.o3 { animation: mo-drift-c 40s ease-in-out infinite; }
.bg-orbs .orb.o4 { animation: mo-drift-b 46s ease-in-out infinite reverse; }
.bg-stars { inset: -220px; --star-lo: 0.18; --star-hi: 0.45; animation: mo-stars 160s linear infinite, mo-twinkle 7s ease-in-out infinite; will-change: transform, opacity; }
html[data-theme="dark"] .bg-stars { --star-lo: 0.35; --star-hi: 0.85; }

/* ---------- page + section entrances ---------- */
.view.enter, #albumBody.enter { animation: none; }
.view.enter > :not(dialog) { animation: mo-rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
.view.enter > :nth-child(2) { animation-delay: 0.07s; }
.view.enter > :nth-child(3) { animation-delay: 0.13s; }
.view.enter > :nth-child(4) { animation-delay: 0.19s; }
.view.enter > :nth-child(5) { animation-delay: 0.24s; }
.view.enter > :nth-child(n+6) { animation-delay: 0.28s; }
.view.enter .home-launch > * { animation: mo-pop 0.6s cubic-bezier(0.2, 0.9, 0.25, 1.3) backwards; }
.view.enter .home-launch > :nth-child(1) { animation-delay: 0.18s; } .view.enter .home-launch > :nth-child(2) { animation-delay: 0.23s; }
.view.enter .home-launch > :nth-child(3) { animation-delay: 0.28s; } .view.enter .home-launch > :nth-child(4) { animation-delay: 0.33s; }
.view.enter .home-launch > :nth-child(5) { animation-delay: 0.38s; } .view.enter .home-launch > :nth-child(6) { animation-delay: 0.43s; }
.view.enter .home-launch > :nth-child(7) { animation-delay: 0.48s; } .view.enter .home-launch > :nth-child(8) { animation-delay: 0.53s; }
.view.enter .today-facts > * { animation: mo-pop 0.55s cubic-bezier(0.2, 0.9, 0.25, 1.3) backwards; }
.view.enter .today-facts > :nth-child(1) { animation-delay: 0.3s; } .view.enter .today-facts > :nth-child(2) { animation-delay: 0.36s; }
.view.enter .today-facts > :nth-child(3) { animation-delay: 0.42s; } .view.enter .today-facts > :nth-child(4) { animation-delay: 0.48s; }
.view.enter .google-tiles > *, .view.enter .folder-grid > * { animation: mo-pop 0.5s cubic-bezier(0.2, 0.9, 0.25, 1.25) backwards; }
.view.enter :is(.google-tiles, .folder-grid) > :nth-child(2) { animation-delay: 0.04s; } .view.enter :is(.google-tiles, .folder-grid) > :nth-child(3) { animation-delay: 0.08s; }
.view.enter :is(.google-tiles, .folder-grid) > :nth-child(4) { animation-delay: 0.12s; } .view.enter :is(.google-tiles, .folder-grid) > :nth-child(5) { animation-delay: 0.16s; }
.view.enter :is(.google-tiles, .folder-grid) > :nth-child(n+6) { animation-delay: 0.2s; }
body.mo-boot > .nav { animation: mo-drop 0.7s cubic-bezier(0.2, 0.9, 0.25, 1.2) backwards; }
body.mo-boot > .site-menu:not([open]) { animation: mo-drawer 0.7s cubic-bezier(0.2, 0.9, 0.25, 1.1) backwards; }
body.mo-boot > .site-menu:not([open]) .site-menu-tabs > :not(.tab-indicator) { animation: mo-slide 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; animation-delay: calc(var(--i, 0) * 28ms + 0.15s); }

/* scroll reveal: motion.js hides things that start fully below the screen (.mo-rv) and, when they scroll in,
   drops the class and plays a Web Animations fade-up — so no CSS animation is swapped or replayed. */
.mo-rv { opacity: 0 !important; }

/* ambient loops rest when nobody has touched the page for a while, or the tab is hidden (saves the GPU) */
html.mo-idle :is(.bg-orbs .orb, .bg-stars, .home-tile-icon, .today-day, .site-menu-logo, .brand-dot) { animation-play-state: paused; }

/* ---------- menu ---------- */
.site-menu[open] { animation: mo-drawer 0.4s cubic-bezier(0.2, 0.9, 0.25, 1.05); }
.site-menu[open] .site-menu-tabs > :not(.tab-indicator) { animation: mo-slide 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; animation-delay: calc(var(--i, 0) * 22ms + 0.06s); }
.tab-indicator { transition: transform 0.55s cubic-bezier(0.2, 0.9, 0.25, 1.15), width 0.3s ease, height 0.3s ease, opacity 0.3s ease; }
.tab-indicator.no-anim { transition: none; }
.nav-current.mo-swap { animation: mo-swap 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
.site-menu-logo { animation: mo-float 6s ease-in-out infinite; }
.brand-dot { animation: mo-pulse-ring 2.4s ease-out infinite; }

/* ---------- controls ---------- */
mo-ripple { position: absolute; inset: 0; display: block; overflow: hidden; border-radius: inherit; pointer-events: none; z-index: 0; }
mo-ripple > b { position: absolute; display: block; border-radius: 50%; background: currentColor; opacity: 0.22; transform: scale(0); animation: mo-ripple 0.65s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
.btn:hover > .i, .tab:hover > .i, .google-btn:hover > .i, .chooser-tool:hover > .i { animation: mo-wiggle 0.55s ease; }
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.96); }
.home-tile, .google-tile, .folder-card { transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.25, 1.2), rotate 0.18s ease-out, box-shadow 0.3s ease, border-color 0.3s ease, background-color 0.2s ease; }
.home-launch, .google-tiles, .folder-grid { perspective: 1000px; }
.home-tile-icon { animation: mo-bob 4.2s ease-in-out infinite; }
.home-tile:nth-child(2n) .home-tile-icon { animation-delay: -1.4s; }
.home-tile:nth-child(3n) .home-tile-icon { animation-delay: -2.6s; }
.clock.mo-tick { animation: mo-tick 0.6s cubic-bezier(0.2, 0.9, 0.25, 1.4); }
.today-day { background-size: 220% 100%; animation: mo-shine 9s ease-in-out infinite alternate; }
.modal { animation: mo-modal 0.45s cubic-bezier(0.2, 0.9, 0.25, 1.3); }
.toast { animation: mo-toast 0.5s cubic-bezier(0.2, 0.9, 0.25, 1.35); }
.toast.out { animation: none; }
.mo-progress { position: fixed; left: 0; top: 0; z-index: 80; width: 100%; height: 3px; transform-origin: 0 50%; transform: scaleX(0); background: var(--grad-primary); pointer-events: none; box-shadow: 0 0 12px rgba(90, 80, 255, 0.6); }

@media (prefers-reduced-motion: reduce) {
  .bg-orbs .orb, .bg-stars, .view.enter > *, .view.enter .home-launch > *, .view.enter .today-facts > *, .view.enter .google-tiles > *, .view.enter .folder-grid > *,
  body.mo-boot > *, body.mo-boot .site-menu-tabs > *, .site-menu[open], .site-menu[open] .site-menu-tabs > *, .nav-current.mo-swap, .site-menu-logo, .brand-dot,
  .home-tile-icon, .clock.mo-tick, .today-day, .modal, .toast, .btn:hover > .i, .tab:hover > .i { animation: none !important; }
  .mo-rv { opacity: 1 !important; }
  .tab-indicator { transition: none; }
  .mo-progress { display: none; }
}
