/* House of Embers: the 3D model frame (static/3d/voxel.js). Uses the site's tokens. The frame keeps its size before the canvas exists, so nothing
   moves when it appears; the poster (a still the build draws with the canvas's own camera, light and blocks, see core/voxelrender.py) is in the frame from
   the first paint, shows until the 3D is drawing, and stays where it cannot: no WebGL, a lost context. */

.vx {
  --vx-ratio: 4 / 5;
  position: relative; width: 100%; aspect-ratio: var(--vx-ratio); overflow: hidden; isolation: isolate;
  background: radial-gradient(ellipse 80% 62% at 50% 38%, #3b2517 0%, #231912 58%, #181210 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.vx-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity .6s ease;
  touch-action: pan-y; cursor: grab; -webkit-tap-highlight-color: transparent;
}
.vx.vx-on .vx-canvas { opacity: 1; }
.vx.vx-drag .vx-canvas { cursor: grabbing; }
.vx-canvas:focus-visible { outline: 2px solid var(--brand); outline-offset: -3px; border-radius: var(--radius); }

.vx-poster {
  position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%; pointer-events: none; transition: opacity .2s ease;
}
/* the poster is drawn at the canvas's own camera, so the two agree: the poster lets go only once the canvas has faded all the way in (no dip between) */
.vx.vx-on .vx-poster { opacity: 0; transition: opacity .1s linear .62s; }

/* the pit's wrapper is marked js-only (its readout needs JS), but the poster inside it is a plain picture: show it, with the readout still hidden */
html:not(.js) .vx-wrap.js-only { display: grid !important; grid-template-columns: minmax(0, 480px); }

.vx-tools { position: absolute; z-index: 2; right: 10px; bottom: 10px; display: none; gap: 8px; }
.vx.vx-on .vx-tools { display: flex; }
.vx-tools button {
  font: 600 13px/1 var(--sans); color: var(--text); background: rgba(31, 24, 20, .82); border: 1px solid var(--line); border-radius: 99px; padding: 8px 14px;
  cursor: pointer; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.vx-tools button:hover { border-color: var(--brand); }
.vx-tools button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.vx-hint {
  position: absolute; z-index: 2; left: 12px; bottom: 12px; margin: 0; display: none; color: var(--muted); font: 13px/1.2 var(--sans); pointer-events: none;
}
.vx.vx-on .vx-hint { display: block; }

.vx-note { position: absolute; z-index: 2; left: 12px; right: 12px; bottom: 12px; margin: 0; padding: 8px 12px; display: none; color: var(--text); font: 14px/1.4 var(--sans);
  background: rgba(21, 16, 13, .86); border: 1px solid var(--line); border-radius: 8px; }
.vx.vx-fail .vx-note { display: block; }
.vx.vx-fail .vx-hint, .vx.vx-fail .vx-tools { display: none; }
.vx:not(.vx-on):not(.vx-fail)::after {
  content: ""; position: absolute; z-index: 2; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--brand); animation: vx-spin 1s linear infinite;
}
html:not(.js) .vx:not(.vx-on)::after { display: none; }
@keyframes vx-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .vx-canvas, .vx-poster, .vx.vx-on .vx-poster { transition: none; }
  .vx:not(.vx-on):not(.vx-fail)::after { animation: none; border-color: var(--brand); }
}
@media (max-width: 480px) { .vx-hint { display: none !important; } }
