/* IBM VGA 8x16 from VileR's Ultimate Oldschool PC Font Pack (CC BY-SA 4.0), int10h.org */
@font-face {
  font-family: "IBM VGA 8x16";
  src: url("fonts/vga-8x16.woff") format("woff");
  font-display: swap;
}

:root {
  --bg: #131313;
  --fg: #d5d5d5;
  --text: #c0c0c0;
  --dim: #aaa;
  --mid: #888;
  --bright: #fff;
  --panel: #1c1c1c; /* window interior, a step above --bg */
  --shadow: #333;
  --shadow-offset: 7px; /* how far window shadows sit right and down */
  --preview: 368px; /* standard post preview inner width; 46 ANSI character cells */
  --preview-wide: 736px; /* .wide previews: the full main column; 2× the standard */
  --accent: oklch(78% 0.08 210); /* dusty teal */
  --transition: 0.15s ease;
  interpolate-size: allow-keywords;
}

/* Transitions: any <details> expands smoothly; reuse var(--transition) elsewhere */

details::details-content {
  height: 0;
  overflow: hidden;
  transition: height var(--transition), content-visibility var(--transition) allow-discrete;
}

details[open]::details-content {
  height: auto;
}

@media (prefers-reduced-motion: reduce) {
  :root { --transition: 0s; }
  .wordmark::before,
  .wordmark::after { animation: none; }

  /* Sprite stands still as a filmstrip at 1× */
  .walk span {
    animation: none;
    width: 100%;
    height: var(--h);
  }
}

/* Reserve the scrollbar's space on every page, so long pages (home) and short ones line up */
html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  padding: 2rem 1rem 1rem;
  background: var(--bg);
  color: var(--fg);
  font-family: "consolas", monospace;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 1fr minmax(0, 85ch) 1fr; /* 85 characters: a comfortable line length, and room for a .wide preview */
  grid-template-rows: auto 1fr auto; /* footer sits at the bottom on short pages */
  gap: 2rem 1.5rem;
}

/* Selection and keyboard focus match the terminal look (dotted focus box, like DOS/Win 3.1) */
::selection {
  background: var(--bright);
  color: var(--bg);
}

:focus-visible {
  outline: 1px dotted var(--bright);
  outline-offset: 1px;
}

/* Header shares body's columns, so its contents align with <main> */
body > header {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
}

body > header > *,
footer {
  grid-column: 2; /* the main content column */
}

/* Wordmark: grey "Spec", white "Labs", between pulsing shaded bars */

.wordmark {
  display: flex;
  margin: 0;
  font: normal 32px/1 "IBM VGA 8x16", monospace; /* 2× the font's 16px cell keeps pixels crisp */
  color: var(--dim);
}

.wordmark span {
  color: var(--bright);
}

.wordmark::before,
.wordmark::after {
  content: "";
  flex: 1;
  height: 0.2em;
  align-self: center;
  background: linear-gradient(90deg, var(--bg), var(--bright));
  animation: pulse 4s ease-in-out infinite;
}

.wordmark::before { margin-right: 1ch; }
.wordmark::after { margin-left: 1ch; transform: scaleX(-1); }

@keyframes pulse {
  50% { opacity: 0.5; }
}

/* Windows: bordered boxes with a hard, DOS-style drop shadow (menu, post previews, code) */

.menu,
.window,
.code {
  border: 2px solid;
  box-shadow: var(--shadow-offset) var(--shadow-offset) 0 var(--shadow);
}

/* Menu: its height follows the <details> transition */

.menu {
  justify-self: end;
  align-self: start;
  position: sticky;
  top: 1rem;
  width: 15ch;
  user-select: none;
  padding: 0.5rem 1ch;
}

.menu ul,
.listing,
.irc {
  list-style: none;
  margin: 0;
  padding: 0;
}

.menu a,
.menu summary {
  display: block;
  padding: 0 1ch;
  color: inherit;
  text-decoration: none;
  list-style: none;
  cursor: pointer;
}

.menu a:hover,
.menu summary:hover {
  text-decoration: underline;
}

/* "page" on the current page's link; "true" on Posts while reading a post */
.menu [aria-current] {
  background: var(--fg);
  color: var(--bg);
}

.menu summary::-webkit-details-marker {
  display: none;
}

.menu summary::before {
  content: "▼";
  display: inline-block;
  width: 1ch;
  margin-right: 1ch;
  transform: rotate(-90deg);
  transition: transform var(--transition);
}

.menu details[open] > summary::before {
  transform: none;
}

/* File-system tree lines under an open folder */

.menu details ul {
  margin-left: 1.5ch;
}

.menu details li {
  position: relative;
  padding-left: 1.5ch;
}

.menu details li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 1ch;
  height: 50%;
  border-left: 1px solid;
  border-bottom: 1px solid;
}

.menu details li:not(:last-child) {
  box-shadow: inset 1px 0;
}

/* Content */

h2,
h3 {
  margin: 0;
  font-size: inherit;
  color: var(--bright);
}

h2 { font-weight: normal; }
h3 { font-weight: 600; }

/* Section heading followed by a line: "Recent posts ────────". Post section headings too. */

