@font-face {
  font-family: "Soehne Mono";
  src: url("fonts/soehne-mono-web-kraftig.woff2") format("woff2"), url("fonts/soehne-mono-web-kraftig.woff") format("woff");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #ffffff;
  --ink: #111214;
  --hot: #4c8dff;
  --strip: 30px;          /* the tractor-feed strip down each edge */
  /* the faint bars across continuous paper */
  --bars: repeating-linear-gradient(0deg, transparent 0 48px, rgb(17 18 20 / 0.028) 48px 96px);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: "Soehne Mono", ui-monospace, Menlo, monospace;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  cursor: default;
}

/* The page is the paper: one long continuous sheet, far taller than the
   screen, fed upwards as it prints. Faint bars across it, and a strip of
   sprocket holes down each edge, torn off along a dotted line. */
.paper {
  position: fixed;
  left: 0;
  right: 0;
  top: -150vh;
  height: 400vh;
  background: var(--bars);
  will-change: transform;
}
.paper::before,
.paper::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--strip);
  background: radial-gradient(circle at 50% 12px, rgb(17 18 20 / 0.13) 0 4.5px, transparent 5px) 0 0 / var(--strip) 24px repeat-y;
}
.paper::before { left: 0; border-right: 1px dashed rgb(17 18 20 / 0.16); }
.paper::after { right: 0; border-left: 1px dashed rgb(17 18 20 / 0.16); }

.ink {
  position: absolute;
  left: 0;
  top: 150vh;
  display: block;
}

