/* Screen-to-screen motion, always on (the OS reduced-motion switch is deliberately ignored).
   Enter animations use fill-mode `backwards` so no transform stays applied after they end: a lingering
   transform would make the wrapper the containing block of position:fixed UI (mini player, sheets, toasts). */
:root { --ease-out: cubic-bezier(.2, .8, .2, 1); --ease-ios: cubic-bezier(.32, .72, 0, 1); --ease-spring: cubic-bezier(.34, 1.56, .64, 1); }

/* Clip (not hidden: no scroll container, sticky keeps working) the few px of sideways travel. */
.app-shell { overflow-x: clip; }

/* Fallback for browsers without View Transitions (js/route-transition.js sets html[data-vt] when supported).
   The direction comes from the view's own data-enter, set once at mount (app.js): an animation keyed off
   a document-level attribute restarts whenever that attribute changes, flashing the screen already shown.
   The old screen is gone at once (no snapshot to fade it out), so the new one never starts fully
   transparent: that would show a blank frame of background. */
html:not([data-vt]) .route-view { animation: route-enter 260ms var(--ease-out) backwards; }
html:not([data-vt]) .route-view[data-enter='push'] { animation: route-push-in 340ms var(--ease-ios) backwards; }
html:not([data-vt]) .route-view[data-enter='pop'] { animation: route-pop-in 340ms var(--ease-ios) backwards; }
html:not([data-vt]) .route-view[data-enter='tab'] { animation: route-tab-in 240ms var(--ease-out) backwards; }
@keyframes route-enter { from { opacity: 0; transform: translateY(10px); } }
@keyframes route-push-in { from { opacity: .4; transform: translateX(42%); box-shadow: -16px 0 32px -18px rgba(0, 0, 0, .35); } }
@keyframes route-pop-in { from { opacity: .4; transform: translateX(-30%); } }
@keyframes route-tab-in { from { opacity: .55; transform: translateY(10px); } }

/* View Transitions: iOS-style push / pop, tab crossfade with a small rise. */
html[data-vt] .bottom-nav { view-transition-name: bottom-nav; }
html[data-vt] .mini-player { view-transition-name: mini-player; }
/* Chrome stays put: show only the new copy, no crossfade ghosting. */
::view-transition-old(bottom-nav), ::view-transition-old(mini-player) { display: none; }
::view-transition-new(bottom-nav), ::view-transition-new(mini-player) { animation: none; }

::view-transition-old(root), ::view-transition-new(root) { animation-duration: 360ms; animation-timing-function: var(--ease-ios); animation-fill-mode: both; mix-blend-mode: normal; }

html[data-nav='push']::view-transition-new(root) { animation-name: vt-push-in; z-index: 2; }
html[data-nav='push']::view-transition-old(root) { animation-name: vt-push-under; z-index: 1; }
html[data-nav='pop']::view-transition-new(root) { animation-name: vt-pop-under; z-index: 1; }
html[data-nav='pop']::view-transition-old(root) { animation-name: vt-pop-out; z-index: 2; }
html[data-nav='tab']::view-transition-new(root) { animation-name: vt-tab-in; animation-duration: 340ms; z-index: 2; }
html[data-nav='tab']::view-transition-old(root) { animation-name: vt-tab-out; animation-duration: 200ms; animation-timing-function: ease-out; z-index: 1; }

@keyframes vt-push-in { from { transform: translateX(100%); box-shadow: -12px 0 24px -12px rgba(0, 0, 0, .35); } }
@keyframes vt-push-under { to { transform: translateX(-28%); filter: brightness(.86); } }
@keyframes vt-pop-under { from { transform: translateX(-28%); filter: brightness(.86); } }
@keyframes vt-pop-out { to { transform: translateX(100%); box-shadow: -12px 0 24px -12px rgba(0, 0, 0, .35); } }
@keyframes vt-tab-in { from { opacity: 0; transform: translateY(14px) scale(.985); } }
@keyframes vt-tab-out { to { opacity: 0; } }

.player-sheet { animation: sheet-up 240ms var(--ease-out) backwards; }
.player-sheet-backdrop { animation: fade-in 200ms ease-out backwards; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }

.profiles-overlay { animation: overlay-in 220ms var(--ease-out) backwards; }
@keyframes overlay-in { from { opacity: 0; transform: scale(.98); } }

/* Toasts toggle via [hidden], so the animation replays each time one appears. */
.status-toast, .reader-toast { animation: toast-in 200ms var(--ease-out) backwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

.profile-tile, .chip, .shelf-toggle { transition: transform 150ms var(--ease-out); }
.profile-tile:active, .chip:active, .shelf-toggle:active { transform: scale(.97); }

/* Pressed states: instant feedback under the finger (iOS needs the touchstart listener in app.js for
   :active to apply). Press is quick (90ms), release springs back. */
.rec .rec-art, .lib-now, .rrow .ringed, .bottom-nav a svg, .bottom-nav a .profile-avatar, .row, .icon-btn, .me-link, .btn {
  transition: transform 220ms var(--ease-spring), opacity 160ms ease-out, background-color 160ms ease-out;
}
.rec:active .rec-art { transform: scale(.94); transition-duration: 90ms; }
.lib-now:active { transform: scale(.985); transition-duration: 90ms; }
.rrow:active .ringed { transform: scale(.94); transition-duration: 90ms; }
.bottom-nav a:active svg, .bottom-nav a:active .profile-avatar { transform: scale(.86); transition-duration: 90ms; }
.row:active, .icon-btn:active, .me-link:active { opacity: .55; transition-duration: 60ms; }
.btn:active { transform: scale(.97); transition-duration: 90ms; }
