/* GBSD Launch Facility — interactive model
   Palette: graphite-blue viewport, slate glass HUD, one amber accent for the action. */
:root {
  --bg-0: #0e1620;
  --bg-1: #1c2a3a;
  --ink: #e8edf2;
  --ink-2: #8a98a8;
  --glass: rgba(14, 22, 32, 0.62);
  --glass-line: rgba(232, 237, 242, 0.14);
  --amber: #f2b33d;
  --amber-ink: #1a1200;
  --font: "Helvetica Neue", "Segoe UI", Roboto, system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: radial-gradient(120% 90% at 50% 70%, var(--bg-1) 0%, var(--bg-0) 60%, #080d13 100%);
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

canvas#viewer, canvas#camerafeed {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
}
/* Must outrank the id rule above, and (hence !important) the inline `display: block` that XR Extras'
   FullWindowCanvas writes onto the camera canvas once AR has run — otherwise the hidden canvas still
   covers the page, showing its last camera frame over the 3D viewer and eating input. */
canvas#viewer[hidden], canvas#camerafeed[hidden] { display: none !important; }

/* ---------- Callout labels (detail view) ----------
   Real text at a fixed pixel size, positioned every frame by js/callouts.js. Touches pass through
   to the canvas.
   --callout-width is the most a label may span. It depends only on the screen (about what fits beside
   a centred missile), never on where the missile is, so a label's line breaks stay put as the view
   moves; a label that runs past the screen edge is simply cut off there. */
.labels {
  position: fixed; inset: 0; z-index: 3; overflow: hidden; pointer-events: none;
  --callout-width: clamp(112px, calc(50vw - 48px), 220px);
}
.labels[hidden] { display: none; }
.leaders { position: absolute; inset: 0; width: 100%; height: 100%; }
.leaders g { visibility: hidden; }
.leaders path { fill: none; stroke: rgba(232, 237, 242, 0.8); stroke-width: 1; }
.leaders path.halo { stroke: rgba(8, 13, 19, 0.5); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.leaders circle { fill: var(--ink); stroke: rgba(8, 13, 19, 0.5); stroke-width: 1; }
.callout {
  position: absolute; top: 0; left: 0; visibility: hidden;
  box-sizing: border-box; /* stated here: XR Extras injects `* { box-sizing: inherit }`, which undoes the global rule */
  display: flex; flex-direction: column; gap: 2px;
  max-width: var(--callout-width);
  margin: 0; padding: 5px 9px;
  font: inherit; color: inherit; text-align: left;
  background: rgba(14, 22, 32, 0.8);
  border: 1px solid var(--glass-line); border-radius: 8px;
  transform-origin: left center;
  pointer-events: auto; cursor: pointer; -webkit-appearance: none; appearance: none;
  transition: border-color 160ms ease, background-color 160ms ease;
}
.callout:hover { border-color: rgba(232, 237, 242, 0.36); }
.callout:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.callout.selected { border-color: var(--amber); background: rgba(38, 29, 9, 0.92); }
.callout.selected .callout-title { color: var(--amber); }
.leaders g.selected path:not(.halo) { stroke: var(--amber); }
.leaders g.selected circle { fill: var(--amber); }
.callout-left {
  left: auto; right: 0; text-align: right;
  transform-origin: right center;
}
.callout-title { font-size: 13px; font-weight: 600; line-height: 1.25; color: var(--ink); text-wrap: balance; }
/* Descriptions only where there is room beside the missile; phones show titles alone. */
.callout-body { display: none; font-size: 12.5px; line-height: 1.35; color: #b6c1cd; }
@media (min-width: 720px) and (min-height: 560px) {
  .labels { --callout-width: 290px; }
  .callout-body { display: block; }
}

/* ---------- Detail card ----------
   Where the labels have no room for descriptions, the selected stage's description shows here. */
.detail-card {
  box-sizing: border-box; width: min(100%, 420px);
  padding: 8px 8px 12px 14px;
  background: rgba(14, 22, 32, 0.88);
  border: 1px solid var(--glass-line); border-radius: 14px;
}
.detail-card[hidden] { display: none; }
.detail-head { display: flex; align-items: center; gap: 6px; min-height: 36px; }
.detail-head h2 {
  flex: 1; margin: 0; font-size: 15px; font-weight: 600; line-height: 1.25; color: var(--amber);
}
.detail-head h2.prompt { font-size: 14px; font-weight: 400; color: var(--ink-2); }
.detail-count { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.detail-step {
  flex: none; width: 36px; height: 36px; padding: 0 0 3px;
  font: inherit; font-size: 22px; line-height: 1; color: var(--ink); cursor: pointer;
  background: transparent; border: 1px solid var(--glass-line); border-radius: 50%;
  -webkit-appearance: none; appearance: none;
}
.detail-step:hover { background: rgba(232, 237, 242, 0.08); }
.detail-step:active { transform: scale(0.94); }
.detail-step:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.detail-card p {
  margin: 4px 6px 0 0; min-height: 2.8em; /* two lines, so the card holds its height between stages */
  font-size: 14px; line-height: 1.4; color: var(--ink);
}
.detail-card p[hidden] { display: none; }
@media (max-width: 719.98px), (max-height: 559.98px) {
  .detail-card:not([hidden]) + .hint.fade { display: none; } /* the card takes the idle hint's place; a live message still shows */
}
@media (min-width: 720px) and (min-height: 560px) {
  .detail-card { display: none; } /* descriptions sit beside the labels here */
}
/* Short and wide (a phone on its side): beside the action button instead of above it. */
@media (max-height: 559.98px) and (min-width: 600px) {
  .detail-card {
    position: fixed; left: calc(16px + env(safe-area-inset-left, 0px)); bottom: calc(14px + var(--safe-b));
    width: min(240px, calc(50vw - 170px)); /* stops short of the labels left of the missile */
  }
}

/* ---------- HUD ---------- */
.hud { position: fixed; z-index: 5; pointer-events: none; }
.hud > * { pointer-events: auto; }

.hud-top {
  top: calc(16px + var(--safe-t)); left: 20px; right: 20px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
}
.title { display: flex; flex-direction: column; gap: 2px; pointer-events: none; }
.title-client { font-size: 12px; color: var(--ink-2); letter-spacing: 0.01em; }
.title h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; }
.title-sub { font-size: 13px; color: var(--ink-2); }

.hud-bottom {
  left: 0; right: 0; bottom: calc(18px + var(--safe-b));
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 0 20px;
}
.hud-credits {
  right: 16px; bottom: calc(14px + var(--safe-b));
  display: flex; align-items: center; gap: 14px;
  opacity: 0.75;
}
.credit { color: var(--ink-2); font-size: 11px; text-decoration: none; }
.credit:hover { color: var(--ink); }
.poweredby img { display: block; opacity: 0.85; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; cursor: pointer; border: 0; border-radius: 999px;
  transition: transform 120ms ease, background-color 160ms ease, opacity 160ms ease;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

.btn-ghost {
  background: var(--glass); color: var(--ink);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  padding: 9px 14px; font-size: 13px; font-weight: 500;
}
.btn-ghost:hover { background: rgba(28, 42, 58, 0.85); }

.btn-action {
  min-width: 200px; padding: 15px 30px;
  background: var(--amber); color: var(--amber-ink);
  font-size: 16px; font-weight: 600; letter-spacing: 0.005em;
  box-shadow: 0 8px 28px rgba(242, 179, 61, 0.28);
}
.btn-action:hover:not(:disabled) { background: #f7c45c; }
.btn-action:disabled {
  cursor: default; opacity: 0.55; box-shadow: none; transform: none;
}

/* ---------- Sequence rail ---------- */
.rail {
  list-style: none; margin: 0; padding: 0;
  display: flex; gap: 22px;
  font-size: 12px; color: var(--ink-2);
}
.rail li { display: flex; align-items: center; gap: 7px; transition: color 200ms ease; }
.rail .dot {
  width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px solid var(--ink-2); transition: all 200ms ease;
}
.rail li.done { color: var(--ink); }
.rail li.done .dot { background: var(--ink); border-color: var(--ink); }
.rail li.current { color: var(--amber); }
.rail li.current .dot { background: var(--amber); border-color: var(--amber); box-shadow: 0 0 0 4px rgba(242, 179, 61, 0.2); }

.hint {
  margin: 0; font-size: 13px; color: var(--ink-2); text-align: center;
  min-height: 1.3em; transition: opacity 400ms ease;
  text-shadow: 0 0 6px rgba(8, 13, 19, 0.95), 0 1px 2px rgba(8, 13, 19, 0.9); /* it can sit over terrain, or the camera feed in AR */
}
.hint.fade { opacity: 0; }
.hint.alert { color: var(--ink); }

/* ---------- AR reticle hint ---------- */
.reticle-hint {
  position: fixed; inset: 0; z-index: 4; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
.reticle-hint[hidden] { display: none; }
.reticle-hint p {
  margin: 0; font-size: 14px; color: var(--ink);
  background: var(--glass); border: 1px solid var(--glass-line);
  padding: 8px 14px; border-radius: 999px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.reticle-ring {
  width: 64px; height: 64px; border-radius: 50%;
  border: 2px solid var(--amber);
  box-shadow: 0 0 0 6px rgba(242, 179, 61, 0.15);
  animation: breathe 1.6s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: scale(1.08); box-shadow: 0 0 0 10px rgba(242, 179, 61, 0.08); } }

/* ---------- Loader ---------- */
.loader {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg-0);
  transition: opacity 500ms ease;
}
.loader.out { opacity: 0; pointer-events: none; }
.loader-bar { width: 180px; height: 3px; background: rgba(232,237,242,0.12); border-radius: 2px; overflow: hidden; }
.loader-bar span { display: block; height: 100%; width: 0; background: var(--amber); transition: width 200ms ease; }
.loader p { margin: 0; font-size: 13px; color: var(--ink-2); }

/* ---------- QR dialog (desktop) ---------- */
.qr-dialog {
  border: 1px solid var(--glass-line); border-radius: 16px; padding: 0;
  background: #121d29; color: var(--ink); max-width: 360px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.qr-dialog::backdrop { background: rgba(8, 13, 19, 0.7); }
.qr-dialog form { padding: 26px 26px 22px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.qr-dialog h2 { margin: 0; font-size: 18px; font-weight: 600; }
.qr-dialog p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.qr { background: #fff; padding: 12px; border-radius: 10px; }
.qr img, .qr svg { display: block; width: 200px; height: 200px; }
.qr-url { font-size: 11px; word-break: break-all; }

/* ---------- 8th Wall loading / error screens restyled to match ---------- */
#loadBackground { background: var(--bg-0) !important; }
#loadImageContainer { display: none !important; }
#requestingCameraPermissions { background: var(--bg-0) !important; color: var(--ink) !important; font-family: var(--font) !important; }
#requestingCameraIcon { filter: invert(1) !important; }
.prompt-box-8w { background: #121d29 !important; color: var(--ink) !important; font-family: var(--font) !important; border-radius: 14px !important; }
.prompt-button-8w { background: var(--amber) !important; color: var(--amber-ink) !important; border-radius: 999px !important; }
.button-primary-8w { background: var(--amber) !important; color: var(--amber-ink) !important; }
#runtimeErrorContainer { font-family: var(--font) !important; }

/* ---------- Responsive / accessibility ---------- */
@media (max-width: 480px) {
  .title h1 { font-size: 17px; }
  .title-sub { display: none; }
  .hud-credits { display: none; }
  .btn-action { min-width: 180px; padding: 14px 26px; font-size: 15px; }
  .rail { gap: 16px; }
  .callout { padding: 4px 7px; }
}
@media (prefers-reduced-motion: reduce) {
  .reticle-ring { animation: none; }
  .btn, .loader, .hint { transition: none; }
}
