/* xr.css — the /xr WebXR diorama, and nothing else.
 *
 * This file is deliberately standalone. It does not @import site.css and
 * site.css does not know it exists, so nothing here can affect the home page.
 * The tokens below are *copied* from site.css rather than shared, for the same
 * reason. If the design language changes, both files change.
 *
 * Everything visible here is an HTML overlay sitting on top of A-Frame's
 * canvas. In immersive mode the same words are redrawn as in-scene canvas
 * panels, because a headset viewer cannot see HTML. The fallback panel at the
 * bottom covers the case where no canvas ever starts.
 */

/* ── Fonts ──
   Same woff2 files the home page uses, declared locally so /xr owns its own
   CSS. font-display: swap means a 404 here costs nothing but a fallback face. */
@font-face {
  font-family: 'Pirata One';
  src: url('../assets/fonts/pirata-one-latin-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../assets/fonts/inter-latin-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../assets/fonts/inter-latin-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* ── Tokens ── */
:root {
  --color-bg:         #0d0b09;
  --color-surface:    rgba(13, 11, 9, 0.82);
  --color-text:       #f0ede8;
  --color-text-muted: rgba(255, 255, 255, 0.58);
  --color-text-faint: rgba(255, 255, 255, 0.32);
  --color-accent:     #c8a96e;
  --color-warn:       #e2a03f;
  --border:           rgba(255, 255, 255, 0.10);

  --font-display: 'Pirata One', 'Papyrus', fantasy;
  --font-ui:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;

  --pad: clamp(12px, 2.4vw, 22px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  overscroll-behavior: none;
}

a { color: var(--color-accent); }
:focus-visible { outline: 2px solid #ffffff; outline-offset: 3px; }

.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 400;
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 12px 16px;
  border-radius: 4px;
  background: var(--color-text);
  color: var(--color-bg);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 16px; }

/* ── Overlay scaffold ──
   pointer-events: none on the layer, re-enabled per interactive control, so
   dragging anywhere that is not a button orbits the camera. */
.hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}
/* The top block must never grow enough to push the control bar off-screen —
   which is exactly what a stack of asset-failure banners would otherwise do. */
.hud > :first-child { min-height: 0; overflow: hidden; }
.hud-bottom { margin-top: auto; }
.hud button,
.hud input,
.hud a,
.hud [data-interactive] { pointer-events: auto; }

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: var(--pad);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: min(56ch, 62vw);
}
.brand a {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  opacity: 0.85;
}
.brand a:hover { opacity: 1; text-decoration: underline; }
.brand h1 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4.4vw, 2.4rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0.01em;
}
.brand p {
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--color-text-muted);
  text-wrap: pretty;
}
.brand code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--color-accent);
}

.chip {
  flex: none;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--color-surface);
  backdrop-filter: blur(6px);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.chip[data-tone="live"]  { color: var(--color-accent); border-color: rgba(200, 169, 110, 0.45); }
.chip[data-tone="warn"]  { color: var(--color-warn);   border-color: rgba(226, 160, 63, 0.45); }

/* ── Banners (asset failures, degraded modes) ── */
.banners {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 var(--pad);
}
.banner {
  max-width: 62ch;
  padding: 10px 14px;
  border: 1px solid rgba(226, 160, 63, 0.42);
  border-left-width: 3px;
  border-radius: 4px;
  background: var(--color-surface);
  backdrop-filter: blur(6px);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--color-text);
  text-wrap: pretty;
}
.banner strong { color: var(--color-warn); font-weight: 600; }
.banner code { font-family: var(--font-mono); font-size: 0.92em; word-break: break-all; }

/* ── The flip banner. This is the moment the project is about, so it gets the
      only large type on the page.

      It sits above the caption rather than dead centre: centre is exactly where
      the beam, the shockwave, and the two contending agents are, and covering
      the thing the banner is announcing defeats the point. ── */
.flip-banner {
  position: fixed;
  left: 50%;
  bottom: clamp(148px, 21vh, 205px);
  z-index: 20;
  transform: translate(-50%, 8px) scale(0.96);
  padding: 14px clamp(18px, 5vw, 38px);
  border: 1px solid rgba(200, 169, 110, 0.55);
  border-radius: 6px;
  background: rgba(13, 11, 9, 0.88);
  backdrop-filter: blur(8px);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 18px 60px rgba(0, 0, 0, 0.6);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
}
.flip-banner[data-on="1"] { opacity: 1; transform: translate(-50%, 0) scale(1); }
.flip-banner .flip-kicker {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-accent);
}
.flip-banner .flip-body {
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 5.2vw, 2.4rem);
  line-height: 1.1;
}
.flip-banner .flip-body .from { color: var(--color-text-faint); }
.flip-banner .flip-body .arrow { color: var(--color-accent); padding: 0 0.18em; }
.flip-banner .flip-foot {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--color-text-muted);
}

/* ── Bottom control bar ── */
.hud-bottom { padding: var(--pad); }

