/* Each solid slab carries old and new page pixels on its two physical faces. */
.theme-flip,
.theme-flip-light {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  pointer-events: none;
  user-select: none;
}
.theme-flip { background: #111; overflow: clip; transform-style: preserve-3d; }
/* The empty slots retain the palette of the mode the tiles are turning away from. */
.theme-flip[data-direction="dark"] { background: #eee; }
.theme-flip-tile {
  position: absolute;
  transform-style: preserve-3d;
  transform-origin: center;
  will-change: transform;
}
.theme-flip-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  visibility: visible;
}
.theme-flip-light { z-index: 10001; }
.theme-flip-shadow {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  background: radial-gradient(ellipse, #000 25%, #0009 56%, #0000 72%);
  will-change: transform, opacity;
}
.theme-flip-shadow[data-illumination="bounce"] {
  background: radial-gradient(ellipse, #fff 15%, #fff9 42%, #fff0 72%);
}
.theme-flip-edge { position: absolute; backface-visibility: hidden; }
.theme-flip-edges { position: absolute; inset: 0; transform-style: preserve-3d; }
/* The opaque surface already carries both palettes. Keeping the whole document
   inside an inversion filter would flatten/rasterize its 3D animation each frame. */
html[data-theme-flip="turning"] { filter: none !important; }
html[data-color-mode="light"]:not([data-theme-flip="turning"]) .theme-flip,
html[data-color-mode="light"]:not([data-theme-flip="turning"]) .theme-flip-light { filter: invert(1); }
html[data-theme-flip] body * { animation-play-state: paused !important; }
@media (prefers-reduced-motion: reduce) {
  .theme-flip, .theme-flip-light { display: none; }
}
