@import url("https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;1,6..72,400&family=Mulish:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap");

/* Palette lifted from the probe page so this reads as the same site. The
   canvas supplies its own sky, so the chrome is paper laid over it. */
:root {
  color-scheme: light;
  --ink: #f7f5f1;
  --panel: #f0ebe1;
  --rule: rgba(31, 27, 36, 0.1);
  --ash: #8c8593;
  --mist: #6b6373;
  --signal: #1f1b24;
  --brass: #b8763a;
  --brass-light: #e6b673;
  --font-serif: Newsreader, "Iowan Old Style", Georgia, serif;
  --font-sans: Mulish, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-family: var(--font-sans);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  color: var(--signal);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#stage {
  position: fixed;
  inset: 0;
}

#view {
  display: block;
  width: 100%;
  height: 100%;
  /* Without this the browser claims one-finger drags for scrolling and
     two-finger gestures for page zoom, and the viewer never sees them. */
  touch-action: none;
  /* Sky-ish, so the first paint before the model arrives is not a black hole. */
  background: linear-gradient(#9db9dd, #dfe6ec);
}

/* Panels floating over the canvas share one recipe. */
#titlecard,
#hud,
#help,
#credits,
#loading,
#failed {
  position: absolute;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(31, 27, 36, 0.16);
}

#titlecard {
  top: clamp(0.75rem, 2vw, 1.5rem);
  left: clamp(0.75rem, 2vw, 1.5rem);
  max-width: min(24rem, calc(100vw - 1.5rem));
  padding: 0.85rem 1.1rem;
}

#titlecard h1 {
  margin: 0;
  font: 500 clamp(1.15rem, 3.2vw, 1.5rem)/1.15 var(--font-serif);
  letter-spacing: -0.01em;
}

#titlecard p {
  margin: 0.3rem 0 0;
  color: var(--mist);
  font-size: 0.78rem;
}

.model-picker {
  margin-top: 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--mist);
}

.model-picker label {
  font-weight: 500;
  white-space: nowrap;
}

.model-picker select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%236b6373' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E") no-repeat right 0.6rem center;
  background-size: 8px 5px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.28rem 1.6rem 0.28rem 0.6rem;
  font: 600 0.74rem/1 var(--font-sans);
  color: var(--signal);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.model-picker select:hover {
  border-color: var(--brass);
}

.model-picker select:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 1px;
}

#hud {
  left: clamp(0.75rem, 2vw, 1.5rem);
  bottom: clamp(0.75rem, 2vw, 1.5rem);
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem 0.6rem 0.5rem 0.5rem;
}

/* The inactive modes' lines stay legible but recede. Keyed off the mode the
   viewer publishes as data-mode, not off paragraph position — position stopped
   working the moment there were three modes rather than two. */
#help p { transition: opacity 0.25s ease; opacity: 0.45; }
body[data-mode="orbit"] #help .for-orbit,
body[data-mode="walk"] #help .for-walk,
body[data-mode="fly"] #help .for-fly { opacity: 1; }

#help-toggle {
  width: 1.9rem;
  padding: 0 !important;
  font-weight: 700;
}

#hud button {
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  background: linear-gradient(135deg, var(--brass), var(--brass-light));
  color: var(--signal);
  font: 600 0.78rem/1 var(--font-sans);
  cursor: pointer;
  transition: box-shadow 0.25s ease;
}

#hud button:hover { box-shadow: 0 0 0 3px rgba(184, 118, 58, 0.22); }
#hud button:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

#readout {
  color: var(--mist);
  font: 400 0.72rem/1 var(--font-mono);
  white-space: nowrap;
}

#help {
  right: clamp(0.75rem, 2vw, 1.5rem);
  bottom: clamp(0.75rem, 2vw, 1.5rem);
  max-width: min(21rem, calc(100vw - 1.5rem));
  padding: 0.7rem 0.95rem;
  color: var(--mist);
  font-size: 0.74rem;
}

#help p { margin: 0.25rem 0; }
#help b { color: var(--signal); font-weight: 600; }

#help kbd {
  display: inline-block;
  min-width: 1.15rem;
  margin: 0 0.05rem;
  padding: 0.05rem 0.28rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--panel);
  color: var(--signal);
  font: 500 0.68rem/1.4 var(--font-mono);
  text-align: center;
}

