/* PiZXel: the ZX Spectrum palette and PiZXel's own 8×8 font.
   The font is pixel-perfect at multiples of 8px, so every size here is
   16px, 24px or 32px. */

@font-face {
  font-family: "PiZXel";
  src: url("/static/fonts/pizxel.woff2") format("woff2");
  font-display: block;
}

:root {
  color-scheme: dark;
  /* Spectrum normal (0xD7) and bright (0xFF) colours */
  --black: #000;
  --ink: #d7d7d7;
  --bright: #fff;
  --blue: #0000d7;
  --red: #d70000;
  --magenta: #d700d7;
  --green: #00d700;
  --cyan: #00d7d7;
  --cyan-bright: #0ff;
  --yellow: #d7d700;
  --yellow-bright: #ff0;

  --bg: var(--black);
  --fg: var(--ink);
  --accent: var(--cyan);
  --muted: #8a8a8a;
  --panel: #0b0b0b;

  --font: "PiZXel", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --s: 16px; /* 2 screen pixels per font pixel */
  --m: 24px;
  --l: 32px;
  --gutter: 16px;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0 auto;
  max-width: 52rem;
  padding: 0 var(--gutter) 3rem;
  background: var(--bg);
  color: var(--fg);
  font: var(--s)/1.5 var(--font);
  font-synthesis: none;
  -webkit-font-smoothing: none;
  text-rendering: optimizeSpeed;
}

/* Faint CRT scanlines over everything; purely decorative. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgb(0 0 0 / 0) 0 2px, rgb(0 0 0 / .18) 2px 3px);
}

a { color: var(--cyan-bright); text-underline-offset: .2em; }
a:hover { color: var(--yellow-bright); }
:focus-visible { outline: 3px solid var(--yellow-bright); outline-offset: 2px; }

h1, h2 {
  font-weight: 400;
  color: var(--bright);
  line-height: 1.5;
}
h1 { font-size: var(--m); margin: 2rem 0 1.25rem; }
h2 { font-size: var(--s); margin: 1.5rem 0 .75rem; color: var(--accent); }
@media (min-width: 600px) { h1 { font-size: var(--l); } }
/* No faux bold: it smears pixel fonts. Emphasis is colour instead. */
b, strong, em { font-weight: 400; font-style: normal; color: var(--bright); }
em { color: var(--yellow-bright); }

/* Header */
.masthead {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.25rem 0 1rem;
  border-bottom: 4px solid var(--accent);
}
.logo {
  font-size: var(--m);
  color: var(--bright);
  text-decoration: none;
}
.stripes { display: inline-flex; transform: skewX(-35deg); height: 1.1rem; }
.stripes i { display: block; width: .55rem; height: 100%; }
.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); }
.masthead nav { margin-left: auto; display: flex; gap: 1.25rem; }

.devbar {
  margin: 0;
  padding: .35rem .75rem;
  background: var(--yellow);
  color: var(--black);
}
.devbar b { color: var(--black); }

