/* PRIME Z SPACE // one real screen per panel, portrait + landscape r2.
   Portrait / landscape values arrive from PrimeZSpaceMap. PrimeSpatialField
   is the ONLY world transform authority. No media/video transforms here. */

/* Physical chassis and its descendants share a single parent coordinate system.
   Outer bezel is Z=0 and already drawn by original site skins/materials. */
html[data-prime-spatial-system-enabled="true"][data-prime-spatial-enabled="true"]
body.prime-v2 #main[data-app-shell]>.app-window [data-prime-z-screen="true"]{
 transform-style:preserve-3d!important;
 backface-visibility:visible!important;
}

/* Physical display recession uses the real, existing four-wall slab. The
   thickness is 6px portrait and 7.5px landscape at balanced scale.
   There is no second backing canvas or cloned glass pane. */
html[data-prime-spatial-system-enabled="true"][data-prime-spatial-enabled="true"]
body.prime-v2 #main[data-app-shell]>.app-window:not(#portfolio)
[data-prime-z-screen="true"][data-prime-spatial-slab="true"]{
 --prime-slab-depth:clamp(3px,calc(var(--prime-z-space-display,-18px) * -.35),7px);
}

/* PANEL DIORAMAS r8: all eligible screen descendants receive their OWN
   recess, calculated once per route by PrimeZSpaceMap. Local Z stacks
   recursively behind existing bezel Z=0. Native XY flow and page scroll
   remain untouched; Field-owned nodes continue using ONE canonical pose. */
html[data-prime-spatial-system-enabled="true"][data-prime-spatial-enabled="true"]
body.prime-v2 #main[data-app-shell]>.app-window:not(#top)
[data-prime-z-screen="true"] [data-prime-z-screen-content]:not([data-prime-spatial-field-child="true"]){
  translate:var(--prime-z2-safe-x,0px) var(--prime-z2-safe-y,0px)
    calc(var(--prime-panel-local-z,-1.5px) * var(--prime-panel-depth-gain,1) * var(--prime-spatial-morph-progress,1))!important;
  transform-style:preserve-3d!important;
  backface-visibility:visible!important;
}
/* PRIME Z2 PHYSICAL CONTENT FIT r32.
   Only a real native, independent DIRECT child can opt into the measured
   inward gutter. Its authored layout dimensions and tap semantics stay real.
   No clip/mask/contain/overflow is placed on the 3D parent or button. */
html[data-prime-spatial-system-enabled="true"][data-prime-spatial-enabled="true"]
body.prime-v2 #main[data-app-shell]>.app-window:not(#top):not(#portfolio)
[data-prime-z-screen="true"] > [data-prime-z2-content-fit="inside"]:not([data-prime-spatial-field-child="true"]){
  scale:var(--prime-z2-fit-scale,1)!important;
  transform-origin:50% 50%!important;
  transform-style:preserve-3d!important;
}
/* A nested screen is a new aperture, recessed inside the preceding screen.
   Its OWN children begin a fresh cascade backward from that new face. */
html[data-prime-spatial-system-enabled="true"][data-prime-spatial-enabled="true"]
body.prime-v2 #main[data-app-shell]>.app-window:not(#top)
[data-prime-z-screen="true"][data-prime-z-screen-level="nested"]:not([data-prime-spatial-field-child="true"]){
  translate:0px 0px calc(var(--prime-z-space-nested,-5px) * var(--prime-spatial-morph-progress,1))!important;
  transform-style:preserve-3d!important;
}
/* Original artwork on Page04 is a single rigid source, never sliced apart
   by a text/content-layout pass. Neighboring gallery chrome may cascade. */
html[data-prime-spatial-enabled="true"]
body.prime-v2 #portfolio .page04-work [data-prime-z-screen-content]{
  translate:none!important;
}
/* Preserve the screen surface as Z=0. No appearance change in 2D mode. */
html[data-prime-spatial-enabled="false"] body.prime-v2
[data-prime-z-screen-content]{--prime-panel-depth-gain:0}
/* Media pixels (including motion video beneath the panel) and page 04 art
   remain at their own real original DOM geometry. This stylesheet never
   adds a backdrop or another glass layer over them. */
html[data-prime-spatial-enabled="false"] body.prime-v2
[data-prime-z-screen="true"]{
 --prime-z-space-nested:0px;
 --prime-z-space-scenery:0px;
 --prime-z-space-accent:0px;
 --prime-z-space-structure:0px;
 --prime-z-space-type:0px;
 --prime-z-space-controls:0px;
}

/* PAGE 07 SCROLL COMPOSITOR SAFETY r1: native scroll containers remain
   untouched, while contained items still keep a modest recessed Z cascade.
   There is no scroll-position-driven element update. */
html[data-prime-performance-mode="light"][data-prime-spatial-enabled="true"],
html[data-prime-resource-tier="low"][data-prime-spatial-enabled="true"]{
  --prime-panel-depth-gain:1;
}
html[data-prime-spatial-enabled="true"] body.prime-v2
#sprite :is([data-prime-local-scroll],[data-prime-native-scroll-host],
.page07-native-scroll-host)[data-prime-z-screen-content]{
  translate:none!important;
  will-change:auto!important;
}


