* {
  margin: 0;
  padding: 0;
  box-sizing: inherit;
}

a {
    color: var(--link);
    text-decoration: none;
    position: relative;
}

a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 0%;
    height: 1px;
    background: var(--link-hover);
    transition: width 0.2s ease;
}

a:hover::after {
    width: 100%;
}

@font-face {
  font-family: "Terminess";
  src: url(fonts/terminess-regular.woff2) format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Terminess";
  src: url(fonts/terminess-bold.woff2) format("woff2");
  font-weight: 700;
  font-display: swap;
}

/* Dark-only "concrete + rust" palette. --c0..--c4 is the ramp bg.js dithers through (one source of truth). */
:root {
  --c0: #121211;
  --c1: #2b2a27;
  --c2: #57544e;
  --c3: #9a958a;
  --c4: #d9d3c5;
  --accent: #b4532a;  /* rust: borders, fills, hover marks */
  --link: #d4723f;    /* lighter rust for link text (AA on --c0) */
  --link-hover: var(--c4);
  --bg: var(--c0);
  --text-rgb: 217, 211, 197;
  --text: rgb(var(--text-rgb));
  --text-muted: var(--c3);
  --text-subtle: rgba(var(--text-rgb), 0.45);
  --text-faint: rgba(var(--text-rgb), 0.3);
  --border: var(--c2);
  --gutter: clamp(20px, 4vw, 64px);
  --font: "Terminess", "M PLUS 1 Code", monospace;
  color-scheme: dark;  /* dark native scrollbars and controls */  /* Terminus looks crispest at 12/14/16/18/24/32/48px */
  background: var(--bg);
}

/* author display rules (e.g. .cards { display: grid }) would otherwise beat the hidden attribute */
[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 1px dashed var(--accent);
  outline-offset: 2px;
}

h1, h2 {
  font-family: var(--font);
  font-weight: 400;
  font-size: 1.25rem;
}

h3, h4 {
  font-family: var(--font);
  font-weight: 400;
  font-size: 1.0rem;
  color: var(--text);
}

.name {
	font-size: 48px;
	font-weight: 700;
	line-height: 1.1;
}

body {
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;

  align-items: center;
  justify-content: center;
  margin: auto;
  padding: 24px;
}

.subitem-list {
	padding: 4px 16px;
	font-size: 0.875rem;
}

.corner-btn,
.corner-label {
  position: fixed;
  z-index: 50;
  font-size: 24px;
  letter-spacing: 0.5px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 10px 14px;
  opacity: 0.9;
}

.corner-btn:hover {
  opacity: 1;
}

.top-left    { top: 20px; left: calc(var(--gutter) - 14px); }
.top-right   { top: 20px; right: calc(var(--gutter) - 14px); }
.bottom-left { bottom: 20px; left: calc(var(--gutter) - 14px); }
.bottom-right{ bottom: 20px; right: calc(var(--gutter) - 14px); }

.layout {
  display: flex;
  gap: 6vw;
  margin-top: 10vh;
  align-items: flex-start;
  position: relative;
  z-index: 10;
}

.university {
	color: var(--text-muted);
	margin-bottom: 1.5rem;
}

.single-column {
    display: flex;
    justify-content: center;
    margin-top: 12vh;
}

.bio-page {
    max-width: 620px;
    padding: 0 12px;
}

.bio-page h1 {
    font-size: 32px;
    margin-bottom: 20px;
}

.bio-page h2 {
    font-size: 20px;
    margin-top: 32px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}

.bio-page p {
    margin-bottom: 16px;
    line-height: 1.65;
}

.mini-meta {
  font-size: 12px;
  opacity: 0.55;
  margin-left: 6px;
}

.paper-item {
  display: flex;
	flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 1rem;
}

.paper-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.paper-title {

	font-size: 14px;
  opacity: 0.9;
}

.paper-links a {
  font-size: 0.875rem;
  opacity: 0.85;
  text-decoration: none;
  padding-left: 4px;
}

.paper-links a:hover {
  opacity: 0.9;
}
html, body {
  overflow-x: hidden;
}