/* Home */
.hero h1 { color: var(--cyan-bright); }
.lede { max-width: 40rem; }
.actions { display: flex; gap: 1rem; flex-wrap: wrap; margin: 2rem 0; }
.hero-screen { margin: 0; }
.bezel-static { padding: 16px; }
.shots img, .gallery img {
  display: block;
  width: 100%;
  max-width: 512px;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: var(--black);
}
.shots img[hidden] { display: none; }
@media (min-width: 600px) { .shots img { width: 512px; } }
.hero-screen .statusbar { color: var(--cyan-bright); }
.gallery {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(256px, 1fr));
  gap: 16px;
}
.gallery li { background: var(--panel); border: 2px solid #222; padding: 8px; }
.gallery span { display: block; padding-top: 8px; color: var(--bright); }
.steps { padding-left: 1.5rem; }
.steps li { margin: .75rem 0; }

/* Notices */
.notice {
  margin: 1.5rem 0;
  padding: .75rem 1rem;
  border: 3px solid;
  background: var(--panel);
}
.notice h2 { margin-top: .25rem; }
.notice p { margin: .5rem 0; }
.notice-warn { border-color: var(--yellow-bright); }
.notice-warn h2 { color: var(--yellow-bright); }
.notice-error { border-color: var(--red); color: var(--bright); }
.notice-info { border-color: var(--green); }

/* Forms */
.form { display: grid; gap: .35rem; max-width: 34rem; }
.form label:not(.check) {
  margin-top: 1rem;
  color: var(--accent);
}
.hint { margin: 0 0 .25rem; color: var(--muted); }
.row { display: flex; gap: .75rem; flex-wrap: wrap; }
.row input { flex: 1 1 12rem; }

input:not([type=checkbox]) {
  width: 100%;
  min-width: 0;
  padding: .45rem .6rem;
  background: var(--black);
  color: var(--bright);
  border: 2px solid var(--accent);
  border-radius: 0;
  font: inherit;
  font-size: var(--m);
  caret-color: var(--yellow-bright);
}
input:focus { outline: none; border-color: var(--yellow-bright); }
input:user-invalid { border-color: var(--red); }

.check { display: flex; gap: .75rem; align-items: flex-start; margin: 1rem 0; cursor: pointer; }
.check input { width: 1.25rem; height: 1.25rem; margin-top: .2rem; accent-color: var(--cyan); flex: none; }

.terms { margin-top: 1.75rem; padding: .25rem 1rem; border: 2px dashed var(--muted); }
.terms ul { padding-left: 1.2rem; margin: .5rem 0; }
.terms li { margin: .5rem 0; }

.button {
  display: inline-block;
  justify-self: start;
  margin-top: 1rem;
  padding: .7rem 1.1rem;
  background: var(--accent);
  color: var(--black);
  border: 0;
  border-radius: 0;
  box-shadow: 4px 4px 0 var(--blue);
  font: var(--s)/1.5 var(--font);
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--cyan-bright); color: var(--black); }
.button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.button:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--blue); }
.button-quiet { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.button-quiet:hover { background: var(--accent); }
.row .button { margin-top: 0; }
.button-danger { background: var(--red); color: var(--bright); box-shadow: 4px 4px 0 var(--magenta); }
.button-danger:hover { background: #f00; color: var(--bright); }

/* Play */
.player { margin: 1rem 0 0; }
.bezel {
  position: relative;
  display: grid;
  place-items: center;
  padding: clamp(.75rem, 4vw, 2rem);
  background: var(--accent);
}
#screen {
  display: block;
  width: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: var(--black);
  cursor: pointer;
  outline: none;
}
#screen.focused { box-shadow: 0 0 0 3px var(--yellow-bright); cursor: none; }
.overlay {
  position: absolute;
  inset: clamp(.75rem, 4vw, 2rem);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: .5rem;
  padding: 1rem;
  text-align: center;
  background: rgb(0 0 0 / .85);
  color: var(--bright);
}
.overlay[hidden] { display: none; }
.overlay .button { justify-self: center; }
.statusbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .35rem .75rem;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-top: 0;
}
#status { margin: 0; color: var(--cyan-bright); }
.chip {
  padding: .2rem .6rem;
  background: transparent;
  color: var(--muted);
  border: 2px solid currentColor;
  font: var(--s) var(--font);
  cursor: pointer;
}
.chip[aria-pressed="true"] { color: var(--red); }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip[hidden] { display: none; }
.chip-mic { color: var(--red); border-color: var(--red); animation: flash 1.2s steps(1) infinite; }
.chip-on { color: var(--black); background: var(--accent); border-color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .chip-mic { animation: none; } }
.mic-ask {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  padding: 8px 16px;
  background: var(--black);
  border: 2px solid var(--yellow-bright);
  color: var(--bright);
  z-index: 1;
}
.mic-ask p { margin: 0 0 8px; }

