
:root {
  --ink: #111111;
  --ink-soft: #656560;
  --paper: #ffffff;
  --card: #f5f5f3;
  --paper-alt: #ededea;
  --line: #e6e6e1;
  --rule: #111111;              /* the hard black borders */

  /* A muted hue per section: a deep tone for type and fills,
     a pale tint for badges. Nothing saturated. */
  --c-literary:    #b54517;  --c-literary-tt:    #fff5e9;
  --c-engineering: #006abd;  --c-engineering-tt: #e6fdff;
  --c-articles:    #007859;  --c-articles-tt:    #e1fffb;
  --c-poems:       #b73e51;  --c-poems-tt:       #fff3f4;
  --c-stories:     #8f4cab;  --c-stories-tt:     #fff6ff;
  --c-books:       #a15400;  --c-books-tt:       #fff9e0;
  --c-art:         #a24592;  --c-art-tt:         #fff3ff;
  --c-music:       #006fa9;  --c-music-tt:       #e0ffff;
  --c-essays:      #545fc3;  --c-essays-tt:      #f2faff;
  --c-research:    #007480;  --c-research-tt:    #deffff;
  --c-software:    #7555bc;  --c-software-tt:    #fdf6ff;
  /* Laurel green, the one hue the site did not have, for the record. */
  --c-achievements: #467500;  --c-achievements-tt: #eefee1;

  --accent: var(--c-literary);
  --accent-tint: var(--c-literary-tt);

  /* 4.9:1 on white. The dark theme swaps in a lighter one below. */
  --danger: #c2261d;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  /* "Words on one side, circuits on the other." The literary half of the
     site is set in the serif; everything built is set in the grotesk.
     Interface chrome — nav, buttons, labels — stays in the grotesk
     throughout, so only the writing changes voice. */
  --font-serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  /* Major headings are set in a grotesk with real character, so a page
     title does not read as body text that happens to be large. The
     literary pages override it with the serif further down: what is
     written keeps the serif voice, what is built takes this one. */
  --font-display: "Space Grotesk", "Inter", -apple-system, BlinkMacSystemFont,
                  "Segoe UI", Roboto, sans-serif;
  --font-head: var(--font-display);

  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;

  /* One spacing scale, so padding and gaps stop being ad-hoc numbers. */
  --s-1: 6px;   --s-2: 12px;  --s-3: 18px;  --s-4: 26px;
  --s-5: 38px;  --s-6: 56px;  --s-7: 80px;  --s-8: 112px;

  /* Three durations: a state change, a movement, a whole panel. */
  --d-fast: 160ms;
  --d-mid: 280ms;
  --d-slow: 460ms;

  --max: 940px;
  /* Type scale. Before this there were six heading sizes between 1.12 and
     1.7rem doing the same job, and fifteen body sizes inside a 0.3rem
     range. Four of each is enough, and the page reads as deliberate. */
  --t-display: 4.2rem;   /* the name on the home page */
  --t-xl: 2.5rem;        /* page and section headings */
  --t-lg: 1.7rem;        /* a featured project title */
  --t-md: 1.35rem;       /* card and listing titles */
  --t-sm: 1.15rem;       /* titles inside a card */

  --t-body: 1.06rem;     /* intros and standfirsts */
  --t-base: 0.96rem;     /* ordinary copy inside a card */
  --t-meta: 0.87rem;     /* captions and secondary lines */
  --t-micro: 0.74rem;    /* monospace labels and chips */

  --ease: cubic-bezier(0.32, 0.72, 0, 1);

  --radius: 24px;
  --radius-sm: 14px;
  --radius-pill: 999px;
  --shadow: none;
  --shadow-lift: none;
}


:root[data-theme="dark"] {
  --ink: #f4f4ef;
  --ink-soft: #9a9a92;
  --paper: #0b0b0a;
  --card: #171715;
  --paper-alt: #1e1e1b;
  --line: #2f2f2a;
  --rule: #f4f4ef;
  --danger: #ff8a7a;

  --c-literary:    #da8365;  --c-literary-tt:    #da836526;
  --c-engineering: #5f9ede;  --c-engineering-tt: #5f9ede26;
  --c-articles:    #2dad92;  --c-articles-tt:    #2dad9226;
  --c-poems:       #dc7f87;  --c-poems-tt:       #dc7f8726;
  --c-stories:     #b988cf;  --c-stories-tt:     #b988cf26;
  --c-books:       #c98e45;  --c-books-tt:       #c98e4526;
  --c-art:         #cb83bb;  --c-art-tt:         #cb83bb26;
  --c-music:       #3aa5d1;  --c-music-tt:       #3aa5d126;
  --c-essays:      #8795e3;  --c-essays-tt:      #8795e326;
  --c-research:    #00abb2;  --c-research-tt:    #00abb226;
  --c-software:    #a28edd;  --c-software-tt:    #a28edd26;
  --c-achievements: #80a657;  --c-achievements-tt: #80a65726;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f4f4ef;
    --ink-soft: #9a9a92;
    --paper: #0b0b0a;
    --card: #171715;
    --paper-alt: #1e1e1b;
    --line: #2f2f2a;
    --rule: #f4f4ef;
    --danger: #ff8a7a;

  --c-literary:    #da8365;  --c-literary-tt:    #da836526;
    --c-engineering: #5f9ede;  --c-engineering-tt: #5f9ede26;
    --c-articles:    #2dad92;  --c-articles-tt:    #2dad9226;
    --c-poems:       #dc7f87;  --c-poems-tt:       #dc7f8726;
    --c-stories:     #b988cf;  --c-stories-tt:     #b988cf26;
    --c-books:       #c98e45;  --c-books-tt:       #c98e4526;
    --c-art:         #cb83bb;  --c-art-tt:         #cb83bb26;
    --c-music:       #3aa5d1;  --c-music-tt:       #3aa5d126;
    --c-essays:      #8795e3;  --c-essays-tt:      #8795e326;
    --c-research:    #00abb2;  --c-research-tt:    #00abb226;
    --c-software:    #a28edd;  --c-software-tt:    #a28edd26;
    --c-achievements: #80a657;  --c-achievements-tt: #80a65726;
  }
}

/* Which hue each page wears. */
body.s-literary { --accent: var(--c-literary); --accent-tint: var(--c-literary-tt); }
body.s-engineering { --accent: var(--c-engineering); --accent-tint: var(--c-engineering-tt); }
body.s-articles { --accent: var(--c-articles); --accent-tint: var(--c-articles-tt); }
body.s-poems { --accent: var(--c-poems); --accent-tint: var(--c-poems-tt); }
body.s-stories { --accent: var(--c-stories); --accent-tint: var(--c-stories-tt); }
body.s-books { --accent: var(--c-books); --accent-tint: var(--c-books-tt); }
body.s-art { --accent: var(--c-art); --accent-tint: var(--c-art-tt); }
body.s-music { --accent: var(--c-music); --accent-tint: var(--c-music-tt); }
body.s-essays { --accent: var(--c-essays); --accent-tint: var(--c-essays-tt); }
body.s-research { --accent: var(--c-research); --accent-tint: var(--c-research-tt); }
body.s-software { --accent: var(--c-software); --accent-tint: var(--c-software-tt); }
body.s-achievements { --accent: var(--c-achievements); --accent-tint: var(--c-achievements-tt); }
body.s-home, body.s-about { --accent: var(--c-research); --accent-tint: var(--c-research-tt); }

/* Cards borrow the hue of wherever they lead. */
.k-literary { --card-accent: var(--c-literary); --card-accent-tint: var(--c-literary-tt); }
.k-engineering { --card-accent: var(--c-engineering); --card-accent-tint: var(--c-engineering-tt); }
.k-articles { --card-accent: var(--c-articles); --card-accent-tint: var(--c-articles-tt); }
.k-poems { --card-accent: var(--c-poems); --card-accent-tint: var(--c-poems-tt); }
.k-stories { --card-accent: var(--c-stories); --card-accent-tint: var(--c-stories-tt); }
.k-books { --card-accent: var(--c-books); --card-accent-tint: var(--c-books-tt); }
.k-art { --card-accent: var(--c-art); --card-accent-tint: var(--c-art-tt); }
.k-music { --card-accent: var(--c-music); --card-accent-tint: var(--c-music-tt); }
.k-essays { --card-accent: var(--c-essays); --card-accent-tint: var(--c-essays-tt); }
.k-research { --card-accent: var(--c-research); --card-accent-tint: var(--c-research-tt); }
.k-software { --card-accent: var(--c-software); --card-accent-tint: var(--c-software-tt); }
.k-achievements { --card-accent: var(--c-achievements); --card-accent-tint: var(--c-achievements-tt); }

/* ---------- Base ---------- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
/* Both, deliberately. A body-only rule does nothing here: with html at
   overflow: visible the body's overflow propagates to the viewport and
   the body itself computes back to visible, so nothing ever clipped. The
   full-bleed hero wash and the software hero both rely on this. */
html { overflow-x: clip; }
body { overflow-x: clip; }

/* The section's own colour, held across the whole viewport rather than in
   a band at the top. One wash falls from the masthead, a second blooms low
   and off to one side, so a long page keeps its hue instead of fading to
   white halfway down. Fixed, so it stays put while the content scrolls. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  /* The first layer is grain. Without it the two wide radial washes below
     band into visible rings on a near-white page, because 8 bits cannot
     hold that shallow a gradient over that much area. */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.22'/%3E%3C/svg%3E"),
    linear-gradient(color-mix(in oklab, var(--accent-tint) 62%, var(--paper)),
                    transparent 400px),
    radial-gradient(60% 45% at 88% 78%,
      color-mix(in oklab, var(--accent) 5%, transparent), transparent 70%),
    radial-gradient(50% 40% at 6% 46%,
      color-mix(in oklab, var(--accent) 3.5%, transparent), transparent 70%);
  background-repeat: repeat, no-repeat, no-repeat, no-repeat;
  background-size: 160px 160px, auto, auto, auto;
  /* The grain only has to break the bands up, not be seen doing it. */
  background-blend-mode: soft-light, normal, normal, normal;
  opacity: 1;
}

/* The grain is a texture, not a tint: it must not survive into print. */
@media print {
  body::before { display: none; }
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  background: var(--paper);
  background-attachment: fixed;
}

h1, h2, h3 { font-family: var(--font-head); font-weight: 700; letter-spacing: -0.03em; }
.brand { font-family: var(--font-sans); font-weight: 800; letter-spacing: -0.03em; }

/* The writing side. */
body.s-literary, body.s-articles, body.s-poems, body.s-stories,
body.s-books, body.s-essays, body.s-research {
  --font-head: var(--font-serif);
}

body.s-literary h1, body.s-articles h1, body.s-poems h1, body.s-stories h1,
body.s-books h1, body.s-essays h1, body.s-research h1,
body.s-literary h2, body.s-articles h2, body.s-poems h2, body.s-stories h2,
body.s-books h2, body.s-essays h2, body.s-research h2 {
  font-weight: 600;
  letter-spacing: -0.02em;
}

a { color: var(--accent); }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 24px; }

/* ---------- Motion ----------
   One recipe, used sparingly: fade up out of a slight blur, so a thing
   materialises rather than simply appearing. Durations are short enough
   that nobody should consciously notice them.

   Deliberately NOT animated: the nav, the section headings, the project
   grid and every listing. Scroll-triggered reveals on ordinary content
   read as decoration, and on a page you return to they become friction. */
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); filter: blur(4px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

/* Once per page load, on the one block that sets up the page. */
.hero, .page-head {
  animation: rise 420ms var(--ease) backwards;
}

/* The search panel is opened by key as often as by click, so it is quick:
   enough to place the panel, not enough to make anyone wait for it. */
.search-overlay:not([hidden]) .search-box {
  animation: rise 160ms var(--ease) backwards;
}

/* A preview leaning in slightly is the whole hover signal on a card; the
   card itself only changes shade. */
.card-media { transition: transform 320ms var(--ease); }


/* ---------- Shared surfaces ----------
   Everything that sits on the page as a raised white card. */
.card, .achievement, .design, .art-piece, .recording,
.highlight, .project, .elsewhere, .qa, .piece-nav a {
  background: var(--card);
  border: 0;
  border-radius: var(--radius);
}

/* Lift on hover, but only where there is a real pointer: phones fire
   :hover on tap and it sticks. */
@media (hover: hover) and (pointer: fine) {
  .achievement:hover, .design:hover, .art-piece:hover,
  .recording:hover, .highlight:hover,
  .piece-nav a:hover { background: var(--paper-alt); }

  .piece:has(h2 a):hover, .book:has(h2 a):hover {
    background-color: var(--accent-tint);
    background-size: 2px 100%;
  }
  .piece:has(h2 a):hover::after, .book:has(h2 a):hover::after {
    transform: translateX(4px);
    color: var(--accent);
  }
  /* The index number is the row's label, so it takes the section colour
     with everything else. */
  .piece:has(h2 a):hover::before, .book:has(h2 a):hover::before {
    color: var(--accent);
  }
  .card:hover { filter: none; }
  .card:hover::before { opacity: 1; }
  .card:hover .card-media { transform: scale(1.04); }
  .card .go { transition: transform 240ms var(--ease); }
  .card:hover .go { transform: translateX(4px); }

  .piece h2 a:hover, .back-link:hover,
  .detail a.d-value:hover, .detail .d-value a:hover { color: var(--ink); }
  .site-footer a:hover { text-decoration: underline; }

  nav.main-nav a:hover { color: var(--ink); background: var(--paper-alt); }
  nav.main-nav.has-glide a:hover { background: transparent; color: var(--accent); }
  .sub-nav a:hover, .tabs label:hover, .tab-labels label:hover { color: var(--ink); }
  .qa summary:hover { color: var(--ink); }
  .search-results a:hover { background: var(--paper-alt); }
  .pub-list a:hover, .design .design-files a:hover { text-decoration: underline; }
  .icon-btn:hover { border-color: var(--rule); color: var(--ink); }
  .channel-link a:hover, .send-btn:hover { background: var(--accent); border-color: var(--accent); }
  .channel-link + .channel-link a:hover { color: var(--paper); }
}

.card, .achievement, .design, .art-piece, .recording, .piece, .book,
.highlight, .piece-nav a {
  transition: background-color 160ms var(--ease);
}

.channel-link a, .send-btn {
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}

.icon-btn {
  transition: color 200ms var(--ease), border-color 200ms var(--ease),
              transform 200ms var(--ease);
}


/* ---------- Shared labels ----------
   Small uppercase text. The first group sits in a tinted pill, the
   second is bare. */
/* The solid yellow badge. */
.pill a { color: inherit; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-tint);
  color: var(--accent);
  border: 0;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 5px 13px;
}

/* Outlined chips, the way the tags read. */
.piece .meta, .book .author, article.prose .byline {
  display: inline-block;
  background: var(--card);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  padding: 3px 10px;
}

.piece .meta, .book .author { margin: 0 0 12px; }
article.prose .byline { margin: 0 0 30px; }

