/* o1next — the site theme.
 *
 * Colours are sampled from a photograph of the machine (oldcomputers.net,
 * osborne-1-rev2.jpg): the blue-grey front panel, the pale grey lid and base,
 * and the cream keycaps.  Sampling was done on the actual pixels, not by eye:
 *
 *   front panel, lit      #687898     keyboard surround, shade   #607090
 *   lid / base            #d0d8d8     keycaps                    #d8d0c0
 *
 * The body face is the Osborne 1's own character generator, extracted from the
 * 2716 in UA15 by tools/romfont.py — so the page is set in the same letters the
 * machine drew on its own screen.
 *
 * It is a fixed 8x10 pixel cell, and the machine has three text widths: 52, 80
 * and 104 columns.  The screen is a fixed width and only the type narrows, so
 * tools/romfont.py emits the same glyphs at 100%, 65% and 50% dot width — one
 * face per mode, identical in height.
 *
 * That is why 52ch in the 52-column face, 80ch in the 80-column face and 104ch
 * in the 104-column face are all the *same physical width*.  The site pairs a
 * face with its own column count and gets the machine's 80-column mode — the
 * width this project's video work is about — at a readable measure.  To change
 * mode, change --mono and --measure together.
 */

/* One face per display width.  Same height, same pixel components; only the
 * horizontal dot width differs.  See the header comment and tools/romfont.py. */