.rule,
.post h3 {
  display: flex;
  align-items: center;
  gap: 1ch;
  margin-bottom: 2rem;
}

.rule::after,
.post h3::after {
  content: "";
  flex: 1;
  border-top: 2px solid var(--dim);
}

.rule + p {
  margin-top: 0; /* the heading already leaves space */
}

main p {
  color: var(--text);
}

.meta {
  margin: 0;
  color: var(--dim);
}

/* Links highlight like a selected terminal line */
main a {
  color: var(--bright);
  text-decoration: none;
  transition: color var(--transition), background var(--transition);
}

main a:hover,
main a:focus-visible {
  background: var(--bright);
  color: var(--bg);
  --accent: currentColor; /* accent brackets inside the link invert with it */
}

/* Full-line links (post titles, post rows): the highlight bleeds 1ch past the text */
h3 a,
.listing a:has(.more) {
  margin: 0 -1ch;
  padding: 0 1ch;
}

h3 a {
  display: block;
}

/* Bracketed labels: <nick>, [more], [read], [All Posts]. Word in white, brackets in the accent. */
.username::before { content: "<"; }
.username::after { content: ">"; }
.more::before { content: "["; }
.more::after { content: "]"; }

:is(.username, .more)::before,
:is(.username, .more)::after {
  color: var(--accent);
}

/* Home page posts */

article + article {
  margin-top: 2rem;
}

/* Centered bracket links that end a page: [All Posts] on the home page, [Home] [All Posts] on posts */
.end-links {
  display: flex;
  justify-content: center;
  gap: 2ch;
  margin: 2rem 0 0;
}

/* Preview cut off after a few lines with a trailing "…" */
.excerpt {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  margin-bottom: 0;
}

/* [more] ends the preview's last line, right-aligned, after the "…". It comes first inside
   .excerpt and floats right; a zero-width spacer float, one line shorter than the clamp,
   pushes it down to the last line. It and [read] repeat the title link, so they're hidden
   from screen readers and tab order. */
.excerpt::before {
  content: "";
  float: right;
  height: 2lh; /* line-clamp (3) minus one line */
}

.excerpt .more {
  float: right;
  clear: right;
  margin-left: 1ch;
}

/* Post preview window: fixed width, centered between the meta line and the preview text.
   Height follows the image. On narrow screens the window shrinks to fit. */
.window {
  display: block;
  width: var(--preview);
  max-width: calc(100% - 4px); /* the 2px border on each side */
  margin: 1rem auto 0;
  background: var(--panel);
}

/* Wide preview for photo-led posts: fills the main column, 3:1 (2:1 at most). Use sparingly. */
.window.wide {
  --preview: var(--preview-wide);
}

/* Clickable images (preview windows, post images): the light gray border fades to white on hover
   (color transition from "main a"), and the window sinks into its shadow when pressed, like a DOS button */
a.window {
  color: var(--fg); /* border color, matching the menu */
}

a.window:hover,
a.window:focus-visible {
  background: var(--panel); /* not the white highlight text links get */
  color: var(--bright);
}

a.window:active {
  translate: var(--shadow-offset) var(--shadow-offset);
  box-shadow: none;
}

/* bordered: false. No frame or shadow; the image shows as it is. The border stays in place but
   transparent (so nothing shifts), turns white on hover, and there's no shadow to sink into. */
.window.borderless {
  border-color: transparent;
  box-shadow: none;
  background: transparent;
  transition: border-color var(--transition);
}

a.window.borderless:hover,
a.window.borderless:focus-visible {
  border-color: var(--bright);
  background: transparent;
}

a.window.borderless:active {
  translate: none;
}

.window img {
  display: block;
  width: 100%;
}

.window img:not(.pixel) {
  height: auto; /* photos scale down with the window */
}

/* Pixel art keeps its exact size (height from the HTML attribute): narrow screens crop the sides
   instead of scaling, and high-DPI screens enlarge it without blurring */
.window .pixel {
  object-fit: none;
  image-rendering: pixelated;
}

/* Sprite walk: a strip of --frames equal frames (--w × --h each), walk cycle only (no idle frame).
   The frames step in place while the sprite walks across the window. */
.walk {
  container-type: inline-size;
  overflow: hidden;
  padding: 0.5rem 0;
}

.walk span {
  display: block;
  width: var(--w);
  height: var(--h);
  background: var(--src);
  animation:
    walk-frames 1s steps(var(--frames)) infinite,
    walk-across 10s linear -3s infinite; /* start mid-walk so the window isn't empty on load */
}

@keyframes walk-frames {
  to { background-position-x: calc(var(--w) * -1 * var(--frames)); }
}

@keyframes walk-across {
  from { translate: calc(var(--w) * -1); }
  to { translate: 100cqw; }
}

/* Post pages */

.post-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.post > .meta {
  margin: 0.25rem 0 2rem;
}

/* An archived post's "Originally posted at" line sits right under the date line */
.post > .meta:has(+ .meta) {
  margin-bottom: 0;
}

.post > .meta + .meta {
  margin-top: 0;
}
.post h3 {
  margin: 2.5rem 0 1rem;
}

