/* v15.10 FIXED STAGE ENGINE — mechanics only.
   OWNERSHIP CONTRACT:
   - This file may style only .sz-stage-* primitives and stage state on html/body.
   - It may never contain Home/Gallery/About/Library/Official selectors.
   - Page composition belongs to the page owner CSS. */
.sz-stage-viewport,
.sz-stage-scroll-track,
.sz-stage-canvas{display:contents}

html.sz-stage-active,
html.sz-stage-active body.sz-stage-page{
  width:100%;min-height:100%;height:auto;margin:0;padding:0;
  overflow-x:hidden;overflow-y:auto;
  background:var(--sz-stage-bg,#07040f)
}

html.sz-stage-active body.sz-stage-page > *:not(.sz-stage-viewport):not(dialog):not(script){display:none}

html.sz-stage-active .sz-stage-viewport{
  display:block;position:relative;width:100%;
  height:var(--sz-stage-height,100vh);min-height:var(--sz-stage-height,100vh);
  margin:0;padding:0;overflow:visible;
  background:var(--sz-stage-bg,#07040f)
}

html.sz-stage-active .sz-stage-canvas{
  display:block;position:absolute;left:0;top:0;
  width:var(--sz-stage-width);height:var(--sz-stage-design-height);
  margin:0;padding:0;overflow:hidden;
  transform-origin:0 0;will-change:transform;
  background:var(--sz-stage-bg,#07040f)
}

html.sz-stage-active:not(.sz-stage-portrait) .sz-stage-viewport{
  height:var(--sz-stage-height);min-height:var(--sz-stage-height);overflow:visible
}

html.sz-stage-active:not(.sz-stage-portrait),
html.sz-stage-active:not(.sz-stage-portrait) body.sz-stage-page{
  height:auto;min-height:100%;overflow-x:hidden;overflow-y:auto;
  -webkit-overflow-scrolling:touch
}

html.sz-stage-portrait,
html.sz-stage-portrait body.sz-stage-page{
  width:100%;height:100%;min-height:100%;overflow:hidden
}

html.sz-stage-portrait .sz-stage-viewport{
  position:fixed;left:0;top:0;
  width:var(--sz-stage-shell-w);height:var(--sz-stage-shell-h);
  min-width:var(--sz-stage-shell-w);min-height:var(--sz-stage-shell-h);
  overflow-x:hidden;overflow-y:auto;-webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
  transform:translateX(var(--sz-stage-shift-x)) rotate(90deg);
  transform-origin:top left;z-index:2147482000
}

html.sz-stage-portrait .sz-stage-viewport::after{
  content:"";display:block;width:1px;height:var(--sz-stage-height);pointer-events:none
}

/* Optional portrait contain mode. The engine enables this only for a stage
   that explicitly opts in with data-stage-portrait-fit="contain". */
html.sz-stage-portrait.sz-stage-contained .sz-stage-viewport{
  overflow:hidden;
  overscroll-behavior:none;
}

html.sz-stage-portrait.sz-stage-contained .sz-stage-viewport::after{
  display:none;
}


/* =========================================================
   PORTRAIT WIDTH-SCROLL MODE
   The viewport is the native physical-X scroller.
   The scroll-track owns geometry.
   The rotated canvas is absolute INSIDE that track.
   ========================================================= */

html.sz-stage-portrait.sz-stage-width-scroll,
html.sz-stage-portrait.sz-stage-width-scroll body.sz-stage-page{
  width:100%;
  height:100%;
  min-height:100%;
  overflow:hidden;
}

html.sz-stage-portrait.sz-stage-width-scroll .sz-stage-viewport{
  position:fixed;
  left:0;
  top:0;

  display:block;
  width:var(--sz-stage-physical-w);
  height:var(--sz-stage-physical-h);
  min-width:var(--sz-stage-physical-w);
  min-height:var(--sz-stage-physical-h);

  transform:none;
  transform-origin:initial;

  overflow-x:auto;
  overflow-y:hidden;

  -webkit-overflow-scrolling:touch;
  touch-action:pan-x pinch-zoom;
  overscroll-behavior-x:contain;

  z-index:2147482000;
}

/* Disable the generic portrait spacer. The track is the only scroll geometry. */
html.sz-stage-portrait.sz-stage-width-scroll .sz-stage-viewport::after{
  display:none;
}

html.sz-stage-portrait.sz-stage-width-scroll .sz-stage-scroll-track{
  display:block;
  position:relative;

  width:var(--sz-stage-track-width);
  height:var(--sz-stage-physical-h);
  min-width:var(--sz-stage-track-width);
  min-height:var(--sz-stage-physical-h);

  margin:0;
  padding:0;
  overflow:visible;
}

html.sz-stage-portrait.sz-stage-width-scroll .sz-stage-canvas{
  position:absolute;
  left:0;
  top:0;

  margin:0;
  padding:0;

  transform-origin:0 0;
  will-change:transform;
}