@font-face {
  font-family: "Osborne 1 52";
  src: url("fonts/osborne1-52.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Osborne 1 80";
  src: url("fonts/osborne1-80.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Osborne 1 104";
  src: url("fonts/osborne1-104.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --blue: #687898;
  --blue-deep: #9db0d0;   /* the panel blue, lifted to read on a black screen */
  --blue-ink: #2b3547;    /* text on the grey footer */
  --grey: #d0d8d8;
  --grey-soft: #16191c;   /* code and quotes, now on the dark side */
  --cream: #d8d0c0;
  --paper: #0b0c0e;       /* the CRT: white on black, not the green of the last
                             production run -- that is a monitor option, and the
                             video personality has to offer both (#24) */
  --ink: #e9e7e0;
  --rule: #2b3034;

  --cell: 15px;
  /* The machine's three text modes.  Pair the face with its own column count --
   * 52/52, 80/80, 104/104 -- because all three are the same physical width: a
   * wider mode means a proportionally narrower dot (tools/romfont.py).  The
   * default is the 80-column mode, the width the video work is about. */
  --mono: "Osborne 1 80", ui-monospace, "SF Mono", Menlo, Consolas,
          "DejaVu Sans Mono", monospace;
  --measure: 80ch;
}

* { box-sizing: border-box; }

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

/* The masthead and the footer are the case; the middle is the screen.  Only the
 * screen scrolls: the header stays on the top of the window and the footer on the
 * bottom, which is what a machine with a fixed case and one display does. */
html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: var(--cell);
  line-height: 1.5;
  /* Safari will render a pixel font crisply; the others antialias it */
  -webkit-font-smoothing: none;
}

.wrap {
  max-width: calc(var(--measure) + 2.5rem);
  margin: 0 auto;
  padding: 0 1.25rem;
}

a { color: var(--blue-deep); text-decoration-thickness: 1px; }
a:hover { color: var(--blue-ink); }

h1, h2, h3 { line-height: 1.2; margin: 1.6em 0 0.6em; }
h1 { font-size: 1.4em; }
h2 { font-size: 1.2em; }
h3 { font-size: 1.05em; }

hr { border: 0; border-top: 1px solid var(--rule); margin: 2em 0; }

blockquote {
  margin: 1.5em 0;
  padding: 0.1em 1em;
  border-left: 4px solid var(--blue);
  background: var(--grey-soft);
}

code, pre { font-family: var(--mono); font-size: 1em; }

pre {
  overflow-x: auto;
  padding: 0.9em 1em;
  background: var(--grey-soft);
  border-left: 4px solid var(--blue);
}

code { background: var(--grey-soft); padding: 0 0.2em; }
pre code { background: none; padding: 0; }

img { max-width: 100%; height: auto; }

/* ---- masthead: the machine's blue front panel ---- */
.site-header {
  flex: 0 0 auto;
  background: var(--blue);
  color: #f1f4f6;
  border-bottom: 6px solid var(--blue-ink);
}

.site-header .wrap {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding-top: 1.1rem;
  padding-bottom: 1.1rem;
}

/* The logo, with the SCREEN PAC box stacked to its right.  `align-items:
 * stretch` is what makes that box exactly the logo's height. */
.masthead {
  display: flex;
  align-items: stretch;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand { display: block; color: inherit; }
.brand img { display: block; width: min(420px, 68vw); height: auto; }

/* The menu is left justified -- never pushed to the right -- and the items are
 * divided by a literal | so the grouping still reads when the row wraps. */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-start;
  gap: 0 0.7rem;
}
.site-nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  /* At 52 columns the face is wide, and a nav label breaking mid-phrase reads
   * as a mistake rather than as wrapping. Let the flex row wrap instead. */
  white-space: nowrap;
}
.site-nav a:hover { color: #fff; border-bottom-color: var(--cream); }
.nav-sep { color: var(--blue-deep); }

/* ---- the SCREEN PAC switch ----
 *
 * A box the height of the logo, standing to its right: the top half names it,
 * the bottom half is split three ways for the machine's three text modes.
 *
 * Each radio forces the matching FACE and its own column count together, so the
 * rendered window is exactly the same width in all three -- the type narrows,
 * the screen does not (see the header comment and tools/romfont.py).
 *
 * Pure CSS, via :has() -- no JavaScript, so the site keeps its no-script
 * character.  Where :has() is unsupported the :root default (80 columns) simply
 * stands, which is a correct mode rather than a broken one.
 */
.screenpac {
  display: grid;
  grid-template-rows: 1fr 1fr;   /* the name, then the modes */
  border: 2px solid var(--cream);
  color: var(--cream);
  font-size: 0.8em;
  line-height: 1;
  white-space: nowrap;
}
.screenpac-name {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.9rem;
  border-bottom: 2px solid var(--cream);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.screenpac-modes {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.screenpac-modes input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.screenpac-modes label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 3em;
  padding: 0 0.5rem;
  cursor: pointer;
}
.screenpac-modes label + label { border-left: 2px solid var(--cream); }
.screenpac-modes label:hover { background: var(--blue-ink); }
.screenpac-modes input:checked + label {
  background: var(--cream);
  color: var(--blue-ink);
}
.screenpac-modes input:focus-visible + label {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

/* `ch` is the selected face's own advance width, so 52ch, 80ch and 104ch are
 * all the same physical width once the face matches the count. */
body:has(#columns-52:checked) {
  --mono: "Osborne 1 52", ui-monospace, "SF Mono", Menlo, Consolas,
          "DejaVu Sans Mono", monospace;
  --measure: 52ch;
}
body:has(#columns-80:checked) {
  --mono: "Osborne 1 80", ui-monospace, "SF Mono", Menlo, Consolas,
          "DejaVu Sans Mono", monospace;
  --measure: 80ch;
}
body:has(#columns-104:checked) {
  --mono: "Osborne 1 104", ui-monospace, "SF Mono", Menlo, Consolas,
          "DejaVu Sans Mono", monospace;
  --measure: 104ch;
}

/* ---- content: the screen, and the only thing that scrolls ---- */
.page-content {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2.2rem 0 3rem;
}
.page-content > .wrap > :first-child { margin-top: 0; }

/* ---- post list ---- */
.post-list { list-style: none; margin: 0; padding: 0; }
.post-list li { margin-bottom: 1.4rem; }
.post-meta { display: block; color: var(--blue-deep); font-size: 0.9em; }
.post-list h3 { margin: 0.15em 0 0; }
.post-link { text-decoration: none; }
.post-link:hover { text-decoration: underline; }

/* ---- a post ---- */
.post-header {
  margin-bottom: 1.8em;
  padding-bottom: 0.7em;
  border-bottom: 3px solid var(--rule);
}
.post-title { margin: 0 0 0.15em; }
.post-meta .post-author { color: var(--blue-deep); }
.post-content h2 { border-bottom: 1px solid var(--rule); padding-bottom: 0.15em; }

/* ---- tables ---- */
table { border-collapse: collapse; width: 100%; margin: 1.5em 0; }
th, td { border: 1px solid var(--rule); padding: 0.35em 0.6em; text-align: left; }
th { background: #1b1f23; }

/* ---- footer: the base of the machine ---- */
.site-footer {
  flex: 0 0 auto;
  background: var(--grey);
  border-top: 6px solid var(--blue);
  color: var(--blue-ink);
  padding: 1.3rem 0;
  font-size: 0.9em;
}
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 0.6rem 1.5rem; }
.site-footer p { margin: 0; }
.site-footer .colophon { margin-left: auto; }
.site-footer a { color: var(--blue-ink); }

/* ---- content pages (Hardware, the Compendium) ---- */
.page-header {
  margin-bottom: 1.8em;
  padding-bottom: 0.7em;
  border-bottom: 3px solid var(--rule);
}
.page-title { margin: 0 0 0.15em; }
.page-subtitle { margin: 0; color: var(--blue-deep); font-size: 0.95em; }
.page-body h2 { border-bottom: 1px solid var(--rule); padding-bottom: 0.15em; }

/* The Compendium is assembled from working docs, so every page says so. */
.draft-banner {
  margin: 0 0 1.8em;
  padding: 0.7em 1em;
  background: var(--grey-soft);
  border-left: 4px solid var(--cream);
  color: var(--cream);
  font-size: 0.9em;
}

/* ---- the Compendium table of contents ---- */
.toc { list-style: none; margin: 0.5em 0 1.5em; padding: 0; }
.toc li { margin: 0.25em 0; }
.toc .toc-part {
  margin-top: 1.2em;
  color: var(--blue-deep);
  font-size: 0.9em;
}
.toc .toc-status { color: var(--blue-deep); font-size: 0.85em; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