/* Bare monospace labels. */
.col-label, .timeline .when, .piece-nav .dir, .search-results .s-kind,
.design .design-meta, .fill .fill-label {
  display: block;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.col-label { margin-bottom: 12px; }
.timeline .when { margin-bottom: 4px; }
.piece-nav .dir { margin-bottom: 6px; }
.search-results .s-kind { display: inline-block; margin-bottom: 4px; }
.design .design-meta { margin-bottom: 10px; }

/* A build that is not finished yet. A chip rather than a coloured word, so
   it carries the same weight in both themes. */
.wip {
  display: inline-block;
  margin-bottom: 10px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-tint);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Beside a title rather than above it: the badge qualifies the heading,
   so it sits on the same line and takes no vertical space of its own. */
h3 .wip, h2 .wip {
  margin: 0 0 0 10px;
  vertical-align: 2px;
}

/* Unfilled placeholder text, wherever it appears. */
.empty { font-style: italic; color: var(--ink-soft); }
.design .design-meta.empty, .timeline .when.empty {
  font-style: normal;
  color: var(--ink-soft);
}
.recording-body .meta.empty, .piece p.empty { font-style: normal; }

/* ---------- Header and navigation ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in oklab, var(--paper) 82%, transparent);
  border-bottom: 1px solid var(--line);
}

/* The bar goes translucent only where the browser can blur what is behind
   it; without that the text would sit on a see-through strip. */
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .site-header {
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    backdrop-filter: saturate(1.6) blur(14px);
  }
}

/* ---------- The menu button ----------
   Built by site.js and shown only below the breakpoint, so the row of
   links stays a row wherever there is room for one. */
/* .icon-btn is declared further down and would otherwise win on source
   order, so this carries both classes. */
.icon-btn.nav-toggle { display: none; }

.nav-bars, .nav-bars::before, .nav-bars::after {
  display: block;
  width: 17px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform var(--d-mid) var(--ease), opacity var(--d-fast) var(--ease);
}
.nav-bars::before, .nav-bars::after { content: ""; position: absolute; }
.nav-bars::before { transform: translateY(-6px); }
.nav-bars::after  { transform: translateY(6px); }

/* The three bars fold into a cross. */
.nav-open .nav-bars { background: transparent; }
.nav-open .nav-bars::before { transform: rotate(45deg); }
.nav-open .nav-bars::after  { transform: rotate(-45deg); }

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.brand { font-size: 1.2rem; font-weight: 700; text-decoration: none; color: var(--ink); }
.brand span { color: var(--accent); }

nav.main-nav ul, .sub-nav ul {
  list-style: none;
  display: flex;
  margin: 0;
  flex-wrap: wrap;
}

nav.main-nav ul { gap: 8px; padding: 0; }
.sub-nav ul { gap: 6px; padding: 10px 0; }

nav.main-nav a, .sub-nav a {
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 500;
  border-radius: var(--radius-pill);
  transition: background-color 200ms var(--ease), color 200ms var(--ease);
}

nav.main-nav a { font-size: var(--t-meta); padding: 7px 14px; }
.sub-nav { border-bottom: 1px solid var(--line); }
.sub-nav a { font-size: var(--t-meta); padding: 6px 13px; }

nav.main-nav a.active, .sub-nav a.active { color: var(--accent); background: var(--accent-tint); }

/* ---------- The nav indicator ----------
   One tinted pill sits behind the current section and slides to whatever
   the pointer is over, so the nav reads as a single control rather than
   six separate links. It is only built when there is a real pointer; the
   static .active background above is what everyone else sees, and the
   .has-glide class is what hands the job over. */
nav.main-nav ul { position: relative; }

nav.main-nav.has-glide a.active { background: transparent; }

.nav-glide {
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1;
  border-radius: var(--radius-pill);
  background: var(--accent-tint);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 320ms var(--ease),
    width 320ms var(--ease),
    height 320ms var(--ease),
    opacity 200ms var(--ease);
}
.nav-glide.on { opacity: 1; }

/* It travels by sliding; with motion turned down it simply appears. */
@media (prefers-reduced-motion: reduce) {
  .nav-glide { transition: opacity 200ms var(--ease); }
}

.header-tools { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}

.icon-btn svg { width: 17px; height: 17px; }

/* One theme glyph at a time. */
/* Both glyphs are always present, stacked; one fades out as the other
   fades in. An instant swap reads as a glitch at this size. */
.theme-toggle { display: grid; place-items: center; }
.theme-toggle svg { grid-area: 1 / 1; }

.theme-toggle .moon { opacity: 0; transform: scale(0.6) rotate(-30deg); }
.theme-toggle .sun  { opacity: 1; transform: none; }
.theme-toggle svg { transition: opacity 220ms var(--ease), transform 220ms var(--ease); }

:root[data-theme="dark"] .theme-toggle .moon { opacity: 1; transform: none; }
:root[data-theme="dark"] .theme-toggle .sun  { opacity: 0; transform: scale(0.6) rotate(30deg); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .moon { opacity: 1; transform: none; }
  :root:not([data-theme="light"]) .theme-toggle .sun  { opacity: 0; transform: scale(0.6) rotate(30deg); }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  padding: 64px 0 8px;
}

/* Two washes of colour behind the hero: the warm one the writing uses and
   the cool one the engineering uses, which is what the tagline says out
   loud. Kept faint enough that the text contrast below is untouched. */
.hero::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 50%;
  translate: -50% 0;
  top: -90px;
  width: 150vw;
  height: 520px;
  pointer-events: none;
  background:
    radial-gradient(42% 58% at 34% 32%, color-mix(in oklab, var(--c-literary) 9%, transparent), transparent 70%),
    radial-gradient(42% 58% at 66% 38%, color-mix(in oklab, var(--c-engineering) 8%, transparent), transparent 70%);
}

.portrait {
  display: block;
  width: 104px;
  height: 104px;
  border-radius: 22px;
  object-fit: cover;
  background: var(--card);
  box-shadow: var(--shadow-lift);
}

.hero h1 { text-wrap: balance; font-size: var(--t-display); line-height: 1.02; margin: 20px 0 14px; font-weight: 700; letter-spacing: -0.04em; max-width: 14ch; }
.hero p.pill { margin: 0 0 4px; }
.hero p:not(.pill) { margin: 0 0 14px; color: var(--ink-soft); font-size: var(--t-body); max-width: 46ch; }
.hero p.tagline { display: inline-block; background: var(--accent-tint); color: var(--accent); font-weight: 700; font-size: var(--t-base); margin: 0 0 20px; padding: 5px 14px; border-radius: var(--radius-pill); }

/* ---------- The home page ---------- */

/* The hero arrives a piece at a time, top to bottom, so the eye is led
   down the page rather than handed all of it at once. `backwards` keeps
   each piece invisible through its own delay instead of flashing first. */
.hero > *          { animation: rise 520ms var(--ease) backwards; }
.hero .portrait    { animation-delay: 60ms; }
.hero > div > h1   { animation: rise 560ms var(--ease) 140ms backwards; }
.hero .tagline     { animation: rise 560ms var(--ease) 240ms backwards; }
.hero > div > p:not(.tagline) { animation: rise 560ms var(--ease) 330ms backwards; }

/* The tagline carries the site's own idea: the writing half set in the
   serif, the building half in the grotesk. */
.hero p.tagline {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 0.4ch;
}

.hero .side-words   { font-family: var(--font-serif); font-style: italic; font-weight: 500; }
.hero .side-circuits{ font-family: var(--font-mono); font-size: 0.92em; letter-spacing: -0.01em; }

/* A pen stroke on one side, a circuit trace on the other, drawing
   themselves in from the edges and meeting at a shared node. */
.duality { max-width: 760px; margin: 6px auto 0; padding: 0 24px; }
.duality svg { display: block; width: 100%; height: auto; overflow: visible; }

.duality path {
  stroke-dasharray: var(--len, 600);
  stroke-dashoffset: var(--len, 600);
  animation: draw 1400ms var(--ease) 420ms forwards;
}

/* The trace draws from the right-hand edge inwards, so the two lines
   travel towards each other and meet at the node. */
.duality .d-trace { stroke-dashoffset: calc(var(--len, 600) * -1); animation-name: draw-from-end; }

@keyframes draw          { to { stroke-dashoffset: 0; } }
@keyframes draw-from-end { to { stroke-dashoffset: 0; } }

.duality .d-node { transform-origin: 450px 30px; animation: pop 420ms var(--ease) 1500ms backwards; }
.duality .d-dot  { opacity: 0; animation: fade-in 320ms var(--ease) 1650ms forwards; }

/* A signal that runs the length of the band: along the handwritten curve,
   then along the circuit trace. It is the tagline as a picture. It fires
   once, when the lines have finished drawing, and again when the reader
   points at the band — never on a loop, because a landing page that moves
   forever is a landing page nobody can read. */
.duality .d-pulse { fill: var(--accent); opacity: 0; }

@supports (offset-path: path("M0 0 H1")) {
  .duality .d-pulse {
    offset-rotate: 0deg;
    offset-distance: 0%;
  }
  .duality .d-p1 {
    offset-path: path("M8 34 C 70 10, 120 52, 182 30 S 296 8, 358 32 Q 400 46, 438 30");
  }
  .duality .d-p2 {
    offset-path: path("M462 30 H 520 V 14 H 580 V 30 H 638 V 46 H 700 V 30 H 760 V 18 H 820 V 30 H 892");
  }
  .duality.pulse .d-p1 { animation: signal 900ms var(--ease) 60ms; }
  .duality.pulse .d-p2 { animation: signal 900ms linear 900ms; }
}

@keyframes signal {
  from { offset-distance: 0%;   opacity: 0; }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  to   { offset-distance: 100%; opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .duality .d-pulse { animation: none !important; opacity: 0; }
}

@keyframes pop     { from { transform: scale(0.2); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { to { opacity: 1; } }

/* ---------- The two sides, introduced ----------
   The tagline claims the site has a writing half and a building half;
   this block is where each half gets to speak. It is a statement, not a
   control: no links, no previews, nothing to press. The identity of each
   side is carried by its typeface, its hue and its paper, so the two read
   as different voices even with the text covered up. */
.duo-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: var(--s-3);
  margin: var(--s-4) 0 var(--s-4);
}

.duo-side {
  --side: var(--accent);
  position: relative;
  padding: var(--s-5) var(--s-4) var(--s-4);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
}

/* The rule across the top is the side's signature: the full width of the
   panel in its own colour, the one piece of saturation it gets. */
.duo-side::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--side);
}

/* And its paper. Ruled lines for the half that is written, a plotted grid
   for the half that is drawn and measured. Both at a few percent, so the
   copy sits on texture rather than on pattern. */
.duo-lit::after,
.duo-eng::after {
  content: "";
  position: absolute;
  inset: 4px 0 0;
  z-index: 0;
  pointer-events: none;
  mask-image: linear-gradient(to bottom, #000, transparent 86%);
}

.duo-lit::after {
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 25px,
    color-mix(in oklab, var(--side) 16%, transparent) 25px 26px);
}

.duo-eng::after {
  background:
    repeating-linear-gradient(to bottom,
      transparent 0 21px,
      color-mix(in oklab, var(--side) 10%, transparent) 21px 22px),
    repeating-linear-gradient(to right,
      transparent 0 21px,
      color-mix(in oklab, var(--side) 10%, transparent) 21px 22px);
}

.duo-side > * { position: relative; z-index: 1; }

.duo-lit { --side: var(--c-literary); }
.duo-eng { --side: var(--c-engineering); }

/* The label above each side. The written half spells its name out in
   small capitals of the serif; the built half stamps its name in
   monospace, the way a part is labelled on a drawing. */
.duo-kind {
  display: block;
  margin: 0 0 var(--s-2);
  color: var(--side);
  font-weight: 700;
}

.duo-lit .duo-kind {
  font-family: var(--font-serif);
  font-size: var(--t-meta);
  font-variant-caps: all-small-caps;
  letter-spacing: 0.14em;
}

.duo-eng .duo-kind {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

/* The opening line of each side, at the same size on both so neither
   outranks the other — only the voice changes. */
.duo-side h3 {
  margin: 0 0 var(--s-2);
  font-size: var(--t-md);
  line-height: 1.22;
  text-wrap: balance;
}

.duo-lit h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-style: italic;
  letter-spacing: -0.01em;
}

.duo-eng h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.duo-side p {
  margin: 0;
  color: var(--ink-soft);
  font-size: var(--t-base);
  line-height: 1.6;
  text-wrap: pretty;
}

/* A drop cap on the written side, because that is what writing looks
   like on a page, and nothing like it on the built side. */
.duo-lit p::first-letter {
  float: left;
  margin: 0.08em 0.12em 0 0;
  color: var(--side);
  font-family: var(--font-serif);
  font-size: 3.1em;
  font-weight: 600;
  line-height: 0.82;
}

.duo-lit p { font-family: var(--font-serif); font-size: var(--t-body); }

/* The forms each side takes. Serif italic, separated by thin rules, for
   the written half; monospace chips, numbered like pins on a header, for
   the built half. */
.duo-forms {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  margin: var(--s-3) 0 0;
  padding: var(--s-3) 0 0;
  border-top: 1px solid var(--line);
}

.duo-lit .duo-forms {
  gap: 0 14px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--t-meta);
  color: var(--ink);
}

.duo-lit .duo-forms li + li {
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.duo-eng .duo-forms {
  gap: 8px;
  counter-reset: pin;
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  color: var(--ink);
}

.duo-eng .duo-forms li {
  counter-increment: pin;
  padding: 4px 10px;
  border: 1px solid color-mix(in oklab, var(--side) 34%, var(--line));
  border-radius: var(--radius-sm);
  background: var(--paper);
}

.duo-eng .duo-forms li::before {
  content: counter(pin, decimal-leading-zero) " ";
  color: var(--side);
}

/* The ampersand. It is the argument of the whole block: not one side and
   then the other, but both at once. It takes its colour from halfway
   between the two hues, and the hairline runs through it so the panels
   read as joined rather than merely adjacent. */
.duo-join {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.6rem;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 2.6rem;
  line-height: 1;
  color: color-mix(in oklab, var(--c-literary) 50%, var(--c-engineering));
}

.duo-join::before {
  content: "";
  position: absolute;
  inset: 50% calc(var(--s-3) * -1) auto;
  height: 1px;
  background: linear-gradient(to right,
    var(--c-literary), transparent 32%, transparent 68%, var(--c-engineering));
  opacity: 0.5;
}

/* The rule fades out before it reaches the glyph, so the two reach
   towards each other and the character is not struck through. */
.duo-join i {
  position: relative;
  z-index: 1;
  font-style: italic;
}

/* The line that closes the block, centred under both panels and set in
   the serif at reading size — the two voices having agreed on something. */
.duo-close {
  max-width: 52ch;
  margin: 0 auto;
  text-align: center;
  color: var(--ink-soft);
  font-family: var(--font-serif);
  font-size: var(--t-body);
  line-height: 1.6;
  text-wrap: pretty;
}

/* Below this width the two panels stop reading as a pair side by side, so
   they stack and the ampersand becomes the join between them: the rule
   turns vertical and runs from one panel into the next. */
@media (max-width: 720px) {
  .duo-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  .duo-join {
    width: auto;
    height: 3.4rem;
    font-size: 2.1rem;
  }
  .duo-join::before {
    inset: 0 50% auto;
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom,
      var(--c-literary), transparent 30%, transparent 70%, var(--c-engineering));
  }
  .duo-join::before { opacity: 0.5; }
}


