/* The Printer: the HUD is the printer's own labelling. Small caps, engraved beige on smoke, one green LED, one amber. */
:root {
  --smoke: #0a0705;
  --smoke-2: #17110d;
  --beige: #d6caa9;
  --beige-2: #b7aa88;
  --beige-3: #8a7f63;
  --key-ink: #2a2620;
  --lamp: #ffb45e;
  --led: #46e47f;
  --amber: #ffa31a;
  --paper: #f7f4e8;
  --band: #dcebd5;
  --ink: #1d2127;
  --ink-soft: #545a62;
  --dots: "Doto", "Courier Prime", monospace;
  --mono: "Courier Prime", "Courier New", Courier, monospace;
  --ed-fg: var(--beige);
  --ed-bg: rgba(16, 11, 8, .86);
  --ed-line: rgba(214, 202, 169, .32);
  --ed-accent: var(--amber);
  --ed-font: var(--mono);
  --ed-radius: 8px;
  --gut: max(16px, env(safe-area-inset-left));
}
* { box-sizing: border-box; }
html { background: var(--smoke); color: var(--beige); }
body {
  margin: 0;
  min-height: 100vh;
  font: 400 16px/1.5 var(--mono);
  background: radial-gradient(120% 80% at 30% 20%, #2a1c10 0%, var(--smoke) 62%);
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 1.2s ease;
  touch-action: none;
  z-index: 0;
}
html.gl #gl { opacity: 1; }
html.gl body { overflow: hidden; height: 100vh; height: 100dvh; }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; display: none; }
html.gl .hud { display: block; animation: hudin 1.4s ease .3s both; }
@keyframes hudin { from { opacity: 0; } }
.hud > * { pointer-events: auto; }

