/* Jooys Games: the title screen.
   The logo's rules (design/logo/arcade/README.md): colour logo on window black only,
   pixel artwork at whole screen pixels per letter pixel, no effects on the logo. */

@font-face {
  font-family: "Parkinsans";
  src: url("/fonts/parkinsans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "Space Mono";
  src: url("/fonts/space-mono-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --window: #070707;
  --ink: #ffffff;
  --ink-2: #b4b4b4;
  --ink-3: #828282;
  --line: #2e2e2e;
  --inspiring: #ed008c;
  --funny: #fef200;
  --mono: "Space Mono", ui-monospace, "Cascadia Mono", Menlo, monospace;
  --sans: "Parkinsans", system-ui, "Segoe UI", Roboto, sans-serif;

  /* Stacked logo width: 38 px per screen pixel per letter pixel. 228 = 6, 304 = 8, 380 = 10. */
  --logo-w: 228px;
  /* Never less than the logo's clear space: 7 letter pixels from the artwork, which is 6 from the SVG's frame */
  --gap-logo: max(calc(var(--logo-w) * 6 / 38), clamp(28px, 5vh, 56px));

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--window);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--line) var(--window);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(16px, 3.5vh, 48px) 24px clamp(12px, 2.5vh, 28px);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
}

::selection { background: var(--inspiring); color: #ffffff; }

p, h1, h2, ul { margin: 0; }

/* The screen: logo over menu, centred in the window */

.screen {
  flex: 1 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.title { line-height: 0; }

.logo {
  display: block;
  width: var(--logo-w);
  height: calc(var(--logo-w) * 1.5);
}

/* The menu */

.menu {
  margin-top: var(--gap-logo);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.menu-title {
  font: 700 14px/1.4 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 14px;
}

.games {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.game {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 16px;
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.game-name {
  position: relative;
  font: 700 22px/1.25 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.game-meta { color: var(--ink-2); }

/* On a phone the genre and the status take a line each; wider, one line with a dot between */
.game-meta > span { display: block; }
.game-meta > .sep { display: none; }

@media (min-width: 600px) {
  .game-meta > span,
  .game-meta > .sep { display: inline; }
}

/* The cursor: the logo's sparkle, in Funny's yellow, hanging left of the chosen name */

.cursor {
  position: absolute;
  right: calc(100% + 14px);
  top: 50%;
  margin-top: -11px;
  fill: var(--funny);
  shape-rendering: crispEdges;
  visibility: hidden;
}

.game.is-selected .game-name,
.game:focus-visible .game-name {
  color: var(--ink);
  text-shadow: 2px 2px 0 var(--inspiring);
}

.game.is-selected .cursor,
.game:focus-visible .cursor {
  visibility: visible;
  animation: blink 1.1s step-end infinite;
}

.game:focus { outline: none; }

.game:focus-visible {
  outline: 2px solid var(--funny);
  outline-offset: 2px;
}

/* Pressing an option sets its name down onto its drop, like an arcade button */

.game:active .game-name,
.game.is-pressed .game-name {
  transform: translate(2px, 2px);
  text-shadow: none;
}

.game.is-off .game-name { color: var(--ink-3); }
.game.is-off .game-meta { color: var(--ink-3); }

.more {
  margin-top: 14px;
  color: var(--ink-3);
}

/* Key hint: only with a keyboard and a mouse, and only once the script runs */

.hint {
  display: none;
  margin-top: 16px;
  font: 700 11px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.js .hint { display: block; }

@media not all and (hover: hover) and (pointer: fine) {
  .js .hint { display: none; }
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  margin: 0 2px;
  border: 1px solid var(--line);
  font: inherit;
  color: var(--ink-2);
  vertical-align: middle;
}

kbd + kbd { margin-left: 0; }

kbd svg { fill: currentColor; shape-rendering: crispEdges; }

/* Credits */

.credits {
  margin-top: clamp(16px, 3vh, 40px);
  font: 700 11px/1.4 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* The contact address: lowercase as typed, underlined so it reads as a link without colour.
   The padding widens the tap target without moving the line. */
.mail {
  display: inline-block;
  padding: 6px 2px;
  margin: -6px -2px;
  color: var(--ink-2);
  text-transform: none;
  letter-spacing: 0.02em;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--ink-3);
}

.mail:hover { color: var(--ink); text-decoration-color: var(--inspiring); }
.mail:focus { outline: none; }
.mail:focus-visible { outline: 2px solid var(--funny); outline-offset: 0; }

/* Very narrow phones: the address takes its own line */
@media (max-width: 359px) {
  .credits p > span:first-child,
  .credits .mail { display: block; }
  .credits .dot { display: none; }
  .credits .mail { margin: -2px auto -6px; width: max-content; }
}

/* Page not found */

.home { display: block; line-height: 0; }
.home:focus-visible { outline: 2px solid var(--funny); outline-offset: 8px; }

/* Horizontal logo: 53 px wide per screen pixel per letter pixel. 212 = 4, 318 = 6. */
.logo-wide { display: block; width: 212px; height: 92px; }

.lost-title {
  margin-top: var(--gap-logo);
  font: 700 26px/1.25 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lost-text {
  margin-top: 10px;
  max-width: 34ch;
  color: var(--ink-2);
  text-wrap: balance;
}

.lost .menu { margin-top: 28px; }

/* Logo steps by window size: whole pixels per letter pixel, never in between */

@media (min-width: 600px) and (max-height: 779px) {
  :root { --logo-w: 152px; }
}

/* Phones whose browser shows less than 740px: the smaller step, so all three games show on arrival */
@media (max-width: 599px) and (max-height: 740px) {
  :root { --logo-w: 152px; }
}

@media (min-width: 600px) and (min-height: 940px) {
  :root { --logo-w: 304px; }
  .game-name { font-size: 24px; }
}

@media (min-width: 900px) and (min-height: 1180px) {
  :root { --logo-w: 380px; }
}

@media (min-width: 600px) and (min-height: 600px) {
  .logo-wide { width: 318px; height: 138px; }
}

@keyframes blink {
  50% { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .game.is-selected .cursor,
  .game:focus-visible .cursor { animation: none; }
}
