/* The 3D viewer. Styles only .splat-viewer and what's inside it, plus the standalone page. */

.splat-viewer {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 80vh;
  overflow: hidden;
  background: #0f0f12;
  color: #f2f2f2;
  outline: none;
}

.splat-viewer:focus-visible {
  box-shadow: inset 0 0 0 2px #7aa7ff;
}

.splat-viewer-canvas {
  display: block;
  width: 100%;
  height: 100%;
  /* The viewer handles every touch itself, so a drag or a pinch never scrolls or zooms the page. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.splat-viewer-status,
.splat-viewer-hint {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  margin: 0;
  font: 0.9rem/1.3 system-ui, sans-serif;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

.splat-viewer-status {
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
}

.splat-viewer-hint {
  bottom: 0.75rem;
  opacity: 0.85;
}

/* The loading screen, over the canvas until the splat is on screen. */
.splat-viewer-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: #0f0f12;
  font: 0.9rem/1.3 system-ui, sans-serif;
}

.splat-viewer-loading p {
  margin: 0;
}

.splat-viewer-loading-detail {
  min-height: 1.3em;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.splat-viewer-bar {
  position: relative;
  width: min(18rem, 70%);
  height: 0.35rem;
  border-radius: 0.2rem;
  background: #2a2a31;
  overflow: hidden;
}

.splat-viewer-bar-fill {
  width: 0;
  height: 100%;
  background: #7aa7ff;
  transition: width 0.2s linear;
}

/* No Content-Length, so no percentage: a strip slides along instead. */
.splat-viewer-bar.is-waiting .splat-viewer-bar-fill {
  width: 30%;
  animation: splat-viewer-waiting 1.2s ease-in-out infinite alternate;
}

@keyframes splat-viewer-waiting {
  from { transform: translateX(-10%); }
  to { transform: translateX(243%); }
}

/* The logo, top left. Three taps turn haunted mode on and off. */
.splat-viewer-logo,
.splat-viewer-play {
  position: absolute;
  z-index: 4;
  width: auto;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  border: 0;
  color: inherit;
  font: 600 0.85rem/1 system-ui, sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.splat-viewer-logo {
  top: 0.6rem;
  left: 0.6rem;
  padding: 0.4rem 0.5rem;
  background: none;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 2px #000;
  opacity: 0.8;
}

.splat-viewer-play {
  right: 0.75rem;
  bottom: 0.75rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: rgba(20, 20, 26, 0.75);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.splat-viewer-play[aria-pressed="true"] {
  background: rgba(122, 167, 255, 0.85);
  color: #0f0f12;
}

.splat-viewer-logo:focus-visible,
.splat-viewer-play:focus-visible {
  outline: 2px solid #7aa7ff;
  outline-offset: 2px;
}

.splat-viewer-hint {
  right: 7.5rem;
}

.splat-viewer-toast {
  position: absolute;
  z-index: 4;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.35rem 0.7rem;
  border-radius: 0.3rem;
  background: rgba(20, 20, 26, 0.8);
  font: 0.85rem/1.3 system-ui, sans-serif;
  white-space: nowrap;
  pointer-events: none;
}

@media (max-width: 30rem) {
  .splat-viewer-toast {
    top: 3.75rem;
    width: max-content;
    max-width: calc(100% - 1.5rem);
    text-align: center;
    white-space: normal;
  }
}

/* Haunted mode: the room dims, cold at the edges, and a faint ghost walks the path. */
.splat-viewer-canvas {
  transition: filter 1.2s ease;
}

.splat-viewer.is-haunted .splat-viewer-canvas {
  filter: brightness(0.45) saturate(0.55);
}

.splat-viewer-veil {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: radial-gradient(ellipse at center, rgba(20, 10, 40, 0) 35%, rgba(8, 4, 24, 0.75) 100%);
  opacity: 0;
  transition: opacity 1.2s ease;
  pointer-events: none;
}

.splat-viewer.is-haunted .splat-viewer-veil {
  opacity: 1;
}

.splat-viewer-ghost {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  width: 100px;
  height: 100px;
  transform-origin: 0 0;
  filter: blur(0.6px) drop-shadow(0 0 6px rgba(200, 225, 255, 0.9));
  pointer-events: none;
}

.splat-viewer-ghost svg {
  display: block;
  width: 100%;
  height: 100%;
}

.splat-viewer-ghost-body {
  fill: #eef4ff;
}

.splat-viewer-ghost-eye {
  fill: #141428;
}

.splat-viewer-status,
.splat-viewer-hint {
  z-index: 4;
}

.splat-viewer [hidden] {
  display: none;
}

/* The standalone page, index.html: the viewer fills the window. */
html:has(.splat-viewer-page),
.splat-viewer-page {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0f0f12;
}

.splat-viewer-page .splat-viewer {
  position: fixed;
  inset: 0;
  aspect-ratio: auto;
  max-height: none;
  height: 100%;
}