/* ---------- Revealed on arrival ----------
   Triggered by position, then run on a fixed duration — motion tied to
   scroll speed plays slowly for slow scrollers and reads as broken. */
.reveal { opacity: 0; }

.reveal.seen {
  animation: rise 560ms var(--ease) backwards;
  animation-delay: calc(var(--i, 0) * 70ms);
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .reveal, .reveal.seen { opacity: 1; animation: none; }
  .duality path, .duality .d-trace { stroke-dashoffset: 0; animation: none; }
  .duality .d-node, .duality .d-dot { opacity: 1; animation: none; transform: none; }
}

/* ---------- Page and section headings ---------- */
.section { padding: 40px 0 46px; border-top: 0; }
.section > h2, .big-head > h2 {
  font-size: var(--t-xl);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.08;
  text-align: center;
  text-wrap: balance;
  max-width: 22ch;
  margin: 0 auto 14px;
}
.section .section-note { color: var(--ink-soft); margin: 0 auto 40px; text-align: center; max-width: 48ch; }
.section > .wrap, .section .section-note { }
.more-note { margin-top: 26px; font-size: var(--t-base); }

.section-intro { max-width: 62ch; margin: 26px 0 40px; color: var(--ink-soft); font-size: var(--t-body); }
.section-intro p { margin: 0 0 16px; }

.page-head { padding: 56px 0 4px; }
.page-head h1 { text-wrap: balance; font-size: calc(var(--t-xl) * 1.2); margin: 14px 0 12px; font-weight: 700; letter-spacing: -0.04em; }
.page-head > p:not(.pill) { color: var(--ink-soft); margin: 0; max-width: 58ch; font-size: var(--t-body); }

.big-head { text-align: center; margin: 54px 0 44px; }
main.wrap > .big-head:first-of-type { margin-top: 48px; }
.big-head .pill { margin-bottom: 16px; }

/* A group heading inside a page that already has one. Smaller, tighter
   and without the big heading's air, so the page reads as one section
   divided rather than as several sections stacked. */
.big-head.sub-head { margin: 40px 0 24px; }
.big-head.sub-head h2 { font-size: var(--t-lg); }
.big-head.sub-head .pill { margin-bottom: 10px; }

.big-head h2 span { color: inherit; }
.big-head > p:not(.pill) { color: var(--ink-soft); margin: 0 auto; max-width: 52ch; }


/* ---------- Page transitions ----------
   Moving between pages is a cross-fade rather than a white flash, and the
   bar at the top is held still through it, so the site reads as one
   surface. Browsers without view transitions simply navigate as before. */
@view-transition { navigation: auto; }

.site-header { view-transition-name: siteheader; }

/* The section cover is the one thing that exists on both sides of a jump
   from a card to its section, so it morphs across instead of fading.
   On a listing page the masthead art carries the name outright; on the
   home page site.js puts it on whichever card was clicked, because a name
   may only be used once per page. */
.section-banner { view-transition-name: cover; }

::view-transition-old(root),
::view-transition-new(root) { animation-duration: 260ms; }

::view-transition-group(cover) {
  animation-duration: 420ms;
  animation-timing-function: var(--ease);
}

/* A transition is motion like any other, so it goes when motion does. */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}

/* ---------- Section masthead ----------
   The title and the section's cover art share one band, so the art reads as
   the heading's own plate rather than a picture dropped above it. */
.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 40px;
  align-items: center;
  margin: 40px 0 10px;
}
.masthead .page-head { padding: 0; }

.section-banner {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 0;
}

/* One column under the point where 40px of gutter stops being affordable.
   The art leads, because a plate above a title still reads as a masthead. */
@media (max-width: 860px) {
  .masthead {
    grid-template-columns: minmax(0, 1fr);
    gap: 26px;
    margin: 28px 0 6px;
  }
  .masthead .section-banner { order: -1; aspect-ratio: 21 / 9; }
}


/* ---------- The art gallery ----------
   Two drawings, hung rather than tiled. The first takes the larger wall;
   the second is smaller and sits lower, which is what stops a pair of
   pictures reading as a row of thumbnails. Each one is matted inside a
   frame, so the paper around the drawing is part of the presentation. */
.art-gallery {
  display: grid;
  grid-template-columns: 1.24fr 1fr;
  gap: var(--s-6);
  align-items: start;
  margin: var(--s-5) 0 var(--s-7);
}

/* The drop is what makes the hang asymmetric. */
.art-gallery > .art-piece:nth-child(2) { margin-top: var(--s-7); }

.art-piece {
  position: relative;
  margin: 0;
  background: none;
  border: 0;
  cursor: zoom-in;
}

/* The mat and the frame. The inner shadow is the lip of the mount. */
.art-frame {
  display: block;
  overflow: hidden;
  padding: var(--s-3);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 18px 40px -22px rgb(0 0 0 / 0.42);
}

.art-frame img {
  display: block;
  width: 100%;
  height: auto;
  /* Never cropped: a drawing decides its own proportions. */
  object-fit: contain;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.07) inset;
  transition: transform var(--d-slow) var(--ease);
}

.art-piece figcaption {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 0 var(--s-2);
  margin-top: var(--s-3);
}

.art-no {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  color: var(--accent);
  letter-spacing: 0.08em;
}

.art-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--t-md);
  color: var(--ink);
}

.art-open {
  grid-column: 2;
  margin-top: 2px;
  font-size: var(--t-micro);
  font-weight: 600;
  color: var(--accent);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--d-mid) var(--ease), transform var(--d-mid) var(--ease);
}

@media (hover: hover) and (pointer: fine) {
  .art-piece:hover .art-frame img { transform: scale(1.035); }
  .art-piece:hover .art-open { opacity: 1; transform: none; }
}

/* The invitation has to be visible to a keyboard too, not only a pointer. */
.art-piece:focus-within .art-open { opacity: 1; transform: none; }

/* One column below the point where two drawings stop having room to
   differ in size; the drop goes with it. */
@media (max-width: 760px) {
  .art-gallery {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-5);
    margin-bottom: var(--s-6);
  }
  .art-gallery > .art-piece:nth-child(2) { margin-top: 0; }
}


/* ---------- Buttons and links ---------- */
/* Consecutive calls to action read as one row of choices, not a stack of
   three equal demands. Inline-flex lets a run of them sit on one line and
   wrap on their own when the column gets narrow. */
.channel-link {
  display: inline-flex;
  vertical-align: top;
  margin: 26px 10px 0 0;
}

/* Only the first of a run is the primary action; the rest step back to an
   outline so the eye is given somewhere to land. */
.channel-link + .channel-link a {
  background: transparent;
  color: var(--accent);
  border-color: var(--rule);
}

.channel-link a, .send-btn {
  color: var(--paper);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-pill);
  font-weight: 700;
}

.channel-link a { display: inline-block; text-decoration: none; padding: 14px 28px; font-size: var(--t-base); }

.send-btn {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  cursor: pointer;
  padding: 14px 26px;
  font: inherit;
  font-weight: 600;
}

.send-btn svg { width: 17px; height: 17px; }

.back-link {
  display: inline-block;
  margin-top: 32px;
  padding: 9px 17px;
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--ink);
  font-size: var(--t-meta);
  font-weight: 600;
  text-decoration: none;
}

/* ---------- Card grids ---------- */
.cards, .achievements, .design-grid, .recordings {
  display: grid;
  gap: 24px;
}

.cards { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.achievements { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-bottom: 76px; }
.design-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-bottom: 20px; }
.recordings { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-bottom: 20px; }

@media (min-width: 720px) {
  .cards.cards-quad { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

main.wrap > .cards:last-of-type { margin-bottom: 76px; }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  background: var(--card);
}

/* A light that follows the pointer across the cover art. It is laid over
   the art alone, never the body text, so nothing it does can touch the
   reading contrast underneath. site.js supplies --mx and --my; with no
   script the layer simply stays at zero opacity. */
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  aspect-ratio: 800 / 300;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 260ms var(--ease);
  background: radial-gradient(42% 70% at var(--mx, 50%) var(--my, 50%),
    rgba(255, 255, 255, 0.22), transparent 68%);
}
/* The cover is the lid of the card: full-bleed across the top, no inset. */
.card-media {
  display: block;
  width: 100%;
  aspect-ratio: 800 / 300;
  object-fit: cover;
  border-bottom: 1px solid var(--line);
}
.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 26px 26px 22px;
  background: var(--card-accent-tint, var(--card));
}
.card h3 {
  margin: 0 0 8px;
  font-size: var(--t-md);
  color: var(--card-accent, var(--accent));
}
.card p {
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-size: var(--t-base);
  text-wrap: pretty;
}

/* The call to action sits on the floor of the card, so a row of cards
   lines its arrows up however long the descriptions are. */
.card .go {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--card-accent, var(--accent));
  font-size: var(--t-meta);
  font-weight: 600;
}

/* Cards that carry a picture: achievements, CAD models, artwork. */
.achievement, .design, .art-piece, .recording { overflow: hidden; }
.design, .art-piece { margin: 0; }

.achievement .shot, .design img, .art-piece img {
  display: block;
  width: 100%;
  object-fit: cover;
  background: var(--paper-alt);
}

.achievement .shot { aspect-ratio: 16 / 10; max-height: 320px; }
.design img, .art-piece img { aspect-ratio: 4 / 3; }

.achievement .body { padding: 20px 22px 24px; }
.achievement h3 { font-size: var(--t-sm); margin: 0 0 8px; }
.achievement p { margin: 0; color: var(--ink-soft); font-size: var(--t-base); }

/* A highlight with no photo spans the row and holds a list. */
.achievement.wide { grid-column: 1 / -1; }
.achievement.wide .body { padding: 26px 28px 28px; }

.design figcaption { padding: 18px 22px 22px; }
.design .design-title { display: block; font-weight: 700; font-size: var(--t-sm); margin-bottom: 3px; }
.design .design-note { margin: 0; color: var(--ink-soft); font-size: var(--t-base); }

.art-piece figcaption { padding: 16px 20px 20px; }
.art-piece .art-title { display: block; font-weight: 600; margin-bottom: 3px; }
.art-piece .art-meta { display: block; color: var(--ink-soft); font-size: var(--t-meta); }

.recording-body { padding: 18px 22px 22px; }
.recording-body h3 { font-size: var(--t-sm); margin: 0 0 10px; }

/* A downloadable file under a card. */
.design .design-files { margin: 12px 0 0; font-size: var(--t-meta); }
.design .design-files a { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; text-decoration: none; }

.design .design-files a::before {
  content: "";
  width: 13px;
  height: 13px;
  flex: none;
  border-bottom: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px) scale(0.8);
}

/* ---------- Literary: five doors, five shapes ----------
   The page says "pick a door below", and a row of five identical cards
   is not five doors, it is one door drawn five times. Each category now
   takes a shape that suits what is behind it: the big collections get
   room and a cover, the single essay gets a band, the poems get air,
   and the shelf gets the full width because a shelf is a long thing. */
.cards.lit-doors {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--s-3);
}

.lit-doors .door { grid-column: span 3; }

/* The count, in the category's own colour, reading as a masthead figure
   rather than as a statistic. */
.door-count {
  margin: 0 0 6px;
  color: var(--card-accent, var(--accent));
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.door-count b {
  font-family: var(--font-serif);
  font-size: 1.9rem;
  font-weight: 600;
  letter-spacing: 0;
  vertical-align: -3px;
  margin-right: 4px;
}

/* --- Articles: the widest of the prose collections, so the cover turns
       on its side and the text reads beside it like a spread. --- */
.d-articles { grid-column: span 4 !important; flex-direction: row; align-items: stretch; }
.d-articles .card-media {
  width: 38%;
  height: auto;
  aspect-ratio: auto;
  border-bottom: 0;
  border-right: 1px solid var(--line);
}
.d-articles::before { inset: 0 62% auto 0; aspect-ratio: auto; height: 100%; }

/* --- Essays: one long argued piece, so it gets a column with a rule
       down the side, the way a quotation is marked in print. --- */
.d-essays { grid-column: span 2 !important; }
.d-essays .card-body { border-left: 3px solid var(--card-accent, var(--accent)); }
.door-title {
  margin: 0 0 18px !important;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--t-base);
  color: var(--ink) !important;
}

/* --- Poems: the shortest of the collections and the one that needs
       space. Centred, serif, and the three titles set as an index. --- */
.d-poems .card-body { align-items: center; text-align: center; padding: var(--s-5) var(--s-4); }
.d-poems h3 { font-family: var(--font-serif); font-style: italic; font-weight: 500; }

.door-list {
  list-style: none;
  margin: 0 0 var(--s-3);
  padding: var(--s-3) 0 0;
  border-top: 1px solid var(--line);
  font-family: var(--font-serif);
  font-size: var(--t-meta);
  line-height: 2;
  color: var(--ink);
}

/* --- Stories: the biggest collection, with its cover as a lid. --- */
.d-stories { grid-column: span 3; }

/* --- Books: a shelf, so it runs the full width and the spines stand
       along the bottom of it. --- */
.d-books {
  grid-column: span 6 !important;
  flex-direction: row;
  align-items: stretch;
}
.d-books .card-body { flex: 1 1 46%; }
.d-books::before { display: none; }

.shelf {
  position: relative;
  flex: 1 1 54%;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  justify-content: center;
  margin: 0;
  padding: var(--s-4);
  list-style: none;
  border-left: 1px solid var(--line);
  background: color-mix(in oklab, var(--card-accent, var(--accent)) 6%, transparent);
}

/* The books stand on a board rather than floating above the floor of the
   card, so the row reads as a shelf and not as a bar chart. */
.shelf::after {
  content: "";
  position: absolute;
  left: var(--s-3);
  right: var(--s-3);
  bottom: calc(var(--s-4) - 5px);
  height: 5px;
  border-radius: 2px;
  background: color-mix(in oklab, var(--card-accent, var(--accent)) 46%, var(--paper));
}
.shelf li { z-index: 1; }

/* Each spine is a book standing on the shelf: a different height and a
   different depth, because a real shelf is never uniform. The title runs
   up the spine, as it does on a book. */