/* Attribution, top-right. OSM's ODbL and the Poly Pizza CC-BY models want
   credit on the produced work, so the summary carries the OSM line itself and
   only the detail is a click away. Below 48rem the summary collapses to
   "credits" so it cannot collide with the titlecard — OSM's guidelines allow
   one-click attribution where screen space is constrained. */
#credits {
  top: clamp(0.75rem, 2vw, 1.5rem);
  right: clamp(0.75rem, 2vw, 1.5rem);
  z-index: 2;
  max-width: min(23rem, calc(100vw - 1.5rem));
  overflow: hidden;
  color: var(--mist);
  font-size: 0.72rem;
}

#credits summary {
  padding: 0.45rem 0.7rem;
  list-style: none;
  white-space: nowrap;
  cursor: pointer;
}

#credits summary::-webkit-details-marker { display: none; }
#credits summary:hover { color: var(--signal); }
#credits summary:focus-visible { outline: 2px solid var(--signal); outline-offset: -2px; }
#credits[open] summary { border-bottom: 1px solid var(--rule); }

#credits div { padding: 0.6rem 0.85rem 0.7rem; }
#credits p { margin: 0.35rem 0; }
#credits p:first-child { margin-top: 0; }
#credits p:last-child { margin-bottom: 0; }
#credits b { color: var(--signal); font-weight: 600; }
#credits a { color: var(--brass); }

@media (max-width: 48rem) {
  #credits summary .osm { display: none; }
  #titlecard { max-width: calc(100vw - 7rem); }
}

/* Centred overlays: loading and the failure card. */
#loading,
#failed {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(22rem, calc(100vw - 2rem));
  padding: 1.2rem 1.3rem;
  text-align: center;
}

#loading .bar {
  height: 3px;
  margin-bottom: 0.85rem;
  border-radius: 999px;
  background: var(--rule);
  overflow: hidden;
}

#bar-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brass), var(--brass-light));
  transition: width 0.2s ease;
}

#loading p,
#failed p { margin: 0; font-size: 0.85rem; }
#failed h1 { margin: 0 0 0.4rem; font: 500 1.1rem/1.2 var(--font-serif); }
#failed-why { font-family: var(--font-mono); font-size: 0.72rem; word-break: break-word; }

.hint {
  margin-top: 0.35rem !important;
  color: var(--ash);
  font-size: 0.72rem !important;
}

/* The on-screen movement stick, positioned at the thumb by the viewer. */
#stick {
  position: absolute;
  width: 104px;
  height: 104px;
  margin: -52px 0 0 -52px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 55%, transparent);
  backdrop-filter: blur(6px);
  pointer-events: none;
}

#stick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brass), var(--brass-light));
  box-shadow: 0 2px 8px rgba(31, 27, 36, 0.3);
}

/* Pointer lock hides the cursor; the help panel would just be in the way.
   Keyed to the lock itself and not to the mode: touch has no pointer lock, and
   phones now open straight into fly, where dimming would fade the very
   instructions that mode exists to make discoverable. */
body.locked #help,
body.locked #credits,
body.locked #titlecard { opacity: 0.25; }
body.locked #titlecard { transition: opacity 0.3s ease; }

/* The help panel used to be display:none below this width, which meant a
   phone — the one device whose gestures are not self-evident — was the only
   device shown no instructions at all. Walking was still discoverable because
   the stick draws itself under the thumb; orbit had no affordance whatsoever.
   It now sits above the HUD instead, compact. */
@media (max-width: 34rem) {
  #titlecard .site-location { display: none; }
  #help {
    right: clamp(0.75rem, 2vw, 1.5rem);
    left: clamp(0.75rem, 2vw, 1.5rem);
    bottom: 4.4rem;
    max-width: none;
    padding: 0.6rem 0.8rem;
    font-size: 0.72rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  #bar-fill, #hud button, #titlecard { transition: none; }
}

.language-picker { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; color: var(--mist); font-size: 0.72rem; }
.language-picker select { min-width: 0; max-width: 100%; color: var(--signal); background: var(--panel); border: 1px solid var(--rule); border-radius: 6px; padding: 5px; font: inherit; cursor: pointer; }
.language-picker select:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