body:not(.revealed) .name,
body:not(.revealed) h1,
body:not(.revealed) h2,
body:not(.revealed) h3,
body:not(.revealed) h4,
body:not(.revealed) p,
body:not(.revealed) a,
body:not(.revealed) .corner-btn,
body:not(.revealed) .corner-label,
body:not(.revealed) .mini-meta,
body:not(.revealed) .icon-label,
body:not(.revealed) .icon-meta {
  visibility: hidden;
}

@media (max-width: 800px) {
  body {
    padding: 12px;
    font-size: 0.9rem;
  }

  .layout {
    display: block;
    margin-top: 12vh;
  }

  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.15rem; }
  h3, h4 { font-size: 1rem; }

  .subitem-list {
    padding: 4px 8px;
  }

  .paper-meta {
    flex-wrap: wrap;
    gap: 6px 12px;
  }

  .paper-title {
    font-size: 0.85rem;
    line-height: 1.45;
  }

  .corner-btn,
  .corner-label {
    font-size: 16px;
    padding: 6px 8px;
  }

  .top-left    { top: 8px;  left: 8px; }
  .top-right   { top: 8px;  right: 8px; }
  .bottom-left { bottom: 8px; left: 8px; }
  .bottom-right{ bottom: 8px; right: 8px; }

}

/* ───────── dithered background (bg.js) ───────── */
/* Fades in once its textures are on the GPU; until then (or without WebGL2) the plain --bg shows. */
#bg {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100lvh;
  z-index: -20;  /* under glyphs.js's glyph field (-10) */
  image-rendering: pixelated;
  opacity: 0;
  transition: opacity 1s ease;
}

#bg.on {
  opacity: 1;
}

/* ───────── desktop: one left column in reading order (who, links, folders, news); the right side is the brain's ───────── */
/* Parallax: bg.js sets --mx/--my on <html> (mouse, -0.5..0.5, eased) and each group moves against the mouse by
   its own amount: title most (nearest), folders less, news less again, glyph field least. The brain and the
   photo's depth map are the back layers. */
#desktop {
  position: fixed;
  top: 0;
  bottom: 0;
  left: var(--gutter);
  width: min(440px, 40vw);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 40px;
}

#glyphs {
  translate: calc(var(--mx, 0) * -20px) calc(var(--my, 0) * -20px);
}

#title {
  translate: calc(var(--mx, 0) * -60px) calc(var(--my, 0) * -60px);
  text-shadow: 0 0 12px var(--bg), 0 0 4px var(--bg);
}

.role {
  margin: 8px 0;
  color: var(--text-muted);
}

#title .paper-links {
  margin-top: 8px;
}

#title .paper-links a {
  padding: 0 8px 0 0;
}

/* folders: a list of rows; hovering peeks (script.js), clicking opens that folder's window */
.folders {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  translate: calc(var(--mx, 0) * -36px) calc(var(--my, 0) * -36px);
}

.icon {
  width: 100%;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  display: grid;
  grid-template-columns: 48px 1fr;
  column-gap: 16px;
  align-items: center;
  padding: 4px 0;
  outline: none;
  animation: slam 0.9s cubic-bezier(.07, 1, .1, 1) calc(0.3s + var(--i) * 0.08s) backwards;
}

.icon canvas {
  grid-row: span 2;
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  filter: grayscale(1) sepia(0.2) brightness(0.8) contrast(1.1);  /* placeholder crops, toned to the concrete palette */
  box-shadow: 0 0 24px rgba(var(--text-rgb), 0.3);
  transition: scale 0.05s;
}

.icon:hover canvas,
.icon:focus-visible canvas,
.icon[aria-expanded="true"] canvas {
  scale: 1.05;
  box-shadow: 0 0 0 1px var(--accent), 0 0 24px rgba(var(--text-rgb), 0.3);
}

.icon-label {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  text-shadow: 0 0 8px var(--bg), 0 0 3px var(--bg);
}

.icon:hover .icon-label,
.icon:focus-visible .icon-label,
.icon[aria-expanded="true"] .icon-label {
  color: var(--link);
}

.icon-meta {
  font-size: 14px;
  color: var(--text-muted);
  text-shadow: 0 0 8px var(--bg);
}

.icon:focus-visible .icon-label {
  outline: 1px dashed var(--text);
}