.shelf li {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 34px;
  height: calc(132px + var(--h, 0px));
  border-radius: 3px 3px 0 0;
  /* Each spine stays mostly paper, so the title on it is readable in both
     themes: paper and ink always contrast, whichever way round they are.
     The accent only tints the spine, it never decides the text colour. */
  background: color-mix(in oklab, var(--card-accent, var(--accent)) var(--d, 30%), var(--paper));
  border: 1px solid color-mix(in oklab, var(--card-accent, var(--accent)) 42%, transparent);
  border-bottom: 0;
  box-shadow: inset -3px 0 0 color-mix(in oklab, var(--card-accent, var(--accent)) 22%, transparent);
}
.shelf li:nth-child(1) { --h: 20px; --d: 40%; }
.shelf li:nth-child(2) { --h: 5px;  --d: 22%; }
.shelf li:nth-child(3) { --h: 28px; --d: 34%; }
.shelf li:nth-child(4) { --h: 0px;  --d: 16%; }
.shelf li:nth-child(5) { --h: 14px; --d: 38%; }
.shelf li:nth-child(6) { --h: 34px; --d: 27%; }

.shelf span {
  writing-mode: vertical-rl;
  rotate: 180deg;
  margin-bottom: 10px;
  max-height: calc(100% - 20px);
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Two columns at tablet width: the wide doors take a whole row each and
   the narrow ones pair up. */
@media (max-width: 900px) {
  .cards.lit-doors { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lit-doors .door { grid-column: span 2; }
  .d-articles { grid-column: span 4 !important; }
  .d-essays   { grid-column: span 2 !important; }
  .d-books    { grid-column: span 4 !important; }
}

/* One column, and the shelf moves below the text rather than beside it. */
@media (max-width: 640px) {
  .cards.lit-doors { grid-template-columns: minmax(0, 1fr); }
  .lit-doors .door,
  .d-articles, .d-essays, .d-books { grid-column: span 1 !important; }
  .d-articles, .d-books { flex-direction: column; }
  .d-articles .card-media {
    width: 100%;
    aspect-ratio: 800 / 300;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .d-articles::before { inset: 0 0 auto 0; aspect-ratio: 800 / 300; height: auto; }
  .shelf {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: var(--s-4) var(--s-3) 0;
  }
}


/* ---------- Software projects ----------
   A bordered grid rather than separate cards: the cells share their rules,
   so the whole block reads as one table of work. */
/* ---------- Software: the studio ----------
   The only page that opens dark. Everything here is deep indigo, a
   drafting grid and electric blue, because a software section should not
   look like the same room as the poems. */
.sw-hero {
  --sw-ink: #f3f1ff;
  position: relative;
  isolation: isolate;
  /* Breaks out of the 940px text column to the full window. body carries
     overflow-x: clip, so the viewport unit cannot start a sideways
     scrollbar on a page that has one vertically. */
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  margin-bottom: var(--s-6);
  padding: var(--s-7) 0 var(--s-6);
  overflow: hidden;
  /* An explicit base colour under the gradients. Without it the computed
     background-color is transparent, so if a gradient ever fails to paint
     the pale text would land on white paper. */
  background-color: #16123a;
  background-image:
    radial-gradient(70% 120% at 82% 10%, #3a2d7a 0%, transparent 62%),
    linear-gradient(148deg, #16123a 0%, #1d1a4d 54%, #121033 100%);
  color: var(--sw-ink);
}

/* It runs the full width of the window, not the text column. */
.sw-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  /* A drafting grid, finer than the content, so it reads as paper. */
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.055) 1px, transparent 1px);
  background-size: 46px 46px, 46px 46px;
  mask-image: radial-gradient(76% 86% at 36% 34%, #000 0%, transparent 78%);
}

.sw-hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: var(--s-5);
  align-items: center;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
}

.sw-hero h1 {
  margin: var(--s-3) 0 var(--s-2);
  font-size: calc(var(--t-xl) * 1.2);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.04;
  color: var(--sw-ink);
  text-wrap: balance;
}
.sw-hero p:not(.pill) {
  margin: 0;
  max-width: 46ch;
  color: #c3bddf;
  font-size: var(--t-body);
}
.sw-hero .pill {
  background: rgba(255, 255, 255, 0.11);
  color: #cfc8f5;
}
.sw-hero-art {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: 0 30px 60px -28px rgba(0, 0, 0, 0.8);
}

/* ---------- A project running in the page ----------
   SW-Crawl is a static page of its own, so the card frames it rather
   than illustrating it: what a visitor sees is the project. The card
   stacks so the frame gets the whole feature row, and the frame keeps a
   fixed height because a page in another origin cannot report its own.
*/
.sw-project.sw-live { flex-direction: column; align-items: stretch; gap: 0; }
.sw-project.sw-live .sw-body { flex: 0 0 auto; padding: var(--s-5) var(--s-5) var(--s-4); }

/* The frame runs edge to edge inside the card: the crawl wants every
   pixel of width, and running it full-bleed reads as the project being
   embedded rather than pasted in. Only the text around it is indented. */
.live-embed {
  padding: var(--s-4) 0 var(--s-4);
  border-top: 1px solid var(--line);
  background: var(--paper);
}
.live-head, .live-foot { padding: 0 var(--s-5); }

/* A line of running text, not a flex row: as a flex container the
   <em> inside it became its own item and collected the row gap on
   both sides, which put a space in front of the comma after it. */
.live-head {
  margin: 0 0 var(--s-3) !important;
  color: var(--ink) !important;
  font-size: var(--t-meta) !important;
  line-height: 1.7;
}
.live-head em { font-family: var(--font-serif); font-size: 1.05em; }

/* A dot that says the thing in the frame is the deployed project and
   not a picture of it. It pulses only where motion is welcome. */
.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: 10px;
  vertical-align: 1px;
  padding: 3px 11px 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--accent-tint);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.live-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: live-pulse 2.4s var(--ease) infinite;
}
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.live-frame {
  position: relative;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  /* The crawl is white type on black, so the frame sits on black and
     there is no white flash before the page inside it paints. */
  background: #05060a;
}

/* The control sits over the frame rather than beside the caption, so
   it is where the motion is and reachable without hunting. */
.live-controls { margin: 0 0 10px !important; padding: 0 var(--s-5); text-align: right; }
.live-controls[hidden] { display: none; }

.live-ctl {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  font-weight: 700;
  cursor: pointer;
  transition: border-color var(--d-fast) var(--ease), color var(--d-fast) var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .live-ctl:hover { border-color: var(--accent); color: var(--accent); }
}

/* Two bars while it is running, one triangle while it is not, drawn
   rather than fetched. aria-pressed carries the same state in words. */
.live-ctl-ic {
  width: 9px;
  height: 11px;
  background: currentColor;
  clip-path: polygon(0 0, 3px 0, 3px 11px, 0 11px, 0 0, 6px 0, 9px 0, 9px 11px, 6px 11px);
}
.live-ctl[aria-pressed="true"] .live-ctl-ic {
  clip-path: polygon(0 0, 9px 50%, 0 100%);
}

/* Behind the frame: something to look at while it starts, and
   something to read instead of an empty box if it never arrives. */
.live-frame::before {
  content: "Starting SW-Crawl\2026";
  position: absolute;
  inset: 0;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
  text-align: center;
  color: #6d7890;
  font-family: var(--font-mono);
  font-size: var(--t-meta);
}

.live-frame iframe {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 560px;
  border: 0;
}
.live-frame iframe[hidden] { display: none; }

/* While the button is standing in for the crawl, the "starting" line
   behind it has nothing to announce, and showed through the button. */
.live-frame:has([data-embed-play]:not([hidden]))::before { content: none; }

/* Stopped on purpose reads differently from still loading. */
.live-frame[data-state="stopped"]::before { content: "Stopped."; }

/* What stands in for the crawl when the reader has asked for less
   movement: the whole frame as one button, so it is a large target and
   says plainly why it is waiting. */
.live-play {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 360px;
  padding: var(--s-4);
  border: 0;
  background: none;
  color: #e7ecf6;
  text-align: center;
  cursor: pointer;
}
.live-play-label {
  padding: 10px 22px;
  border: 1px solid #39425c;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: var(--t-meta);
  font-weight: 700;
}
.live-play-note { max-width: 42ch; color: #98a3bb; font-size: var(--t-meta); line-height: 1.5; }

/* display: flex above beats the hidden attribute's own display: none,
   so the button has to be told again. Without this it sits under the
   frame for everyone, not only for the readers it is meant for. */
.live-play[hidden] { display: none; }
@media (hover: hover) and (pointer: fine) {
  .live-play:hover .live-play-label { border-color: #8fa0c8; }
}

.live-foot {
  margin: var(--s-2) 0 0 !important;
  color: var(--ink-soft);
  font-size: var(--t-meta) !important;
}
.live-foot a { font-weight: 600; }

/* A phone has no room for a 560px frame above the fold, and the page
   inside scrolls itself. */
@media (max-width: 760px) { .live-frame iframe { height: 460px; } }
@media (max-width: 480px) {
  .live-embed { padding: var(--s-3) 0 var(--s-3); }
  .live-head, .live-foot { padding: 0 var(--s-4); }
  .live-frame iframe { height: 380px; }
  .live-play { height: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  .live-chip::before { animation: none; }
}

/* ---------- The project grid ----------
   Six columns, so cards can take a half, a third or two thirds and the
   page stops being a stack of equal boxes. The narrow cell is for the
   project with the least to say. */
.sw-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--s-4);
  margin: 0 0 var(--s-7);
}

.sw-project {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  grid-column: span 3;
  padding: var(--s-4) var(--s-4) var(--s-4);
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: transform var(--d-mid) var(--ease),
              box-shadow var(--d-mid) var(--ease),
              border-color var(--d-mid) var(--ease);
}

.sw-feature { grid-column: span 6; }
.sw-wide    { grid-column: span 4; }
.sw-narrow  { grid-column: span 2; }

/* The featured project puts its decoration beside the words. */
.sw-feature {
  flex-direction: row;
  align-items: stretch;
  gap: var(--s-5);
  padding: 0;
}
.sw-feature .sw-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  flex: 1 1 58%;
  padding: var(--s-5);
}
.sw-feature h2 { font-size: var(--t-md); }

@media (hover: hover) and (pointer: fine) {
  .sw-project:hover {
    transform: translateY(-3px);
    border-color: color-mix(in oklab, var(--accent) 45%, var(--line));
    box-shadow: 0 18px 38px -26px rgb(0 0 0 / 0.5);
  }
}

.sw-kind {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.sw-project h2 { margin: 0; font-size: var(--t-sm); letter-spacing: -0.015em; }
.sw-project p { margin: 0; color: var(--ink-soft); font-size: var(--t-base); }
.sw-project p.empty { color: var(--ink-soft); font-style: italic; }

.sw-tags { display: flex; flex-wrap: wrap; gap: 7px; list-style: none; margin: 4px 0 0; padding: 0; }

.sw-tags li {
  background: var(--accent-tint);
  border: 1px solid color-mix(in oklab, var(--accent) 22%, transparent);
  border-radius: var(--radius-pill);
  padding: 3px 11px;
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  color: var(--accent);
}

/* Pushed to the foot of the cell so the buttons line up across a row. */
.sw-project .sw-links {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin: auto 0 0;
  padding-top: var(--s-3);
}

.sw-links a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  font-weight: 700;
  text-decoration: none;
  transition: background-color var(--d-fast) var(--ease),
              color var(--d-fast) var(--ease),
              border-color var(--d-fast) var(--ease);
}

/* Something you can open outranks something you can read. */
.sw-links a.sw-demo {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}
.sw-links a.sw-demo::after {
  content: "\2197";
  transition: transform var(--d-fast) var(--ease);
}

@media (hover: hover) and (pointer: fine) {
  .sw-links a:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }
  .sw-links a.sw-demo:hover { background: var(--ink); border-color: var(--ink); }
  .sw-links a.sw-demo:hover::after { transform: translate(2px, -2px); }
}

/* ---------- What each project looks like ----------
   A small amount of decoration per project, drawn in CSS from what the
   project actually is: a graph, a row of letter tiles. SW-Crawl has
   none, because it runs in the card for real. */

/* MathCanvas: a coordinate grid with a curve across it. */
[data-sw="math"]::before {
  content: "";
  position: absolute;
  inset: auto -10% -14% 42%;
  height: 170px;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    linear-gradient(color-mix(in oklab, var(--accent) 24%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in oklab, var(--accent) 24%, transparent) 1px, transparent 1px);
  background-size: 26px 26px, 26px 26px;
  mask-image: radial-gradient(70% 80% at 60% 80%, #000, transparent 72%);
}

/* Hangman: the word, as the tiles you would guess it on. */
.sw-tiles {
  display: flex;
  gap: 5px;
  margin: var(--s-2) 0 0;
}
.sw-tiles span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 30px;
  border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--line));
  border-radius: 4px;
  background: var(--accent-tint);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  font-weight: 700;
}
/* Two of the seven are still blank, the way the game starts. */
.sw-tiles span:nth-child(3),
.sw-tiles span:nth-child(6) {
  color: transparent;
  background: var(--paper-alt);
  border-style: dashed;
}

/* ---------- Narrower screens ----------
   Six columns stop being readable long before they stop fitting. */
@media (max-width: 900px) {
  .sw-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sw-project, .sw-feature, .sw-wide, .sw-narrow { grid-column: span 1; }
  .sw-feature { flex-direction: column; padding: 0; }
  .sw-feature .sw-body { padding: var(--s-4); }
  .sw-hero-inner { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
  .sw-hero { padding: var(--s-6) 0 var(--s-5); }
}

@media (max-width: 620px) {
  .sw-grid { grid-template-columns: minmax(0, 1fr); }
  .sw-project { padding: 22px 20px 24px; }
}

.piece-list, .book-list { list-style: none; margin: 30px 0 76px; padding: 0; }
/* ---------- Elsewhere ----------
   Six places the work is published, each in the hue of whatever it
   carries: writing warm, code purple, builds blue. A tile is a link and
   nothing else, so there is no second thing to press inside it. */
.places {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--s-3);
  list-style: none;
  margin: var(--s-4) 0 var(--s-6);
  padding: 0;
}

.place { margin: 0; }

.place a {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  gap: 2px var(--s-2);
  height: 100%;
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--d-fast) var(--ease),
              background var(--d-fast) var(--ease),
              transform var(--d-mid) var(--ease);
}

.place-ic {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--card-accent-tint, var(--accent-tint));
  color: var(--card-accent, var(--accent));
}
.place-ic svg { width: 20px; height: 20px; }

