/* ByteVortex: a man page printed on green-bar fanfold, or read on an amber
   terminal after dark. Every vertical measure is a multiple of --lh so the
   green bars stay in step with the lines of text. */

@font-face {
  font-family: "Plex Mono";
  src: url("/assets/fonts/plex-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("/assets/fonts/plex-mono-latin-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("/assets/fonts/plex-mono-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --lh: 1.5rem;
  --indent: 7ch;
  --strip: 3rem;

  --desk: #c6cbbf;
  --paper: #f4f7ef;
  --bar: #dfecd8;
  --ink: #1f2622;
  --ink-soft: #536058;
  --ribbon: #a8261b;
  --rule: #a9b6a3;
  --glow: none;
  --strip-display: block;
  --paper-pad: calc(var(--strip) + 2ch);
  --paper-max: calc(80ch + 2 * var(--strip));
  color-scheme: light;
}

/* Dark is the amber terminal. It applies when the system asks for dark, or
   when the optional theme switch flips a light system to dark. */
@media (prefers-color-scheme: dark) {
  :root:not(:has(#theme-flip:checked)) {
    --desk: #181207;
    --paper: #181207;
    --bar: rgba(255, 181, 71, 0.035);
    --ink: #ffb547;
    --ink-soft: #c58f42;
    --ribbon: #ffe0a3;
    --rule: #5a4422;
    --glow: 0 0 0.45em rgba(255, 166, 50, 0.28);
    --strip-display: none;
    --paper-pad: 2ch;
    --paper-max: calc(80ch + 4ch);
    color-scheme: dark;
  }
}
@media (prefers-color-scheme: light) {
  :root:has(#theme-flip:checked) {
    --desk: #181207;
    --paper: #181207;
    --bar: rgba(255, 181, 71, 0.035);
    --ink: #ffb547;
    --ink-soft: #c58f42;
    --ribbon: #ffe0a3;
    --rule: #5a4422;
    --glow: 0 0 0.45em rgba(255, 166, 50, 0.28);
    --strip-display: none;
    --paper-pad: 2ch;
    --paper-max: calc(80ch + 4ch);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font: 400 1rem/var(--lh) "Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  text-shadow: var(--glow);
  font-variant-ligatures: none;
}

/* The sheet, with its tractor-feed strips either side. */
.paper {
  position: relative;
  max-width: var(--paper-max);
  min-height: 100vh;
  margin: 0 auto;
  padding: var(--lh) var(--paper-pad) calc(var(--lh) * 2);
  background:
    repeating-linear-gradient(to bottom,
      var(--bar) 0 calc(var(--lh) * 3),
      transparent calc(var(--lh) * 3) calc(var(--lh) * 6))
    var(--paper);
  background-origin: border-box;
}
.paper::before,
.paper::after {
  content: "";
  display: var(--strip-display);
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--strip);
  background:
    radial-gradient(circle at 50% 50%, var(--desk) 0 0.42rem, var(--rule) 0.42rem 0.5rem, transparent 0.5rem)
    0 calc(var(--lh) * 0.5) / 100% calc(var(--lh) * 3) repeat-y,
    var(--paper);
}
.paper::before { left: 0; border-right: 1px dashed var(--rule); }
.paper::after { right: 0; border-left: 1px dashed var(--rule); }

/* Running header and footer, as man(1) prints them. */
.runhead,
.runfoot {
  display: flex;
  justify-content: space-between;
  gap: 2ch;
  margin: 0;
}
.runhead a { color: inherit; text-decoration: none; }
.runhead a:hover { text-decoration: underline; }
.runfoot { margin-top: calc(var(--lh) * 2); color: var(--ink-soft); }

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 2ch;
  margin: 0 0 calc(var(--lh) * 2);
  padding-left: var(--indent);
}

a { color: var(--ribbon); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--ribbon); outline-offset: 2px; }

/* The optional theme switch: a checkbox, so it needs no script. */
.flip {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.flip-label {
  color: var(--ribbon);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.flip:focus-visible ~ .paper .flip-label { outline: 2px solid var(--ribbon); outline-offset: 2px; }

.skip {
  position: absolute;
  left: -100vw;
  top: 0;
  z-index: 2;
  padding: 0 1ch;
  background: var(--paper);
}
.skip:focus { left: 1ch; }

/* The banner page that headed every print job. */
.banner { margin: 0 0 calc(var(--lh) * 2); overflow: hidden; }
.banner pre {
  margin: 0;
  font-weight: 600;
  font-size: min(1rem, calc((100vw - 4ch) / 68 / 0.6));
  line-height: 1.5;
  animation: print 1.1s steps(7, end) both;
}
@keyframes print {
  from { clip-path: inset(0 0 100% 0); }
  to { clip-path: inset(0 0 0 0); }
}

/* Sections: heading in column one, body indented, exactly as in man(1). */
.sh { margin: 0 0 var(--lh); }
.sh h2 {
  margin: 0;
  font-size: 1rem;
  line-height: var(--lh);
  font-weight: 600;
}
.sb { padding-left: var(--indent); }

h1, h3 {
  margin: 0 0 var(--lh);
  font-size: 1rem;
  line-height: var(--lh);
  font-weight: 400;
}
h3 { font-weight: 600; margin-bottom: 0; }
h3 a { color: inherit; }

p, ul, ol, dl, blockquote, pre { margin: 0 0 var(--lh); }

b, strong, dt { font-weight: 600; }
code { font-family: inherit; font-weight: 600; }

.synopsis i { text-decoration: underline; font-style: normal; }

.entry { margin: 0 0 calc(var(--lh) * 2); }
.entry > p:first-of-type { margin-top: 0; }

blockquote {
  margin-left: 0;
  padding-left: 2ch;
  border-left: 2px solid var(--ribbon);
  color: var(--ribbon);
  font-style: italic;
}

/* Two-column facts: key, value. */
.facts {
  display: grid;
  grid-template-columns: 11ch 1fr;
  gap: 0 2ch;
}
.facts dt { color: var(--ink-soft); font-weight: 400; }
.facts dd { margin: 0; }

/* Option lists: term flush, description indented beneath it. */
.opts dt { margin: 0; }
.opts dd { margin: 0 0 var(--lh) var(--indent); }
.opts dd:last-child { margin-bottom: 0; }

.links { display: flex; flex-wrap: wrap; gap: 0 3ch; }

.caveat { color: var(--ink-soft); font-style: italic; }

.steps { padding-left: 4ch; }

.shell {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-weight: 600;
}
.prompt { color: var(--ink-soft); }

.button {
  display: inline-block;
  min-height: calc(var(--lh) * 2);
  padding: calc(var(--lh) / 2 - 2px) 2ch;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  text-shadow: inherit;
  cursor: pointer;
}
.button::before { content: "[ "; }
.button::after { content: " ]"; }
.button:hover,
.button:focus-visible { background: var(--ink); color: var(--paper); text-shadow: none; }

/* Contact form. */
.form { max-width: 60ch; }
.form label { display: block; }
.form label code { margin-right: 1ch; }
.form input,
.form select,
.form textarea {
  display: block;
  width: 100%;
  margin: 0 0 var(--lh);
  padding: 0 1ch;
  min-height: var(--lh);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: inset 0 -1px 0 var(--ink);
  color: inherit;
  font: inherit;
  text-shadow: inherit;
}
.form select {
  appearance: none;
  padding-right: 4ch;
  cursor: pointer;
  /* A chevron drawn from two gradients, so it follows the ink colour. */
  background:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%) calc(100% - 1.6ch) 55% / 0.4rem 0.4rem no-repeat,
    linear-gradient(135deg, var(--ink) 50%, transparent 50%) calc(100% - 1ch) 55% / 0.4rem 0.4rem no-repeat;
}
.form select option { background: var(--paper); color: var(--ink); }
.form textarea {
  line-height: var(--lh);
  box-shadow: inset 0 0 0 1px var(--ink);
  padding: 0 1ch;
  resize: vertical;
}
.form input:focus-visible,
.form select:focus-visible,
.form textarea:focus-visible { outline: 2px solid var(--ribbon); outline-offset: 0; }
.notice { color: var(--ink-soft); }

.trap {
  position: absolute;
  left: -100vw;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.errors { color: var(--ribbon); }
.errors ul { list-style: none; padding: 0; }

/* Narrow screens: drop the tractor strips and most of the indent. */
@media (max-width: 40rem) {
  :root { --indent: 2ch; --strip: 0rem; }
  html { font-size: 93.75%; }
  .paper { padding-left: 2ch; padding-right: 2ch; }
  .paper::before, .paper::after { display: none; }
  .runhead span:first-child, .runfoot span:nth-child(2) { display: none; }
  .nav { padding-left: 0; }
  .facts { grid-template-columns: 1fr; }
  .facts dd { margin-bottom: 0; padding-left: 2ch; }
  /* Seven banner rows in exactly four lines, to keep the bars in step. */
  .banner pre { line-height: calc(var(--lh) * 4 / 7); }
}

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

@media print {
  :root { --bar: transparent; --glow: none; }
  body { background: #fff; color: #000; }
  .nav, .skip, .cta, .paper::before, .paper::after { display: none; }
  .paper { max-width: none; padding: 0; }
  a { color: inherit; }
}