/* Images in a post: in the window frame, centered, scaled down to fit the column when wider.
   The frame links to the full-size file (same hover and press as preview windows). */
.image {
  margin: 2rem 0;
}

.image .window {
  width: fit-content;
  margin-top: 0;
}

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

.image .window .pixel {
  object-fit: fill; /* in posts pixel art scales to fit; preview windows crop it instead */
}

.image figcaption {
  margin-top: 0.75rem;
  color: var(--dim);
  text-align: center;
}

/* Lists and quotes in posts */
.post ul {
  padding-left: 2ch;
  color: var(--text);
}

.post li::marker {
  content: "■ ";
  color: var(--accent);
}

.post blockquote {
  margin: 1.5rem 0;
  padding-left: 2ch;
  border-left: 2px solid var(--accent);
}

.post blockquote p {
  color: var(--bright);
}

/* Older and newer posts at the end of a post: older on the left, newer on the right. Each link
   is one block: the arrow sits in its own column at the top outer corner, and the title wraps
   beside it (left-aligned on the left, right-aligned on the right). The whole block highlights
   on hover and is clickable. Arrows are in the accent and invert with the link. */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2ch;
  margin-top: 3rem;
}

.post-nav a {
  display: flex;
  align-items: start;
  gap: 1ch;
  margin: 0 -1ch; /* the highlight bleeds 1ch past the text, like other full-line links */
  padding: 0 1ch;
}

.post-nav .older {
  justify-self: start;
}

.post-nav .newer {
  grid-column: 2;
  justify-self: end;
  text-align: right;
}

.post-nav .arrow {
  flex: none;
  color: var(--accent);
}

/* Inline code: white on the panel color; kept on one line so "line-clamp" isn't split at its hyphen */
.post :not(pre) > code {
  color: var(--bright);
  background: var(--panel);
  white-space: nowrap;
}

/* Code windows: the window frame, with the file name set into the top border like a DOS title.
   Markdown code fences become these (see eleventy.config.js); terminals use {% terminal %}. */

.code {
  margin: 1.5rem 0;
  border-color: var(--fg); /* the text inside is dimmer than the frame */
  background: var(--panel);
  color: var(--text);
}

.code figcaption {
  width: fit-content;
  margin: calc(-0.75lh - 1px) auto 0; /* centered on the 2px top border */
  padding: 0 1ch;
  background: inherit;
}

.code pre {
  margin: 0;
  padding: 0.25rem 2ch 1rem;
  overflow-x: auto;
  font: inherit;
  tab-size: 4;
}

.code:not(:has(figcaption)) pre {
  padding-top: 1rem;
}

.code code {
  font: inherit; /* the browser default would switch to its own monospace */
}

/* Terminals: black, with the prompt in the accent and output dimmed */
.terminal {
  background: #0a0a0a;
  color: var(--bright);
}

.prompt {
  color: var(--accent);
  user-select: none; /* copying a command leaves the prompt behind */
}

.output {
  color: var(--dim);
}

/* Syntax colors for Prism's token classes, picked around the teal accent */
.token.comment,
.token.prolog,
.token.doctype { color: var(--mid); }
.token.keyword,
.token.builtin,
.token.property,
.token.atrule { color: var(--accent); }
.token.string,
.token.char,
.token.template-string,
.token.url { color: oklch(82% 0.08 85); } /* sand */
.token.number,
.token.boolean,
.token.constant { color: oklch(78% 0.09 30); } /* coral */
.token.function,
.token.selector { color: var(--bright); }
.token.class-name { color: oklch(82% 0.07 150); } /* sage */
.token.macro,
.token.macro .token { color: oklch(78% 0.08 320); } /* mauve: #include and friends */
.token.operator,
.token.punctuation { color: var(--dim); }
.token.interpolation { color: var(--text); } /* code inside $"…{x}" and `…${x}` */

/* Two-column list, like a dir listing: dim date or label, then the entry */

.listing > li {
  display: flex;
  gap: 2ch;
}

.listing > li > :first-child {
  flex: none;
  width: 11ch;
  color: var(--dim);
}

.listing .meta,
.listing .more {
  flex: none;
  margin-left: auto;
}

/* Post rows: one link spans the title and [read], so the whole line highlights */
.listing a:has(.more) {
  flex: 1;
  display: flex;
  gap: 2ch;
}

/* IRC networks, one per line: <nick> @ server */
.at {
  color: var(--mid);
}

/* Footer styled as a DOS-style status bar */

.status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 2ch;
  padding: 0 1ch;
  background: var(--dim);
  color: var(--bg);
}

@media (max-width: 60rem) {
  body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto 1fr auto;
  }

  body > header > *,
  footer {
    grid-column: 1;
  }

  /* Menu becomes a one-line DOS-style bar; About is last, so opening it shifts nothing */
  .menu {
    position: static;
    width: auto;
    justify-self: stretch;
    padding: 0.25rem 0;
  }

  .menu > ul {
    display: flex;
    flex-wrap: wrap;
    align-items: start;
  }

  .code pre {
    padding-inline: 1ch;
  }
}