#news {
  translate: calc(var(--mx, 0) * -24px) calc(var(--my, 0) * -24px);
  animation-delay: 0.7s;
  animation-fill-mode: backwards;
}

#news ul {
  list-style: none;
}

#news li:nth-child(n+4) {
  display: none;  /* newest three (script.js sorts journal posts in with the rest by data-date) */
}

#news li {
  display: grid;
  grid-template-columns: 4.5em 1fr;
  margin-top: 8px;
  font-size: 14px;
}

#news .mini-meta {
  margin: 0;
}

/* photo credit, bottom centre */
#credit {
  position: fixed;
  bottom: 28px;
  left: 50%;
  translate: -50% 0;
  z-index: 40;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 0 6px var(--bg), 0 0 2px var(--bg);
}

#credit a {
  color: inherit;
  text-decoration: underline;
}

/* HUD corner brackets (from the old brain frame) */
.hud {
  --hud-len: 18px;
  --hud-thick: 3px;
  --hud-color: rgba(var(--text-rgb), 0.45);
  background:
    linear-gradient(var(--hud-color), var(--hud-color)) left  0 top 0                   / var(--hud-len) var(--hud-thick) no-repeat,
    linear-gradient(var(--hud-color), var(--hud-color)) left  0 top var(--hud-thick)    / var(--hud-thick) calc(var(--hud-len) - var(--hud-thick)) no-repeat,
    linear-gradient(var(--hud-color), var(--hud-color)) right 0 top 0                   / var(--hud-len) var(--hud-thick) no-repeat,
    linear-gradient(var(--hud-color), var(--hud-color)) right 0 top var(--hud-thick)    / var(--hud-thick) calc(var(--hud-len) - var(--hud-thick)) no-repeat,
    linear-gradient(var(--hud-color), var(--hud-color)) left  0 bottom 0                / var(--hud-len) var(--hud-thick) no-repeat,
    linear-gradient(var(--hud-color), var(--hud-color)) left  0 bottom var(--hud-thick) / var(--hud-thick) calc(var(--hud-len) - var(--hud-thick)) no-repeat;
}

/* frosted window with a cut bottom-right corner */
.window {
  width: 100%;
  max-height: 70vh;
  overflow: auto;
  padding: 16px 20px 20px;
  background-color: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(6px);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%);
  animation: slam 0.5s cubic-bezier(.07, 1, .1, 1);
}

.window h2 {
  margin-bottom: 8px;
  font-size: 18px;
  font-weight: 700;
}

.window h2 ~ h2,
.window h4 {
  margin-top: 12px;
}

.window .subitem-list > p {
  margin-bottom: 8px;
}

.window .university {
  margin-bottom: 1rem;
}

@keyframes slam {
  from { opacity: 0; transform: translateX(-4vw); }
}

/* ───────── folder windows ───────── */
/* Modal <dialog>s opened by script.js beside the folder list: --left = list's right edge + 32px,
   --top = the list's vertical centre (clamped on screen). The backdrop stays clear; instead the page
   dims everything except the window and the folder that opened it. */
dialog.window {
  position: fixed;
  inset: auto;
  margin: 0;
  left: var(--left, 50%);
  top: var(--top, 50%);
  translate: 0 -50%;
  width: min(520px, calc(100vw - var(--left, 0px) - var(--gutter)));
  max-height: 80vh;
  padding: 0;
  border: 0;
  color: var(--text);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

dialog.window[open] {
  display: flex;
}

dialog.window.wide {
  width: min(640px, calc(100vw - var(--left, 0px) - var(--gutter)));
}

dialog.window::backdrop {
  background: transparent;
}

.window-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 16px 20px 8px;
}

.window-head h2 {
  margin: 0;
}

.window-head button,
.gallery-nav button {
  background: none;
  border: 0;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
}

.window-head button:hover,
.gallery-nav button:hover {
  color: var(--link);
}

.window-body {
  overflow: auto;
  padding: 0 20px 24px;
}

.window-body > p {
  margin-bottom: 12px;
}

.window-body h4 {
  margin-top: 12px;
}

body :is(#title, #news, .icon, .corner-btn, .corner-label, #credit, #glyphs, #bg) {
  transition: opacity 0.3s, filter 0.3s;
}