/* PANEL-ONLY WORLD POSE r13.
   Static page scaffolds keep authored XY. Never neutralize a Field descendant
   INSIDE an enrolled machine screen, or its inherited world Z is destroyed.
   Actual panel interiors are tier 5-15; Page 04 owns its separate rigid art. */
html[data-prime-spatial-system-enabled="true"][data-prime-spatial-enabled="true"]
body.prime-v2 #main[data-app-shell]>.app-window:not(#top):not(#portfolio)
[data-prime-spatial-field-child="true"]:not([data-prime-z-screen="true"]):not([data-prime-z-screen="true"] *){
  translate:none!important;
  rotate:none!important;
  transform:none!important;
  will-change:auto!important;
}
html[data-prime-spatial-system-enabled="true"][data-prime-spatial-enabled="true"]
body.prime-v2 #main[data-app-shell]>.app-window:not(#top):not(#portfolio)
[data-prime-z-screen="true"][data-prime-spatial-field-child="true"]{
  translate:
    clamp(-3px,var(--prime-spatial-field-x,0px),3px)
    clamp(-3px,var(--prime-spatial-field-y,0px),3px)
    clamp(-10px,var(--prime-spatial-field-z,0px),8px)!important;
  rotate:none!important;
  transform:rotateX(clamp(-4deg,var(--prime-spatial-field-pitch,0deg),4deg))
    rotateY(clamp(-4deg,var(--prime-spatial-field-yaw-y,0deg),4deg))!important;
  transform-style:preserve-3d!important;
  transform-origin:50% 50%!important;
  backface-visibility:visible!important;
}
/* Static page layout retains its original 2D transforms. This is achieved
   by declining Field enrollment, not by flattening a screen's ancestors. */
/* Keep high-fidelity glass over media, but don't allocate a permanently
   promoted compositing layer for every descendant. */
html[data-prime-spatial-system-enabled="true"][data-prime-spatial-enabled="true"]
body.prime-v2 #main[data-app-shell]>.app-window
[data-prime-z-screen-content]:not([data-prime-spatial-field-child="true"]){
  will-change:auto!important;
}

/* PRIME CLICKABLE BUTTONS BEHIND GLASS r30.
   Original native controls occupy screen-local Z -2 through -5, behind the
   transparent, pointer-inert optical glass. Their own XY click rectangles,
   listeners and keyboard semantics remain untouched. No proxy or overlay. */
html[data-prime-spatial-system-enabled="true"][data-prime-spatial-enabled="true"]
body.prime-v2 #main[data-app-shell]>.app-window:not(#top)
[data-prime-z-screen="true"]
:is(button,a[href],summary,input,textarea,select,[role="button"],[role="tab"],[role="switch"],[role="menuitem"],[role="combobox"])[data-prime-z-screen-content="controls"]:not([data-prime-spatial-field-child="true"]){
  pointer-events:auto!important;
  z-index:60!important;
}
/* The local solver and Field-owned controls share the same 2/3/4/5px
   rearward staircase. Their hardware glass never accepts pointer events.
   No global click capture, z-index takeover, parent mask or XY move. */
html[data-prime-spatial-system-enabled="true"][data-prime-spatial-enabled="true"]
body.prime-v2 #main[data-app-shell]>.app-window:not(#top):not(#portfolio)
[data-prime-z-screen="true"]
:is(button,a[href],summary,input,textarea,select,[role="button"],[role="tab"],[role="switch"],[role="menuitem"],[role="combobox"])[data-prime-z-screen-content="controls"][data-prime-spatial-field-child="true"]{
  translate:var(--prime-spatial-field-x,0px) var(--prime-spatial-field-y,0px) calc(var(--prime-spatial-field-z,0px) - 2px - var(--prime-panel-button-z-boost,0px))!important;
  z-index:60!important;
  pointer-events:auto!important;
}

/* Expanded Services popovers are native TOP LAYER views rather than
   recessed Z2 screens. The normal in-grid chamber fit cannot shrink
   their large readability-first typography once the card opens. */
html[data-prime-spatial-system-enabled="true"][data-prime-spatial-enabled="true"]
body.prime-v2 #main[data-app-shell]>#intro
.service-card:popover-open > [data-prime-z2-content-fit="inside"]{
  scale:1!important;
}

/* SMART CHILD Z2 // Layout writes absolute child depth, Field only owns
   the shared parent camera. Crisp type relief adds no duplicate texture,
   filter isolation, or new animated compositing layer. */
html[data-prime-spatial-system-enabled="true"][data-prime-spatial-enabled="true"]
body.prime-v2 #main[data-app-shell]>.app-window.is-prime-viewport-active:not(#top):not(#portfolio)
[data-prime-z-screen="true"]:not(.pc-book-cover)
:is(h1,h2,h3,h4,h5,h6,[role="heading"])[data-prime-smart-child-z2="foreground-type"]{
  text-shadow:0 1px 0 rgba(0,7,16,.66),0 0 11px color-mix(in srgb,currentColor 15%,transparent);
  transform-style:preserve-3d!important;
}
html[data-prime-spatial-system-enabled="true"][data-prime-spatial-enabled="true"]
body.prime-v2 #main[data-app-shell]>.app-window.is-prime-viewport-active:not(#top):not(#portfolio)
[data-prime-z-screen="true"]:not(.pc-book-cover)
[data-prime-smart-child-z2="type"]{
  text-shadow:0 1px 0 rgba(0,8,16,.35);
}
