/* zxGammon's pages. Copyright (C) 2026 Paul Hankin; GPL version 3 or later. */

:root {
  --bg: #0b0b0d;
  --panel: #16161a;
  --line: #2a2a31;
  --text: #e8e6e1;
  --muted: #9a978f;
  --link: #6fd3e8;
  --red: #d8312a;
  --yellow: #f2c230;
  --green: #3fae49;
  --cyan: #2aa7d6;
  --key: #26262c;
  --key-top: #33333b;
  --legend: #ff5a4f;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
:root, html { color-scheme: dark; }
body {
  margin: 0;
  touch-action: manipulation; /* no double-tap zoom on the keys */
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--sans);
}
a { color: var(--link); }
a:hover { color: #a5e6f3; }
code { font-family: var(--mono); font-size: 0.92em; }

/* the header: the name beside the Spectrum's four stripes */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}
.stripes { display: inline-flex; transform: skewX(-30deg); }
.stripes i { display: block; width: 7px; height: 24px; }
.stripes i:nth-child(1) { background: var(--red); }
.stripes i:nth-child(2) { background: var(--yellow); }
.stripes i:nth-child(3) { background: var(--green); }
.stripes i:nth-child(4) { background: var(--cyan); }
nav { display: flex; gap: 6px; }
nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
}
nav a:hover { color: var(--text); background: var(--panel); }
nav a[aria-current="page"] { color: var(--text); background: var(--panel); }

main { max-width: 980px; margin: 0 auto; padding: 0 16px 32px; }

