/* spoti-reverse.
 *
 * Helvetica Neue because the Centre Pompidou opened in 1977 signed in a
 * grotesque, and because the seven numbers being displayed are the residue of
 * an industrial measuring instrument. One family, carrying the whole thing on
 * weight contrast: ultra light for the figure you read across the room, medium
 * for the seven you read up close.
 *
 * Colour is the building's own service code — blue for air, green for water,
 * yellow for electricity, red for movement — used the way the building uses
 * it, to say what something does rather than to decorate it. Cold is far from
 * the corpus, hot is near, and the volt yellow is reserved for the threshold.
 */

:root {
  --void: #000;
  --rail: #131313;
  --tick: #5a5a5a;
  --structure: #7d7d7d;
  --dim: #3d3d3d;
  --volt: #ffc400;
  --trigger-red: #e0271b;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--void);
}

body {
  font-family: var(--sans);
  color: var(--structure);
  -webkit-font-smoothing: antialiased;
  cursor: default;
}

/* ---------------------------------------------------------------- stage */

#stage {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  padding: clamp(1rem, 3.2vh, 3rem) clamp(1rem, 4vw, 5rem);
  gap: clamp(0.75rem, 2vh, 2rem);
  isolation: isolate;
}

/* The continuous field: almost nothing when the live vector is far away,
   saturating as it closes. */
#stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(
    ellipse 90% 70% at 50% 34%,
    var(--wash, transparent),
    transparent 72%
  );
  transition: background 120ms linear;
}

#stage.is-silent #proximity,
#stage.is-silent #tracks {
  opacity: 0.42;
}

#proximity,
#tracks {
  transition: opacity 400ms ease;
}

/* ----------------------------------------------------------------- mode */

#mode {
  display: flex;
  gap: clamp(0.9rem, 2vw, 2rem);
  align-items: baseline;
}

#mode button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: clamp(11px, 0.95vw, 15px);
  letter-spacing: 0.09em;
  color: var(--dim);
  cursor: pointer;
  transition: color 180ms ease;
}

#mode button:hover {
  color: var(--structure);
}

#mode button.on {
  color: #e4e4e4;
}

#mode button:focus-visible {
  outline: 1px solid var(--structure);
  outline-offset: 4px;
}

/* ------------------------------------------------------------ proximity */

#proximity {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

#prox-value {
  font-size: min(31vh, 27vw);
  font-weight: 200;
  line-height: 0.82;
  letter-spacing: -0.055em;
  font-variant-numeric: tabular-nums;
  color: #2f6f9e;
  transition:
    color 120ms linear,
    text-shadow 220ms ease;
}

#stage.is-triggered #prox-value {
  text-shadow: 0 0 clamp(24px, 5vw, 110px) currentColor;
}

/* --------------------------------------------------------------- tracks */

#tracks {
  display: grid;
  gap: clamp(0.35rem, 1.1vh, 1.1rem);
}

.track {
  display: grid;
  grid-template-columns: minmax(5.5rem, 13vw) 1fr minmax(3.2rem, 5.5vw);
  align-items: center;
  gap: clamp(0.7rem, 1.8vw, 2.2rem);
}

.track-name {
  text-align: right;
  font-size: clamp(10px, 1.05vw, 18px);
  font-weight: 400;
  letter-spacing: 0.055em;
  color: var(--structure);
  white-space: nowrap;
}

.rail {
  position: relative;
  display: block;
  height: clamp(2px, 0.4vh, 6px);
  background: var(--rail);
}

/* The coloured span between the live value and the corpus target. Length is
   the error; it shrinks to nothing when the two meet. */
.gap {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  background: #1c4f7a;
}

/* The seven targets: a fixed constellation, drawn as tall thin ruler marks so
   they stay legible underneath the marker that is chasing them. */
.tick {
  position: absolute;
  top: -1.1em;
  bottom: -1.1em;
  width: 1px;
  background: var(--tick);
  transition: background 220ms ease;
}

/* The live value: short, solid, bright. The only thing on the rail that moves
   of its own accord. */
.marker {
  position: absolute;
  top: -0.45em;
  bottom: -0.45em;
  width: 3px;
  margin-left: -1.5px;
  background: #ededed;
}

#stage.is-triggered .tick {
  background: var(--volt);
}

.track-value {
  text-align: right;
  font-size: clamp(14px, 1.95vw, 36px);
  font-weight: 500;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
  color: #ededed;
}

/* --------------------------------------------------------------- notice */

#notice {
  margin: 0;
  text-align: center;
  font-size: clamp(11px, 0.95vw, 15px);
  letter-spacing: 0.06em;
  color: #5c5c5c;
  cursor: pointer;
  min-height: 1.4em;
}

body.dragging #notice {
  color: var(--volt);
}

/* ---------------------------------------------------------------- flash */

#flash {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--trigger-red);
  opacity: 0;
  pointer-events: none;
}

#flash.go {
  animation: flash 1400ms ease-out;
}

@keyframes flash {
  0% {
    opacity: 0.97;
  }
  35% {
    opacity: 0.97;
  }
  100% {
    opacity: 0;
  }
}

/* ---------------------------------------------------- calibration panel */

#calibration {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 60;
  width: min(500px, 96vw);
  height: 100%;
  overflow-y: auto;
  padding: 1rem 1.1rem 4rem;
  background: var(--void);
  border-left: 1px solid #222;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  color: #9a9a9a;
}

#calibration[hidden] {
  display: none;
}

.cal-head {
  position: sticky;
  top: -1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin: -1rem -1.1rem 0.9rem;
  padding: 0.85rem 1.1rem;
  background: var(--void);
  border-bottom: 1px solid #222;
  color: #e4e4e4;
  letter-spacing: 0.08em;
}

.cal-actions {
  display: flex;
  gap: 0.55rem;
}

.cal-head button,
.cal-import {
  border: 1px solid #2e2e2e;
  background: none;
  padding: 0.2rem 0.5rem;
  font: inherit;
  color: #9a9a9a;
  cursor: pointer;
}

.cal-head button:hover,
.cal-import:hover {
  color: #e4e4e4;
  border-color: #4a4a4a;
}

.cal-readout {
  margin: 0 0 1.2rem;
  padding: 0.7rem 0.8rem;
  background: #080808;
  border: 1px solid #1c1c1c;
  color: #b9b9b9;
  white-space: pre;
  overflow-x: auto;
}

.cal-group {
  margin-bottom: 1.1rem;
}

.cal-group h2 {
  margin: 0 0 0.35rem;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.12em;
  color: #e4e4e4;
  border-bottom: 1px solid #1c1c1c;
  padding-bottom: 0.25rem;
}

.cal-row {
  display: grid;
  grid-template-columns: 17ch 1fr 7ch;
  align-items: center;
  gap: 0.6rem;
  padding: 0.1rem 0;
}

.cal-key {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-row input[type="range"] {
  width: 100%;
  accent-color: var(--volt);
  height: 14px;
}

.cal-row output {
  text-align: right;
  color: #e4e4e4;
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 640px) {
  .track {
    grid-template-columns: 7.5rem 1fr 3rem;
  }

  #prox-value {
    font-size: min(26vh, 44vw);
  }
}

@media (prefers-reduced-motion: reduce) {
  #flash.go {
    animation: none;
  }

  #stage::before,
  #prox-value,
  .tick,
  #proximity,
  #tracks,
  #mode button {
    transition: none;
  }
}