body:has(dialog[open]) :is(#title, #news, .icon:not([aria-expanded="true"]), .corner-btn, .corner-label, #credit, #glyphs) {
  opacity: 0.2;
}

body:has(dialog[open]) #bg {
  filter: brightness(0.4);
}

/* projects: cards, then a gallery in their place */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.card h3 {
  margin-top: 8px;
  font-size: 18px;
  font-weight: 700;
}

.card-desc {
  font-size: 14px;
}

.tags {
  font-size: 12px;
  color: var(--text-muted);
}

.card .paper-links {
  margin-top: 4px;
}

.shot {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--c1);
  overflow: hidden;
  cursor: pointer;
}

.shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) sepia(0.2) brightness(0.8) contrast(1.1);  /* concrete-toned until you point at it */
  transition: filter 0.3s;
}

.shot:hover,
.shot:focus-visible {
  border-color: var(--accent);
}

.shot:hover img,
.shot:focus-visible img {
  filter: none;
}

/* a project without screenshots: a checker "dither" panel */
.shot.blank {
  display: grid;
  place-items: center;
  color: var(--text);
  background: repeating-conic-gradient(var(--c1) 0 25%, var(--c0) 0 50%) 0 0 / 4px 4px;
}

.shot.blank::after {
  display: none;
}

.gallery img {
  display: block;
  width: 100%;
  max-height: 55vh;
  object-fit: contain;
  background: var(--c0);
  border: 1px solid var(--border);
}

.gallery-caption {
  margin: 8px 0;
  font-size: 14px;
}

.gallery-nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.gallery-count {
  margin-left: auto;
}

/* ───────── custom cursor ───────── */
/* A small pixel corner bracket with its tip on the mouse (script.js moves it). Over anything clickable
   it grows and gets an inner line. Built from borders and an inset shadow, so it follows the theme.
   The real cursor is only hidden once this one is on, so a script failure never leaves you without one. */
html:has(#cursor.on) *,
html:has(#cursor.on) *:hover {
  cursor: none;
}

#cursor {
  position: fixed;
  inset: auto;  /* undo the popover defaults (centred box with a border and background) */
  margin: 0;
  padding: 0;
  background: none;
  overflow: visible;
  top: 0;
  left: 0;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  width: 12px;
  height: 12px;
  border: solid var(--text);
  border-width: 2px 0 0 2px;
  filter: drop-shadow(0 0 1px var(--bg));
  transition: width 0.2s, height 0.2s, box-shadow 0.2s;
}

#cursor.on {
  opacity: 1;
}

html:has(a:hover, button:hover, summary:hover, input:hover, select:hover) #cursor {
  width: 16px;
  height: 16px;
  box-shadow: inset 2px 2px 0 var(--bg), inset 3px 3px 0 var(--accent);
}

@media (hover: none) {
  #cursor { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .icon, .window { animation: none; }
}

/* ───────── tweak panel (?tweak) ───────── */
#tweak {
  position: fixed;
  top: 64px;
  right: 12px;
  z-index: 60;
  padding: 4px 10px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
}

#tweak form {
  display: grid;
  gap: 4px;
  padding: 6px 0;
}

#tweak label {
  display: grid;
  grid-template-columns: 5.5em 110px 2.5em;
  align-items: center;
  gap: 6px;
}


/* laptop-height screens: tighten the column so it clears the corner buttons */
@media (max-height: 860px) {
  #desktop {
    gap: 24px;
    padding-block: 64px;
  }

  .name {
    font-size: 32px;
  }

  .folders {
    gap: 0;
  }

  #news li:nth-child(n+3) {
    display: none;
  }
}

/* ───────── phones and short screens: the column scrolls, folders open inline ───────── */
@media (max-width: 600px), (max-height: 640px) {
  .name {
    font-size: 2rem;
  }

  #desktop {
    position: static;
    width: auto;
    gap: 24px;
    padding: 72px var(--gutter) 88px;
  }

  #title,
  .folders,
  #news {
    translate: none;
  }

  dialog.window,
  dialog.window.wide {
    inset: 0;
    margin: auto;
    translate: none;
    width: calc(100vw - 2 * var(--gutter));
    max-height: 85vh;
  }

  #credit {
    position: static;
    translate: none;
    white-space: normal;
    padding: 0 var(--gutter) 88px;
  }
}