.plate {
  position: absolute;
  left: max(28px, env(safe-area-inset-left));
  top: max(26px, env(safe-area-inset-top));
  max-width: 25rem;
  padding: 0;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .7), 0 0 22px rgba(0, 0, 0, .8);
  pointer-events: none;
}
.plate > * { pointer-events: auto; }
.plate .kicker { margin: 0 0 .7rem; font-size: .72rem; letter-spacing: .26em; text-transform: uppercase; color: var(--beige-2); }
.plate h1 {
  margin: 0;
  font: 900 clamp(2.1rem, 3.8vw, 3.1rem)/1 var(--dots);
  letter-spacing: .02em;
  color: #f1e6c6;
  text-shadow: 0 0 18px rgba(255, 180, 94, .35), 0 2px 0 rgba(0, 0, 0, .6);
}
.plate .role { margin: .55rem 0 0; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; font-size: .86rem; color: var(--beige); }
.plate .lede { margin: .9rem 0 0; font-size: 1rem; max-width: 22rem; color: #e7dcc0; }
.plate .status { display: flex; gap: .7rem; align-items: flex-start; margin: 1rem 0 0; font-size: .85rem; color: var(--beige); max-width: 22rem; }
.plate .status .led { margin-top: .32rem; flex: none; }

.led { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--led); box-shadow: 0 0 0 1px rgba(0, 0, 0, .5), 0 0 10px 1px rgba(70, 228, 127, .85); }
.led.amber { background: var(--amber); box-shadow: 0 0 0 1px rgba(0, 0, 0, .5), 0 0 10px 1px rgba(255, 163, 26, .85); }
.led.off { background: #2b2a24; box-shadow: 0 0 0 1px rgba(0, 0, 0, .6) inset; }

.projects { position: absolute; right: max(28px, env(safe-area-inset-right)); top: max(26px, env(safe-area-inset-top)); width: 15.5rem; text-shadow: 0 1px 0 rgba(0,0,0,.7); pointer-events: none; }
.projects > * { pointer-events: auto; }
.projects .cap, .links + .cap { margin: 0 0 .5rem; font-size: .7rem; letter-spacing: .26em; text-transform: uppercase; color: var(--beige-2); text-align: right; }
.projects ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid rgba(214, 202, 169, .22); }
.projects li { border-bottom: 1px solid rgba(214, 202, 169, .22); }
.projects a {
  display: grid; grid-template-columns: 1fr auto; gap: .8rem; align-items: baseline;
  padding: .55rem .15rem; text-decoration: none; font-size: .88rem; min-height: 40px;
  transition: background .15s, color .15s;
}
.projects a b { font-weight: 700; }
.projects a span { font-size: .72rem; color: var(--beige-2); letter-spacing: .04em; }
.projects a:hover, .projects a:focus-visible { background: rgba(255, 180, 94, .12); color: #fff3d6; }

.links { position: absolute; right: max(28px, env(safe-area-inset-right)); bottom: max(26px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; text-shadow: 0 1px 0 rgba(0,0,0,.8); pointer-events: none; }
.links > * { pointer-events: auto; }
.lk { display: inline-flex; align-items: baseline; gap: .8rem; padding: .35rem .2rem; font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; text-decoration: none; color: var(--beige); border-bottom: 1px solid rgba(214,202,169,.22); min-height: 34px; }
.lk small { font-size: .72rem; letter-spacing: .02em; text-transform: none; color: var(--beige-2); }
.lk:hover, .lk:focus-visible { color: #fff3d6; border-bottom-color: var(--amber); }
.lk.phone { border-color: var(--led); color: #cfffe0; }

/* the deck: a strip of keycaps, like the front of the printer */
.deck {
  position: absolute;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, #ddd1b0, #bdb08d);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .45) inset, 0 -2px 0 rgba(0, 0, 0, .18) inset, 0 10px 30px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0, 0, 0, .4);
}
.key {
  all: unset;
  box-sizing: border-box;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0 .95rem;
  border-radius: 8px;
  cursor: pointer;
  font: 700 .72rem/1 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--key-ink);
  background: linear-gradient(180deg, #e9dfc2, #cfc3a0);
  box-shadow: 0 3px 0 #8d8163, 0 4px 6px rgba(0, 0, 0, .35), 0 1px 0 rgba(255, 255, 255, .7) inset;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .55);
  transition: transform .06s, box-shadow .06s, background .2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.key kbd { font: 400 .62rem var(--mono); opacity: .55; letter-spacing: 0; border: 1px solid rgba(0,0,0,.3); border-radius: 3px; padding: .08rem .28rem; }
.key:active, .key.down { transform: translateY(3px); box-shadow: 0 0 0 #8d8163, 0 1px 2px rgba(0, 0, 0, .35); }
.key:focus-visible { outline: 2px solid #1d6b3a; outline-offset: 2px; }
.key[aria-pressed="false"] .led:not(.amber) { background: #2b2a24; box-shadow: 0 0 0 1px rgba(0, 0, 0, .6) inset; }
.key.snd[aria-pressed="false"] .led { background: #2b2a24; box-shadow: 0 0 0 1px rgba(0, 0, 0, .6) inset; }
.key.read[aria-pressed="true"] { background: linear-gradient(180deg, #f3e7c3, #ddd0a8); box-shadow: 0 1px 0 #8d8163, 0 0 14px rgba(255, 180, 94, .55), 0 1px 0 rgba(255,255,255,.7) inset; transform: translateY(2px); }
.key.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 3px 0 #8d8163, 0 0 18px 3px rgba(255, 180, 94, .85), 0 1px 0 rgba(255, 255, 255, .7) inset; } }

.newpaper {
  all: unset; box-sizing: border-box; cursor: pointer; position: absolute; left: 50%; bottom: calc(max(22px, env(safe-area-inset-bottom)) + 76px); transform: translateX(-50%);
  padding: .6rem 1rem; min-height: 44px; font: 700 .72rem var(--mono); letter-spacing: .14em; text-transform: uppercase;
  color: #ffe9bd; background: rgba(20, 14, 10, .85); border: 1px solid var(--amber); border-radius: 8px;
}
.newpaper[hidden] { display: none; }

.hint {
  position: absolute; left: 50%; bottom: calc(max(22px, env(safe-area-inset-bottom)) + 78px); transform: translateX(-50%);
  margin: 0; padding: .35rem .8rem; font-size: .78rem; letter-spacing: .08em; color: var(--beige); text-align: center; white-space: nowrap;
  background: rgba(16, 11, 8, .78); border-radius: 999px; transition: opacity .8s; pointer-events: none;
}
.hint.gone { opacity: 0; }
.toast {
  position: absolute; left: 50%; top: 22px; transform: translate(-50%, -8px); opacity: 0; max-width: min(34rem, calc(100vw - 32px));
  padding: .55rem 1rem; border-radius: 8px; background: rgba(16, 11, 8, .9); border: 1px solid rgba(214, 202, 169, .35);
  font-size: .8rem; letter-spacing: .06em; text-align: center; transition: opacity .3s, transform .3s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
html.reading .plate .lede, html.reading .plate .status { opacity: .0; pointer-events: none; }
html.reading .plate, html.reading .projects { transition: opacity .6s; }
html.reading .projects { opacity: .0; pointer-events: none; }
html.reading .plate h1 { font-size: 1.5rem; }
html.reading .plate .kicker { margin-bottom: .3rem; }
html.reading .hint { opacity: 0; }

/* ---------- the document: real HTML, also the no-WebGL page and the plain-text sheet ---------- */
.doc { position: relative; z-index: 2; padding: 3rem 12px 5rem; color: var(--ink); outline: none; }
.sheet {
  position: relative; display: grid; grid-template-columns: 2.5rem minmax(0, 1fr) 2.5rem; max-width: 52rem; margin: 0 auto;
  background: var(--paper); box-shadow: 0 2px 4px rgba(0, 0, 0, .35), 0 28px 60px rgba(0, 0, 0, .55);
}
.tractor { background: radial-gradient(circle, var(--smoke) 0 .4rem, transparent .45rem) 50% 1.4rem / 100% 2.8rem repeat-y; }
.page { padding: 1.5rem clamp(1rem, 4vw, 3rem) 3rem; background: repeating-linear-gradient(to bottom, var(--band) 0 4.5rem, transparent 4.5rem 9rem); font-size: 1rem; line-height: 1.5rem; }
.page .runhead { display: flex; justify-content: space-between; font-size: .8rem; letter-spacing: .08em; color: var(--ink-soft); }
.page .name { margin: 1.5rem 0 0; font: 900 clamp(2.3rem, 8vw, 4rem)/4.5rem var(--dots); letter-spacing: .02em; color: var(--ink); }
.page h3 { margin: 3rem 0 1.5rem; font: 900 1.4rem/1.5rem var(--dots); letter-spacing: .06em; text-transform: uppercase; }
.page p { margin: 0 0 1.5rem; max-width: 42em; }
.page .titleline { margin-top: 0; }
.page .lede { font-size: 1.12rem; }
.page a { color: var(--ink); text-decoration: underline 1px; text-underline-offset: 3px; }
.page a:hover, .page a:focus-visible { background: linear-gradient(transparent 55%, #fff06a 55% 92%, transparent 92%); }
.ledger { list-style: none; margin: 0 0 1.5rem; padding: 0; max-width: 42em; }
.ledger li { display: flex; align-items: flex-end; }
.ledger i { flex: 1; min-width: 2ch; margin: 0 1ch .45rem; border-bottom: 2px dotted var(--ink-soft); }
.built { margin: 0; max-width: 42em; }
.built dt { font-weight: 700; }
.built dt span { font-weight: 400; color: var(--ink-soft); margin-left: 1ch; }
.built dd { margin: 0 0 1.5rem 3ch; }
.tearbtn { font: 700 .85rem var(--mono); letter-spacing: .08em; text-transform: uppercase; padding: .6rem 1rem; min-height: 44px; border: 2px dashed var(--ink); background: transparent; color: var(--ink); cursor: pointer; }
.tearbtn:hover { background: #fff06a; }
#dial { font-weight: 700; font-size: 1.15rem; }
.eor { margin-top: 3rem; text-align: center; letter-spacing: .1em; color: var(--ink-soft); }
.page .close { display: none; }

/* with WebGL the document is screen-reader text until the visitor opens it */
html.gl .doc:not(.open) {
  position: fixed; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; z-index: -1;
}
html.gl .doc.open {
  position: fixed; inset: 0; z-index: 30; overflow: auto; background: rgba(6, 4, 3, .88); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding-top: max(1.5rem, env(safe-area-inset-top));
}
html.gl .doc.open .close {
  display: block; position: sticky; top: 0; margin: 0 0 1rem auto; padding: .6rem 1rem; min-height: 44px; font: 700 .75rem var(--mono); letter-spacing: .14em; text-transform: uppercase;
  background: var(--ink); color: var(--paper); border: 0; cursor: pointer; z-index: 3;
}
html:not(.gl) body { overflow: auto; }

@media (max-width: 760px) {
  /* the paper fills a phone screen, so the title needs its own backing to stay readable over print */
  .plate { left: 8px; top: max(8px, env(safe-area-inset-top)); max-width: calc(100vw - 150px); padding: 10px 12px; background: rgba(16, 11, 8, .82); border-radius: 10px; }
  html.reading .plate .lede, html.reading .plate .status { display: none; } /* faded out already; stop them padding the backing */
  .plate .kicker { font-size: .62rem; letter-spacing: .18em; margin-bottom: .4rem; }
  .plate h1 { font-size: 1.7rem; }
  .plate .role { font-size: .74rem; margin-top: .4rem; letter-spacing: .08em; }
  .plate .lede { font-size: .86rem; margin-top: .6rem; max-width: 100%; }
  .plate .status { font-size: .78rem; margin-top: .6rem; }
  .projects, .links { display: none; }
  .deck { left: 8px; right: 8px; transform: none; bottom: max(10px, env(safe-area-inset-bottom)); gap: 5px; padding: 8px 8px 10px; justify-content: space-between; }
  .key { flex: 1 1 0; min-width: 0; padding: 0 .2rem; font-size: .62rem; letter-spacing: .06em; flex-direction: column; gap: .3rem; min-height: 48px; }
  .key kbd { display: none; }
  .key .led { position: absolute; top: 5px; right: 5px; }
  edition-switcher { left: 8px; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 84px); }
  .hint { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 136px); font-size: .72rem; white-space: normal; width: calc(100vw - 32px); }
  .newpaper { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 136px); }
  #k-tear { display: none; }
  .toast { top: auto; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 196px); }
  .sheet { grid-template-columns: 1.2rem minmax(0, 1fr) 1.2rem; }
  .tractor { background-size: 100% 2rem; background-image: radial-gradient(circle, var(--smoke) 0 .26rem, transparent .3rem); }
  .page .name { line-height: 3rem; }
  .ledger li { flex-wrap: wrap; }
  .ledger i { display: none; }
  .ledger li > span:last-child { width: 100%; padding-left: 3ch; color: var(--ink-soft); }
}
@media (max-width: 1000px) and (min-width: 761px) {
  .projects { width: 12.5rem; }
  .deck .key { padding: 0 .6rem; }
  .deck .key kbd { display: none; }
}
@media (max-height: 560px) and (min-width: 761px) { .hint { display: none; } }
@media (prefers-reduced-motion: reduce) {
  #gl { transition: none; }
  html.gl .hud { animation: none; }
  .key.pulse { animation: none; }
  .toast, .hint { transition: none; }
}