/* Large view (a modal) and full screen */
.big {
  width: calc(100vw - 32px);
  height: calc(100dvh - 32px);
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  background: var(--accent);
  color: var(--fg);
}
.big[open] { display: grid; grid-template-rows: 1fr auto; }
.big::backdrop { background: rgb(0 0 0 / .95); }
.big-screen {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 16px;
}
.big-screen:fullscreen { background: var(--black); padding: 0; }
.big-hint {
  position: absolute;
  top: 16px;
  left: 50%;
  translate: -50% 0;
  margin: 0;
  padding: 8px 16px;
  background: var(--black);
  color: var(--yellow-bright);
  border: 2px solid var(--yellow-bright);
  white-space: nowrap;
}
.big-hint[hidden] { display: none; }
.big-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem 1rem;
  padding: 8px 16px;
  background: var(--black);
}
.big-bar p { margin: 0; }
#big-status { color: var(--cyan-bright); }
.big-bar .chips { margin-left: auto; }
.big-bar .chip { color: var(--accent); }
.big-bar .chip[hidden] { display: none; }

/* On-screen keys: a D-pad and three action keys */
.pad {
  display: grid;
  grid-template-columns: repeat(3, 3.25rem) 1fr repeat(3, auto);
  grid-template-rows: repeat(2, 3.25rem);
  grid-template-areas:
    ".    up   .     . tab esc enter"
    "left down right . tab esc enter";
  gap: .4rem;
  margin: 1rem 0 .5rem;
  user-select: none;
  touch-action: manipulation;
}
.pad button {
  background: var(--black);
  color: var(--accent);
  border: 2px solid var(--accent);
  font: var(--s) var(--font);
  cursor: pointer;
}
.pad button:active { background: var(--accent); color: var(--black); }
.pad .k-up { grid-area: up; } .pad .k-down { grid-area: down; }
.pad .k-left { grid-area: left; } .pad .k-right { grid-area: right; }
.pad .k-enter { grid-area: enter; padding: 0 .9rem; }
.pad .k-esc { grid-area: esc; padding: 0 .9rem; }
.pad .k-tab { grid-area: tab; padding: 0 .9rem; }
@media (max-width: 480px) {
  .pad {
    grid-template-columns: repeat(3, 3.25rem) 1fr;
    grid-template-rows: repeat(3, 3.25rem);
    grid-template-areas:
      ".    up   .     enter"
      "left down right esc"
      ".    .    .     tab";
  }
}
.keys kbd {
  padding: 0 .3rem;
  border: 1px solid var(--muted);
  font: inherit;
  color: var(--fg);
}

/* App shelf */
.apps { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.app {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  align-items: center;
  gap: .75rem;
  padding: .5rem .75rem;
  background: var(--panel);
  border: 2px solid #222;
}
.app-icon { font-size: 1.8rem; line-height: 1; text-align: center; }
.app-text { display: grid; }
.app-text b { color: var(--bright); }
.app-text .hint { margin: 0; }
.chip-static { cursor: default; white-space: nowrap; }
.toggle { display: flex; align-items: center; gap: .4rem; cursor: pointer; white-space: nowrap; }
.toggle input { width: 1.4rem; height: 1.4rem; accent-color: var(--cyan); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.manage { margin-top: 2.5rem; border-top: 2px solid #222; }

footer { margin-top: 4rem; padding-top: 1rem; border-top: 2px solid #222; color: var(--muted); }
footer a { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
}

/* Vault dialogs */
.vault-dialog {
  max-width: min(40rem, calc(100vw - 32px));
  padding: 16px 24px;
  background: var(--black);
  color: var(--fg);
  border: 3px solid var(--yellow-bright);
}
.vault-dialog::backdrop { background: rgb(0 0 0 / .9); }
.vault-dialog h2 { color: var(--yellow-bright); margin-top: 8px; }
.vault-dialog .code {
  padding: 8px 12px;
  font-size: var(--m);
  color: var(--bright);
  background: var(--panel);
  border: 2px dashed var(--accent);
  letter-spacing: .05em;
  user-select: all;
  overflow-wrap: anywhere;
}
.vault-dialog label:not(.check) { display: grid; gap: 4px; margin: 12px 0; color: var(--accent); }
.vault-dialog .error { color: var(--red); min-height: 1.5em; margin: 0; }
.vault-dialog .notice-error-text { color: var(--yellow-bright); }
.vault-dialog details { margin-top: 16px; color: var(--muted); }
.vault-dialog summary { cursor: pointer; }
.vault .vault-status { margin: 0 0 8px; }
#me-error { color: var(--red); }
