/* IXIR — 3D brand sculpture container.
 * Default state shows the fallback image with a CSS ember glow.
 * ixir-3d.js adds .is-live once a WebGL frame is on screen, which swaps to the canvas.
 *
 * Sizing knobs (set on .scene3d or any ancestor):
 *   --scene3d-size      inline size of the box            (default 100%)
 *   --scene3d-ratio     aspect ratio of the box           (default 16 / 9)
 *   --scene3d-opacity   overall opacity, for backgrounds  (default 1)
 *   --scene3d-fallback  width of the fallback image       (default 56%)
 * Modifiers: .scene3d--square, .scene3d--tall, .scene3d--fill (absolute, fills a
 * positioned parent), .scene3d--bg (sits behind content; parent needs isolation:isolate).
 */
.scene3d {
  position: relative;
  display: block;
  inline-size: var(--scene3d-size, 100%);
  max-inline-size: 100%;
  aspect-ratio: var(--scene3d-ratio, 16 / 9);
  opacity: var(--scene3d-opacity, 1);
  pointer-events: none;
  user-select: none;
  overflow: visible;
}

.scene3d--square { --scene3d-ratio: 1 / 1; }
.scene3d--tall { --scene3d-ratio: 4 / 5; }

.scene3d--fill {
  position: absolute;
  inset: 0;
  inline-size: auto;
  aspect-ratio: auto;
}

.scene3d--bg { z-index: -1; }

.scene3d > canvas {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  display: block;
  opacity: 0;
  transition: opacity 600ms cubic-bezier(.16, 1, .3, 1);
}

.scene3d__fallback {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  inline-size: var(--scene3d-fallback, 56%);
  max-block-size: 70%;
  block-size: auto;
  object-fit: contain;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 24px rgba(245, 69, 10, .45)) drop-shadow(0 0 90px rgba(245, 69, 10, .35));
  opacity: .92;
  transition: opacity 400ms cubic-bezier(.16, 1, .3, 1);
}

[dir="rtl"] .scene3d__fallback { transform: translate(50%, -50%); }

/* The fallback artwork is the white logo file: darken it on the light theme. */
[data-theme="light"] .scene3d__fallback {
  filter: invert(1) hue-rotate(180deg) drop-shadow(0 0 28px rgba(245, 69, 10, .35));
}

.scene3d.is-live > canvas { opacity: 1; }
.scene3d.is-live > .scene3d__fallback { opacity: 0; visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  .scene3d > canvas,
  .scene3d__fallback { transition: none; }
}

@media print {
  .scene3d > canvas { display: none; }
  .scene3d > .scene3d__fallback { opacity: 1; visibility: visible; filter: none; }
}