/* The real heading, for anything that reads the page rather than looks at it. */
.word {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Each printed link has a real one lying over it, live once it has printed. */
.links a,
.links button {
  padding: 0;
  border: 0;
  background: none;
  position: absolute;
  color: transparent;
  font-size: 1px;
  border-radius: 3px;
  pointer-events: none;
  outline: none;
  transition: background-color 150ms ease;
}
.links .printed { pointer-events: auto; cursor: pointer; }
.links .printed:focus-visible { background: rgb(76 141 255 / 0.22); }
@media (hover: hover) { .links .printed:hover { background: rgb(76 141 255 / 0.22); } }

/* The print head rides one fine guide line across the paper. */
.rail {
  position: fixed;
  left: var(--strip);
  right: var(--strip);
  height: 1px;
  background: rgb(17 18 20 / 0.14);
  transition: opacity 600ms ease;
}
/* The carriage: a dark moulded block with cooling fins up top, the ribbon
   running through it and out either side, and in the middle the steel nose
   that holds the nine pins. */
.head {
  position: fixed;
  left: 0;
  width: 34px;
  margin-left: -17px;
  border-radius: 5px;
  background: linear-gradient(180deg, #45464c 0, #26272b 14%, #131416 55%, #1d1e21 86%, #34353a 100%);
  box-shadow: 0 5px 10px rgb(17 18 20 / 0.3), 0 1px 2px rgb(17 18 20 / 0.4), inset 0 1px 0 rgb(255 255 255 / 0.22), inset 0 -1px 0 rgb(0 0 0 / 0.6), inset 1px 0 0 rgb(255 255 255 / 0.06);
  will-change: transform;
  transition: opacity 600ms ease;
}
.head i { position: absolute; }
.head .ribbon {
  left: -9px;
  right: -9px;
  top: calc(50% - 4px);
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(180deg, #050506, #2c2c31 45%, #0a0a0c);
  box-shadow: 0 1px 2px rgb(17 18 20 / 0.3);
}
.head .fins {
  left: 5px;
  right: 5px;
  top: 3px;
  height: 6px;
  background: repeating-linear-gradient(180deg, rgb(255 255 255 / 0.26) 0 1px, rgb(0 0 0 / 0.35) 1px 2px, transparent 2px 3px);
}
.head .nose {
  left: 50%;
  top: 12px;
  width: 10px;
  height: var(--band, 28px);
  margin-left: -5px;
  border-radius: 2px;
  background:
    radial-gradient(circle, #111214 0 1px, transparent 1.3px) center / 100% calc(100% / 9) repeat-y,
    linear-gradient(90deg, #7f8186, #f1f2f3 42%, #b4b6ba 70%, #8a8c90);
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.45), 0 1px 2px rgb(0 0 0 / 0.5);
}
.head .screw {
  left: 50%;
  bottom: 3px;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #d7d8da, #6f7175);
}
body.done .head { opacity: 0; }
body.done .rail { opacity: 0; }

.again,
.skip,
.in,
.sound {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom));
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: color 180ms ease, opacity 200ms ease;
}
/* Bottom left: "skip" while it prints, the printer (print again) once it has.
   All three controls are made of printer dots, like everything else. */
.again,
.skip,
.in,
.sound {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  padding: 0 8px;
  opacity: 0.45;
}
.again,
.skip { left: calc(var(--strip) + 4px); }
.sound { right: calc(var(--strip) + 4px); }
/* LinkedIn, just to the left of the speaker and as quiet as it */
.in { right: calc(var(--strip) + 4px + 46px); }
.again[hidden],
.skip[hidden] { display: none; }
.dotty { display: block; fill: currentColor; }
.sound[aria-pressed="true"] .off,
.sound[aria-pressed="false"] .on { display: none; }
.again:focus-visible,
.skip:focus-visible,
.in:focus-visible,
.sound:focus-visible { color: var(--hot); opacity: 1; outline: none; }
@media (hover: hover) {
  .again:hover,
  .skip:hover,
  .in:hover,
  .sound:hover { color: var(--hot); opacity: 1; }
}

/* ---------------------------------------------------------------- the game */

/* A clean stretch of the same paper laid over the page, with the game drawn
   on it in printer dots. The holes down the edges still show. */
.game {
  position: fixed;
  z-index: 5;
  inset: 0 var(--strip);
  background: var(--paper);
}
.game canvas {
  position: absolute;
  left: calc(var(--strip) * -1);
  top: 0;
  width: 100vw;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.game button {
  position: absolute;
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  padding: 0 10px;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  opacity: 0.5;
  transition: color 180ms ease, opacity 200ms ease;
}
/* The way out is always plain to see: "back", big and dark on its own patch of
   paper in the top corner, with "esc" under it where there is a keyboard. */
.game .game-back {
  top: max(8px, env(safe-area-inset-top));
  right: 6px;
  z-index: 1;
  height: 48px;
  padding: 0 16px;
  border: 1px dashed rgb(17 18 20 / 0.32);
  border-radius: 24px;
  background: var(--paper);
  opacity: 0.9;
}
.game-esc { position: absolute; z-index: 1; top: calc(max(8px, env(safe-area-inset-top)) + 54px); right: 22px; opacity: 0.35; pointer-events: none; }
@media (pointer: coarse) { .game-esc { display: none; } }
/* When a go is over: "again" and "back", side by side. */
.game-over { position: absolute; left: 50%; top: 72%; translate: -50% 0; display: flex; gap: 12px; }
.game-over[hidden] { display: none; }
.game .game-over button { position: static; height: 56px; padding: 0 22px; border: 1px dashed rgb(17 18 20 / 0.32); border-radius: 28px; background: var(--paper); opacity: 0.9; }
.game .game-over .game-again { border-style: solid; border-color: rgb(17 18 20 / 0.7); }
.game-again .dotty { scale: 1.3; }
.game button:focus-visible { color: var(--hot); opacity: 1; outline: none; }
@media (hover: hover) { .game button:hover { color: var(--hot); opacity: 1 !important; } }
/* The games played on the sheet itself have no paper of their own: the page
   shows through, and only their pieces are drawn over it. */
.game.play { background: none; }
.game.play canvas { cursor: crosshair; }
/* "again" and "back" sit low, clear of what is printed */
.game.play .game-over { top: auto; bottom: max(96px, 14vh); }
/* While a game is on, the page's own skip and reprint step aside; sound stays. */
body.gaming .again,
body.gaming .in,
body.gaming .skip { display: none; }
body.gaming .sound { z-index: 6; }

/* The way back to the first version: tiny, in the middle of the bottom row. */
.v1 {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  translate: -50% 0;
  display: grid;
  place-items: center;
  height: 44px;
  padding: 0 10px;
  color: inherit;
  opacity: 0.32;
  transition: color 180ms ease, opacity 200ms ease;
}
.v1:focus-visible { color: var(--hot); opacity: 1; outline: none; }
@media (hover: hover) { .v1:hover { color: var(--hot); opacity: 1; } }
body.gaming .v1 { display: none; }

/* ---------------------------------------------------------------- the drawing pad */

/* Another clean stretch of paper, with a sheet of faint dots to draw on.
   Everything on it sits where the screen says, so the sheet can be fed down
   past the controls and printed back up under the head. */
.draw {
  position: fixed;
  z-index: 5;
  inset: 0 var(--strip);
  background: var(--bars), var(--paper);      /* the same barred paper as the page */
}
.draw-sheet {
  position: fixed;
  will-change: transform;
}
.draw-sheet canvas { display: block; }
.draw[data-state="printing"] .draw-sheet,
.draw[data-state="printed"] .draw-sheet { outline-color: transparent; }
.draw[data-state="printing"] .draw-sheet canvas,
.draw[data-state="printed"] .draw-sheet canvas { cursor: default; }
/* its own head, out only while it prints */
.draw .head { opacity: 0; }
.draw[data-state="printing"] .head { opacity: 1; }

.draw button {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  padding: 0 10px;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  opacity: 0.55;
  transition: color 180ms ease, opacity 200ms ease;
}
.draw button[hidden],
.draw form[hidden] { display: none; }
.draw button:focus-visible,
.draw button[aria-pressed="true"] { color: var(--hot); opacity: 1; outline: none; }
@media (hover: hover) { .draw button:hover { color: var(--hot); opacity: 1; } }
.draw-back { position: fixed; z-index: 3; top: max(8px, env(safe-area-inset-top)); right: calc(var(--strip) + 4px); }

/* "log" sits top left, opposite "back". */
.draw-logs { position: fixed; z-index: 3; top: max(8px, env(safe-area-inset-top)); left: calc(var(--strip) + 4px); }

/* Under the sheet, a slip to fill in: what to draw, with the button that
   prints it, and under that a quieter line for a name. */
.draw-bar {
  position: fixed;
  left: var(--strip);
  right: var(--strip);
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 44px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);      /* so the slip is sized by the screen, not by what is in it */
  justify-items: center;
  transition: opacity 250ms ease;
}
.draw-ask { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; width: min(560px, calc(100% - 20px)); }
.draw-line { display: flex; align-items: center; gap: 10px; height: 46px; min-width: 0; }
.draw-line > label { flex: none; width: 46px; opacity: 0.5; }
.draw-line input {
  flex: 1;
  width: 0;
  min-width: 0;
  height: 40px;
  padding: 0 2px;
  border: 0;
  border-bottom: 1px dashed rgb(17 18 20 / 0.4);
  border-radius: 0;
  background: none;
  color: var(--ink);
  font: 16px/1 "Soehne Mono", ui-monospace, Menlo, monospace;
  letter-spacing: 0.01em;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
  touch-action: manipulation;
}
.draw-line input::placeholder { color: rgb(17 18 20 / 0.3); }
.draw-line input:focus { border-bottom-color: var(--hot); }
/* the one real button on the slip: boxed, so it reads as the thing to press */
.draw .draw-go {
  flex: none;
  height: 40px;
  padding: 0 12px;
  border: 1px dashed rgb(17 18 20 / 0.55);
  border-radius: 3px;
  opacity: 0.9;
}
.draw .draw-go:focus-visible { border-color: var(--hot); }
@media (hover: hover) { .draw .draw-go:hover { border-color: var(--hot); } }
/* the name is the lesser line: shorter and lighter */
.draw-sign { height: 36px; }
.draw-sign > label { opacity: 0.35; }
.draw-sign input { flex: 0 1 240px; height: 32px; border-bottom-color: rgb(17 18 20 / 0.22); font-size: 16px; color: rgb(17 18 20 / 0.75); }
.draw-tools { display: flex; align-items: center; justify-content: center; }
.draw[data-state="printing"] .draw-bar,
.draw[data-state="asking"] .draw-bar { opacity: 0; pointer-events: none; }

/* Something the printer has to say, in the middle of the empty sheet. */
.draw-say {
  position: fixed;
  left: var(--strip);
  right: var(--strip);
  top: calc(46% - 10px);
  display: grid;
  place-items: center;
  height: 20px;
  margin: 0;
  color: var(--hot);
  pointer-events: none;
}

/* The gallery: everyone's drawings, small, over the sheet. */
.draw-log {
  position: fixed;
  z-index: 2;
  inset: 0 var(--strip);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr));
  align-content: start;
  gap: 30px 22px;
  padding: 64px 18px 90px;
  overflow-y: auto;
  touch-action: pan-y;
  /* barred paper too, and the bars move with the drawings as it is scrolled */
  background: var(--bars) local, var(--paper);
}
.draw-log[hidden] { display: none; }
/* Over the gallery, at the foot: the way to ask for one of your own. */
.draw .draw-own {
  position: fixed;
  z-index: 3;
  left: 50%;
  bottom: max(16px, calc(env(safe-area-inset-bottom) + 12px));
  transform: translateX(-50%);
  height: 44px;
  padding: 0 14px;
  border: 1px dashed rgb(17 18 20 / 0.55);
  border-radius: 3px;
  background: var(--paper);
  opacity: 1;
  box-shadow: 0 6px 20px rgb(17 18 20 / 0.1);
}
.draw .draw-own:focus-visible { border-color: var(--hot); }
@media (hover: hover) { .draw .draw-own:hover { border-color: var(--hot); } }
@media (pointer: coarse) { .draw .draw-own { bottom: max(24px, calc(env(safe-area-inset-bottom) + 12px)); } }
.draw-log p { grid-column: 1 / -1; display: grid; place-items: center; height: 120px; margin: 0; opacity: 0.6; }
.draw .draw-log button {
  display: grid;
  justify-items: start;
  align-content: start;
  gap: 8px;
  height: auto;
  min-width: 0;
  padding: 0;
  opacity: 1;
  text-align: left;
}
.draw-log canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;      /* every frame the same shape, whatever shape the drawing */
  object-fit: contain;
  border: 1px dashed rgb(17 18 20 / 0.2);
  background: #fff;
  transition: border-color 180ms ease;
}
.draw-log div,
.draw-log span { display: grid; gap: 3px; }
.draw-log .dotty { opacity: 0.8; max-width: 100%; }
.draw-log span { opacity: 0.55; }
.draw-log button:focus-visible canvas { border-color: var(--hot); }
@media (hover: hover) { .draw-log button:hover canvas { border-color: var(--hot); } }

/* ---------------------------------------------------------------- on real paper */

/* What goes to the printer (or a PDF) is the drawing alone. */
.print-out { display: none; }
@media print {
  @page { margin: 0; }                      /* no room for the browser's own date and address */
  html, body { height: auto; overflow: visible; background: #fff; }
  body > *:not(.print-out) { display: none !important; }
  .print-out { display: block; padding: 18mm; }
  .print-out svg { display: block; width: 100%; height: auto; max-height: 250mm; margin: 0 auto; }
}

/* The page's own head and guide line stay out of the way of a game or the pad. */
body.gaming > .head,
body.gaming > .rail { opacity: 0; }

/* On a phone, keep the bottom row clear of the bottom edge, where the browser
   takes taps for its own toolbar and the home bar. */
@media (pointer: coarse) {
  .again, .skip, .in, .sound { bottom: max(24px, calc(env(safe-area-inset-bottom) + 12px)); }
  .draw-bar { bottom: calc(max(24px, calc(env(safe-area-inset-bottom) + 12px)) + 44px); }
}
