/* Tokens. Themes override the colour and font variables; layout scales from 1920×1080. */
:root {
  --bg: #141414;
  --surface: #1e1e1e;
  --fg: #e0e0e0;
  --muted: #9a9a9a;
  --accent: #b0b0b0;
  --accent-2: #b0b0b0;
  --font-sans: system-ui, sans-serif;
  --font-mono: ui-monospace, monospace;
  --scene: none;

  --gutter: clamp(16px, 2.2vw, 72px);
  --fs-label: clamp(11px, 0.68vw, 20px);
  --fs-body: clamp(14px, 0.83vw, 24px);
  --fs-goal: clamp(20px, 1.4vw, 44px);
  --fade: 900ms;
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);

  color-scheme: dark;
}

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

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font: var(--fs-body) / 1.5 var(--font-sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }

/* Waiting for something (loading.js sets data-loading on <body> and --progress): a progress bar
   near the bottom of the page. While it is a scene that is being built, the still picture
   behind goes out of focus. */
body[data-loading="scene"] .scene { filter: blur(14px) brightness(0.8); transform: scale(1.04); }
.loading {
  position: fixed;
  left: 50%;
  bottom: 26vh;
  z-index: 6;
  display: grid;
  gap: 0.9em;
  justify-items: center;
  width: min(22em, 60vw);
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s var(--ease);
}
body[data-loading] .loading { opacity: 1; }
.loading .label { text-shadow: 0 1px 10px color-mix(in srgb, var(--bg) 80%, transparent); white-space: nowrap; }
.loading-bar { width: 100%; height: 1px; background: color-mix(in srgb, var(--fg) 30%, transparent); }
.loading-bar i { display: block; width: var(--progress, 0%); height: 3px; margin-top: -1px; background: var(--accent); transition: width 0.25s linear; }
/* A wait for something that freezes the page arrives all at once (loading.js). */
body[data-sudden] .scene, body[data-sudden] .loading { transition: none; }

/* asocial.fps(): the frame-rate read-out. */
.fps {
  position: fixed;
  left: var(--gutter);
  top: calc(var(--gutter) + 3.4em);
  z-index: 20;
  padding: 0.35em 0.6em;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  font: var(--fs-label) var(--font-mono);
  letter-spacing: 0.08em;
  color: var(--fg);
  white-space: pre-line;
  opacity: 0.5;
  pointer-events: none;
}

/* A text cursor belongs in a text field only. Browsers with caret browsing on (F7) would
   otherwise blink one in the page itself. */
html { caret-color: transparent; }
input { caret-color: auto; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; }

.label {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}

.icon { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }

.scene {
  position: fixed;
  inset: 0;
  background: var(--bg) var(--scene) center / cover no-repeat;
}

/* The WebGL canvas fades in over the identical static image once its first frame is drawn. */
.scene canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 1.5s; }
.scene canvas.ready { opacity: 1; }

/* No WebGL: the still image drifts slowly instead. */
.scene.drift { animation: drift 90s ease-in-out infinite alternate; }
@keyframes drift {
  from { background-size: auto 104%; background-position: 46% 50%; }
  to { background-size: auto 108%; background-position: 54% 50%; }
}

.scrim {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--bg) 60%, transparent),
    transparent 20%,
    transparent 72%,
    color-mix(in srgb, var(--bg) 70%, transparent)
  );
}

.noscript { position: fixed; inset: auto 0 40% 0; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  :root { --fade: 1ms; }
}
