/* The ordinary route mask clips a window without resizing the page. */
:root { --transition-surface:#fff; }
html[data-theme="dark"] { --transition-surface:#08090a; }
.home-aperture {
  position:fixed;
  z-index:10020;
  inset:0;
  overflow:hidden;
  background:transparent;
  pointer-events:auto;
  touch-action:none;
}
.home-aperture > svg { display:block; width:100%; height:100%; }
html[data-page-transition-visit] .opening-portal { display:none!important; }
html[data-page-entering] { background:var(--transition-surface); scrollbar-color:var(--transition-surface) var(--transition-surface); }
html:has(body.page-departing) { scrollbar-color:var(--transition-surface) var(--transition-surface); }

/* Consultation joins the destination UI after the opening mask is removed.
   Keep its normal foreground priority once navigation has finished or cancelled. */
html:is([data-page-entry-gate],[data-page-entering],[data-home-return="pending"]) chingke-chat,
body.page-departing chingke-chat {
  opacity:0!important;
  visibility:hidden!important;
  pointer-events:none!important;
}

/* A menu-to-home return keeps one continuous scene. Neither ui-ready nor the
   startup fallback may reveal controls before its matching frame is ready. */
html[data-home-return] body :is(.stage-header,.case-rail,.stage-title-wrap,.stage-intro) {
  animation:none!important;
  transition:none!important;
}
html[data-home-return="pending"] body :is(.stage-header,.case-rail,.stage-title-wrap,.stage-intro) {
  opacity:0!important;
  visibility:hidden!important;
}
html[data-home-return="revealing"] body :is(.stage-header,.case-rail,.stage-title-wrap,.stage-intro) {
  visibility:visible;
}

/* Local reload/direct-entry scripts run in the head. Cover the first paint
   until body-start mount attaches the actual closed SVG aperture. */
html[data-page-entry-gate]::before {
  content:"";
  position:fixed;
  z-index:10021;
  inset:0;
  background:var(--transition-surface);
  pointer-events:auto;
}

/* Keep wheel, touch and keyboard scrolling without the visible scrollbar. */
html, body,
.site-menu :is(.menu-main,.menu-news),
.inner-menu-panel .inner-menu-scroll { scrollbar-width:none; }
html::-webkit-scrollbar,
body::-webkit-scrollbar,
.site-menu :is(.menu-main,.menu-news)::-webkit-scrollbar,
.inner-menu-panel .inner-menu-scroll::-webkit-scrollbar {
  display:none;
  width:0;
  height:0;
}

@media (prefers-reduced-motion:reduce) {
  .home-aperture,html[data-page-entry-gate]::before { display:none; }
}

/* Menu routes expand the visible window directly. The bitmap retains the
   source viewport dimensions while only its clipping rectangle changes. */
.menu-transfer {
  position:fixed;
  z-index:10020;
  inset:0;
  overflow:hidden;
  opacity:1;
  pointer-events:auto;
  touch-action:none;
}
.menu-transfer-backdrop { position:absolute; inset:0; }
.menu-transfer-media {
  position:absolute;
  top:0;
  left:0;
  overflow:hidden;
  will-change:clip-path;
}
.menu-transfer-media > :is(canvas,img) {
  display:block;
  width:100%;
  height:100%;
  object-fit:cover;
}

/* Keep the departing full-screen menu bitmap across native document replacement.
   The destination releases this bridge only after its own canvas has painted. */
@view-transition { navigation:auto; }
html[data-menu-native-bridge="hold"]::view-transition-group(root) {
  animation:none;
}
html[data-menu-native-bridge="hold"]::view-transition-image-pair(root) {
  isolation:isolate;
}
html[data-menu-native-bridge="hold"]::view-transition-old(root) {
  animation:chingke-menu-native-hold 6s linear both;
  opacity:1;
  mix-blend-mode:normal;
}
html[data-menu-native-bridge="hold"]::view-transition-new(root) {
  animation:none;
  opacity:0;
  mix-blend-mode:normal;
}
@keyframes chingke-menu-native-hold {
  from { opacity:1; }
  to { opacity:1; }
}
@media (prefers-reduced-motion:reduce) {
  @view-transition { navigation:none; }
}
