/* THE COMMON PEOPLE: a teletext service. one screen of 40 columns x 25 rows */

@font-face {
  font-family: "Bedstead";
  src: url("fonts/bedstead.woff2") format("woff2"), url("fonts/bedstead.otf") format("opentype");
  font-display: block;
}

:root {
  --k: #000; --r: #f00; --g: #0f0; --y: #ff0; --b: #00f; --m: #f0f; --c: #0ff; --w: #fff;
  --b2: #3a3aff;
  /* a cell is 0.6em wide, so 40 columns = 24em; 25 rows = 25em */
  --fit-w: calc((100vw - 16px) / 24);
  --fs: min(var(--fit-w), 26px);
}
html[data-size="s"]   { --fs: min(var(--fit-w), 17px); }
html[data-size="m"]   { --fs: min(var(--fit-w), 26px); }
html[data-size="l"]   { --fs: min(var(--fit-w), 40px); }
html[data-size="fit"] { --fs: min(var(--fit-w), calc((100vh - 24px - env(safe-area-inset-bottom, 0px)) / 25.4)); }
@supports (height: 100svh) {
  html[data-size="fit"] { --fs: min(var(--fit-w), calc((100svh - 24px - env(safe-area-inset-bottom, 0px)) / 25.4)); }
}

* { box-sizing: border-box; }
html { background: #000; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: #000; color: var(--w);
  font-family: "Bedstead", ui-monospace, "Courier New", monospace;
  font-variant-ligatures: none; font-feature-settings: "liga" 0, "clig" 0;
  -webkit-font-smoothing: none;
}

.tv { display: flex; justify-content: center; padding: calc(env(safe-area-inset-top, 0px) + 12px) 8px 12px; }
.screen {
  position: relative;
  font-size: var(--fs);
  font-size: round(down, var(--fs), 1px);   /* whole pixels, so mosaic blocks meet without hairlines */
  line-height: 1em;
  width: 24em;
  background: #000;
}
.row { display: block; height: 1em; white-space: pre; overflow: hidden; position: relative; }
.row.dh { height: 2em; }
.row.dh > .in { display: inline-block; transform: scaleY(2); transform-origin: 0 0; white-space: pre; }
.body { position: relative; height: 22em; }

/* colours */
.f-k { color: var(--k); } .f-r { color: var(--r); } .f-g { color: var(--g); } .f-y { color: var(--y); }
.f-b { color: var(--b2); } .f-m { color: var(--m); } .f-c { color: var(--c); } .f-w { color: var(--w); }
.b-k { background: var(--k); } .b-r { background: var(--r); } .b-g { background: var(--g); } .b-y { background: var(--y); }
.b-b { background: var(--b); } .b-m { background: var(--m); } .b-c { background: var(--c); } .b-w { background: var(--w); }
.f-b.b-b { color: var(--b); }

/* header */
.hdr .pno { color: var(--w); }
.hdr .pno.typing { color: var(--y); }
.hdr .chan { color: var(--c); }
.hdr .chan.hold { color: var(--r); }
.hdr .date { color: var(--w); }
.hdr .time { color: var(--y); }

/* links */
.screen a { color: inherit; text-decoration: none; cursor: pointer; }
.screen a:hover, .screen a:focus-visible, .screen a.is-remote-focus {
  outline: none; background: var(--y) !important; color: var(--k) !important;
}
.dots { opacity: 0.9; }

/* hidden until REVEAL */
.conceal { visibility: hidden; }
body.revealed .conceal { visibility: visible; }

/* picture placeholders and pictures */
.shade { background-image: radial-gradient(circle, var(--b2) 0.06em, transparent 0.08em); background-size: 0.3em 0.333em; }
.pic { position: absolute; display: block; }
.pic canvas, .pic img { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.pic img { object-fit: cover; image-rendering: auto; opacity: 0; transition: opacity 0.25s; }
body.revealed .pic.has-real img { opacity: 1; }

/* subtitles (888) */
.subtitle { background: #000; }

/* status row: subpages, clues, the cat */
.status { color: var(--w); }
.status .sub { color: var(--w); }
.status button {
  font: inherit; line-height: 1em; height: 1em; padding: 0; margin: 0; border: 0;
  background: none; color: var(--c); cursor: pointer;
}
.status button:hover, .status button:focus-visible { background: var(--c); color: var(--k); outline: none; }

/* coloured keys */
.fastext { display: grid; grid-template-columns: repeat(4, 6em); }
.fastext a { padding: 0; }
.fastext a:nth-child(1) { color: var(--r); }
.fastext a:nth-child(2) { color: var(--g); }
.fastext a:nth-child(3) { color: var(--y); }
.fastext a:nth-child(4) { color: var(--c); }

/* searching for a page that isn't there */
.snow { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }

/* mix: the black goes see-through and the page sits over the painted sky */
.mixsky { position: fixed; inset: 0; background: url("images/sky.jpg") center / cover no-repeat; opacity: 0; transition: opacity 0.4s; pointer-events: none; }
body.mix .mixsky { opacity: 1; }
body.mix, body.mix html, body.mix .screen, body.mix .b-k, body.mix .subtitle { background: transparent !important; }
body.mix .screen { text-shadow: 0 0 0.08em #000; }
html:has(body.mix) { background: #000; }

/* attract mode: pages from the common people, full screen */
body.attract .remote, body.attract .remote-tab { opacity: 0; pointer-events: none; }

/* arthur the cat */
.cat { position: absolute; top: 0; height: 1em; color: var(--w); cursor: pointer; white-space: pre; z-index: 2; }
.cat:hover { color: var(--y); }

@media (prefers-reduced-motion: reduce) {
  .pic img, .mixsky { transition: none; }
}