.place-name {
  align-self: end;
  font-family: var(--font-display);
  font-size: var(--t-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* The handle, in monospace, so it reads as an address rather than as a
   sentence. It is allowed to run out of room rather than wrap. */
.place-at {
  align-self: start;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
}

/* The arrow only appears on a device that can point, because on a
   touchscreen it is decoration nobody asked for. */
@media (hover: hover) and (pointer: fine) {
  .place a::after {
    content: "\2197";
    position: absolute;
    top: 10px;
    right: 12px;
    color: var(--card-accent, var(--accent));
    opacity: 0;
    transition: opacity var(--d-fast) var(--ease), transform var(--d-fast) var(--ease);
  }
  .place a:hover {
    border-color: var(--card-accent, var(--accent));
    transform: translateY(-2px);
  }
  .place a:hover::after { opacity: 1; transform: translate(2px, -2px); }
}

@media (prefers-reduced-motion: reduce) {
  .place a { transition: border-color var(--d-fast) var(--ease); }
  .place a:hover { transform: none; }
}


/* ---------- The contribution calendar ----------
   A year of squares, one per day, five shades. The shades are mixed from
   the section's own accent rather than borrowed from GitHub's green, so
   the panel belongs to the page it sits on and changes with the theme. */
.gh {
  margin: 0 0 var(--s-7);
  padding: var(--s-5);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.gh-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
}

.gh-total { margin: 0; color: var(--ink-soft); font-size: var(--t-base); }
.gh-total b {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--t-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.gh-as-of { margin: 0; color: var(--ink-soft); font-family: var(--font-mono); font-size: var(--t-micro); }

/* The year scrolls sideways rather than squashing its squares: a day is
   a day, and a calendar with unreadable cells is not a calendar. */
.gh-cal { overflow-x: auto; padding-bottom: 6px; }
.gh-cal[hidden] { display: none; }

.gh-months {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--cell, 13px);
  gap: 0 3px;
  margin: 0 0 5px 30px;
  min-width: max-content;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
}
.gh-months span { grid-row: 1; }

.gh-body { display: flex; gap: 6px; min-width: max-content; }

/* Three weekday labels, on the rows GitHub labels: Monday, Wednesday,
   Friday. They sit on the second, fourth and sixth square of a column. */
.gh-days {
  display: grid;
  grid-template-rows: repeat(7, var(--cell, 13px));
  gap: 3px;
  width: 24px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  line-height: var(--cell, 13px);
}
.gh-days span:nth-child(1) { grid-row: 2; }
.gh-days span:nth-child(2) { grid-row: 4; }
.gh-days span:nth-child(3) { grid-row: 6; }

.gh-grid { display: flex; gap: 3px; }

.gh-week {
  display: grid;
  grid-template-rows: repeat(7, var(--cell, 13px));
  gap: 3px;
}

.gh-grid i, .gh-legend i {
  display: block;
  width: var(--cell, 13px);
  height: var(--cell, 13px);
  border-radius: 3px;
}

/* Five steps from the paper to the accent. The lightest still carries a
   faint outline, so an empty day reads as a day and not as a gap. */
.l0 { background: var(--paper-alt); box-shadow: inset 0 0 0 1px var(--line); }
.l1 { background: color-mix(in oklab, var(--accent) 26%, var(--paper-alt)); }
.l2 { background: color-mix(in oklab, var(--accent) 50%, var(--paper-alt)); }
.l3 { background: color-mix(in oklab, var(--accent) 74%, var(--paper-alt)); }
.l4 { background: var(--accent); }

.gh-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin: var(--s-3) 0 0;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
}
.gh-legend span:first-child { margin-right: 5px; }
.gh-legend span:last-child { margin-left: 5px; }

.gh-none {
  margin: 0;
  padding: var(--s-4);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: var(--t-meta);
  text-wrap: pretty;
}
.gh-none[hidden] { display: none; }

.gh-link { margin: var(--s-4) 0 0; }
.gh-link a { color: var(--accent); font-size: var(--t-meta); font-weight: 600; }

/* A smaller square on a phone, so a little less of the year is off the
   edge before anyone scrolls. */
@media (max-width: 620px) {
  .gh { --cell: 11px; padding: var(--s-4); }
  .gh-head { margin-bottom: var(--s-3); }
}


/* ---------- Listings ----------
   An archive reads better as an index than as a stack of identical
   boxes: a quiet number, a rule between entries, and the whole row
   clickable where there is somewhere to go. */
.piece-list, .book-list { counter-reset: idx; border-top: 1px solid var(--line); }

.piece, .book {
  position: relative;
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) 1.6rem;
  align-items: start;
  gap: 0 18px;
  padding: 26px 10px;
  margin: 0;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}

.piece::before, .book::before {
  counter-increment: idx;
  content: counter(idx, decimal-leading-zero);
  grid-column: 1;
  grid-row: 1 / -1;
  padding-top: 0.5em;
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  color: var(--ink-soft);
}

/* A rule down the left edge of a row, drawn as a background so it needs
   neither an extra element nor the two pseudo-elements already spoken for
   by the index number and the arrow. It grows from nothing on hover. */
.piece:has(h2 a), .book:has(h2 a) {
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-position: left center;
  background-size: 2px 0%;
  transition: background-size 280ms var(--ease), background-color 200ms var(--ease);
}

.piece::before, .book::before { transition: color 200ms var(--ease); }

.piece > *, .book > * { grid-column: 2; }
/* Chips are grid items now, so they must be told not to stretch. */
.piece .meta, .book .author { justify-self: start; }
.piece .summary, .book .reason { max-width: 68ch; }

/* The arrow, and the whole-row link, only where the title leads somewhere. */
.piece:has(h2 a)::after, .book:has(h2 a)::after {
  content: "\2192";
  grid-column: 3;
  grid-row: 1 / -1;
  align-self: center;
  justify-self: end;
  color: var(--ink-soft);
  transition: transform 240ms var(--ease), color 240ms var(--ease);
}

.piece h2 a::after, .book h2 a::after { content: ""; position: absolute; inset: 0; }
.piece .summary a, .book .reason a { position: relative; z-index: 1; }
.piece h2, .book h2 { font-size: var(--t-md); margin: 0 0 10px; }
.piece h2 a { text-decoration: none; color: var(--ink); }
.piece .summary, .book .reason { margin: 0; color: var(--ink-soft); }

/* The featured list on the home page borrows each piece's own hue. */
.featured-list { margin: 0 0 8px; }
.featured-list .meta { border-color: var(--rule); color: var(--ink); }
.featured-list .piece h2 a:hover { color: var(--card-accent, var(--accent)); }

/* ---------- One index, six voices ----------
   The archive is the same component on every category page — numbered,
   ruled, whole-row clickable — but a list of poems should not be set the
   way a list of research papers is. Each page's body class retunes the
   same markup, so nothing has to be duplicated to look different. */

/* --- Poems: three of them, so they get the room. Serif titles at
       reading size, the number large and pale in the margin, and the
       summary set as prose rather than as metadata. --- */
.s-poems .piece { padding: var(--s-5) 10px; grid-template-columns: 4.5rem minmax(0, 1fr) 1.6rem; }
.s-poems .piece h2 { font-family: var(--font-serif); font-size: var(--t-lg); font-weight: 500; }
.s-poems .piece::before {
  font-family: var(--font-serif);
  font-size: 2rem;
  color: color-mix(in oklab, var(--accent) 38%, transparent);
  padding-top: 0;
}
.s-poems .piece .summary {
  font-family: var(--font-serif);
  font-size: var(--t-body);
  line-height: 1.65;
  max-width: 54ch;
}

/* --- Short stories: eight of them, and a path through them. The rail
       joins one number to the next so the column reads as a route. --- */
.s-stories .piece::before {
  color: var(--accent);
  font-weight: 700;
  font-size: var(--t-meta);
}
.s-stories .piece { padding-left: 10px; }
.s-stories .piece > *, .s-stories .piece::before { position: relative; z-index: 1; }

/* The rail itself: one line behind the whole column of numbers, stopped
   short at the top and bottom entries so it does not run off the list. */
.s-stories .piece-list { position: relative; }
.s-stories .piece-list::before {
  content: "";
  position: absolute;
  top: 48px;
  bottom: 48px;
  left: calc(10px + 1.5rem);
  width: 1px;
  background: color-mix(in oklab, var(--accent) 30%, transparent);
}

/* Each number is a bead on that rail rather than a label beside it, so
   it is sized to the digits and centred on the line. */
.s-stories .piece::before {
  justify-self: center;
  width: fit-content;
  margin-top: 0.35em;
  padding: 4px 7px;
  border-radius: var(--radius-pill);
  border: 1px solid color-mix(in oklab, var(--accent) 30%, transparent);
  background: var(--paper);
}

/* --- Articles: non-fiction, so the kind of piece leads. The meta chip
       moves up beside the title rather than sitting under it. --- */
.s-articles .piece { grid-template-columns: 3rem minmax(0, 1fr) 1.6rem; }
.s-articles .piece h2 { margin-bottom: 6px; }
.s-articles .piece .meta { margin-bottom: 10px; }

/* --- Essays: one long argued piece, so it is a feature and not a row
       in a list. It takes the full width and sets its title large. --- */
.s-essays .piece-list { border-top: 0; }
.s-essays .piece {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  padding: var(--s-5) var(--s-5) var(--s-5) var(--s-5);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--card);
}
.s-essays .piece::before { display: none; }
.s-essays .piece::after {
  grid-column: 1;
  grid-row: auto;
  align-self: start;
  justify-self: start;
  margin-top: 16px;
  color: var(--accent);
}
.s-essays .piece > * { grid-column: 1; }
.s-essays .piece h2 { font-size: var(--t-xl); line-height: 1.12; text-wrap: balance; }
.s-essays .piece .summary { font-size: var(--t-body); line-height: 1.6; }

/* --- Research: a structured record rather than an index. The metadata
       is a labelled column of its own, because a paper is found by its
       field and year as often as by its title. --- */
.s-research .piece {
  grid-template-columns: 9rem minmax(0, 1fr) 1.6rem;
  padding: var(--s-4) 10px;
}
.s-research .piece::before { display: none; }
.s-research .piece .meta {
  grid-column: 1;
  grid-row: 1;
  align-self: start;
  margin: 6px 0 0;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  line-height: 1.6;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.s-research .piece h2, .s-research .piece .summary { grid-column: 2; }

/* --- Books: each row carries the edge of its own spine, so the page
       reads down a shelf. --- */
.s-books .book {
  padding-left: 26px;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-position: 6px center;
  background-size: 6px calc(100% - 26px);
  border-radius: 3px;
}
.s-books .book::before { display: none; }
.s-books .book h2 { font-family: var(--font-serif); font-weight: 600; }
.s-books .book .author {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 0.04em;
}

/* The hover rule on the left edge would fight the spine, so on this page
   the row lightens instead. */
.s-books .book:has(h2 a) { background-image: linear-gradient(var(--accent), var(--accent)); }

@media (max-width: 620px) {
  .s-poems .piece { grid-template-columns: 3rem minmax(0, 1fr) 1.2rem; padding: var(--s-4) 6px; }
  .s-poems .piece::before { font-size: 1.5rem; }
  .s-research .piece { grid-template-columns: minmax(0, 1fr) 1.2rem; }
  .s-research .piece .meta { grid-column: 1; grid-row: auto; margin: 0 0 8px; }
  .s-research .piece h2, .s-research .piece .summary { grid-column: 1; }
  .s-essays .piece { padding: var(--s-4); }
  .s-essays .piece h2 { font-size: var(--t-lg); }
}


/* ---------- Reading pages ---------- */
article.prose {
  max-width: 43rem;          /* about 68 characters at this size */
  margin: 0 auto 76px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 46px 52px 52px;
}

article.prose h1 { font-size: calc(var(--t-xl) * 1.04); line-height: 1.08; margin: 18px 0 14px; font-weight: 700; letter-spacing: -0.03em; }
article.prose h2 { font-size: var(--t-sm); margin: 34px 0 14px; }

/* The writing itself reads better in the serif, whatever section the
   piece sits under. */
article.prose p, article.prose li, article.prose blockquote {
  font-family: var(--font-serif);
  font-size: 1.12rem;
  line-height: 1.75;
}

article.prose p { margin: 0 0 20px; }
article.prose ul { margin: 0 0 20px; padding-left: 1.3em; }
article.prose li { margin-bottom: 8px; }
article.prose p.block { color: var(--ink-soft); }
article.prose.poem { max-width: 34rem; }
article.prose.poem .stanza { margin: 0 0 30px; line-height: 1.85; }

article.prose .end-mark {
  color: var(--ink-soft);
  text-align: center;
  letter-spacing: 0.6em;
  margin: 40px 0 0;
}

/* Cited sources, and the note saying where a piece was published.
   Both step out of the serif back into the interface font. */
article.prose ol.sources { margin: 0 0 22px; padding-left: 1.4em; }

article.prose ol.sources li {
  font-family: var(--font-sans);
  font-size: var(--t-meta);
  line-height: 1.55;
  color: var(--ink-soft);
}

article.prose p.published-note {
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-family: var(--font-sans);
  font-size: var(--t-meta);
  color: var(--ink-soft);
}

article.prose ol.sources li { margin-bottom: 12px; }
.sources .src-what { font-style: italic; color: var(--ink); }
.sources .src-use { display: block; font-size: var(--t-meta); opacity: 0.85; }

/* Moving between pieces. */
.piece-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 40rem;
  margin: 0 auto 76px;
}

.piece-nav a { display: block; text-decoration: none; padding: 18px 22px; }

.piece-nav .name {
  display: block;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--t-body);
  line-height: 1.35;
}

.piece-nav .next { text-align: right; }
.piece-nav .next-placeholder { visibility: hidden; }

/* ---------- Video, tags and clips ---------- */

.tags { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }

.tags li {
  background: var(--paper-alt);
  border: 0;
  border-radius: var(--radius-pill);
  padding: 5px 13px;
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  color: var(--ink-soft);
}

/* A 16:9 frame for an embedded video. */
.video {
  position: relative;
  padding-top: 56.25%;
  background: var(--paper-alt);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.recording .video { border-radius: 0; border: 0; }

/* Shown until a real video ID replaces it. */
.video-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  color: var(--ink-soft);
  font-size: var(--t-meta);
  font-style: italic;
}

/* Build clips are portrait phone recordings. Each build card sizes its
   own frame; this is the fallback for a clip used anywhere else. */
.clip { margin: 0; max-width: 100%; }

.clip video {
  display: block;
  height: 340px;
  width: auto;
  max-width: 100%;
  border-radius: var(--radius-sm);
  background: #000;
  box-shadow: var(--shadow);
}

.clip figcaption { margin-top: 8px; color: var(--ink-soft); font-size: var(--t-meta); }

/* ---------- The builds, each shaped like itself ----------
   These were four identical panels behind radio tabs: three hidden at
   any moment, and the visible one indistinguishable from the others.
   All four are on the page now, and the grid gives each the room its
   content asks for rather than an equal quarter. */
.builds {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--s-4);
  margin: 0 0 var(--s-7);
}

.build {
  position: relative;
  grid-column: span 3;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-4);
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* A label in the grotesk, saying what kind of thing this is: the build
   itself, a tutorial about it, an assembly, a colour piece. */