/* The page's background lives on <html>, and on the desktop layout the body has no height at all
   (nothing in it is in flow), so nothing (e.g. a dark-mode extension styling body) can paint over the
   fixed canvases. That was the black bar at the top. */
body:has(#desktop) {
  padding: 0;
}

/* ───────── journal (pages built by tools/publish.mjs) ───────── */
/* links styled as tiles skip the sliding underline */
.icon::after,
.zine-card::after {
  display: none;
}

.post,
.journal-index {
  max-width: 960px;
  margin: 0 auto;
  padding: 96px var(--gutter) 120px;
}

/* zine header: the dithered cover with the title set huge across its bottom edge */
.zine {
  position: relative;
  margin-bottom: 80px;
}

.zine-cover {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  image-rendering: pixelated;
}

.zine-title {
  position: absolute;
  left: -0.04em;
  bottom: -0.5em;
  max-width: 100%;
  font-size: clamp(48px, 9vw, 128px);
  font-weight: 700;
  line-height: 0.95;
  color: var(--c4);
  text-shadow: 4px 4px 0 var(--c0), 0 0 2px var(--c0);
  overflow-wrap: anywhere;
}

/* cover furniture, kept small: the post's ## headings as cover lines, and a barcode of its date */
.zine-lines {
  position: absolute;
  top: 16px;
  left: 16px;
  max-width: 45%;
  padding: 4px 10px;
  list-style: none;
  background: color-mix(in srgb, var(--c0) 80%, transparent);
  font-size: 14px;
  line-height: 1.5;
  color: var(--c4);
}

.zine-lines li::before {
  content: "— ";
  color: var(--accent);
}

.zine-code {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  padding: 6px 8px 2px;
  background: var(--c4);
  color: var(--c0);
  font-size: 10px;
  letter-spacing: 0.3em;
  text-align: center;
}

.zine-code svg {
  width: 96px;
  height: 28px;
  fill: currentColor;
}

@media (max-width: 600px) {
  .zine-lines { display: none; }
  .zine-code svg { width: 64px; height: 20px; }
}

.post-meta {
  margin-bottom: 32px;
  color: var(--text-muted);
}

.post-meta .mini-meta {
  margin: 0 8px 0 0;
}

.post-body {
  max-width: 68ch;
  line-height: 1.7;
}

.post-body :is(p, ul, ol, pre, blockquote, figure, table) {
  margin-bottom: 1.2em;
}

.post-body h2 {
  margin: 2em 0 0.6em;
  font-size: 24px;
  font-weight: 700;
}

.post-body h3 {
  margin: 1.6em 0 0.5em;
  font-size: 18px;
  font-weight: 700;
}

.post-body :is(ul, ol) {
  padding-left: 1.5em;
}

.post-body img {
  max-width: 100%;
  filter: grayscale(1) sepia(0.2) brightness(0.85) contrast(1.1);
  transition: filter 0.3s;
}

.post-body img:hover {
  filter: none;
}

.post-body blockquote {
  padding-left: 1em;
  border-left: 2px solid var(--accent);
  color: var(--text-muted);
}

.post-body :is(pre, code) {
  background: var(--c1);
}

.post-body pre {
  padding: 1em;
  overflow: auto;
}

.post-body code {
  padding: 0 0.2em;
}

.post-body pre code {
  padding: 0;
}

.post-foot {
  margin-top: 64px;
}

/* journal index: a grid of little zine covers */
.zines {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 40px 32px;
  margin-top: 48px;
}

.zine-card {
  display: grid;
  gap: 4px;
  color: var(--text);
}

.zine-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  image-rendering: pixelated;
  border: 1px solid var(--border);
  transition: transform 0.3s, border-color 0.3s;
}

.zine-card:hover img,
.zine-card:focus-visible img {
  transform: perspective(700px) rotateY(-6deg) rotateX(2deg) scale(1.02);
  border-color: var(--accent);
}

.zine-card-title {
  position: relative;
  margin: -1.2em 0 4px 8px;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  text-shadow: 3px 3px 0 var(--c0);
}

.zine-card:hover .zine-card-title {
  color: var(--link);
}