.caption {
  min-height: 1.4em;
  margin: 0 auto 10px;
  max-width: 68ch;
  text-align: center;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--color-text);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.9);
  text-wrap: balance;
}
.hud[data-flip="1"] .caption { opacity: 0; }
.caption { transition: opacity 160ms ease; }
.caption .caption-who {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--color-accent);
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 900px;
  margin: 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--color-surface);
  backdrop-filter: blur(10px);
}

.btn {
  flex: none;
  min-width: 92px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(200, 169, 110, 0.5);
  border-radius: 5px;
  background: transparent;
  color: var(--color-accent);
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}
.btn:hover:not(:disabled) { background: var(--color-accent); color: var(--color-bg); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.scrub-wrap { flex: 1 1 auto; min-width: 0; }

.beat-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}
.beat-label .beat-name { color: var(--color-text); text-transform: uppercase; }

input[type="range"].scrub {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 20px;
  background: transparent;
  cursor: pointer;
}
input[type="range"].scrub::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.16);
}
input[type="range"].scrub::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.16);
}
input[type="range"].scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5px;
  border: none;
  border-radius: 50%;
  background: var(--color-accent);
}
input[type="range"].scrub::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: var(--color-accent);
}

/* Flip markers under the scrubber — the two decision.changed moments, at their
   true frames. Positioned inline by the script from leaderFlips. */
.ticks {
  position: relative;
  height: 12px;
  margin-top: 1px;
}
.tick {
  position: absolute;
  top: 0;
  width: 1px;
  height: 6px;
  background: var(--color-accent);
  transform: translateX(-0.5px);
}
.tick::after {
  content: attr(data-label);
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: var(--color-text-faint);
}

.hint {
  margin-top: 8px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.05em;
  color: var(--color-text-faint);
}

/* ── Fallback panel: shown when the 3D scene cannot start at all ──
      Never a blank canvas. This says what failed, in words. ── */
.fallback {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-content: center;
  padding: var(--pad);
  background: var(--color-bg);
  overflow-y: auto;
}
.fallback[data-on="1"] { display: grid; }
.fallback-inner { max-width: 60ch; margin: auto; }
.fallback h2 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  font-weight: 400;
  margin-bottom: 12px;
}
.fallback p { font-size: 0.9375rem; line-height: 1.65; margin-bottom: 12px; color: var(--color-text-muted); text-wrap: pretty; }
.fallback p strong { color: var(--color-text); font-weight: 600; }
.fallback code { font-family: var(--font-mono); font-size: 0.9em; color: var(--color-accent); word-break: break-all; }
.fallback ul { margin: 0 0 16px 1.1em; }
.fallback li { font-size: 0.9375rem; line-height: 1.65; color: var(--color-text-muted); margin-bottom: 6px; }

/* ── A-Frame chrome ── */
a-scene { position: fixed; inset: 0; }
.a-enter-vr-button { background-color: rgba(200, 169, 110, 0.9) !important; }

/* Small screens: the control bar stacks so nothing overlaps at 375px. */
@media (max-width: 560px) {
  .brand p { display: none; }
  .controls { flex-direction: column; align-items: stretch; gap: 10px; }
  .btn { width: 100%; }
  .hint { display: none; }
}

@media (max-height: 620px) {
  .flip-banner { bottom: auto; top: 14%; transform: translate(-50%, 0) scale(0.96); }
  .flip-banner[data-on="1"] { transform: translate(-50%, 0) scale(1); }
}

@media (max-height: 460px) {
  .brand h1 { font-size: 1.2rem; }
  .brand p { display: none; }
  .caption { display: none; }
}

/* Respect the user's motion setting for the overlay chrome too. */
@media (prefers-reduced-motion: reduce) {
  .flip-banner { transition: none; }
  .caption { transition: none; }
  .btn { transition: none; }
}

/* ── Embed mode ──
   Used only when this page is loaded as /xr?embed=1, i.e. inside the
   front-page hero iframe. /xr visited directly (no query param) is
   completely unaffected by this section — body never gets the
   "is-embed" class, so none of these rules match.

   The HUD, skip-link, and VR button are all wrong or redundant inside a
   homepage hero: there is no back-link to follow, no scrubber to drag, no
   headset button to press from a passive marketing page. Hiding them also
   removes every focusable element from the embedded document, which is
   what lets the parent give the iframe tabindex="-1" without stranding
   keyboard focus inside it. */
body.is-embed .hud,
body.is-embed .skip-link {
  display: none;
}
body.is-embed .a-enter-vr-button {
  display: none !important;
}

/* The flip banner is the one piece of HUD that survives: "decision.changed
   — skate -> surf" is the narrative payoff of the 12 seconds and it is
   transient, not persistent chrome. Its default bottom-centre anchor would
   collide with the hero's bottom-left headline/CTA on narrow viewports, so
   pin it to the top instead. Horizontal centring (translate(-50%, 0)) is
   left intact so the [data-on="1"] scale transition above still applies. */
body.is-embed .flip-banner {
  bottom: auto;
  top: 10%;
}