.build-kind {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.build h3 {
  margin: 0 0 10px;
  font-size: var(--t-md);
  line-height: 1.2;
  text-wrap: balance;
}

.build .lede { margin: 0; color: var(--ink-soft); font-size: var(--t-base); line-height: 1.6; text-wrap: pretty; }

/* The video fills whatever column it is given rather than standing at a
   fixed height, so the four cards do not all end up the same shape. */
.build-media .clip { margin: 0; width: 100%; }
/* contain, not cover: these were filmed on a phone and are taller than
   they are wide, so cropping them to a landscape box would throw away
   most of the bench. Letterboxed on black keeps the whole frame. */
.build-media .clip video {
  width: 100%;
  height: 300px;
  object-fit: contain;
  background: #000;
  border-radius: var(--radius-sm);
}

.build-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: var(--s-3);
  margin-top: auto;
  padding-top: var(--s-3);
  border-top: 1px solid var(--line);
}
.build-foot .links a { color: var(--accent); font-size: var(--t-meta); font-weight: 600; }

/* --- The radar is the build the others are about, so it is the feature:
       full width, the video given the larger half, and the text beside
       it rather than under it. --- */
.build-feature {
  grid-column: span 6;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  padding: 0;
}
/* The duration sits on the video itself, so it must be positioned
   against the frame and not against the whole card — otherwise on a
   phone, where the video moves to the top, the caption stays at the
   bottom and lands on the YouTube link. */
.build-feature .build-media { flex: 1 1 56%; display: flex; position: relative; }
.build-feature .build-media .clip { display: flex; }
.build-feature .build-media .clip { flex: 1; }
.build-feature .build-media .clip video {
  height: 440px;
  border-radius: 0;
}
.build-feature .build-media figcaption {
  position: absolute;
  left: var(--s-3);
  bottom: var(--s-3);
  margin: 0;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-family: var(--font-mono);
  font-size: var(--t-micro);
}
.build-feature .build-body {
  flex: 1 1 44%;
  display: flex;
  flex-direction: column;
  padding: var(--s-5);
  border-left: 1px solid var(--line);
}
.build-feature h3 { font-size: var(--t-lg); }
.build-feature .lede { font-size: var(--t-body); margin-bottom: var(--s-4); }

/* --- The two tutorials are a matched pair, so they share a shape and a
       marker: a corner rule, like the step number on a worksheet. Their
       feet stack, so the pair lines up however long the component list
       on each one happens to be. --- */
.b-tutorial .build-foot, .b-crane .build-foot {
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-2);
}

.b-tutorial::before, .b-crane::before {
  content: "";
  position: absolute;
  top: 0;
  left: var(--s-4);
  width: 42px;
  height: 3px;
  background: var(--accent);
}

/* --- Tiranga is about three colours, so the card carries them: a still
       band at the edge, in the flag's own saffron, white and green. It
       is a picture of the subject, not a simulation of the hardware. --- */
.build-wide {
  grid-column: span 6;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  padding: 0;
}
.build-wide .build-body {
  flex: 1 1 46%;
  display: flex;
  flex-direction: column;
  padding: var(--s-5);
}
.build-wide .build-media { flex: 1 1 54%; display: flex; padding: var(--s-4); }
.build-wide .build-media .clip video { aspect-ratio: 16 / 9; }

/* The white band would vanish into the card without an edge on it. */
.flag {
  flex: 0 0 14px;
  display: flex;
  flex-direction: column;
  box-shadow: inset -1px 0 0 var(--line);
}
.flag i { flex: 1; }
.flag i:nth-child(1) { background: #ff9933; }   /* saffron */
.flag i:nth-child(2) { background: #ffffff; }
.flag i:nth-child(3) { background: #138808; }   /* green */

/* Two columns for the pair, one for everything wide. */
@media (max-width: 900px) {
  .builds { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .build { grid-column: span 1; }
  .build-feature, .build-wide { grid-column: span 2; }
}

/* Below this the side-by-side halves stop working: the video gets too
   narrow to watch and the text too narrow to read. */
@media (max-width: 720px) {
  .build-feature, .build-wide { flex-direction: column; }
  .build-feature .build-body, .build-wide .build-body { border-left: 0; padding: var(--s-4); }
  .build-feature .build-media .clip video { height: auto; aspect-ratio: 16 / 9; }
  .build-wide .build-media { padding: 0 var(--s-4) var(--s-4); }
  .flag { flex: 0 0 10px; flex-direction: row; }
}

@media (max-width: 620px) {
  .builds { grid-template-columns: minmax(0, 1fr); }
  .build, .build-feature, .build-wide { grid-column: span 1; }
}


/* ---------- Fill-in placeholders ----------
   A slot waiting for real text. Replace the whole <div class="fill">
   with your own paragraphs and the dashed styling goes with it. */
.fill {
  border: 2px dashed var(--rule);
  background: var(--paper-alt);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 0 0 20px;
}

.fill .fill-label {
  display: inline-block;
  background: var(--ink);
  color: var(--paper);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.09em;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  margin-bottom: 12px;
}

.fill p { margin: 0 0 10px; color: var(--ink-soft); font-size: var(--t-base); }
.fill p:last-child { margin-bottom: 0; }
.fill .hint { font-style: italic; opacity: 0.85; font-size: var(--t-meta); }
.fill code {
  background: color-mix(in srgb, var(--ink) 10%, transparent);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 0.88em;
}

/* ---------- About: prose beside highlight cards ---------- */
.page-head + .about-split { margin-top: 30px; }

.about-split {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
  margin-bottom: 30px;
}

.about-split .prose-col p { color: var(--ink-soft); margin: 0 0 18px; }
.about-split .prose-col strong { color: var(--ink); font-weight: 600; }
.about-split .prose-col .hl { color: var(--accent); font-weight: 600; }

/* ---------- About: the introduction ----------
   Words on one side, a face on the other. The portrait is squared off and
   tilted a degree, so it sits on the page like a print rather than an
   avatar. */
.about-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: var(--s-6);
  align-items: center;
  margin: var(--s-5) 0 var(--s-6);
}

.about-words p {
  margin: 0 0 var(--s-3);
  color: var(--ink-soft);
  font-size: var(--t-body);
  text-wrap: pretty;
}
.about-words p:last-child { margin-bottom: 0; }

.about-portrait {
  position: relative;
  margin: 0;
  justify-self: end;
  width: min(100%, 300px);
  padding: var(--s-2);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: 0 22px 44px -26px rgb(0 0 0 / 0.5);
  rotate: -1.1deg;
  transition: rotate var(--d-slow) var(--ease);
}
/* The source photograph is tall; left at its own height it opened a
   column of empty page beside the two short paragraphs. Cropped to a
   print proportion instead, holding the face rather than the centre. */
.about-portrait img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: 50% 28%;
  border-radius: 1px;
}

@media (hover: hover) and (pointer: fine) {
  .about-portrait:hover { rotate: 0deg; }
}

/* ---------- About: the four facts ----------
   Each one wears a different section colour, which is how the page shows
   the whole site at a glance. */
.highlights {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-6);
}

.highlight {
  position: relative;
  padding: var(--s-4) var(--s-3) var(--s-3);
  text-align: left;
  background: var(--card-accent-tint, var(--card));
  border: 1px solid color-mix(in oklab, var(--card-accent, var(--accent)) 20%, transparent);
  border-radius: var(--radius);
  overflow: hidden;
}

/* A bar of the card's own colour along the top edge. */
.highlight::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--card-accent, var(--accent));
}

.h-ic {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: var(--s-2);
  border-radius: 9px;
  background: var(--paper);
  color: var(--card-accent, var(--accent));
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.07);
}
.h-ic svg { width: 19px; height: 19px; }

.highlight svg { color: var(--card-accent, var(--accent)); }
.highlight .h-title {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--t-body);
  margin-bottom: 3px;
}
.highlight .h-sub { display: block; color: var(--ink-soft); font-size: var(--t-meta); }
.highlight .empty { font-weight: 500; }

@media (max-width: 900px) {
  .about-intro { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
  .about-portrait { justify-self: start; max-width: 240px; }
  .highlights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .highlights { grid-template-columns: minmax(0, 1fr); }
}

/* A dated list: school years, competitions, build sessions. */
.timeline { list-style: none; margin: 0 0 20px; padding: 0; }
.timeline li { position: relative; padding: 0 0 24px 30px; border-left: 2px solid var(--line); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }

.timeline li::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-bright);
  border: 3px solid var(--paper);
}

.timeline .what { display: block; font-weight: 600; margin-bottom: 4px; }
.timeline .detail { margin: 0; color: var(--ink-soft); font-size: var(--t-base); }

/* Question and answer. */
.qa-list { max-width: 68ch; margin: 0 0 20px; }
.qa { margin-bottom: 14px; overflow: hidden; }

/* ---------- What went wrong ----------
   A rail with a node for each setback. The rail is what turns three
   collapsed boxes into a sequence you read downwards, and each step wears
   a different section colour because each one went wrong somewhere else. */
.timeline-qa {
  list-style: none;
  margin: var(--s-4) 0 var(--s-6);
  padding: 0 0 0 var(--s-5);
  counter-reset: step;
}

.qa-step {
  position: relative;
  padding-bottom: var(--s-3);
}

/* The rail itself, drawn behind the nodes and stopped at the last one. */
.qa-step::before {
  content: "";
  position: absolute;
  left: calc(var(--s-5) * -1 + 13px);
  top: 26px;
  bottom: -6px;
  width: 2px;
  background: var(--line);
}
.qa-step:last-child::before { display: none; }

/* The node, numbered in the card's own colour. */
.qa-step::after {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: calc(var(--s-5) * -1 + 1px);
  top: 12px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--card-accent-tint, var(--accent-tint));
  border: 2px solid var(--card-accent, var(--accent));
  color: var(--card-accent, var(--accent));
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  font-weight: 700;
}

.qa-step .qa {
  margin-bottom: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--card-accent, var(--accent));
  border-radius: var(--radius-sm);
  transition: border-color var(--d-mid) var(--ease),
              background-color var(--d-mid) var(--ease);
}

.qa-step .qa[open] {
  background: var(--card-accent-tint, var(--accent-tint));
}

.qa-step .qa summary::after {
  border-right-color: var(--card-accent, var(--accent));
  border-bottom-color: var(--card-accent, var(--accent));
}

@media (hover: hover) and (pointer: fine) {
  .qa-step .qa:hover { border-color: color-mix(in oklab, var(--card-accent, var(--accent)) 40%, var(--line)); }
  .qa-step .qa:hover { border-left-color: var(--card-accent, var(--accent)); }
}

/* The answer slides open rather than appearing, where the browser can do
   it and the reader has not asked for less movement. */
@supports (interpolate-size: allow-keywords) {
  @media (prefers-reduced-motion: no-preference) {
    .qa-step .qa::details-content {
      block-size: 0;
      overflow: hidden;
      transition: block-size var(--d-mid) var(--ease), content-visibility var(--d-mid) allow-discrete;
    }
    .qa-step .qa[open]::details-content { block-size: auto; }
  }
}

@media (max-width: 620px) {
  .timeline-qa { padding-left: var(--s-4); }
  .qa-step::before { left: calc(var(--s-4) * -1 + 10px); }
  .qa-step::after { left: calc(var(--s-4) * -1 - 2px); width: 24px; height: 24px; }
}

.qa summary {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 22px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 600;
  list-style: none;
  transition: color 200ms var(--ease);
}

.qa summary::-webkit-details-marker { display: none; }
.qa summary:focus-visible { outline: 3px solid var(--accent-bright); outline-offset: -3px; }

.qa summary::after {
  content: "";
  margin-left: auto;
  flex: none;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 220ms var(--ease);
}

.qa[open] summary::after { transform: rotate(225deg) translate(-2px, -2px); }

/* Collapse the answer ourselves; some engines get <details> wrong. */
.qa:not([open]) .answer { display: none; }
.qa .answer { padding: 0 22px 22px; color: var(--ink-soft); }
.qa .answer p { margin: 0 0 14px; }
.qa .answer p:last-child, .qa .answer .fill { margin-bottom: 0; }

/* ---------- Ask about me ----------
   A chat panel that looks like a conversation without pretending to be a
   person: the replies are plainly sourced, each one carrying the page it
   was taken from. */
.ask {
  margin: 0 0 var(--s-6);
  padding: var(--s-4);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* The log grows to fit and then scrolls, so the panel does not shove the
   rest of the page down as a conversation goes on. */
.ask-log {
  max-height: 340px;
  overflow-y: auto;
  padding: var(--s-2) 2px;
  margin-bottom: var(--s-3);
}
.ask-log:empty { display: none; }

.ask-msg { margin-bottom: var(--s-3); max-width: 46ch; }
.ask-msg p { margin: 0; font-size: var(--t-base); line-height: 1.6; text-wrap: pretty; }

/* The bubble is the answer only. The source line underneath is a
   caption on it, not a second thing said. */
.ask-bot p:not(.ask-src) {
  padding: 11px 15px;
  border-radius: 16px 16px 16px 4px;
  background: var(--paper-alt);
  color: var(--ink);
}

/* The reader's own words sit on the other side, in the accent, so a
   glance tells you who said what without reading either. */
.ask-you {
  margin-left: auto;
  text-align: right;
}
.ask-you p {
  display: inline-block;
  text-align: left;
  padding: 11px 15px;
  border-radius: 16px 16px 4px 16px;
  background: var(--accent);
  color: var(--paper);
}

/* Where the answer came from. Every reply carries one: an answer with no
   source is an answer nobody can check. */
.ask-src {
  margin-top: 6px !important;
  padding-left: 15px;
  color: var(--ink-soft);
  font-size: var(--t-meta) !important;
}
.ask-src a { color: var(--accent); font-weight: 600; }

.ask-handoff {
  margin: 10px 0 0 15px;
  padding: 8px 15px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-pill);
  background: none;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--d-fast) var(--ease), color var(--d-fast) var(--ease);
}
.ask-handoff:disabled {
  border-color: var(--line);
  color: var(--ink-soft);
  cursor: default;
}
@media (hover: hover) and (pointer: fine) {
  .ask-handoff:not(:disabled):hover { background: var(--accent); color: var(--paper); }
}

.ask-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: var(--s-3);
}
.ask-chips-label {
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.ask-chips button {
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: var(--t-meta);
  cursor: pointer;
  transition: border-color var(--d-fast) var(--ease), color var(--d-fast) var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .ask-chips button:hover { border-color: var(--accent); color: var(--accent); }
}

.ask-form { display: flex; gap: 10px; }

.ask-form input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--t-base);
}
.ask-form input::placeholder { color: var(--ink-soft); }

.ask-send {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--paper);
  cursor: pointer;
  transition: background var(--d-fast) var(--ease);
}
.ask-send svg { width: 19px; height: 19px; }
@media (hover: hover) and (pointer: fine) {
  .ask-send:hover { background: var(--ink); }
}

.ask-note {
  margin: var(--s-3) 0 0;
  color: var(--ink-soft);
  font-size: var(--t-meta);
  line-height: 1.55;
  text-wrap: pretty;
}

