/*
 * Black on white, one monospace font, nothing else.
 * The only colour on the site is a product screenshot while you hover it.
 */

:root {
  --ink: #0b0b0b;
  --paper: #ffffff;
  --muted: #666666;   /* 5.7:1 on white; the lightest grey used for text */
  --faint: #9c9c9c;   /* decoration only, never for text a visitor must read */
  --rule: #dcdcdc;
  --wash: #f3f3f3;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  --gutter: clamp(16px, 4vw, 48px);
  --bar: 52px;
  /* One container for everything, so every left edge lines up. */
  --page: calc(1280px + 2 * var(--gutter));
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: var(--bar);
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  font: 15px/1.65 var(--mono);
  background: var(--paper);
  color: var(--ink);
  font-variant-ligatures: none; /* "->" and "!=" stay two characters here */
}
@media (max-width: 560px) { body { font-size: 14px; } }

::selection { background: var(--ink); color: var(--paper); }

a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { background: var(--ink); color: var(--paper); text-decoration: none; }
:focus-visible { outline: 2px dashed var(--ink); outline-offset: 3px; }

p { margin: 0 0 1em; }
h1, h2, h3 { margin: 0; }
kbd {
  font: inherit; font-size: 0.92em; font-weight: 700;
  border: 1px solid var(--ink); padding: 0 5px; border-radius: 2px;
}
.muted { color: var(--muted); }

.skip {
  position: absolute; left: 8px; top: -60px; z-index: 50;
  background: var(--ink); color: var(--paper); padding: 6px 10px;
}
.skip:focus { top: 8px; }

/* ---------- boxes whose borders draw themselves ---------- */

