/* Pico Race — the public site.
 *
 * The palette and the two faces are the game's, straight out of `DESIGN.md`
 * and `art/pixel-ui-kit/`. What is deliberately *not* the game's is the layout
 * discipline: the app composes in canvas pixels and multiplies by a whole
 * number, because it is a fixed-resolution picture. A web page is not, and
 * pretending otherwise gives you a site that is unreadable on a phone.
 *
 * So: brand at the edges, ordinary responsive typography in the middle. The
 * one place that matters most is the legal pages, and there the rule is
 * legibility beats character — see `--face-prose` below.
 */

:root {
  /* DESIGN.md, verbatim. */
  --background: #06162d;
  --surface: #0b2342;
  --selected: #4b9fe7;
  --text: #f5e9d2;
  --text-muted: #a9b7c6;
  --accent: #f3c623;
  --grass: #4c8b1f;
  --road: #3a3e43;
  --kerb-red: #d53a2f;
  --outline: #05080d;

  --face-display: 'Press Start 2P', monospace;
  --face-ui: 'Silkscreen', monospace;

  /* Legal prose is the one thing on this site that somebody has to read
   * carefully rather than glance at. A pixel face at paragraph length is a
   * way of not being read, which for a privacy policy is the opposite of the
   * point. */
  --face-prose: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto,
    Helvetica, Arial, sans-serif;
}

@font-face {
  font-family: 'Press Start 2P';
  src: url('fonts/PressStart2P-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Silkscreen';
  src: url('fonts/Silkscreen-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html {
  /* The kerb red is what shows behind an overscroll bounce on iOS, and the
   * navy would read as a hole in the page. */
  background: var(--background);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--face-ui);
  font-size: 16px;
  line-height: 1.6;

  /* Open ground, exactly as the menus draw it: a tiled grass sprite at a
   * whole-number scale, nearest-neighbour. 32px art at 4x. */
  background-color: var(--grass);
  background-image: url('img/grass.png');
  background-repeat: repeat;
  background-size: 128px 128px;
  image-rendering: pixelated;

  -webkit-font-smoothing: none;
  font-smooth: never;
}

img {
  image-rendering: pixelated;
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

a:hover,
a:focus-visible {
  border-bottom-color: var(--accent);
}

a:focus-visible {
  outline: 3px solid var(--selected);
  outline-offset: 2px;
}

/* ---- The panel ------------------------------------------------------- */

/* The kit's containers are nine-sliced sprites with a 3px inset. This is the
 * same shape in CSS: hard outline, flat navy fill, no radius beyond the kit's
 * 2px, and no shadow blur — a blurred edge is a hundred intermediate shades
 * on a screen that has thirty-two colours. */
.panel {
  background: var(--surface);
  border: 3px solid var(--outline);
  border-radius: 2px;
  box-shadow: inset 0 0 0 2px rgba(75, 159, 231, 0.18);
  padding: 24px;
}

.wrap {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
}

.narrow {
  width: min(720px, calc(100% - 32px));
}

/* ---- Type ------------------------------------------------------------ */

h1,
h2,
h3 {
  font-family: var(--face-display);
  font-weight: 400;
  line-height: 1.35;
  color: var(--text);
  margin: 0 0 16px;
}

h1 {
  font-size: clamp(18px, 4vw, 28px);
}

h2 {
  font-size: clamp(14px, 2.6vw, 18px);
  color: var(--accent);
  margin-top: 40px;
}

h3 {
  font-size: clamp(12px, 2.2vw, 14px);
  color: var(--selected);
  margin-top: 28px;
}

p,
li {
  color: var(--text);
}

.muted {
  color: var(--text-muted);
}

small,
.small {
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- Header ---------------------------------------------------------- */

.site-head {
  padding: 32px 0 8px;
  text-align: center;
}

.site-head img.wordmark {
  /* 128x74 authored; 3x on a phone, 4x above that. Whole numbers only — a
   * fractional scale on pixel art is a blurred edge whatever the renderer. */
  width: 384px;
  max-width: calc(100% - 32px);
  height: auto;
}

.tagline {
  font-family: var(--face-display);
  font-size: clamp(9px, 2.2vw, 12px);
  color: var(--text);
  letter-spacing: 0.04em;
  margin: 16px 0 0;
  text-shadow: 2px 2px 0 var(--outline);
}

/* ---- Buttons --------------------------------------------------------- */

.button {
  display: inline-block;
  font-family: var(--face-display);
  font-size: clamp(11px, 2.4vw, 15px);
  line-height: 1;
  padding: 18px 28px;
  border: 3px solid var(--outline);
  border-radius: 2px;
  background: var(--selected);
  color: var(--text);
  text-shadow: 2px 2px 0 var(--outline);
  box-shadow: 0 4px 0 var(--outline);
  cursor: pointer;
}

.button:hover,
.button:focus-visible {
  background: var(--accent);
  color: var(--outline);
  text-shadow: none;
  border-bottom-color: var(--outline);
}

.button:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 var(--outline);
}

.button.secondary {
  background: var(--surface);
  color: var(--text);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  margin: 28px 0 8px;
}

/* ---- Feature grid ---------------------------------------------------- */

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.grid li {
  background: rgba(6, 22, 45, 0.6);
  border: 2px solid var(--outline);
  padding: 16px;
}

.grid strong {
  display: block;
  font-family: var(--face-display);
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 10px;
  line-height: 1.5;
}

.grid span {
  font-size: 14px;
  color: var(--text-muted);
}

/* ---- Prose ----------------------------------------------------------- */

/* Silkscreen draws lowercase as small capitals. On a label that is character;
 * on a sentence it is a shout, and it flattens every capital that carries
 * meaning — a proper noun stops looking like one, and a name with a capital
 * inside it reads as a typo. So anything longer than a label gets the prose
 * face: the legal pages entirely, and the descriptive paragraphs on the
 * landing page.
 *
 * The pixel faces keep their hard edges; this one needs its antialiasing back,
 * because `font-smooth: never` on the body would otherwise apply to it too. */
.prose,
.lede {
  font-family: var(--face-prose);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  font-smooth: always;
}

.lede {
  font-size: 17px;
}

.prose h2,
.prose h3 {
  font-family: var(--face-display);
}

.prose ul {
  padding-left: 22px;
}

.prose li {
  margin-bottom: 10px;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 15px;
}

.prose th,
.prose td {
  border: 2px solid var(--outline);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.prose th {
  background: rgba(6, 22, 45, 0.6);
  color: var(--accent);
  font-family: var(--face-ui);
  font-weight: 400;
}

/* A table is the one thing here that can be wider than a phone. It scrolls
 * inside its own box; the page itself never scrolls sideways. */
.scroller {
  overflow-x: auto;
}

.updated {
  font-family: var(--face-ui);
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 24px;
}

/* ---- Footer ---------------------------------------------------------- */

.site-foot {
  margin: 40px 0;
  text-align: center;
  font-size: 14px;
  color: var(--text);
  text-shadow: 1px 1px 0 var(--outline);
}

.site-foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: center;
  margin-bottom: 12px;
}

.site-foot a {
  color: var(--text);
}

.site-foot a:hover {
  color: var(--accent);
}

/* Skip link — the page is short, but a keyboard user should not have to walk
 * the footer nav on every legal page to reach the text. */
.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 16px;
  top: 16px;
  z-index: 10;
  background: var(--surface);
  padding: 12px 16px;
  border: 3px solid var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