@media (max-width: 560px) {
  .ask { padding: var(--s-3); }
  .ask-msg { max-width: 100%; }
  .ask-log { max-height: 300px; }
}


/* ---------- Get in touch ---------- */
.contact-split {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 48px;
  align-items: start;
  margin-bottom: 76px;
}

.contact-details { display: grid; gap: 26px; padding-top: 6px; }
.detail { display: flex; align-items: flex-start; gap: 14px; }

.detail .ic {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: var(--radius-sm);
  background: var(--accent-tint);
  color: var(--accent);
}

.detail .ic svg { width: 18px; height: 18px; }
.detail .d-label { display: block; font-weight: 700; margin-bottom: 2px; }

.detail .d-value, .detail a.d-value, .detail .d-value a {
  display: block;
  color: var(--ink-soft);
  text-decoration: none;
  word-break: break-word;
}

.contact-form { display: grid; gap: 14px; }

.contact-form input, .contact-form textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 15px 18px;
  outline: none;
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease);
}

.contact-form textarea { resize: vertical; min-height: 130px; }
.contact-form ::placeholder { color: var(--ink-soft); opacity: 1; }

.contact-form input:focus, .contact-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

/* The label stays visible once the field has something in it, which a
   placeholder cannot do. The placeholder is kept as a format hint. */
.contact-form .field { display: grid; gap: 6px; }
.contact-form label {
  font-size: var(--t-meta);
  font-weight: 600;
  color: var(--ink);
}
.contact-form .opt { font-weight: 400; color: var(--ink-soft); }

.contact-form .invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--danger) 16%, transparent);
}
.form-note.error { color: var(--danger); }
.form-note.ok { color: var(--accent); }
.form-note { margin: 2px 0 0; color: var(--ink-soft); font-size: var(--t-meta); min-height: 1.2em; }

/* The button gives way slightly under the press. */
.send-btn { transition: transform var(--d-fast) var(--ease), background-color var(--d-fast) var(--ease); }
.send-btn:active { transform: translateY(1px) scale(0.99); }

/* ---------- Elsewhere, publications ---------- */
.elsewhere { padding: 32px 34px 36px; margin: 8px 0 76px; }
.elsewhere h2 { font-size: var(--t-sm); margin: 0 0 8px; }
.elsewhere p { color: var(--ink-soft); margin: 0 0 14px; max-width: 58ch; }
.elsewhere .channel-link { margin-top: 20px; }

.pub-list { list-style: none; margin: 16px 0 0; padding: 0; }
.pub-list li { border-top: 1px solid var(--line); padding: 12px 0; }
.pub-list li:last-child { padding-bottom: 0; }
.pub-list a { font-weight: 600; text-decoration: none; }
.pub-list .pub-date { display: block; color: var(--ink-soft); font-size: var(--t-meta); margin-top: 2px; }

/* ---------- Search ---------- */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgb(20 14 10 / 46%);
  backdrop-filter: blur(3px);
  display: flex;
  justify-content: center;
  padding: 12vh 20px 20px;
}

.search-overlay[hidden] { display: none; }

.search-box {
  width: 100%;
  max-width: 620px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.search-field svg { width: 19px; height: 19px; color: var(--accent); flex: none; }

.search-field input {
  flex: 1;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: var(--t-body);
  outline: none;
  min-width: 0;
}

.search-close {
  border: 1px solid var(--line);
  background: var(--paper-alt);
  color: var(--ink-soft);
  border-radius: var(--radius-pill);
  padding: 4px 9px;
  font: inherit;
  font-size: var(--t-micro);
  cursor: pointer;
}

.search-results { overflow-y: auto; padding: 8px; }

.search-results a {
  display: block;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
}

.search-results a.on { background: var(--accent-tint); }

.search-results .s-title {
  display: block;
  font-family: var(--font-sans);
  font-size: var(--t-body);
  margin-bottom: 2px;
}

.search-results .s-text {
  display: -webkit-box;
  color: var(--ink-soft);
  font-size: var(--t-meta);
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
}

.search-empty { color: var(--ink-soft); padding: 20px 14px; margin: 0; font-size: var(--t-base); }

/* ---------- The nav as a panel ----------
   Below this width seven links and three buttons stop fitting on one
   line. Rather than wrapping the header into three stacked rows, the
   links become a panel that drops out of it. Adding Achievements moved
   this point up from 760px: at 800px the row had started to wrap. */
@media (max-width: 860px) {
  .icon-btn.nav-toggle {
    display: grid;
    place-items: center;
    position: relative;
  }

  .site-header .wrap { flex-wrap: nowrap; }

  nav.main-nav {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 29;
    padding: var(--s-2) 16px var(--s-4);
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 20px 36px -28px rgb(0 0 0 / 0.55);

    /* Closed: folded away and out of the tab order. */
    visibility: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity var(--d-mid) var(--ease),
                transform var(--d-mid) var(--ease),
                visibility 0s linear var(--d-mid);
  }

  .site-header.nav-open nav.main-nav {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition-delay: 0s;
  }

  nav.main-nav ul {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
  }

  nav.main-nav a {
    display: block;
    padding: 13px 14px;
    font-size: var(--t-base);
    border-radius: var(--radius-sm);
  }

  /* The sliding pill is a pointer affordance; a stacked panel shows the
     current page with the plain tint instead. */
  nav.main-nav.has-glide a.active { background: var(--accent-tint); }
  .nav-glide { display: none; }
}

/* ---------- Engineering: the workshop ----------
   A drafting grid behind the masthead, and the small technical labels
   that go on a drawing. Kept faint: the builds have to stay readable
   through it. No markup changes; this is all scoped to the body class. */
body.s-engineering .masthead {
  position: relative;
  isolation: isolate;
}

body.s-engineering .masthead::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: calc(var(--s-5) * -1) -40px;
  pointer-events: none;
  background-image:
    linear-gradient(color-mix(in oklab, var(--accent) 13%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in oklab, var(--accent) 13%, transparent) 1px, transparent 1px),
    linear-gradient(color-mix(in oklab, var(--accent) 7%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in oklab, var(--accent) 7%, transparent) 1px, transparent 1px);
  background-size: 96px 96px, 96px 96px, 24px 24px, 24px 24px;
  /* Fades out before it reaches the text, so nothing is read through it. */
  mask-image: radial-gradient(78% 92% at 22% 34%, #000 0%, transparent 76%);
}

/* The corner ticks of a drawing frame, on the build cards. */
/* designs.html and electrical.html both carry s-engineering, so one
   selector covers all three pages. */
body.s-engineering .achievement,
body.s-engineering .design {
  position: relative;
}
body.s-engineering .achievement::after,
body.s-engineering .design::after {
  content: "";
  position: absolute;
  top: 9px;
  right: 9px;
  width: 13px;
  height: 13px;
  border-top: 1.5px solid color-mix(in oklab, var(--accent) 55%, transparent);
  border-right: 1.5px solid color-mix(in oklab, var(--accent) 55%, transparent);
  pointer-events: none;
}

/* ---------- Literary: the publishing house ----------
   Warm, quiet, and set to be read. The serif already carries the
   headings; what it was missing was the furniture of a printed page. */
body.s-literary .big-head > h2::after,
body.s-articles .big-head > h2::after,
body.s-poems .big-head > h2::after,
body.s-stories .big-head > h2::after,
body.s-essays .big-head > h2::after,
body.s-research .big-head > h2::after,
body.s-books .big-head > h2::after {
  content: "";
  display: block;
  width: 54px;
  height: 2px;
  margin: var(--s-3) auto 0;
  background: var(--accent);
  opacity: 0.55;
}

/* A drop-cap-sized opening line on the section introductions, the way a
   magazine opens a piece. */
body.s-literary .section-intro > p:first-child::first-line,
body.s-articles .section-intro > p:first-child::first-line,
body.s-poems .section-intro > p:first-child::first-line,
body.s-stories .section-intro > p:first-child::first-line {
  font-variant-caps: small-caps;
  letter-spacing: 0.015em;
  color: var(--ink);
}

/* ---------- Reading progress ----------
   Only on a piece, where it answers a real question: how much is left.
   scaleX rather than width, so it never triggers layout. */
.read-progress {
  position: fixed;
  inset: 0 0 auto;
  height: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
  z-index: 40;
  pointer-events: none;
}

/* ---------- Copy to clipboard ----------
   The icon swap is the whole feedback, so it has to be legible: the tick
   arrives as the clipboard leaves. */
.copy-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-left: 8px;
  vertical-align: -8px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--accent-tint);
  color: var(--accent);
  cursor: pointer;
  padding: 0;
}

.copy-btn svg { grid-area: 1 / 1; width: 15px; height: 15px; transition: opacity 180ms var(--ease), transform 180ms var(--ease); }
.copy-btn .tick { opacity: 0; transform: scale(0.5); }
.copy-btn.done .clip { opacity: 0; transform: scale(0.5); }
.copy-btn.done .tick { opacity: 1; transform: none; }

/* ---------- Artwork lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 5vh 5vw;
  background: rgb(12 10 8 / 72%);
  backdrop-filter: blur(4px);
}

.lightbox[hidden] { display: none; }

.lightbox figure { margin: 0; display: grid; justify-items: center; gap: 14px; max-height: 90vh; }

.lightbox img {
  max-width: 100%;
  max-height: 78vh;
  border-radius: var(--radius-sm);
  background: var(--card);
  animation: lift 260ms var(--ease) backwards;
}

@keyframes lift {
  from { opacity: 0; transform: scale(0.96); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

.lightbox figcaption { color: #f2f2ee; font-size: var(--t-meta); text-align: center; }
.lightbox .lb-count { display: block; color: #b9b9b2; font-family: var(--font-mono); font-size: var(--t-micro); margin-top: 4px; }

.lightbox .lb-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: var(--radius-pill);
  background: rgb(255 255 255 / 14%);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}

.lightbox .lb-nav {
  position: absolute;
  top: calc(50% - 24px);
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: var(--radius-pill);
  background: rgb(255 255 255 / 14%);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.lightbox .lb-prev { left: 16px; }
.lightbox .lb-next { right: 16px; }
.lightbox .lb-nav svg { width: 20px; height: 20px; }
.lightbox .lb-next svg { transform: scaleX(-1); }

@media (hover: hover) and (pointer: fine) {
  .lightbox .lb-close:hover, .lightbox .lb-nav:hover { background: rgb(255 255 255 / 26%); }
  .copy-btn:hover { filter: brightness(0.95); }
  .to-top:hover { background: var(--accent); color: var(--paper); }
  .art-gallery .art-piece:has(img), figure.design:has(img),
  .achievement:has(.shot) { cursor: zoom-in; }
}

/* ---------- Back to top ---------- */
.to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 35;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 220ms var(--ease), transform 220ms var(--ease),
              background-color 180ms var(--ease), color 180ms var(--ease);
}

.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top svg { width: 17px; height: 17px; }

/* ---------- Terminal ----------
   The site as a filesystem. Always dark, the way a terminal is, whatever
   the page behind it is set to. */
.term {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 6vh 16px;
  background: rgb(8 8 7 / 68%);
  backdrop-filter: blur(4px);
}

.term[hidden] { display: none; }

.term-box {
  width: 100%;
  max-width: 720px;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  background: #0d0f0e;
  border: 1px solid #27302c;
  border-radius: var(--radius-sm);
  box-shadow: 0 30px 80px rgb(0 0 0 / 55%);
  overflow: hidden;
  animation: rise 200ms var(--ease) backwards;
}

.term-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  background: #151916;
  border-bottom: 1px solid #27302c;
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  color: #7d8a83;
}