.box { position: relative; padding: 24px; }
.box::before,
.box::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.box::before { border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.box::after { border-left: 1px solid var(--ink); border-right: 1px solid var(--ink); }
/* Stepped, so the rule arrives a few characters at a time rather than sliding. */
.js .box::before { transition: clip-path 0.8s steps(28); }
.js .box::after { transition: clip-path 0.45s steps(12) 0.55s; }
.js .box:not(.is-drawn)::before { clip-path: inset(0 100% 0 0); }
.js .box:not(.is-drawn)::after { clip-path: inset(0 0 100% 0); }
.box > .label {
  position: absolute; top: -0.85em; left: 14px; z-index: 1;
  padding: 0 8px; background: var(--paper); font-weight: 700; line-height: 1.7;
}

.chip {
  font: inherit; color: var(--ink); background: none; border: 0;
  padding: 3px 8px; cursor: pointer; white-space: nowrap;
}
.chip::before { content: "[ "; color: var(--muted); }
.chip::after { content: " ]"; color: var(--muted); }
.chip:hover { background: var(--ink); color: var(--paper); }
.chip:hover::before, .chip:hover::after { color: var(--paper); }

/* ---------- header ---------- */

.top {
  position: sticky; top: 0; z-index: 20;
  height: var(--bar);
  background: rgb(255 255 255 / 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
}
.top-inner {
  max-width: var(--page); height: 100%; margin: 0 auto;
  display: flex; align-items: center; gap: 20px;
  padding-inline: var(--gutter);
}
.home { font-weight: 700; text-decoration: none; white-space: nowrap; }
.home .path { color: var(--muted); font-weight: 400; }
.home:hover .path { color: var(--paper); }
.blink { margin-left: 2px; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* On a narrow phone the links don't all fit beside the prompt; the strip then
   scrolls sideways inside the header instead of widening the page. The first
   link's auto margin (not justify-content) pushes them right, because an auto
   margin gives way when space runs out and flex-end would clip the start. */
.nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a:first-child { margin-left: auto; }
.nav a { text-decoration: none; padding: 3px 8px; white-space: nowrap; }
.nav a[aria-current] { background: var(--ink); color: var(--paper); }

.meter { color: var(--muted); white-space: pre; font-size: 13px; }

@media (max-width: 900px) { .meter { display: none; } }
@media (max-width: 560px) {
  .top-inner { gap: 4px; }
  .home { flex-shrink: 0; font-size: 13px; }
  .nav a { padding: 3px 4px; font-size: 12.5px; }
}
@media (max-width: 400px) { .blink { display: none; } }

/* ---------- hero ---------- */

.hero {
  max-width: var(--page); margin: 0 auto;
  min-height: calc(100svh - var(--bar));
  padding: 28px var(--gutter) 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.75fr) minmax(0, 1fr);
  gap: 24px;
}
.hero-text { align-self: start; padding-top: 7vh; }
.hello { color: var(--muted); margin-bottom: 10px; }
.name {
  font-size: clamp(40px, 5.4vw, 92px);
  font-weight: 800; line-height: 0.95; letter-spacing: -0.045em;
}
.role { margin-top: 18px; font-weight: 700; }

.portrait { align-self: center; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.portrait-stage { width: 100%; }
#portrait { display: block; margin: 0 auto; cursor: crosshair; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.portrait-hint { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; text-align: center; }
.for-touch { display: none; }
@media (hover: none) {
  .for-mouse { display: none; }
  .for-touch { display: inline; }
}

.hero-side { align-self: end; padding-bottom: 7vh; }
.intro { font-size: 17px; line-height: 1.55; max-width: 30ch; }
.facts { margin: 22px 0 0; display: grid; gap: 4px; }
.facts > div { display: grid; grid-template-columns: 7ch 1fr; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.kbd-hint { margin-top: 22px; color: var(--muted); font-size: 12.5px; }
@media (hover: none) { .kbd-hint { display: none; } }

@media (max-width: 1023px) {
  .hero { grid-template-columns: minmax(0, 1fr); min-height: 0; gap: 8px; padding-top: 32px; }
  .hero-text, .hero-side { padding: 0; }
  .hero-side { margin-top: 12px; }
  .intro { max-width: 40ch; }
}

/* ---------- sections ---------- */

.section {
  max-width: var(--page); margin: 0 auto;
  padding: clamp(72px, 10vw, 136px) var(--gutter) 0;
}
.section-term { padding-top: clamp(40px, 6vw, 72px); }
.section-head { margin-bottom: 40px; }
.cmd { color: var(--muted); margin: 0 0 8px; }
.ps1 { color: var(--ink); font-weight: 700; }
.section-head h2 {
  font-size: clamp(30px, 3.8vw, 48px);
  font-weight: 800; line-height: 1.05; letter-spacing: -0.035em;
}

/* ---------- terminal ---------- */

.term { max-width: 940px; margin: 0 auto; padding: 0; }
.term-bar {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 18px 20px 0; color: var(--muted); font-size: 12.5px;
}
/* Output and prompt scroll together, so the prompt always sits right after
   the last line, as in a real terminal. */
.term-screen {
  height: clamp(260px, 44vh, 400px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 12px 0 8px;
}
.term-out { padding: 0 20px; font-size: 14px; line-height: 1.6; }
.term-out .ln { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.6em; }
.term-out .cols { display: grid; grid-template-columns: max-content minmax(0, 1fr); }
.term-out .left { white-space: pre; }
.term-out .key { display: inline-block; min-width: 11ch; font-weight: 700; }
.term-out .dim { color: var(--muted); }
.term-out strong { font-weight: 800; }
.term-line { display: flex; align-items: baseline; gap: 1ch; padding: 2px 20px; font-size: 14px; }
.term-line:focus-within { background: var(--wash); }
.term-line .ps1 { white-space: nowrap; }
.term-in {
  flex: 1; min-width: 0; padding: 0; border: 0; outline: 0;
  font: inherit; color: var(--ink); background: transparent; caret-color: var(--ink);
}
.term-chips {
  display: flex; flex-wrap: wrap; gap: 4px 2px;
  padding: 12px 12px 14px; border-top: 1px dashed var(--rule);
}
@media (max-width: 560px) {
  .term-hint { display: none; }
  .term-out, .term-line { padding-inline: 14px; font-size: 13px; }
  .term-line .ps1 { font-size: 0; }          /* keep only "$" on a phone */
  .term-line .ps1::after { content: "$"; font-size: 13px; }
}

/* ---------- about: the man page ---------- */

.man { max-width: 90ch; padding: 22px clamp(16px, 3vw, 32px) 24px; }
.man-top, .man-foot { display: flex; justify-content: space-between; gap: 2ch; }
.man-top { font-weight: 700; }
.man-foot { margin-top: 32px; color: var(--muted); }
.man-sec { margin-top: 26px; }
.man-sec h3 { font-size: inherit; font-weight: 800; letter-spacing: 0.04em; margin-bottom: 6px; }
.man-sec > :not(h3) { margin-left: clamp(2ch, 5vw, 7ch); }
.man-sec p { max-width: 72ch; }
.man-sec p:last-child, .man-sec dl:last-child { margin-bottom: 0; }
.man dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 3ch; margin: 0; }
.man dd { margin: 0; }
.man u { text-underline-offset: 3px; }
@media (max-width: 560px) {
  .man-title, .man-foot span:nth-child(2) { display: none; }
  .man dl { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .man dd { margin-bottom: 8px; }
}

/* ---------- work ---------- */

.work-intro {
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: clamp(32px, 5vw, 72px); align-items: start;
  margin-bottom: clamp(64px, 8vw, 104px);
}
.lead { font-size: 18px; line-height: 1.55; max-width: 48ch; }
.loop { font-size: 16px; margin: 22px 0 10px; }
.work-intro .muted { max-width: 60ch; }
.tree-box { padding: 26px 24px 20px; }
.tree { margin: 0; font: inherit; line-height: 1.75; white-space: pre; }
.tree a { font-weight: 700; }
@media (max-width: 860px) { .work-intro { grid-template-columns: minmax(0, 1fr); } }

.products { display: grid; gap: clamp(64px, 9vw, 112px); }
.product {
  display: grid; grid-template-columns: 520px minmax(0, 1fr);
  gap: clamp(28px, 4vw, 56px); align-items: start;
}
@media (max-width: 1080px) { .product { grid-template-columns: minmax(0, 1fr); gap: 24px; } }

.shot-link, .shot-link:hover { display: block; background: none; width: min(100%, 520px); }
/* Image pixels stay at exactly one CSS pixel each: a narrow screen crops the
   picture rather than shrinking it, because a dither scaled by a fraction
   turns into moire. */
.shot {
  position: relative; margin: 0;
  width: 100%; aspect-ratio: 8 / 5; overflow: hidden;
  outline: 1px solid var(--ink); background: var(--paper);
}
.shot img, .shot canvas {
  position: absolute; top: 0; left: 0;
  width: 520px; height: 325px; max-width: none; display: block;
}
.shot .bw { image-rendering: pixelated; }
.shot canvas { opacity: 0; }
.shot.is-live canvas { opacity: 1; }
.shot .color { clip-path: inset(0 0 100% 0); transition: clip-path 0.5s steps(13); }
@media (hover: hover) {
  .product:hover .shot .color { clip-path: inset(0); }
}
.product:focus-within .shot .color { clip-path: inset(0); }

.product-meta { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.idx { color: var(--ink); font-weight: 800; margin-right: 1ch; }
.product-name { font-size: clamp(26px, 2.6vw, 34px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.product-line { font-weight: 700; font-size: 16.5px; margin: 8px 0 16px; }
.product-body p { max-width: 62ch; }
.product-link { display: inline-block; margin-top: 4px; font-weight: 700; }

/* ---------- other projects: ls -l ---------- */

.ls-head { margin-bottom: 8px; }
.ls { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); }
.project {
  position: relative;
  display: grid; grid-template-columns: 11ch 5ch 13ch minmax(0, 1fr) 12ch;
  gap: 2ch; align-items: baseline;
  padding: 14px 10px; border-bottom: 1px solid var(--rule);
}
.perm, .project-year, .project-tag { color: var(--muted); }
.project-name { font-weight: 800; text-decoration: none; }
a.project-name::after { content: ""; position: absolute; inset: 0; } /* the whole row is the link */
.project-tag { text-align: right; }
.project:has(a):hover { background: var(--ink); color: var(--paper); }
.project:has(a):hover .perm,
.project:has(a):hover .project-year,
.project:has(a):hover .project-tag { color: var(--paper); }
.project a:hover { background: none; color: inherit; }
.more { margin-top: 20px; }
@media (max-width: 900px) {
  .project { grid-template-columns: 5ch minmax(0, 1fr); gap: 2px 2ch; }
  .perm { display: none; }
  .project-line, .project-tag { grid-column: 2; }
  .project-tag { text-align: left; font-size: 12.5px; }
}

/* ---------- contact ---------- */

.contact-say { font-size: clamp(17px, 2vw, 21px); line-height: 1.5; max-width: 46ch; }
.contact-list { margin: 36px 0 0; max-width: 780px; border-top: 1px solid var(--ink); }
.contact-list > div {
  display: grid; grid-template-columns: 10ch minmax(0, 1fr) auto;
  gap: 2ch; align-items: baseline;
  padding: 14px 4px; border-bottom: 1px solid var(--rule);
}
.contact-list dt { color: var(--muted); }
.contact-list dd { margin: 0; overflow-wrap: anywhere; }
.contact-list .aside { justify-self: end; }
.todo { color: var(--muted); border: 1px dashed var(--faint); padding: 0 6px; }
@media (max-width: 560px) {
  .contact-list > div { grid-template-columns: 9ch minmax(0, 1fr); }
  .contact-list .aside { grid-column: 2; justify-self: start; margin-left: -8px; }
}

/* ---------- footer ---------- */

.site-footer {
  max-width: var(--page); margin: clamp(96px, 12vw, 168px) auto 0;
  padding: 20px var(--gutter) 36px;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 32px;
  color: var(--muted); font-size: 12.5px;
  border-top: 1px solid var(--rule);
}

/* ---------- reduced motion: every effect shows its end state ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