/* the Spectrum's screen, scaled up crisply */
.tv {
  background: #000;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 0 0 1px var(--line), 0 18px 50px rgba(0, 0, 0, 0.6);
  max-width: 820px;
  margin: 0 auto;
}
.tv canvas {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 16px auto;
}
button, .button {
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 14px;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { border-color: #44444d; color: var(--text); }
button[aria-pressed="true"] { border-color: var(--cyan); }
button:disabled { opacity: 0.45; cursor: default; }

/* the keys the game will take now, as the 48K's rubber keys on its black
   case: each key's keyword printed above it in green and below it in red,
   on the key its letter, keyword (white) and symbol (red); under that, in
   the site's own type, what the key does in the game */
.keypad {
  --zx-face: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", sans-serif;
  --zx-green: #3fcf4a;
  --zx-red: #ff4436;
  display: grid;
  grid-template-columns: repeat(7, 64px);
  grid-template-rows: repeat(2, 112px);
  justify-content: center;
  gap: 0 6px;
  max-width: 820px;
  margin: 14px auto 4px;
  padding: 12px 14px 6px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.012) 0 2px, transparent 2px 5px),
    linear-gradient(#121214, #0a0a0b);
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 0 0 1px #1e1e23;
}
.zxcell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  animation: keyin 140ms ease-out;
}
@keyframes keyin { from { opacity: 0; transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) { .zxcell { animation: none; } }
.zxcell .above, .zxcell .below {
  font: 700 9px/1 var(--zx-face);
  font-stretch: condensed;
  letter-spacing: 0.02em;
  min-height: 9px;
  white-space: nowrap;
}
.zxcell .above { color: var(--zx-green); }
.zxcell .below { color: var(--zx-red); }
.zxkey {
  position: relative;
  width: 56px;
  height: 52px;
  padding: 0;
  border: none;
  border-radius: 7px 7px 9px 9px;
  /* the 48K's grey-blue rubber, matt, a little lighter on top */
  background:
    radial-gradient(110% 60% at 50% 12%, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 65%),
    linear-gradient(#6d7a96, #56627c 55%, #48536a);
  box-shadow:
    0 3px 0 #262c3a,
    0 5px 8px rgba(0, 0, 0, 0.6),
    inset 0 -2px 3px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  color: #fff;
  font-family: var(--zx-face);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.zxkey.wide { width: 126px; }
.zxkey:hover { filter: brightness(1.07); }
.zxkey:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.zxkey .cap {
  position: absolute;
  left: 6px;
  top: 4px;
  font: 700 19px/1 var(--zx-face);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}
.zxkey .red {
  position: absolute;
  right: 5px;
  top: 5px;
  color: var(--zx-red);
  font: 700 10px/1 var(--zx-face);
  font-stretch: condensed;
}
.zxkey .red.word { font-size: 8px; top: 6px; letter-spacing: -0.01em; }
.zxkey .kw {
  position: absolute;
  left: 5px;
  right: 3px;
  bottom: 5px;
  font: 700 8.5px/1.05 var(--zx-face);
  font-stretch: condensed;
  text-align: left;
  letter-spacing: 0.01em;
}
.zxkey .kw.centre { top: 50%; bottom: auto; transform: translateY(-50%); text-align: center; font-size: 10px; letter-spacing: 0.04em; }
.zxkey.down {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #262c3a, 0 2px 4px rgba(0, 0, 0, 0.5), inset 0 -1px 2px rgba(0, 0, 0, 0.3);
  filter: brightness(0.94);
}
.zxcell .label {
  margin-top: 3px;
  color: var(--text);
  font: 600 10.5px/1.1 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
  max-width: 100%;
}

.howto { max-width: 760px; margin: 28px auto 0; }
.howto h2, .page h2 { font-size: 1.15rem; margin: 1.6em 0 0.5em; }
.howto dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 18px;
  margin: 12px 0 16px;
}
.howto dt { font-family: var(--mono); color: var(--yellow); white-space: nowrap; }
.howto dd { margin: 0; color: var(--text); }

/* text pages */
.page { max-width: 760px; margin: 0 auto; }
.page h1 { font-size: 1.6rem; margin: 0.4em 0 0.6em; }
.page p, .page li { color: var(--text); }
.muted { color: var(--muted); }

/* the source's listing */
table.files { width: 100%; border-collapse: collapse; margin: 12px 0 24px; font-size: 0.95rem; }
table.files th, table.files td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.files th { color: var(--muted); font-weight: 600; }
table.files td.size { text-align: right; white-space: nowrap; font-family: var(--mono); color: var(--muted); }
table.files td.name { font-family: var(--mono); white-space: nowrap; }

pre.code {
  font: 13px/1.5 var(--mono);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 0;
  overflow-x: auto;
  counter-reset: line;
}
pre.cmd {
  font: 14px/1.5 var(--mono);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  overflow-x: auto;
}
pre.code .l { display: block; padding: 0 16px 0 0; }
pre.code .l::before {
  counter-increment: line;
  content: counter(line);
  display: inline-block;
  width: 4.5em;
  padding-right: 1.2em;
  text-align: right;
  color: #55555e;
  user-select: none;
}
pre.code .c { color: #8d9a7c; }
pre.code .lb { color: var(--yellow); }
pre.code .d { color: #c9a0f0; }
pre.code .s { color: #f0a87a; }

.bottom {
  max-width: 980px;
  margin: 24px auto 0;
  padding: 18px 16px 30px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}

/* the notice on a first visit: until it is answered, the page is hidden
   and only the notice shows */
html.notice-pending body > *:not(.notice) { display: none !important; }
.notice {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
}
.notice-card {
  max-width: 32rem;
  padding: 28px 28px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.notice-card .brand { margin: 0 0 18px; }
.notice-card p { margin: 0 0 12px; line-height: 1.5; }
.notice-card p.muted { font-size: 0.9rem; }
.notice-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.notice-buttons button { padding: 8px 18px; }
#notice-ok { border-color: var(--cyan); }
.notice button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* A phone held upright: no keyboard, so the screen and its keys fit the
   window together; the header a single line, the picture edge to edge,
   the keys' columns shrinking to the width. */
@media (max-width: 600px) {
  .top { padding: 8px 12px; gap: 6px; flex-wrap: nowrap; }
  .brand { font-size: 0.98rem; gap: 6px; flex: none; }
  .stripes i { width: 4px; height: 16px; }
  nav { gap: 0; flex-wrap: nowrap; }
  nav a { padding: 4px 5px; font-size: 0.8rem; white-space: nowrap; }
  main { padding: 0 12px 24px; }
  .tv { padding: 0; border-radius: 4px; box-shadow: none; }
  .keypad {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: repeat(2, 86px);
    gap: 0 3px;
    max-width: 420px;
    margin-top: 8px;
    padding: 8px 4px 2px;
  }
  .zxkey { width: min(44px, 100%); height: 42px; }
  .zxkey.wide { width: 100%; max-width: 96px; }
  .zxkey .cap { font-size: 15px; left: 5px; top: 4px; }
  .zxkey .kw { font-size: 7px; left: 4px; bottom: 4px; }
  .zxkey .kw.centre { font-size: 8.5px; }
  .zxkey .red { right: 3px; font-size: 9px; }
  .zxkey .red.word { font-size: 6px; top: 5px; }
  .zxcell { gap: 2px; }
  .zxkey { margin-bottom: 3px; }
  .zxcell .above, .zxcell .below { font-size: 7px; min-height: 7px; }
  .zxcell .label { font-size: 9.5px; margin-top: 1px; }
  .controls { margin: 10px auto; gap: 6px; }
  .controls button { font-size: 0.85rem; padding: 6px 10px; }
  .controls .dl { display: none; }
  .howto dl { grid-template-columns: 1fr; gap: 0 0; }
  .howto dt { margin-top: 8px; }
}

/* A phone on its side: the screen as tall as the window, the keys beside
   it, the header out of the way. */
@media (max-height: 500px) and (orientation: landscape) {
  .top { padding: 4px 12px; }
  .brand { font-size: 0.95rem; }
  .stripes i { width: 4px; height: 14px; }
  nav a { padding: 2px 8px; font-size: 0.85rem; }
  main.play {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "tv pad" "tv ctl" "howto howto";
    gap: 0 12px;
    max-width: none;
    padding: 0 12px 24px;
  }
  .play .tv { grid-area: tv; padding: 0; box-shadow: none; border-radius: 4px; margin: 0; }
  .play .tv canvas { width: auto; height: calc(100vh - 40px); height: calc(100dvh - 40px); }
  .play .keypad {
    grid-area: pad;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: repeat(2, 84px);
    gap: 0 3px;
    margin: 0;
    padding: 6px 4px 2px;
    align-self: start;
  }
  .play .controls { grid-area: ctl; margin: 8px 0; align-self: start; }
  .play .controls .dl { display: none; }
  .play .howto { grid-area: howto; }
  .zxkey { width: min(44px, 100%); height: 40px; }
  .zxkey.wide { width: 100%; max-width: 96px; }
  .zxkey .cap { font-size: 15px; left: 5px; top: 4px; }
  .zxkey .kw { font-size: 7px; left: 4px; bottom: 4px; }
  .zxkey .kw.centre { font-size: 8.5px; }
  .zxkey .red { right: 3px; font-size: 9px; }
  .zxkey .red.word { font-size: 6px; top: 5px; }
  .zxcell .above, .zxcell .below { font-size: 7px; min-height: 7px; }
  .zxcell .label { font-size: 9.5px; }
}

/* the narrowest phones: the header tighter still, to stay on one line */
@media (max-width: 380px) {
  .top { padding: 8px 10px; }
  .brand { font-size: 0.9rem; }
  nav a { padding: 4px 3px; font-size: 0.76rem; }
}