.term-bar .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.term-bar .dot:nth-child(1) { background: #ff5f57; }
.term-bar .dot:nth-child(2) { background: #febc2e; }
.term-bar .dot:nth-child(3) { background: #28c840; }
.term-bar .where { margin-left: 8px; }
.term-bar .term-close { margin-left: auto; border: 0; background: none; color: #7d8a83; cursor: pointer; font-family: inherit; font-size: inherit; }

.term-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 10px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.62;
  color: #c6d0ca;
}

.term-body p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.term-body .cmd { color: #e8efe9; }
.term-body .dir { color: #58b6ff; font-weight: 700; }
.term-body .file { color: #c6d0ca; }
.term-body .ok { color: #35d07f; }
.term-body .warn { color: #ffb454; }
.term-body .err { color: #ff6b6b; }
.term-body .dim { color: #7d8a83; }
.term-body .head { color: #35d07f; font-weight: 700; }

/* The command list, lined up by the grid rather than by counting
   spaces. The first column is as wide as the longest command and no
   wider, so the descriptions start on one line whatever is in it. */
.term-help {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 2px 22px;
  margin: 2px 0 8px;
  padding-left: 14px;
}
.term-help dt { color: #e8efe9; white-space: nowrap; }
.term-help dd { margin: 0; color: #7d8a83; }

/* In a narrow terminal two columns leave the descriptions a few
   characters wide, so they move under their command instead. */
@media (max-width: 560px) {
  .term-help { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .term-help dd { margin: 0 0 7px 14px; }
}

.term-line { display: flex; align-items: baseline; gap: 8px; padding: 2px 16px 16px; font-family: var(--font-mono); font-size: 0.84rem; }
.term-line .ps1 { color: #ffd166; white-space: nowrap; }
.term-line .ps1 b { color: #58b6ff; font-weight: 700; }

.term-line input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: #e8efe9;
  font: inherit;
  padding: 0;
  outline: none;
  caret-color: #35d07f;
}

/* The button that opens it, beside search and the theme toggle. */
.term-open { font-family: var(--font-mono); font-weight: 700; font-size: 0.8rem; }

@media (max-width: 620px) {
  .term { padding: 2vh 8px; }
  .term-box { max-height: 88vh; }
  .term-body, .term-line { font-size: 0.78rem; }
}

/* ---------- Footer ---------- */
.site-footer {
  max-width: none;
  margin: 80px calc(50% - 50vw) 0;
  /* Full bleed, but the text still lines up with the page column. */
  padding: 54px max(24px, calc(50vw - 470px)) 44px;
  background: #121211;
  border-radius: var(--radius) var(--radius) 0 0;
  color: #8d8d86;
  font-size: var(--t-meta);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.site-footer a { color: #e9e9e4; text-decoration: none; }

/* ---------- 404 ---------- */
.notfound { text-align: center; padding: 90px 0 100px; }
.notfound h1 { font-size: 3.2rem; margin: 16px 0 12px; }
.notfound p:not(.pill) { color: var(--ink-soft); margin: 0 auto 26px; max-width: 46ch; }

/* ---------- Keyboard access ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--ink);
  color: var(--paper);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: var(--t-meta);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus { left: 0; }

/* Form controls were missing from this list, which left the MathCanvas
   select and sliders without a ring when tabbed to. */
a:focus-visible, button:focus-visible,
select:focus-visible, input:focus-visible, textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent-bright);
  outline-offset: 3px;
  border-radius: 4px;
}

main:focus { outline: none; }

.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;
}

/* The placeholder graphics are drawn light; dim them in dark mode.
   Scoped to those files, so real photos are untouched. */
:root[data-theme="dark"] img[src$="photo-placeholder.svg"],
:root[data-theme="dark"] img[src$="portrait-placeholder.svg"] {
  filter: brightness(0.26) saturate(0.7);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) img[src$="photo-placeholder.svg"],
  :root:not([data-theme="light"]) img[src$="portrait-placeholder.svg"] {
    filter: brightness(0.26) saturate(0.7);
  }
}

/* ---------- Achievements: the record, each one drawn ----------
   Built on the same bones as the software grid: six columns, cards of
   two widths, and a panel of decoration per card drawn in CSS from what
   the thing actually is. The bars fill and the figures count up as a
   card arrives; every number on the page is the real one. */
.ach-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--s-4);
  margin: 0 0 var(--s-7);
}

.ach-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  grid-column: span 3;
  padding: var(--s-4);
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: transform var(--d-mid) var(--ease),
              box-shadow var(--d-mid) var(--ease),
              border-color var(--d-mid) var(--ease);
}

/* A full-width card puts its decoration beside the words instead. */
.ach-feature {
  grid-column: span 6;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  padding: 0;
}
.ach-feature .ach-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  flex: 1 1 58%;
  padding: var(--s-5);
}
.ach-feature h2 { font-size: var(--t-md); }

/* The light that follows the pointer on the section cards, here over the
   card itself. site.js supplies --mx and --my; with no script the layer
   stays at zero opacity and nothing is lost. */
.ach-item::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--d-mid) var(--ease);
  background: radial-gradient(38% 60% at var(--mx, 50%) var(--my, 50%),
    color-mix(in oklab, var(--card-accent, var(--accent)) 12%, transparent), transparent 70%);
}
.ach-item > * { position: relative; z-index: 1; }

@media (hover: hover) and (pointer: fine) {
  .ach-item:hover {
    transform: translateY(-3px);
    border-color: color-mix(in oklab, var(--card-accent, var(--accent)) 45%, var(--line));
    box-shadow: 0 18px 38px -26px rgb(0 0 0 / 0.5);
  }
  .ach-item:hover::after { opacity: 1; }
}

.ach-kind {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--card-accent, var(--accent));
}
.ach-item h2 { margin: 0; font-size: var(--t-sm); letter-spacing: -0.015em; text-wrap: balance; }
.ach-item p { margin: 0; color: var(--ink-soft); font-size: var(--t-base); text-wrap: pretty; }

/* ---------- The three Checkpoint marks ----------
   Three bars beside three figures. The bars are only the three numbers
   drawn next to each other: the longest is the highest mark, and there
   is no scale behind them to read anything else off. */
.scores { list-style: none; width: 100%; margin: var(--s-2) 0 0; padding: 0; display: grid; gap: 10px; }
.scores li {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 36px max-content;
  align-items: center;
  gap: 12px;
}

/* The denominator every mark is out of. Set smaller and quieter than
   the mark itself, and at the same baseline, so the row reads as
   "50 / 50" rather than as two separate numbers. */
.s-out {
  margin-left: -5px;
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: var(--t-meta);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.s-name {
  font-family: var(--font-display);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.s-bar {
  position: relative;
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--paper-alt);
  overflow: hidden;
}
.s-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--v, 100%);
  border-radius: inherit;
  background: linear-gradient(90deg,
    color-mix(in oklab, var(--card-accent, var(--accent)) 55%, var(--paper)),
    var(--card-accent, var(--accent)));
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform var(--d-slow) var(--ease);
}
.ach-item.seen .s-bar i { transform: none; }
.s-val {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--t-sm);
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--card-accent, var(--accent));
}

/* One figure, big, because the rank is the whole point of that card. */
.ach-stat { display: grid; gap: 1px; margin: var(--s-2) 0 0; }
.stat-pre {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.stat-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--t-xl);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--card-accent, var(--accent));
}

/* The belts behind the one I hold. Three steps, the last one lit. */
.belts {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin: var(--s-2) 0 0;
  padding: 0;
}
.belts li {
  padding: 3px 11px;
  border: 1px solid color-mix(in oklab, var(--card-accent, var(--accent)) 22%, var(--line));
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  color: var(--ink-soft);
}
.belts li.here {
  background: var(--card-accent, var(--accent));
  border-color: var(--card-accent, var(--accent));
  color: var(--paper);
  font-weight: 700;
}

/* ---------- What each one looks like ----------
   A panel per full-width card, and a corner mark on the narrow ones.
   All of it decoration: the markup that carries it is aria-hidden. */
.ach-art {
  flex: 1 1 42%;
  position: relative;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: linear-gradient(160deg, #14240c, #2f4f1d);
}

/* Checkpoint: squared paper, and a tick on it. */
[data-ach="checkpoint"] .ach-art::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.5;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.16) 1px, transparent 1px);
  background-size: 22px 22px, 22px 22px;
  mask-image: radial-gradient(78% 86% at 52% 46%, #000, transparent 74%);
}
[data-ach="checkpoint"] .tick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72px;
  height: 36px;
  translate: -50% -60%;
  border-left: 7px solid rgba(255, 255, 255, 0.92);
  border-bottom: 7px solid rgba(255, 255, 255, 0.92);
  border-radius: 3px;
  transform: rotate(-45deg) scale(0.6);
  opacity: 0;
  transition: transform var(--d-slow) var(--ease), opacity var(--d-mid) var(--ease);
}
.ach-item.seen .tick { transform: rotate(-45deg) scale(1); opacity: 1; }

/* Taekwondo: the belt, tied. */
[data-ach="belt"] .ach-art { background: linear-gradient(160deg, #16280d, #35591f); }
[data-ach="belt"] .ach-art::before {
  content: "";
  position: absolute;
  left: -4%;
  right: -4%;
  top: 50%;
  height: 26px;
  translate: 0 -50%;
  rotate: -4deg;
  background: linear-gradient(180deg, #7fb45c, #4e8033);
  box-shadow: 0 10px 26px -14px rgb(0 0 0 / 0.8);
}
[data-ach="belt"] .belt {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 46px;
  translate: -50% -50%;
  rotate: -4deg;
  border-radius: 7px;
  background: linear-gradient(180deg, #90c76c, #51862f);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.25),
              0 12px 24px -14px rgb(0 0 0 / 0.9);
}
[data-ach="belt"] .belt::before,
[data-ach="belt"] .belt::after {
  content: "";
  position: absolute;
  top: 78%;
  width: 17px;
  height: 58px;
  border-radius: 4px;
  background: linear-gradient(180deg, #7fb45c, #3f6b27);
}
[data-ach="belt"] .belt::before { left: 6px; rotate: 9deg; }
[data-ach="belt"] .belt::after { right: 6px; rotate: -11deg; }

/* The narrow cards carry a corner mark rather than a panel, so a short
   card is not mostly decoration. */
.ach-item:not(.ach-feature) .ach-art {
  position: absolute;
  right: -14%;
  bottom: -18%;
  width: 62%;
  height: 150px;
  flex: none;
  border-left: 0;
  background: none;
  opacity: 0.85;
  pointer-events: none;
}

/* The Olympiad rank: rings closing on a point. */
[data-ach="finance"] .ach-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-radial-gradient(circle at 42% 42%,
    color-mix(in oklab, var(--card-accent, var(--accent)) 55%, transparent) 0 1.8px,
    transparent 1.8px 17px);
  mask-image: radial-gradient(60% 60% at 42% 42%, #000, transparent 72%);
}

/* Homi Bhabha: a nucleus with an electron going round it. */
[data-ach="bhabha"] .ach-art::before {
  content: "";
  position: absolute;
  left: 38%;
  top: 40%;
  width: 11px;
  height: 11px;
  translate: -50% -50%;
  border-radius: 50%;
  background: var(--card-accent, var(--accent));
}
[data-ach="bhabha"] .orbit {
  position: absolute;
  left: 38%;
  top: 40%;
  width: 108px;
  height: 108px;
  translate: -50% -50%;
  border-radius: 50%;
  border: 1.5px solid color-mix(in oklab, var(--card-accent, var(--accent)) 46%, transparent);
  animation: ach-orbit 7s linear infinite;
}
[data-ach="bhabha"] .orbit::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in oklab, var(--card-accent, var(--accent)) 28%, transparent);
  rotate: 58deg;
  scale: 1 0.52;
}
[data-ach="bhabha"] .orbit i {
  position: absolute;
  top: -4px;
  left: 50%;
  width: 9px;
  height: 9px;
  translate: -50% 0;
  border-radius: 50%;
  background: var(--card-accent, var(--accent));
}
@keyframes ach-orbit { to { rotate: 360deg; } }

@media (max-width: 900px) {
  .ach-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ach-item, .ach-feature { grid-column: span 1; }
  .ach-feature { flex-direction: column; padding: 0; }
  .ach-feature .ach-body { padding: var(--s-4); }
  .ach-feature .ach-art { flex: 0 0 150px; border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 620px) {
  .ach-grid { grid-template-columns: minmax(0, 1fr); }
  .ach-item { padding: 22px 20px 24px; }
  .scores li { grid-template-columns: 62px minmax(0, 1fr) 32px max-content; gap: 9px; }
}

/* A photograph set inside a card, bounded rather than cropped to the
   card's own shape: a page scan has to stay readable. */
.inset-shot {
  margin: var(--s-3) 0 0;
  max-width: 280px;
}
.inset-shot img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: var(--paper-alt);
  border: 1px solid var(--line);
}

/* ---------- Three more on the record ---------- */

/* The year a result belongs to, under the number rather than beside it. */
.ach-when {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 0.08em;
}

/* "2 times": the unit after the figure, smaller, so the figure leads. */
.stat-post {
  margin-top: 2px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* French Champions League: a hatch, ruled the way a page of exercises
   is ruled. */
[data-ach="french"] .ach-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(58deg,
    color-mix(in oklab, var(--card-accent, var(--accent)) 46%, transparent) 0 2px,
    transparent 2px 13px);
  mask-image: radial-gradient(74% 86% at 66% 84%, #000, transparent 70%);
}

/* Math Ingenious Fest: a lattice of plus signs, which is the one mark
   that reads as arithmetic at any size. */
[data-ach="mathfest"] .ach-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(to right,
      transparent 0 13px,
      color-mix(in oklab, var(--card-accent, var(--accent)) 52%, transparent) 13px 15px,
      transparent 15px 28px),
    repeating-linear-gradient(to bottom,
      transparent 0 13px,
      color-mix(in oklab, var(--card-accent, var(--accent)) 52%, transparent) 13px 15px,
      transparent 15px 28px);
  mask-image: radial-gradient(74% 86% at 66% 84%, #000, transparent 70%);
}

/* Kuari Pass: a ridge under a cold sky, which is what a pass at this
   height looks like from the approach. */
[data-ach="kuari"] .ach-art {
  background: linear-gradient(175deg, #0a1a26 0%, #16313f 62%, #1d4152 100%);
}

/* A few points of light above the ridge. Static: a sky that twinkles on
   a record page is a sky nobody asked for. */
[data-ach="kuari"] .ach-art::before {
  content: "";
  position: absolute;
  inset: 0 0 42% 0;
  background-image:
    radial-gradient(1.3px 1.3px at 18% 28%, #ffffff, transparent),
    radial-gradient(1.1px 1.1px at 62% 18%, #ffffff, transparent),
    radial-gradient(1.5px 1.5px at 81% 42%, #ffffff, transparent),
    radial-gradient(1px 1px at 38% 54%, #ffffff, transparent),
    radial-gradient(1.2px 1.2px at 92% 22%, #ffffff, transparent);
  opacity: 0.62;
}

.ridge {
  position: absolute;
  inset: auto 0 0 0;
  height: 62%;
  background: linear-gradient(to bottom,
    color-mix(in oklab, #cfe6f2 70%, transparent),
    color-mix(in oklab, #7fa8bd 70%, transparent));
  clip-path: polygon(0% 100%, 0% 62%, 13% 40%, 24% 56%, 38% 18%, 52% 48%, 63% 30%, 78% 58%, 89% 36%, 100% 54%, 100% 100%);
}

/* A second ridge behind the first, paler, so the range has depth. */
.ridge::before {
  content: "";
  position: absolute;
  inset: 12% 0 0 0;
  background: color-mix(in oklab, #ffffff 26%, transparent);
  clip-path: polygon(0% 100%, 0% 54%, 18% 30%, 31% 52%, 47% 24%, 61% 46%, 74% 26%, 88% 50%, 100% 34%, 100% 100%);
}

/* The height itself, set like the other figures on this page. */
.alt { white-space: nowrap; }
.alt .stat-num { font-size: var(--t-lg); }


/* ---------- Narrow screens ---------- */
@media (max-width: 820px) {
  .about-split, .contact-split { grid-template-columns: 1fr; }
  .about-split { gap: 28px; }
  .contact-split { gap: 32px; }
  .project { padding: 26px 22px; }
}

@media (max-width: 760px) {
  body { font-size: 16px; }
  .hero { padding-top: 48px; }
  .portrait { width: 88px; height: 88px; border-radius: 20px; }
  .hero h1 { font-size: 2.6rem; }
  .page-head h1 { font-size: 2.1rem; }
  .section > h2, .big-head > h2 { font-size: 1.9rem; }
  .site-header .wrap, nav.main-nav ul { justify-content: center; }
  article.prose { padding: 32px 26px 38px; }
  .search-overlay { padding-top: 6vh; }
}

@media (max-width: 620px) {
  .piece-nav { grid-template-columns: 1fr; }
  .piece-nav .next { text-align: left; }
  .piece-nav .next-placeholder { display: none; }

  /* On a phone the number and arrow columns cost more width than they
     are worth; the number moves above the title and the row stays
     tappable without the arrow. */
  .piece, .book { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 22px 2px; }
  .piece::before, .book::before { grid-row: auto; grid-column: 1; padding: 0 0 6px; }
  .piece > *, .book > * { grid-column: 1; }
  .piece:has(h2 a)::after, .book:has(h2 a)::after { display: none; }
}

@media (max-width: 520px) {
  .clip video { height: 300px; }
}

@media (max-width: 480px) {
  .highlights { grid-template-columns: 1fr; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  /* Covers keyframes as well as transitions, and keeps the end state so
     nothing that faded in is left invisible. */
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  html { scroll-behavior: auto; }
  .card:hover .card-media { transform: none; }
}

/* ---------- Print: the writing, nothing else ---------- */
@media print {
  body { background: #fff; color: #000; font-size: 12pt; }
  .site-header, .sub-nav, .skip-link, .back-link,
  .piece-nav, .site-footer, .section-banner, .end-mark { display: none; }

  article.prose {
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: none;
  }

  article.prose .byline { background: none; color: #444; padding: 0; }
  a { text-decoration: none; color: #000; }
}
