/* nav-motion.css — the motion for nav-motion.js. One curve and one
   duration everywhere, so every screen change feels like the same app.
   Right-to-left: deeper screens arrive from the left edge. */

:root { --mj-nav-ease: cubic-bezier(0.32, 0.72, 0, 1); --mj-nav-time: 420ms; }
/* The home artwork's own main colour: what shows for the frame before the
   picture is decoded must match it, or a page switch blinks. */
:root, html[data-appearance="light"] { --mj-art-home-colour: #0164a5; }
html[data-appearance="dark"] { --mj-art-home-colour: #032333; }

/* Behind a moving screen: the app's own blue, never a dark flash. */
html[data-mj-nav]::view-transition { background: #084260; }

html[data-mj-nav]::view-transition-group(*),
html[data-mj-nav]::view-transition-old(*),
html[data-mj-nav]::view-transition-new(*) {
  animation-duration: var(--mj-nav-time);
  animation-timing-function: var(--mj-nav-ease);
}

/* Screens over the shared background (Home ⇄ the game library, the joining
   steps): the background stays put and the screens slide whole, edge to
   edge, so two screens never overlap or show through each other (founder,
   21 Nov 2026: "finicky, flashy and weird"). Nothing else flies across. */
html[data-mj-nav-still] :is(.join-sheet, .wait-sheet) { view-transition-name: mj-page; }
html[data-mj-nav-still][data-mj-surface="host"] #main-menu:not(.hidden) { view-transition-name: mj-home; }
html[data-mj-nav-still][data-mj-surface="host"] #app { view-transition-name: mj-app; }
html[data-mj-nav-still]::view-transition { background: transparent; }
html[data-mj-nav-still][data-mj-nav="push"]::view-transition-new(*) { animation-name: mj-nav-in-from-left; }
html[data-mj-nav-still][data-mj-nav="push"]::view-transition-old(*) { animation-name: mj-nav-out-to-right; }
html[data-mj-nav-still][data-mj-nav="pop"]::view-transition-new(*) { animation-name: mj-nav-in-from-right; }
html[data-mj-nav-still][data-mj-nav="pop"]::view-transition-old(*) { animation-name: mj-nav-out-to-left; }
html[data-mj-nav-still]::view-transition-old(root),
html[data-mj-nav-still]::view-transition-new(root) { animation: none; }

/* Full pages with their own backdrop (settings, store, a game's page):
   push slides the new page in from the left over the old one, which eases
   right; pop is the reverse. No dimming. */
html[data-mj-nav="push"]:not([data-mj-nav-still])::view-transition-new(root) { animation-name: mj-nav-in-from-left; }
html[data-mj-nav="push"]:not([data-mj-nav-still])::view-transition-old(root) { animation-name: mj-nav-drift-right; }
html[data-mj-nav="pop"]:not([data-mj-nav-still])::view-transition-old(root) { animation-name: mj-nav-out-to-left; z-index: 2; }
html[data-mj-nav="pop"]:not([data-mj-nav-still])::view-transition-new(root) { animation-name: mj-nav-return-from-right; }

/* fade: arriving somewhere (the room), not going deeper. */
html[data-mj-nav="fade"]::view-transition-old(*) { animation: mj-nav-fade-out 260ms ease-out both; }
html[data-mj-nav="fade"]::view-transition-new(*) { animation: mj-nav-settle-in 420ms var(--mj-nav-ease) both; }

@keyframes mj-nav-in-from-left { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes mj-nav-in-from-right { from { transform: translateX(100%); } to { transform: none; } }
@keyframes mj-nav-out-to-left { to { transform: translateX(-100%); } }
@keyframes mj-nav-out-to-right { to { transform: translateX(100%); } }
@keyframes mj-nav-drift-right { to { transform: translateX(30%); } }
@keyframes mj-nav-return-from-right { from { transform: translateX(30%); } to { transform: none; } }
@keyframes mj-nav-fade-out { to { opacity: 0; } }
@keyframes mj-nav-settle-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }

/* The phone host's Home and library share one background, painted by the
   page itself, so only their content moves between them. */
html.mobile-shell[data-mj-surface="host"]:not([data-shell-screen="play"]) body {
  background: var(--mj-art-home-colour) var(--mj-art-home) center / cover no-repeat !important;
}
html.mobile-shell[data-mj-surface="host"]:not([data-shell-screen="play"]) #main-menu { background: transparent !important; }

/* The phone app's first screen and joining steps sit on the same artwork as
   the host's Home and library, so moving between the two pages never
   changes the background (founder, 21 Nov 2026: "flashy"). */
@media (orientation: portrait) and (max-width: 599px) {
  html.native[data-mj-surface="player"],
  html.native[data-mj-surface="host"] { background-color: var(--mj-art-home-colour) !important; }
  html.native[data-mj-surface="player"] body:has(.join-wrap),
  html.native[data-mj-surface="player"] .join-wrap {
    background: var(--mj-art-home-colour) var(--mj-art-home) center / cover no-repeat !important;
  }
}

/* Page to page on a phone (player.html ⇄ host.html): where supported, the
   browser keeps the old page up until the next is ready and slides both as
   one View Transition (nav-motion.js opts each switch in or out). */
@media (orientation: portrait) and (max-width: 599px) {
  @view-transition { navigation: auto; }
}
html.mj-nav-xpage .join-logo { view-transition-name: mj-p-logo; }
html.mj-nav-xpage #player-settings-btn { view-transition-name: mj-p-gear; }
html:is(.mj-nav-xpage, .mj-nav-arrived) #boot-loader { display: none !important; }

/* A back swipe shows the screen it goes back to, following the finger
   (mj-gestures.js). */
html.mj-peek-home #main-menu { display: flex !important; opacity: 1 !important; transition: none !important; visibility: visible !important; }

/* A screen that arrived inside a transition already moved; its own
   entrance animation would play a second time inside the snapshot. */
.mj-nav-opened, .mj-nav-opened .join-step,
.mj-nav-opened.join-step { animation: none !important; }
.mj-nav-opened { transition: none !important; }

/* Page to page: the next page holds its content until it slides in, and the
   loading screen never shows between two screens of the same app. */
html.mj-nav-enter :is(#main-menu, #app, #player-settings-btn, #gear-btn) { opacity: 0 !important; }
/* The very first paint of the next page (before its loading screen is even
   parsed) is the page background: make it the same picture, not navy. On
   the phone that dark frame flashed on every switch (founder, 21 Nov 2026). */
html.mj-nav-enter, html.mj-nav-enter body {
  background: var(--mj-art-home-colour) var(--mj-art-home, none) center / cover no-repeat !important;
}
html.mj-nav-enter #boot-loader {
  background: var(--mj-art-home-colour) var(--mj-art-home, none) center / cover no-repeat !important;
  transition: none !important;
}
html.mj-nav-enter #boot-loader > * { visibility: hidden !important; }
html.mj-nav-leaving body { pointer-events: none; }
/* What shows behind the screen sliding away is the app's own background,
   the same one the next page starts on. */
html.mj-nav-leaving, html.mj-nav-leaving body {
  background: var(--mj-art-home-colour) var(--mj-art-home, none) center / cover no-repeat !important;
}
html.mj-open-library #main-menu { visibility: hidden !important; }

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

/* The phone app is the host's screen during a room; becoming a player from
   it would leave the room without its host. Host/Player is chosen on the
   first screen instead (founder, 21 Nov 2026). */
html.native-iphone #host-player-switch { display: none !important; }

/* Dragging a page back (mj-gestures.js): the screen under it shows through. */
dialog.mj-edge-dragging::backdrop { background: rgba(2, 11, 18, 0.25) !important; }
