/* OpenGameRoom design tokens and primitives.
 *
 * The constraint that drives everything: the host page is read from three metres away
 * on a TV. So type is large, contrast is high, and nothing important is thin.
 *
 * The chrome is deliberately near-monochrome. The eight player hues are the only
 * saturated colour on screen, which means a glance at the room tells you who is in it.
 * Rounding is zero and shadows are hard offsets — a blurred shadow is the one thing
 * that instantly breaks a pixel surface. */

@font-face {
  font-family: 'Pixelify Sans Fallback';
  src: local('Courier New');
  size-adjust: 105%;
}

:root {
  color-scheme: dark;

  /* ground */
  --void: #0a0c12;
  --grid: #171c2b;
  --panel: #12161f;
  --panel-2: #1a1f2b;
  --line: #2a3140;
  --line-bright: #3d4657;

  /* ink */
  --chalk: #e8edf7;
  --dim: #6b7692;
  --dimmer: #454e63;

  /* signal */
  --live: #66e0a3;
  --warn: #ffb03a;
  --dead: #ff5c5c;

  /* the eight, in join order */
  --p1: #ff5c5c;
  --p2: #ffb03a;
  --p3: #ffe45c;
  --p4: #66e0a3;
  --p5: #4dd0e1;
  --p6: #6c8cff;
  --p7: #c77dff;
  --p8: #ff7ac6;

  /* 4px base grid — every space in the UI is a multiple */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s6: 24px;
  --s8: 32px;
  --s12: 48px;
  --s16: 64px;

  --display: 'Pixelify Sans', 'Pixelify Sans Fallback', monospace;
  --label: 'Silkscreen', 'Pixelify Sans Fallback', monospace;
  --body: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Menlo, monospace;

  --border: 2px solid var(--line);
  --border-bright: 2px solid var(--line-bright);
  --drop: 4px 4px 0 rgba(0, 0, 0, 0.55);
  --drop-lg: 8px 8px 0 rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--void);
  color: var(--chalk);
  font-family: var(--body);
  /* Pixel faces are drawn on a grid; smoothing them defeats the point. */
  -webkit-font-smoothing: none;
  font-smooth: never;
  /* Pixelify Sans ships an "fi" ligature whose glyph reads as a capital A at UI
     sizes — "Choose a file" renders as "Choose a Ale". Ligatures buy a pixel face
     nothing, so they are off everywhere. */
  font-variant-ligatures: none;
  font-feature-settings: 'liga' 0, 'clig' 0;
  overflow: hidden;
}

canvas {
  /* Order matters: the last declaration a browser understands wins, and `pixelated`
     is the one that gives hard nearest-neighbour upscaling. Putting `crisp-edges`
     after it silently downgrades every sprite on the platform. */
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

/* ---------------------------------------------------------------- primitives */

.eyebrow {
  font-family: var(--label);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

.panel {
  background: var(--panel);
  border: var(--border);
  box-shadow: var(--drop);
}

/* A button that looks physically pressed rather than tinted. */
.btn {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--void);
  background: var(--chalk);
  border: 2px solid var(--chalk);
  border-radius: 0;
  padding: var(--s3) var(--s6);
  cursor: pointer;
  box-shadow: var(--drop);
  transition: transform 60ms steps(2), box-shadow 60ms steps(2);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover:not(:disabled) {
  background: var(--live);
  border-color: var(--live);
}

.btn:active:not(:disabled) {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}

.btn:disabled {
  background: transparent;
  color: var(--dimmer);
  border-color: var(--line);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--chalk);
  border-color: var(--line-bright);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--panel-2);
  color: var(--chalk);
  border-color: var(--chalk);
}

:where(a, button, input, [tabindex]):focus-visible {
  outline: 3px solid var(--live);
  outline-offset: 3px;
}

/* Avatars arrive at 128x128 and are shown at every size from a 28px header thumbnail
   to a preview that fills half a phone, so they want the browser's smooth resample in
   both directions. `pixelated` here would point-sample and shred a face — on a phone
   at 3x that is a 128px photo in hard 3x3 blocks. It is a photograph; the posterising
   already happened, on the phone, once. Canvases, which are genuinely upscaled from a
   low internal resolution, keep the hard nearest-neighbour treatment above. */
img {
  image-rendering: auto;
}

.sprite {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background: var(--panel-2);
}

/* Blinking cursor block, used wherever the UI is waiting on a person. */
.caret::after {
  content: '';
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 0.15em;
  background: currentColor;
  vertical-align: -0.13em;
  animation: blink 1s steps(1, end) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.hidden {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
