/* SpatialWeb prototype — single small stylesheet, no build step.
   The site ships a strict CSP (style-src 'self'), so all styling lives here. */

:root {
  --bg: #101014;
  --surface: #1a1a21;
  --surface-raised: #23232c;
  --text: #ece9e2;
  --text-dim: #a7a49c;
  --accent: #e4b34a;
  --accent-ink: #241a05;
  --focus: #7ecbff;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* Author display values (e.g. .button's inline-block) must never beat the
   hidden attribute. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

main {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
}

h1 { font-size: 1.9rem; line-height: 1.2; }
h2 { font-size: 1.2rem; margin-top: 2rem; }

a { color: var(--accent); }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip-link:focus { left: 0; }

.site-header {
  border-bottom: 1px solid var(--surface-raised);
  padding: 0.75rem 1.25rem;
}
.site-brand { margin: 0; font-weight: 700; letter-spacing: 0.04em; }
.site-brand a { color: var(--text); text-decoration: none; }

.lede { color: var(--text-dim); }

.stage-grid {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1.25rem;
}

.stage-card {
  background: var(--surface);
  border: 1px solid var(--surface-raised);
  border-radius: var(--radius);
  padding: 1rem;
}
.stage-card img {
  width: 100%;
  height: auto;
  border-radius: calc(var(--radius) - 4px);
}
.stage-card p { color: var(--text-dim); }

.button {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius);
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { filter: brightness(1.1); }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button--secondary {
  background: var(--surface-raised);
  color: var(--text);
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* The model element must keep a rendered box — Safari 27 defers loading a
   display:none model's src indefinitely. It serves as the inline preview;
   non-supporting browsers render the fallback <img> child instead. */
.stage-model {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  border: 1px solid var(--surface-raised);
}
.stage-model img {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
}

/* Debug probes: an explicit rendered box. */
.stage-model--visible {
  display: block;
  width: 100%;
  height: 20rem;
}

/* XR stage: WebGL canvas host; texture-source videos never display directly
   (unlike <model>, hidden <video> elements keep decoding just fine). */
.xr-canvas {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  border: 1px solid var(--surface-raised);
  overflow: hidden;
}
.xr-canvas canvas { display: block; width: 100%; height: 100%; }
/* Texture-source videos: keep them technically rendered — browsers throttle
   or pause display:none media, which freezes the GPU texture. */
.texture-video {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 2px;
  height: 2px;
  opacity: 0.01;
  pointer-events: none;
}

.stage-hero {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--surface-raised);
}

.controls {
  background: var(--surface);
  border: 1px solid var(--surface-raised);
  border-radius: var(--radius);
  padding: 1rem 1.25rem 1.25rem;
  margin-top: 1.5rem;
}
.controls h2 { margin-top: 0; }

.control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.control-row label { min-width: 7rem; color: var(--text-dim); }

select {
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid #34343f;
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  font: inherit;
  min-width: 12rem;
}

.status { min-height: 1.5rem; color: var(--accent); }

.debug-links {
  margin-top: 2.5rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px dashed #3a3a46;
  border-radius: var(--radius);
  color: var(--text-dim);
}
.debug-links h2 { margin-top: 0; font-size: 1rem; }
.debug-links code {
  background: var(--surface-raised);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-dim);
}
.check-label input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
}

.debug-log {
  background: #000;
  color: #9fdc9f;
  font: 0.75rem/1.5 ui-monospace, "SF Mono", Menlo, monospace;
  padding: 0.75rem;
  border-radius: 6px;
  max-height: 16rem;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
}

.note {
  background: var(--surface-raised);
  border-left: 4px solid var(--accent);
  padding: 0.6rem 0.9rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.preview-video {
  width: 100%;
  margin-top: 1.5rem;
  border-radius: var(--radius);
  background: #000;
}

/* While immersive, strip the page back to its controls. */
body.immersive .stage-hero,
body.immersive .explainer,
body.immersive .preview-video { display: none; }

.explainer { color: var(--text-dim); }
.explainer code {
  background: var(--surface-raised);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  color: var(--text);
}

.site-footer {
  border-top: 1px solid var(--surface-raised);
  color: var(--text-dim);
  padding: 1rem 1.25rem;
  max-width: 46rem;
  margin: 0 auto;
}

@media (prefers-reduced-motion: no-preference) {
  .button { transition: filter 120ms ease; }
}
