/* Self-hosted, one weight, Latin only. */
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono.woff2") format("woff2");
  font-display: swap;
}

:root {
  --bg: #0a0a0b;
  --fg: #9b9b9b;
  --fg-bright: #f0f0f0;
  --px: 4px; /* one canvas pixel in CSS px, set from JS */
  /* Set from JS: the text greys for the time of day. */
  --text-sub: #8a8a8a;
  --text-link: #d0d0d0;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  font-family: "Courier New", ui-monospace, monospace;
}

#stage {
  position: fixed;
  touch-action: none;
}

#stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* The light layer is the one thing allowed to be smooth. */
#stage #light {
  image-rendering: auto;
  image-rendering: smooth;
}

/* Vignette: the room fades into darkness toward the window edges. */
#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 78% 90% at 50% 50%,
    transparent 52%, rgba(10, 10, 11, 0.45) 78%, rgba(10, 10, 11, 0.85) 100%);
}

/* HTML twin of the drawn name/subtitle/links. Without JS it is simply visible text. */
#overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  text-align: center;
  pointer-events: none;
}

#subtitle, #links { font-family: "JetBrains Mono", "Courier New", ui-monospace, monospace; }
/* Same clamp() values as CONFIG.typography, for when JS does not run. */
#subtitle { color: var(--text-sub); letter-spacing: 0.04em; font-size: clamp(16px, 1.25vw, 20px); }
#links { font-size: clamp(18px, 1.375vw, 22px); }
#overlay a {
  color: var(--text-link);
  pointer-events: auto;
  letter-spacing: 0.04em;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
}
#overlay a:hover, #overlay a:focus-visible { color: #fff; }

.js #overlay { display: block; place-content: initial; }

.js #overlay h1,
.js #overlay #subtitle span,
.js #overlay a {
  position: absolute;
  display: block;
  margin: 0;
  font-weight: normal;
  white-space: nowrap;
  text-align: left;
  pointer-events: none;
}

/* The name is drawn on the canvas: its HTML twin stays invisible. */
.js #overlay h1 { overflow: hidden; color: transparent; letter-spacing: 0; }
.js #overlay h1::selection { background: rgba(240, 240, 240, 0.28); color: transparent; }

.js #overlay.revealed h1,
.js #overlay.revealed #subtitle span,
.js #overlay.revealed a { pointer-events: auto; }

.js #overlay #subtitle span::selection,
.js #overlay a::selection { background: rgba(240, 240, 240, 0.28); }

#overlay a:focus-visible {
  outline: 2px solid var(--fg-bright);
  outline-offset: 2px;
}

#replay, #sound {
  position: fixed;
  top: max(12px, calc(var(--px) * 3));
  right: max(12px, calc(var(--px) * 3));
  width: max(32px, calc(var(--px) * 9));
  height: max(32px, calc(var(--px) * 9));
  display: grid;
  place-items: center;
  font: inherit;
  font-size: max(16px, calc(var(--px) * 5));
  line-height: 1;
  color: var(--fg-bright);
  background: var(--bg);
  border: 2px solid #535353;
  border-radius: 0;
  cursor: pointer;
}

/* Small text in a corner during the intro: quiet, but with a full-size touch target. */
#skip {
  position: fixed;
  right: max(12px, calc(var(--px) * 3));
  bottom: max(12px, calc(var(--px) * 3));
  min-height: 32px;
  padding: 0 8px;
  font: 14px "JetBrains Mono", "Courier New", ui-monospace, monospace;
  letter-spacing: 0.04em;
  color: var(--text-link);
  background: none;
  border: 0;
  cursor: pointer;
}
#skip[hidden] { display: none; }
#skip:hover, #skip:focus-visible { color: #fff; text-decoration: underline; }
#skip:focus-visible { outline: 2px solid var(--fg-bright); outline-offset: 2px; }

/* "sound on?": left of the sound button, which is left of replay. */
#sound-hint {
  position: fixed;
  top: max(12px, calc(var(--px) * 3));
  right: calc(max(12px, calc(var(--px) * 3)) + 2 * max(32px, calc(var(--px) * 9)) + 2 * max(6px, calc(var(--px) * 1.5)));
  height: max(32px, calc(var(--px) * 9));
  display: flex;
  align-items: center;
  font: 14px "JetBrains Mono", "Courier New", ui-monospace, monospace;
  letter-spacing: 0.04em;
  color: var(--text-link);
  pointer-events: none;
}
#sound-hint[hidden] { display: none; }

@media (prefers-reduced-motion: no-preference) {
  #sound.prompt { animation: sound-pulse 1.6s ease-in-out infinite; }
}
@keyframes sound-pulse {
  50% { border-color: var(--fg-bright); color: var(--fg-bright); }
}

/* Just left of replay: its right edge + its width + a small gap. */
#sound { right: calc(max(12px, calc(var(--px) * 3)) + max(32px, calc(var(--px) * 9)) + max(6px, calc(var(--px) * 1.5))); }
#sound[aria-pressed="false"] { color: var(--fg); }
#sound[aria-pressed="false"] .sound-on,
#sound[aria-pressed="true"] .sound-off { display: none; }

#replay svg, #sound svg { width: 60%; height: 60%; }
#replay:hover, #sound:hover { border-color: var(--fg-bright); }
#replay:focus-visible, #sound:focus-visible { outline: 2px solid var(--fg-bright); outline-offset: 2px; }
